Search in sources :

Example 1 with Preferences

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

the class SshLsfResourceBrokerAdaptor method getSubContext.

static GATContext getSubContext(GATContext context) {
    // Create a gatContext that can be used to submit sbatch, squeue, etc
    // commands.
    Preferences p = context.getPreferences();
    Preferences prefs = new Preferences();
    if (p != null) {
        prefs.putAll(p);
    }
    prefs.remove("resourcebroker.adaptor.name");
    prefs.remove("sshtrilead.stoppable");
    GATContext subContext = (GATContext) context.clone();
    subContext.removePreferences();
    subContext.addPreferences(prefs);
    return subContext;
}
Also used : GATContext(org.gridlab.gat.GATContext) Preferences(org.gridlab.gat.Preferences)

Example 2 with Preferences

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

the class FileAdaptorTest method test.

public AdaptorTestResult test(String adaptor, String host) {
    run(host, "adaptor-test-init.sh");
    AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, host);
    GATContext gatContext = new GATContext();
    PasswordSecurityContext password = new PasswordSecurityContext("username", "TeMpPaSsWoRd");
    password.addNote("adaptors", "ftp");
    gatContext.addSecurityContext(password);
    // CertificateSecurityContext ctxt = new CertificateSecurityContext(null, null, "username", "passphrase");
    // gatContext.addSecurityContext(ctxt);
    Preferences preferences = new Preferences();
    preferences.put("file.adaptor.name", adaptor + ",local");
    adaptorTestResult.put("exists: absolute existing file", existTest(gatContext, preferences, host, "/tmp/JavaGAT-test-exists-file", 0, true));
    adaptorTestResult.put("exists: absolute existing dir", existTest(gatContext, preferences, host, "/tmp/JavaGAT-test-exists-dir", 0, true));
    adaptorTestResult.put("exists: absolute non-existing file", existTest(gatContext, preferences, host, "/tmp/JavaGAT-test-exists-fake", 0, false));
    adaptorTestResult.put("exists: relative existing file", existTest(gatContext, preferences, host, "JavaGAT-test-exists-file", 1, true));
    adaptorTestResult.put("exists: relative existing dir", existTest(gatContext, preferences, host, "JavaGAT-test-exists-dir", 1, true));
    adaptorTestResult.put("exists: relative non-existing file", existTest(gatContext, preferences, host, "JavaGAT-test-exists-fake", 1, false));
    adaptorTestResult.put("mkdir: absolute non-existing dir", mkdirTest(gatContext, preferences, host, "/tmp/JavaGAT-test-mkdir-dir", 0, true));
    adaptorTestResult.put("mkdir: absolute existing dir", mkdirTest(gatContext, preferences, host, "/tmp/JavaGAT-test-mkdir-dir", 0, false));
    adaptorTestResult.put("mkdir: relative non-existing dir", mkdirTest(gatContext, preferences, host, "JavaGAT-test-mkdir-dir", 1, true));
    adaptorTestResult.put("mkdir: relative existing dir", mkdirTest(gatContext, preferences, host, "JavaGAT-test-mkdir-dir", 1, false));
    adaptorTestResult.put("mkdirs: absolute non-existing dir", mkdirsTest(gatContext, preferences, host, "/tmp/JavaGAT-test-mkdirs/1/2/3", 0, true));
    adaptorTestResult.put("mkdirs: absolute existing dir", mkdirsTest(gatContext, preferences, host, "/tmp/JavaGAT-test-mkdirs/1/2/3", 0, false));
    adaptorTestResult.put("mkdirs: relative non-existing dir", mkdirsTest(gatContext, preferences, host, "JavaGAT-test-mkdirs/1/2/3", 0, true));
    adaptorTestResult.put("mkdirs: relative existing dir", mkdirsTest(gatContext, preferences, host, "JavaGAT-test-mkdirs/1/2/3", 0, false));
    adaptorTestResult.put("delete: absolute existing file", deleteTest(gatContext, preferences, host, "/tmp/JavaGAT-test-delete-file", 0, true));
    adaptorTestResult.put("delete: absolute non-existing file", deleteTest(gatContext, preferences, host, "/tmp/JavaGAT-test-delete-file", 0, false));
    adaptorTestResult.put("delete: absolute existing dir", deleteTest(gatContext, preferences, host, "/tmp/JavaGAT-test-delete-dir/", 0, true));
    adaptorTestResult.put("delete: absolute non-existing dir", deleteTest(gatContext, preferences, host, "/tmp/JavaGAT-test-delete-fake", 0, false));
    adaptorTestResult.put("delete: relative existing file", deleteTest(gatContext, preferences, host, "JavaGAT-test-delete-file", 0, true));
    adaptorTestResult.put("delete: relative non-existing file", deleteTest(gatContext, preferences, host, "JavaGAT-test-delete-file", 0, false));
    adaptorTestResult.put("delete: relative existing dir", deleteTest(gatContext, preferences, host, "JavaGAT-test-delete-dir", 1, true));
    adaptorTestResult.put("delete: relative non-existing dir", deleteTest(gatContext, preferences, host, "JavaGAT-test-delete-dir", 1, false));
    adaptorTestResult.put("isFile: existing dir", isFileTest(gatContext, preferences, host, "JavaGAT-test-filedir-dir", 0, false));
    adaptorTestResult.put("isFile: existing file", isFileTest(gatContext, preferences, host, "JavaGAT-test-filedir-file", 0, true));
    adaptorTestResult.put("isFile: non-existing file", isFileTest(gatContext, preferences, host, "JavaGAT-test-filedir-fake", 0, false));
    adaptorTestResult.put("isDirectory: existing dir", isDirectoryTest(gatContext, preferences, host, "JavaGAT-test-filedir-dir", 0, true));
    adaptorTestResult.put("isDirectory: existing file", isDirectoryTest(gatContext, preferences, host, "JavaGAT-test-filedir-file", 0, false));
    adaptorTestResult.put("isDirectory: non-existing file", isDirectoryTest(gatContext, preferences, host, "JavaGAT-test-filedir-fake", 0, false));
    adaptorTestResult.put("canRead: readable file", canReadTest(gatContext, preferences, host, "JavaGAT-test-mode-readable", 0, true));
    adaptorTestResult.put("canRead: non-readable file", canReadTest(gatContext, preferences, host, "JavaGAT-test-mode-unreadable", 0, false));
    adaptorTestResult.put("canRead: non-existent file", canReadTest(gatContext, preferences, host, "JavaGAT-test-mode-does-not-exist", 0, false));
    adaptorTestResult.put("canWrite: writable file", canWriteTest(gatContext, preferences, host, "JavaGAT-test-mode-writable", 0, true));
    adaptorTestResult.put("canWrite: non-writable file", canWriteTest(gatContext, preferences, host, "JavaGAT-test-mode-unwritable", 0, false));
    adaptorTestResult.put("canWrite: non-existent file", canWriteTest(gatContext, preferences, host, "JavaGAT-test-mode-does-not-exist", 0, false));
    adaptorTestResult.put("length, existing file:", lengthTest(gatContext, preferences, host, "JavaGAT-test-length", 1, 6));
    adaptorTestResult.put("length, non-existent file:", lengthTest(gatContext, preferences, host, "JavaGAT-test-length-nonexistent", 1, 0));
    adaptorTestResult.put("list:", listTest(gatContext, preferences, host, "JavaGAT-test-list", 2, "file1", "file2", "dir1"));
    adaptorTestResult.put("lastModified, existent file:", lastModifiedTest(gatContext, preferences, host, "JavaGAT-test-last-modified", 0, 458258400000L));
    adaptorTestResult.put("lastModified, non-existent file:", lastModifiedTest(gatContext, preferences, host, "JavaGAT-test-last-modified-nonexist", 0, 0L));
    adaptorTestResult.put("createNewFile: non-existent file", createNewFileTest(gatContext, preferences, host, "JavaGAT-test-new-file", 1, true));
    adaptorTestResult.put("createNewFile: existent file", createNewFileTest(gatContext, preferences, host, "JavaGAT-test-new-file", 1, false));
    adaptorTestResult.put("copy: small relative file", copyFileTest(gatContext, preferences, host, "JavaGAT-test-copy-small", 1, true));
    adaptorTestResult.put("copy: large relative file", copyFileTest(gatContext, preferences, host, "JavaGAT-test-copy-large", 1, true));
    adaptorTestResult.put("copy: small absolute file", copyFileTest(gatContext, preferences, host, "/tmp/JavaGAT-test-copy-small", 1, true));
    adaptorTestResult.put("copy: large absolute file", copyFileTest(gatContext, preferences, host, "/tmp/JavaGAT-test-copy-large", 1, true));
    run(host, "adaptor-test-clean.sh");
    return adaptorTestResult;
}
Also used : GATContext(org.gridlab.gat.GATContext) PasswordSecurityContext(org.gridlab.gat.security.PasswordSecurityContext) Preferences(org.gridlab.gat.Preferences)

