Search in sources :

Example 6 with RemoteSource

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));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File) Test(org.junit.Test)

Example 7 with RemoteSource

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());
}
Also used : URI(java.net.URI) ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File) Test(org.junit.Test)

Example 8 with RemoteSource

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());
}
Also used : URI(java.net.URI) ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File) Test(org.junit.Test)

Example 9 with RemoteSource

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);
}
Also used : RemoteSource(org.ow2.proactive.scheduler.rest.ds.RemoteSource)

Example 10 with 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());
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) RemoteSource(org.ow2.proactive.scheduler.rest.ds.RemoteSource) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException)

Aggregations

ListFile (org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile)10 Test (org.junit.Test)9 File (java.io.File)8 RemoteSource (org.ow2.proactive.scheduler.rest.ds.RemoteSource)5 URI (java.net.URI)4 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)3 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)3 IOException (java.io.IOException)2 AwaitedJob (org.ow2.proactive.scheduler.smartproxy.common.AwaitedJob)2 AwaitedTask (org.ow2.proactive.scheduler.smartproxy.common.AwaitedTask)2 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 OutputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector)1 LocalDestination (org.ow2.proactive.scheduler.rest.ds.LocalDestination)1