Search in sources :

Example 41 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class DataTransferTest method testCreateFolder.

@Test
public void testCreateFolder() throws Exception {
    URI srcDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0));
    String testFolderName = "testcreatefolder";
    System.out.println(testFolderName);
    RemoteSource source = new RemoteSource(USER, testFolderName);
    source.setType(FileType.FOLDER);
    IDataSpaceClient client = clientInstance();
    assertTrue(client.create(source));
    File expectedFile = new File(srcDirPath.getPath(), testFolderName);
    assertTrue(expectedFile.exists());
    assertTrue(expectedFile.isDirectory());
}
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 42 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class DataTransferTest method testDownloadArchiveFile.

private void testDownloadArchiveFile(String archiveFileName, URL archiveSource) throws Exception {
    String srcDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
    File srcFile = new File(srcDirPath, archiveFileName);
    if (srcFile.exists()) {
        assertTrue(srcFile.delete());
    }
    FileUtils.copyInputStreamToFile(archiveSource.openStream(), srcFile);
    File tmpFile = tmpDir.newFile(archiveFileName);
    if (tmpFile.exists()) {
        assertTrue(tmpFile.delete());
    }
    // use standard client
    IDataSpaceClient client = clientInstance();
    RemoteSource source = new RemoteSource(USER, archiveFileName);
    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(archiveFileName, tmpFile);
    assertTrue(Files.equal(srcFile, downloadedFile));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File)

Example 43 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client 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 44 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client 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 45 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class SchedulerNodeClient method connect.

/**
 * Connects to the scheduler at the specified schedulerRestUrl, using the current user credentials
 * @param url schedulerRestUrl of the scheduler
 * @throws Exception
 */
public void connect(String url) throws Exception {
    CredData userCreds = decrypter.decrypt();
    if (client == null) {
        client = SchedulerClient.createInstance();
    }
    if (client.isConnected()) {
        return;
    }
    client.init(new ConnectionInfo(url, userCreds.getLogin(), userCreds.getPassword(), null, true));
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) ConnectionInfo(org.ow2.proactive.authentication.ConnectionInfo)

Aggregations

Test (org.junit.Test)69 ISchedulerClient (org.ow2.proactive.scheduler.rest.ISchedulerClient)36 Client (org.ow2.proactive.resourcemanager.authentication.Client)31 JobId (org.ow2.proactive.scheduler.common.job.JobId)30 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)28 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)25 SimpleJob (functionaltests.jobs.SimpleJob)25 Job (org.ow2.proactive.scheduler.common.job.Job)25 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)18 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)18 ListFile (org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile)18 File (java.io.File)17 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)13 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)13 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)11 Node (org.objectweb.proactive.core.node.Node)9 IOException (java.io.IOException)8 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)8 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)8 NodeSet (org.ow2.proactive.utils.NodeSet)7