use of org.ow2.proactive.scheduler.rest.ds.RemoteSource in project scheduling by ow2-proactive.
the class DataTransferTest method testDownloadFile.
@Test
public void testDownloadFile() throws Exception {
String srcDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
File srcFile = new File(srcDirPath, TEMP_FILE_TMP_NAME);
if (srcFile.exists()) {
assertTrue(srcFile.delete());
}
Files.write(randomFileContents(), srcFile);
File tmpFile = tmpDir.newFile(TEMP_FILE_TMP_NAME);
if (tmpFile.exists()) {
assertTrue(tmpFile.delete());
}
// use standard client
IDataSpaceClient client = clientInstance();
RemoteSource source = new RemoteSource(USER, TEMP_FILE_TMP_NAME);
LocalDestination dest = new LocalDestination(tmpFile);
assertTrue(client.download(source, dest));
assertTrue(Files.equal(srcFile, tmpFile));
// use RemoteSpace API
FileUtils.deleteQuietly(tmpFile);
File downloadedFile = client.getUserSpace().pullFile(TEMP_FILE_TMP_NAME, tmpFile);
assertTrue(Files.equal(srcFile, downloadedFile));
}
use of org.ow2.proactive.scheduler.rest.ds.RemoteSource in project scheduling by ow2-proactive.
the class DataTransferTest method testCreateFile.
@Test
public void testCreateFile() throws Exception {
URI srcDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0));
String filename = TEMP_FILE_TMP_NAME;
RemoteSource source = new RemoteSource(USER, filename);
source.setType(FileType.FILE);
IDataSpaceClient client = clientInstance();
assertTrue(client.create(source));
File expectedFile = new File(srcDirPath.getPath(), filename);
assertTrue(expectedFile.exists());
assertTrue(expectedFile.isFile());
}
use of org.ow2.proactive.scheduler.rest.ds.RemoteSource in project scheduling by ow2-proactive.
the class DataTransferTest method testDeleteFile.
@Test
public void testDeleteFile() throws Exception {
URI srcDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0));
File srcFile = new File(new File(srcDirPath), TEMP_FILE_TMP_NAME);
if (srcFile.exists()) {
assertTrue(srcFile.delete());
}
Files.write(randomFileContents(), srcFile);
// use standard client
IDataSpaceClient client = clientInstance();
RemoteSource source = new RemoteSource(USER, TEMP_FILE_TMP_NAME);
assertTrue(client.delete(source));
assertFalse(srcFile.exists());
// use RemoteSpace API
Files.write(randomFileContents(), srcFile);
client.getUserSpace().deleteFile(TEMP_FILE_TMP_NAME);
assertFalse(srcFile.exists());
}
use of org.ow2.proactive.scheduler.rest.ds.RemoteSource in project scheduling by ow2-proactive.
the class RestSmartProxyImpl method createFolder.
@Override
protected void createFolder(String fUri) throws NotConnectedException, PermissionException {
RemoteSource remoteSource = new RemoteSource(USER, fUri);
remoteSource.setType(FileType.FOLDER);
restDataSpaceClient.create(remoteSource);
}
use of org.ow2.proactive.scheduler.rest.ds.RemoteSource in project scheduling by ow2-proactive.
the class RestSmartProxyImpl method removeJobIO.
@Override
protected void removeJobIO(Job job, String pushURL, String pullURL, String newFolderName) {
pushURL = pushURL + "/" + newFolderName;
RemoteSource remoteSource = new RemoteSource(IDataSpaceClient.Dataspace.USER, pushURL);
try {
restDataSpaceClient.delete(remoteSource);
} catch (NotConnectedException | PermissionException e) {
logger.debug("Error in removeJobIO push for job " + job.getName());
}
pullURL = pullURL + "/" + newFolderName;
remoteSource.setPath(pullURL);
try {
restDataSpaceClient.delete(remoteSource);
} catch (NotConnectedException | PermissionException e) {
logger.debug("Error in removeJobIO pull for job " + job.getName());
}
}
Aggregations