use of org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector in project scheduling by ow2-proactive.
the class JobComparator method isEqualInputFiles.
/**
* Compares the element in the 2 lists in the exact order they appear in the
* lists
*/
private boolean isEqualInputFiles(List<InputSelector> l1, List<InputSelector> l2) {
if ((l1 == null) && (l2 == null))
return true;
if ((l1 == null) ^ (l2 == null)) {
stack.push("One of 2 values is null");
return false;
}
if (l1.size() != l2.size()) {
stack.push("sizes don't match");
return false;
}
for (InputSelector is1 : l1) {
boolean found = false;
for (int i = 0; i < l2.size(); i++) {
InputSelector is2 = l2.get(i);
if (!is1.getMode().equals(is2.getMode())) {
continue;
}
Set<String> i1 = is1.getInputFiles().getIncludes();
Set<String> i2 = is2.getInputFiles().getIncludes();
if (!i1.equals(i2)) {
continue;
}
Set<String> e1 = is1.getInputFiles().getExcludes();
Set<String> e2 = is2.getInputFiles().getExcludes();
if (!e1.equals(e2)) {
continue;
}
found = true;
break;
}
if (!found) {
return false;
}
}
return true;
}
use of org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector in project scheduling by ow2-proactive.
the class TaskLauncherInitializerTest method input_empty_filters.
@Test
public void input_empty_filters() throws Exception {
initializer.setTaskInputFiles(inputSelectors("$TEST/a", "b"));
List<InputSelector> filteredInputFiles = initializer.getFilteredInputFiles(Collections.<String, Serializable>emptyMap());
InputSelector selector = filteredInputFiles.get(0);
assertEquals(ImmutableSet.of("$TEST/a", "b"), selector.getInputFiles().getIncludes());
}
use of org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector in project scheduling by ow2-proactive.
the class TaskLauncherInitializerTest method input_null_filters.
@Test
public void input_null_filters() throws Exception {
initializer.setTaskInputFiles(inputSelectors("$TEST/a", "b"));
List<InputSelector> filteredInputFiles = initializer.getFilteredInputFiles(null);
InputSelector selector = filteredInputFiles.get(0);
assertEquals(ImmutableSet.of("$TEST/a", "b"), selector.getInputFiles().getIncludes());
}
use of org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector in project scheduling by ow2-proactive.
the class TaskLauncherInitializer method getFilteredInputFiles.
public List<InputSelector> getFilteredInputFiles(Map<String, Serializable> variables) {
List<InputSelector> filteredTaskInputFiles = new ArrayList<>();
if (taskInputFiles != null) {
for (InputSelector is : taskInputFiles) {
InputSelector filteredInputSelector = new InputSelector(is.getInputFiles(), is.getMode());
Set<String> includes = filteredInputSelector.getInputFiles().getIncludes();
Set<String> excludes = filteredInputSelector.getInputFiles().getExcludes();
Set<String> filteredIncludes = filteredSelector(includes, variables);
Set<String> filteredExcludes = filteredSelector(excludes, variables);
filteredInputSelector.getInputFiles().setIncludes(filteredIncludes);
filteredInputSelector.getInputFiles().setExcludes(filteredExcludes);
filteredTaskInputFiles.add(filteredInputSelector);
}
}
return filteredTaskInputFiles;
}
use of org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector in project scheduling by ow2-proactive.
the class TaskProActiveDataspaces method findFilesToCopyFromInput.
private void findFilesToCopyFromInput(List<InputSelector> inputSelectors, ArrayList<DataSpacesFileObject> inResults, ArrayList<DataSpacesFileObject> outResults, ArrayList<DataSpacesFileObject> globResults, ArrayList<DataSpacesFileObject> userResults, ArrayList<DataSpacesFileObject> inResultsCache, ArrayList<DataSpacesFileObject> outResultsCache, ArrayList<DataSpacesFileObject> globResultsCache, ArrayList<DataSpacesFileObject> userResultsCache) throws FileSystemException, InterruptedException {
long startTime = System.currentTimeMillis();
ArrayList<Future<List<DataSpacesFileObject>>> inResultsFutures = new ArrayList<>();
ArrayList<Future<List<DataSpacesFileObject>>> outResultsFutures = new ArrayList<>();
ArrayList<Future<List<DataSpacesFileObject>>> globResultsFutures = new ArrayList<>();
ArrayList<Future<List<DataSpacesFileObject>>> userResultsFutures = new ArrayList<>();
ArrayList<Future<List<DataSpacesFileObject>>> inResultsCacheFutures = new ArrayList<>();
ArrayList<Future<List<DataSpacesFileObject>>> outResultsCacheFutures = new ArrayList<>();
ArrayList<Future<List<DataSpacesFileObject>>> globResultsCacheFutures = new ArrayList<>();
ArrayList<Future<List<DataSpacesFileObject>>> userResultsCacheFutures = new ArrayList<>();
for (InputSelector is : inputSelectors) {
org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector selector = new org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector();
selector.setIncludes(is.getInputFiles().getIncludes());
selector.setExcludes(is.getInputFiles().getExcludes());
switch(is.getMode()) {
case TransferFromInputSpace:
inResultsFutures.add(findFilesToCopyFromInput(INPUT, "INPUT", is, selector));
break;
case TransferFromOutputSpace:
outResultsFutures.add(findFilesToCopyFromInput(OUTPUT, "OUTPUT", is, selector));
break;
case TransferFromGlobalSpace:
globResultsFutures.add(findFilesToCopyFromInput(GLOBAL, "GLOBAL", is, selector));
break;
case TransferFromUserSpace:
userResultsFutures.add(findFilesToCopyFromInput(USER, "USER", is, selector));
break;
case CacheFromInputSpace:
inResultsCacheFutures.add(findFilesToCopyFromInput(INPUT, "INPUT", is, selector));
break;
case CacheFromOutputSpace:
outResultsCacheFutures.add(findFilesToCopyFromInput(OUTPUT, "OUTPUT", is, selector));
break;
case CacheFromGlobalSpace:
globResultsCacheFutures.add(findFilesToCopyFromInput(GLOBAL, "GLOBAL", is, selector));
break;
case CacheFromUserSpace:
userResultsCacheFutures.add(findFilesToCopyFromInput(USER, "USER", is, selector));
case none:
// do nothing
break;
}
}
addFilesResultToList(inResultsFutures, inResults);
addFilesResultToList(outResultsFutures, outResults);
addFilesResultToList(globResultsFutures, globResults);
addFilesResultToList(userResultsFutures, userResults);
addFilesResultToList(inResultsCacheFutures, inResultsCache);
addFilesResultToList(outResultsCacheFutures, outResultsCache);
addFilesResultToList(globResultsCacheFutures, globResultsCache);
addFilesResultToList(userResultsCacheFutures, userResultsCache);
logger.info("Time needed to create list of files to copy: " + (System.currentTimeMillis() - startTime) + " ms");
}
Aggregations