Example 3 with Preferences

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

the class FileOutputStreamAdaptorTest method test.

public AdaptorTestResult test(String adaptor, String host) {
    AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, host);
    GATContext gatContext = new GATContext();
    PasswordSecurityContext password = new PasswordSecurityContext("username", "TeMpPaSsWoRd");
    password.addNote("adaptors", "ftp");
    gatContext.addSecurityContext(password);
    // CertificateSecurityContext ctxt = new CertificateSecurityContext(null, null, "username", "passphrase");
    // gatContext.addSecurityContext(ctxt);
    Preferences preferences = new Preferences();
    preferences.put("fileoutputstream.adaptor.name", adaptor);
    FileOutputStream out = null;
    try {
        out = GAT.createFileOutputStream(gatContext, preferences, "any://" + host + "/JavaGAT-test-fileoutputstream");
    } catch (GATObjectCreationException e) {
        adaptorTestResult.put("create         ", new AdaptorTestResultEntry(false, 0, e));
        run(host, "fileoutputstream-adaptor-test-clean.sh");
        return adaptorTestResult;
    }
    byte[] large = new byte[10 * 1024 * 1024];
    for (int i = 0; i < large.length; i++) {
        large[i] = 'a';
    }
    adaptorTestResult.put("write (small)", writeTest(out, "test\n"));
    adaptorTestResult.put("write (large)", writeTest(out, new String(large)));
    adaptorTestResult.put("flush        ", flushTest(out));
    adaptorTestResult.put("close        ", closeTest(out));
    run(host, "fileoutputstream-adaptor-test-clean.sh");
    return adaptorTestResult;
}
Also used : GATContext(org.gridlab.gat.GATContext) PasswordSecurityContext(org.gridlab.gat.security.PasswordSecurityContext) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) FileOutputStream(org.gridlab.gat.io.FileOutputStream) Preferences(org.gridlab.gat.Preferences)

