Search in sources :

Example 46 with GATObjectCreationException

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

the class RandomAccessFileExample method start.

public void start(String source, String target) {
    RandomAccessFile sourceFile = null;
    try {
        sourceFile = GAT.createRandomAccessFile(source, "r");
    } catch (GATObjectCreationException e) {
        System.err.println("Failed to create random access file '" + source + "': " + e);
        return;
    }
    RandomAccessFile targetFile = null;
    try {
        targetFile = GAT.createRandomAccessFile(target, "rw");
    } catch (GATObjectCreationException e) {
        System.err.println("Failed to create random access file '" + target + "': " + e);
        return;
    }
    try {
        targetFile.setLength(sourceFile.length());
    } catch (IOException e) {
        System.err.println("Failed to set/get the length: " + e);
        return;
    }
    try {
        for (int i = 0; i < sourceFile.length(); i++) {
            targetFile.seek(targetFile.length() - 1 - i);
            sourceFile.seek(i);
            targetFile.writeByte(sourceFile.readByte());
        }
    } catch (IOException e) {
        System.out.println("Failed to seek/read/write: " + e);
        return;
    }
}
Also used : RandomAccessFile(org.gridlab.gat.io.RandomAccessFile) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) IOException(java.io.IOException)

Example 47 with GATObjectCreationException

use of org.gridlab.gat.GATObjectCreationException 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)

Aggregations

GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)47 GATInvocationException (org.gridlab.gat.GATInvocationException)39 URI (org.gridlab.gat.URI)18 JobDescription (org.gridlab.gat.resources.JobDescription)18 URISyntaxException (java.net.URISyntaxException)17 SoftwareDescription (org.gridlab.gat.resources.SoftwareDescription)17 ResourceBroker (org.gridlab.gat.resources.ResourceBroker)16 FileInterface (org.gridlab.gat.io.FileInterface)14 Job (org.gridlab.gat.resources.Job)14 IOException (java.io.IOException)11 Preferences (org.gridlab.gat.Preferences)9 BufferedReader (java.io.BufferedReader)5 File (java.io.File)5 InputStreamReader (java.io.InputStreamReader)5 FileOutputStream (java.io.FileOutputStream)4 PrintWriter (java.io.PrintWriter)4 StringWriter (java.io.StringWriter)4 AdaptorNotApplicableException (org.gridlab.gat.AdaptorNotApplicableException)4 GATContext (org.gridlab.gat.GATContext)4 InputStream (java.io.InputStream)3