Search in sources :

Example 46 with URI

use of org.gridlab.gat.URI in project compss by bsc-wdc.

the class FileAdaptorTest method run.

private void run(String host, String script) {
    Preferences preferences = new Preferences();
    preferences.put("resourcebroker.adaptor.name", "commandlinessh,sshtrilead,local");
    preferences.put("file.adaptor.name", "commandlinessh,sshtrilead,local");
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable("/bin/bash");
    sd.setArguments(script);
    try {
        sd.addPreStagedFile(GAT.createFile(preferences, "tests" + java.io.File.separator + "src" + java.io.File.separator + "benchmarks" + java.io.File.separator + script));
    } catch (GATObjectCreationException e) {
        e.printStackTrace();
        System.exit(1);
    }
    ResourceBroker broker = null;
    try {
        broker = GAT.createResourceBroker(preferences, new URI("any://" + host));
    } catch (GATObjectCreationException e) {
        e.printStackTrace();
        System.exit(1);
    } catch (URISyntaxException e) {
        e.printStackTrace();
        System.exit(1);
    }
    Job job = null;
    try {
        job = broker.submitJob(new JobDescription(sd));
    } catch (GATInvocationException e) {
        e.printStackTrace();
        System.exit(1);
    }
    while (job.getState() != Job.JobState.STOPPED && job.getState() != Job.JobState.SUBMISSION_ERROR) {
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
        // ignored
        }
    }
}
Also used : JobDescription(org.gridlab.gat.resources.JobDescription) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) URISyntaxException(java.net.URISyntaxException) Preferences(org.gridlab.gat.Preferences) Job(org.gridlab.gat.resources.Job) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription)

Example 47 with URI

use of org.gridlab.gat.URI in project compss by bsc-wdc.

the class FileOutputStreamAdaptorTest method run.

private void run(String host, String script) {
    Preferences preferences = new Preferences();
    preferences.put("resourcebroker.adaptor.name", "commandlinessh,sshtrilead,local");
    preferences.put("file.adaptor.name", "commandlinessh,sshtrilead,local");
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable("/bin/bash");
    sd.setArguments(script);
    try {
        sd.addPreStagedFile(GAT.createFile(preferences, "tests" + java.io.File.separator + "src" + java.io.File.separator + "benchmarks" + java.io.File.separator + script));
    } catch (GATObjectCreationException e) {
        e.printStackTrace();
        System.exit(1);
    }
    ResourceBroker broker = null;
    try {
        broker = GAT.createResourceBroker(preferences, new URI("any://" + host));
    } catch (GATObjectCreationException e) {
        e.printStackTrace();
        System.exit(1);
    } catch (URISyntaxException e) {
        e.printStackTrace();
        System.exit(1);
    }
    Job job = null;
    try {
        job = broker.submitJob(new JobDescription(sd));
    } catch (GATInvocationException e) {
        e.printStackTrace();
        System.exit(1);
    }
    while (job.getState() != Job.JobState.STOPPED && job.getState() != Job.JobState.SUBMISSION_ERROR) {
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
        // ignored
        }
    }
}
Also used : JobDescription(org.gridlab.gat.resources.JobDescription) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) URISyntaxException(java.net.URISyntaxException) Preferences(org.gridlab.gat.Preferences) Job(org.gridlab.gat.resources.Job) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription)

Example 48 with URI

use of org.gridlab.gat.URI in project compss by bsc-wdc.

the class LogicalFileExample method main.

/**
 * This example shows the use of the LogicalFile object in JavaGAT
 *
 * This example requires three valid JavaGAT URIs. The first two URIs should
 * point to files which from the user's perspective are identical. The third
 * URI should point to a location where the logical file should be
 * replicated to. The replication will be done from the 'closest' file.
 *
 * @param args
 *                a String array of size 3 with each element containing a
 *                String representation of a valid URI.
 */