Example 4 with Preferences

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

the class AdvertServiceAdaptorTest method test.

public AdaptorTestResult test(String adaptor, String host) {
    AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, host);
    Preferences preferences = new Preferences();
    preferences.put("advertservice.adaptor.name", adaptor);
    AdvertService advertService = null;
    try {
        advertService = GAT.createAdvertService(preferences);
    } catch (GATObjectCreationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    MetaData meta = new MetaData();
    meta.put("version", "5.0");
    meta.put("price", "2000");
    adaptorTestResult.put("put object '1' at path 'a'", addTest(advertService, "1", meta, "a"));
    adaptorTestResult.put("getMetaData 'a'             ", getMetaDataTest(advertService, "a", meta));
    meta = new MetaData();
    meta.put("version", "5.0");
    meta.put("price", "50");
    adaptorTestResult.put("put object '2' at path 'b'", addTest(advertService, "2", meta, "b"));
    adaptorTestResult.put("test path 'a' (CORRECT)   ", getAdvertisableTest(advertService, "a", "1", true));
    adaptorTestResult.put("test path 'a' (INCORRECT) ", getAdvertisableTest(advertService, "a", "2", false));
    adaptorTestResult.put("test path 'b' (CORRECT)   ", getAdvertisableTest(advertService, "b", "2", true));
    adaptorTestResult.put("export                    ", exportTest(advertService, "any://" + host + "/exported-advert-database"));
    meta = new MetaData();
    meta.put("version", "9.1");
    meta.put("price", "50");
    adaptorTestResult.put("put object '3' at path 'c'", addTest(advertService, "3", meta, "c"));
    adaptorTestResult.put("test path 'c' (CORRECT)   ", getAdvertisableTest(advertService, "c", "3", true));
    adaptorTestResult.put("import                    ", importTest(advertService, "any://" + host + "/exported-advert-database"));
    adaptorTestResult.put("test path 'c' (INCORRECT) ", getAdvertisableTest(advertService, "c", null, true));
    meta = new MetaData();
    meta.put("price", "50");
    adaptorTestResult.put("find price=50             ", findTest(advertService, meta, new String[] { "/b" }, true));
    meta = new MetaData();
    meta.put("version", "5.0");
    adaptorTestResult.put("find version=5.0          ", findTest(advertService, meta, new String[] { "/b", "/a" }, true));
    adaptorTestResult.put("delete 'b'                ", deleteTest(advertService, "b"));
    adaptorTestResult.put("setPWD 'test'             ", setPWDTest(advertService, "/test"));
    adaptorTestResult.put("getPWD 'test'             ", getPWDTest(advertService, "/test"));
    return adaptorTestResult;
}
Also used : GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) MetaData(org.gridlab.gat.advert.MetaData) AdvertService(org.gridlab.gat.advert.AdvertService) Preferences(org.gridlab.gat.Preferences)

