Skip to content

Commit

Permalink
Code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmcmu committed Oct 13, 2023
1 parent 6dca48f commit 280aadd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.hpccsystems.dfs.client;

import java.io.Serializable;
import java.security.InvalidParameterException;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -264,7 +265,10 @@ public String[] getCopyLocations()
public String getCopyIP(int copyindex)
{
int copiescount = copyLocations.length;
if (copyindex < 0 || copyindex >= copiescount) return null;
if (copyindex < 0 || copyindex >= copiescount)
{
return null;
}

return copyLocations[copyindex];
}
Expand All @@ -278,7 +282,10 @@ public String getCopyIP(int copyindex)
*/
public void setCopyIP(int copyIndex, String copyIP)
{
if (copyIndex < 0 || copyIndex >= copyLocations.length) return;
if (copyIndex < 0 || copyIndex >= copyLocations.length)
{
return;
}

copyLocations[copyIndex] = copyIP;
}
Expand All @@ -290,8 +297,19 @@ public void setCopyIP(int copyIndex, String copyIP)
* @param copyIP The IP of the new file part copy
* @param copyPath The path of the new file part copy
*/
public void add(int index, String copyIP, String copyPath)
public void add(int index, String copyIP, String copyPath) throws Exception
{
if (index < 0 || index > copyLocations.length)
{
throw new InvalidParameterException("Insertion index: " + index + " is invalid."
+ "Expected index in range of: [0," + copyLocations.length + "]");
}

if (copyIP == null || copyPath == null)
{
throw new InvalidParameterException("Copy IP or Path are invalid, must be non-null.");
}

List<String> copyLocationsList = new ArrayList<>(Arrays.asList(copyLocations));
copyLocationsList.add(index, copyIP);
copyLocations = copyLocationsList.toArray(new String[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,11 @@ public String getIP()
return this.dataPart.getCopyIP(prioritizedCopyIndexes.get(getFilePartCopy()));
}

private String getCopyPath()
{
return this.dataPart.getCopyPath(prioritizedCopyIndexes.get(getFilePartCopy()));
}

private int getFilePartCopy()
{
return filePartCopyIndexPointer;
Expand Down Expand Up @@ -1535,7 +1540,7 @@ private void makeActive() throws HpccFileException
try
{
log.debug("Attempting to connect to file part : '" + dataPart.getThisPart() + "' Copy: '"
+ (getFilePartCopy() + 1) + "' on IP: '" + getIP() + "'");
+ (getFilePartCopy() + 1) + "' on IP: '" + getIP() + "'" + " for Path: '" + getCopyPath() + "'");
try
{
if (getUseSSL())
Expand Down Expand Up @@ -1574,7 +1579,7 @@ private void makeActive() throws HpccFileException
}
catch (java.net.UnknownHostException e)
{
throw new HpccFileException("Bad file part addr " + this.getIP(), e);
throw new HpccFileException("Bad file part IP address or host name: " + this.getIP(), e);
}
catch (java.io.IOException e)
{
Expand Down

0 comments on commit 280aadd

Please sign in to comment.