-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HPCC4J-542 DFSClient: Create JUnit for read retry #648
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,10 @@ | |
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; | ||
|
||
import org.hpccsystems.commons.ecl.FileFilter; | ||
import org.hpccsystems.commons.errors.HpccFileException; | ||
|
@@ -261,11 +265,60 @@ 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]; | ||
} | ||
|
||
/** | ||
* Set the copy IP | ||
* | ||
* @param copyIndex | ||
* the copyindex | ||
* @param copyIP The IP of the file part copy | ||
*/ | ||
public void setCopyIP(int copyIndex, String copyIP) | ||
{ | ||
if (copyIndex < 0 || copyIndex >= copyLocations.length) | ||
{ | ||
return; | ||
} | ||
|
||
copyLocations[copyIndex] = copyIP; | ||
} | ||
|
||
/** | ||
* Add file part copy | ||
* | ||
* @param index The index at which to insert the file part copy | ||
* @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) 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]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems a little bit extraneous, not sure what type copyLocations is, but are we not able to append the copyIP directly? and if not, are we using the most appropriate datastructure to track copyIPs, copypaths? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, the existing type is a simple array; I had considered moving this to a List but other parts of the code are expecting an array, so it would require the internal list be converted to an Array at those locations. I thought it would be better to do the conversion here in the add() function because this unlikely to be used outside of test cases. |
||
|
||
List<String> copyPathList = new ArrayList<>(Arrays.asList(copyPaths)); | ||
copyPathList.add(index, copyPath); | ||
copyPaths = copyPathList.toArray(new String[0]); | ||
} | ||
|
||
/** | ||
* Count of copies available for this file part. | ||
* @return copy locations size | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if either index, copyIP, or copyPath are invalid, we should throw