Example 5 with Preferences

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

the class FileInputStreamAdaptorTest method test.

public AdaptorTestResult test(String adaptor, String host) {
    run(host, "fileinputstream-adaptor-test-init.sh");
    AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, host);
    GATContext gatContext = new GATContext();
    PasswordSecurityContext password = new PasswordSecurityContext("username", "TeMpPaSsWoRd");
    password.addNote("adaptors", "ftp");
    gatContext.addSecurityContext(password);
    // CertificateSecurityContext ctxt = new CertificateSecurityContext(null, null, "username", "passphrase");
    // gatContext.addSecurityContext(ctxt);
    Preferences preferences = new Preferences();
    preferences.put("fileinputstream.adaptor.name", adaptor);
    FileInputStream in = null;
    try {
        in = GAT.createFileInputStream(gatContext, preferences, "any://" + host + "/JavaGAT-test-fileinputstream");
    } catch (GATObjectCreationException e) {
        adaptorTestResult.put("create         ", new AdaptorTestResultEntry(false, 0, e));
        run(host, "fileinputstream-adaptor-test-clean.sh");
        return adaptorTestResult;
    }
    adaptorTestResult.put("markSupported      ", markSupportedTest(in));
    adaptorTestResult.put("available:         ", availableTest(in, 0, true));
    adaptorTestResult.put("read: single char a", readTest(in, 'a', true));
    adaptorTestResult.put("read: single char b", readTest(in, 'b', true));
    adaptorTestResult.put("read: single char c", readTest(in, 'c', true));
    adaptorTestResult.put("read: single char !d", readTest(in, 'q', false));
    adaptorTestResult.put("read: small       ", readTest(in, "efg".getBytes(), true));
    byte[] bytes = new byte[1024 * 1024 * 10];
    byte current = 'h';
    for (int i = 0; i < bytes.length; i++) {
        bytes[i] = current;
        if (current == 'z') {
            current = '\n';
        } else if (current == '\n') {
            current = 'a';
        } else {
            current++;
        }
    }
    adaptorTestResult.put("read: large          ", readTest(in, bytes, true));
    adaptorTestResult.put("skip: small          ", skipTest(in, 100));
    adaptorTestResult.put("skip: large          ", skipTest(in, 10 * 1024 * 1024));
    adaptorTestResult.put("close                ", closeTest(in));
    run(host, "fileinputstream-adaptor-test-clean.sh");
    return adaptorTestResult;
}
Also used : GATContext(org.gridlab.gat.GATContext) PasswordSecurityContext(org.gridlab.gat.security.PasswordSecurityContext) GATObjectCreationException(org.gridlab.gat.GATObjectCreationException) Preferences(org.gridlab.gat.Preferences) FileInputStream(org.gridlab.gat.io.FileInputStream)

Aggregations

Preferences (org.gridlab.gat.Preferences)18 GATContext (org.gridlab.gat.GATContext)11 URI (org.gridlab.gat.URI)11 GATObjectCreationException (org.gridlab.gat.GATObjectCreationException)9 JobDescription (org.gridlab.gat.resources.JobDescription)8 ResourceBroker (org.gridlab.gat.resources.ResourceBroker)8 SoftwareDescription (org.gridlab.gat.resources.SoftwareDescription)8 Job (org.gridlab.gat.resources.Job)6 URISyntaxException (java.net.URISyntaxException)5 GATInvocationException (org.gridlab.gat.GATInvocationException)4 AdvertService (org.gridlab.gat.advert.AdvertService)3 File (org.gridlab.gat.io.File)3 PasswordSecurityContext (org.gridlab.gat.security.PasswordSecurityContext)3 MetaData (org.gridlab.gat.advert.MetaData)2 CertificateSecurityContext (org.gridlab.gat.security.CertificateSecurityContext)2 FileInputStream (org.gridlab.gat.io.FileInputStream)1 FileOutputStream (org.gridlab.gat.io.FileOutputStream)1 LogicalFile (org.gridlab.gat.io.LogicalFile)1 RandomAccessFile (org.gridlab.gat.io.RandomAccessFile)1 HardwareResourceDescription (org.gridlab.gat.resources.HardwareResourceDescription)1