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);
}
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));
}
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)));
}
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));
}
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));
}
Aggregations