public static void main(String[] args) {
    if (args.length != 3) {
        System.out.println("\tUsage: bin/run_gat_app examples20.FileExample <location1> <location2> <location3> (where location is a valid JavaGAT URI)\n\n" + "\twhere:\n" + "\t\t<location1> <location2> point to the same file\n" + "\t\tthis example will replicate to <location3> from the closest\n");
        System.exit(1);
    }
    try {
        new LogicalFileExample().start(new URI(args[0]), new URI(args[1]), new URI(args[2]));
    } catch (URISyntaxException e) {
        System.out.println(e);
        System.out.println("\tUsage: bin/run_gat_app examples20.FileExample <location1> <location2> <location3> (where location is a valid JavaGAT URI)\n\n" + "\twhere:\n" + "\t\t<location1> <location2> point to the same file\n" + "\t\tthis example will replicate to <location3> from the closest\n");
        System.exit(1);
    }
    GAT.end();
}
Also used : URISyntaxException(java.net.URISyntaxException) URI(org.gridlab.gat.URI)

Example 49 with URI

use of org.gridlab.gat.URI in project compss by bsc-wdc.

the class ResourceBrokerStreamingOutExample method start.

public void start(String brokerURI) {
    ResourceBroker broker = null;
    try {
        broker = GAT.createResourceBroker(new URI(brokerURI));
    } catch (GATObjectCreationException e) {
        System.err.println("Failed to create resource broker at location '" + brokerURI + "': " + e);
        return;
    } catch (URISyntaxException e) {
        System.err.println("Wrong uri '" + brokerURI + "': " + e);
        return;
    }
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable("/usr/bin/env");
    sd.enableStreamingStdout(true);
    JobDescription jd = new JobDescription(sd);
    Job job = null;
    try {
        job = broker.submitJob(jd);
    } catch (GATInvocationException e) {
        System.err.println("Failed to submit the job: " + e);
        return;
    }
    InputStream in = null;
    try {
        in = job.getStdout();
    } catch (GATInvocationException e) {
        System.err.println("Failed to get the stdout stream: " + e);
        return;
    }
    while (true) {
        int i = 0;
        try {
            i = in.read();
        } catch (IOException e) {
            System.err.println("Failed to read: " + e);
            return;
        }
        if (i == -1) {
            break;
        } else {
            System.out.print((char) i);
        }
    }
}
Also used : JobDescription(org.gridlab.gat.resources.JobDescription) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) GATInvocationException(org.gridlab.gat.GATInvocationException) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) InputStream(java.io.InputStream) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) Job(org.gridlab.gat.resources.Job) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription)

Example 50 with URI

use of org.gridlab.gat.URI in project compss by bsc-wdc.

the class SubmitLocalJob method main.

public static void main(String[] args) throws Exception {
    SoftwareDescription sd = new SoftwareDescription();
    sd.setExecutable("/bin/hostname");
    File stdout = GAT.createFile("hostname.txt");
    sd.setStdout(stdout);
    JobDescription jd = new JobDescription(sd);
    ResourceBroker broker = GAT.createResourceBroker(new URI("any://localhost"));
    Job job = broker.submitJob(jd);
    while ((job.getState() != JobState.STOPPED) && (job.getState() != JobState.SUBMISSION_ERROR)) Thread.sleep(1000);
    GAT.end();
}
Also used : JobDescription(org.gridlab.gat.resources.JobDescription) ResourceBroker(org.gridlab.gat.resources.ResourceBroker) Job(org.gridlab.gat.resources.Job) File(org.gridlab.gat.io.File) URI(org.gridlab.gat.URI) SoftwareDescription(org.gridlab.gat.resources.SoftwareDescription)

Aggregations

URI (org.gridlab.gat.URI)53 URISyntaxException (java.net.URISyntaxException)28 JobDescription (org.gridlab.gat.resources.JobDescription)28 SoftwareDescription (org.gridlab.gat.resources.SoftwareDescription)27 ResourceBroker (org.gridlab.gat.resources.ResourceBroker)26 GATInvocationException (org.gridlab.gat.GATInvocationException)24 Job (org.gridlab.gat.resources.Job)23 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)19 Preferences (org.gridlab.gat.Preferences)11 BufferedReader (java.io.BufferedReader)8 File (java.io.File)8 IOException (java.io.IOException)8 GATContext (org.gridlab.gat.GATContext)8 File (org.gridlab.gat.io.File)8 InputStreamReader (java.io.InputStreamReader)5 LinkedList (java.util.LinkedList)4 AdvertService (org.gridlab.gat.advert.AdvertService)4 CertificateSecurityContext (org.gridlab.gat.security.CertificateSecurityContext)4 GATScriptExecutor (es.bsc.compss.gat.master.utils.GATScriptExecutor)3 MultiURI (es.bsc.compss.types.uri.MultiURI)3