Search in sources :

Example 1 with RemoteDestination

use of org.ow2.proactive.scheduler.rest.ds.RemoteDestination in project scheduling by ow2-proactive.

the class RestSmartProxyImpl method uploadInputFilesForTask.

private void uploadInputFilesForTask(String localInputFolderPath, String remotePath, Task task) throws NotConnectedException, PermissionException {
    logger.debug("Pushing files for task " + task.getName());
    List<String> includes = Lists.newArrayList();
    List<String> excludes = Lists.newArrayList();
    List<InputSelector> inputFilesList = task.getInputFilesList();
    if (inputFilesList != null) {
        for (InputSelector is : inputFilesList) {
            addfileSelection(is.getInputFiles(), includes, excludes);
        }
    }
    LocalDirSource source = new LocalDirSource(localInputFolderPath);
    source.setIncludes(includes);
    source.setExcludes(excludes);
    RemoteDestination dest = new RemoteDestination(USER, remotePath);
    restDataSpaceClient.upload(source, dest);
}
Also used : RemoteDestination(org.ow2.proactive.scheduler.rest.ds.RemoteDestination) InputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector) LocalDirSource(org.ow2.proactive.scheduler.rest.ds.LocalDirSource)

Example 2 with RemoteDestination

use of org.ow2.proactive.scheduler.rest.ds.RemoteDestination in project scheduling by ow2-proactive.

the class DataTransferTest method testUploadSingleFile.

@Test
public void testUploadSingleFile() throws Exception {
    String testFolderName = "testUploadSingleFile";
    System.out.println(testFolderName);
    File tmpFile = tmpDir.newFile(TEMP_FILE_TMP_NAME);
    Files.write(randomFileContents(), tmpFile);
    // use standard client
    IDataSpaceClient client = clientInstance();
    LocalFileSource source = new LocalFileSource(tmpFile);
    RemoteDestination dest = new RemoteDestination(USER, testFolderName + "/" + TEMP_FILE_TMP_NAME);
    assertTrue(client.upload(source, dest));
    String destDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
    File destFile = new File(destDirPath, testFolderName + "/" + TEMP_FILE_TMP_NAME);
    assertTrue(Files.equal(tmpFile, destFile));
    // use RemoteSpace API
    FileUtils.deleteQuietly(destFile);
    client.getUserSpace().pushFile(tmpFile, testFolderName + "/" + TEMP_FILE_TMP_NAME);
    assertTrue(Files.equal(tmpFile, destFile));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File) Test(org.junit.Test)

Example 3 with RemoteDestination

use of org.ow2.proactive.scheduler.rest.ds.RemoteDestination in project scheduling by ow2-proactive.

the class DataTransferTest method testUploadSelectedFilesUsingFilenames.

@Test
public void testUploadSelectedFilesUsingFilenames() throws Exception {
    String testFolderName = "testUploadSelectedFilesUsingFilenames";
    System.out.println(testFolderName);
    TestFilesToUploadCreator testFiles = new TestFilesToUploadCreator().invoke();
    File tempTextFile = testFiles.getTempTextFile();
    File tempFile = testFiles.getTempFile();
    // use standard client
    IDataSpaceClient client = clientInstance();
    LocalDirSource source = new LocalDirSource(tmpDir.getRoot());
    source.setIncludes("**/" + TEMP_FILE_TMP_NAME);
    RemoteDestination dest = new RemoteDestination(USER, testFolderName);
    assertTrue(client.upload(source, dest));
    String destRootUri = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
    File[] destRootFiles = new File(destRootUri, testFolderName).listFiles();
    System.out.println("Files in destination: " + Arrays.asList(destRootFiles));
    assertEquals(1, destRootFiles.length);
    assertTrue(destRootFiles[0].isDirectory());
    assertTrue(Files.equal(tempFile, new File(destRootFiles[0], TEMP_FILE_TMP_NAME)));
    // use RemoteSpace API
    FileUtils.deleteDirectory(new File(destRootUri, testFolderName));
    client.getUserSpace().pushFiles(tmpDir.getRoot(), "**/" + TEMP_FILE_TMP_NAME, testFolderName);
    destRootFiles = new File(destRootUri, testFolderName).listFiles();
    assertEquals(1, destRootFiles.length);
    assertTrue(destRootFiles[0].isDirectory());
    assertTrue(Files.equal(tempFile, new File(destRootFiles[0], TEMP_FILE_TMP_NAME)));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File) Test(org.junit.Test)

Example 4 with RemoteDestination

use of org.ow2.proactive.scheduler.rest.ds.RemoteDestination in project scheduling by ow2-proactive.

the class DataTransferTest method testUploadArchiveFile.

private void testUploadArchiveFile(String archiveFileName, URL archiveFileSource, String testFolderName) throws Exception {
    File tmpZipFile = tmpDir.newFile(archiveFileName);
    FileUtils.copyInputStreamToFile(archiveFileSource.openStream(), tmpZipFile);
    // use standard client
    IDataSpaceClient client = clientInstance();
    LocalFileSource source = new LocalFileSource(tmpZipFile);
    RemoteDestination dest = new RemoteDestination(USER, testFolderName + "/" + archiveFileName);
    assertTrue(client.upload(source, dest));
    String destDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
    File destFile = new File(destDirPath, testFolderName + "/" + archiveFileName);
    assertTrue(Files.equal(tmpZipFile, destFile));
    // use RemoteSpace API
    FileUtils.deleteQuietly(destFile);
    client.getUserSpace().pushFile(tmpZipFile, testFolderName + "/" + archiveFileName);
    assertTrue(Files.equal(tmpZipFile, destFile));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File)

Example 5 with RemoteDestination

use of org.ow2.proactive.scheduler.rest.ds.RemoteDestination in project scheduling by ow2-proactive.

the class DataTransferTest method testUploadSingleFileInDir.

@Test
public void testUploadSingleFileInDir() throws Exception {
    String testFolderName = "testUploadSingleFileInDir";
    System.out.println(testFolderName);
    String subFolderName = "subFolder";
    File tmpFolder = tmpDir.newFolder(testFolderName);
    File subFolder = new File(tmpFolder, subFolderName);
    subFolder.mkdirs();
    File tmpFile = new File(subFolder, TEMP_FILE_TMP_NAME);
    Files.write(randomFileContents(), tmpFile);
    // use standard client
    IDataSpaceClient client = clientInstance();
    LocalDirSource source = new LocalDirSource(tmpFolder);
    source.setIncludes(subFolder.getName() + "/" + TEMP_FILE_TMP_NAME);
    RemoteDestination dest = new RemoteDestination(USER, testFolderName);
    assertTrue(client.upload(source, dest));
    String destDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
    File destFile = new File(destDirPath, testFolderName + "/" + subFolderName + "/" + TEMP_FILE_TMP_NAME);
    assertTrue(destFile.exists());
    assertTrue(Files.equal(tmpFile, destFile));
    // use RemoteSpace API
    FileUtils.deleteQuietly(destFile);
    client.getUserSpace().pushFile(tmpFile, testFolderName + "/" + subFolderName + "/" + TEMP_FILE_TMP_NAME);
    assertTrue(destFile.exists());
    assertTrue(Files.equal(tmpFile, destFile));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)6 ListFile (org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile)6 Test (org.junit.Test)5 InputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector)1 LocalDirSource (org.ow2.proactive.scheduler.rest.ds.LocalDirSource)1 RemoteDestination (org.ow2.proactive.scheduler.rest.ds.RemoteDestination)1