Search in sources :

Example 6 with InputSelector

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;
}
Also used : InputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector)

Example 7 with InputSelector

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());
}
Also used : InputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector) Test(org.junit.Test)

Example 8 with InputSelector

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());
}
Also used : InputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector) Test(org.junit.Test)

Example 9 with InputSelector

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;
}
Also used : ArrayList(java.util.ArrayList) InputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector)

Example 10 with InputSelector

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");
}
Also used : DataSpacesFileObject(org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject) FileSelector(org.objectweb.proactive.extensions.dataspaces.api.FileSelector) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) InputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector)

Aggregations

InputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector)14 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 FileSelector (org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector)4 Task (org.ow2.proactive.scheduler.common.task.Task)3 OutputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector)3 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)3 File (java.io.File)2 Future (java.util.concurrent.Future)2 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)2 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)2 AwaitedTask (org.ow2.proactive.scheduler.smartproxy.common.AwaitedTask)2 SelectionScript (org.ow2.proactive.scripting.SelectionScript)2 SimpleScript (org.ow2.proactive.scripting.SimpleScript)2 TaskScript (org.ow2.proactive.scripting.TaskScript)2 HashMap (java.util.HashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 FileObject (org.apache.commons.vfs2.FileObject)1 FileSelector (org.apache.commons.vfs2.FileSelector)1 DataSpacesFileObject (org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject)1