Skip to content
csuarez edited this page Aug 13, 2012 · 3 revisions

VOMS Examples

Creating Grid proxy

GridSessionConfig gridSessionConfig = generateGridSessionConfig("password");
int lifetime = 4 * 43200;

GliteProxyFactoryConfig gliteProxyFactoryConfig = new GliteProxyFactoryConfig(
    gridSessionConfig,
    lifetime,
    "ceta");

GlobusCredential gliteProxy = GliteProxyFactory.generateGliteProxy(gliteProxyFactoryConfig);

//VO config
private static GridSessionConfig generateGridSessionConfig(String password) {
    VOMSServerInfo vomsServerInfo = generateVOMSServerInfo();
    GridSessionConfig gridSessionConfig = new GridSessionConfig();
    gridSessionConfig.setProxyPath("proxyTest");
    gridSessionConfig.addVOMSServer(vomsServerInfo);
    gridSessionConfig.setVOMSCertDir("etc/certs/voms");
    gridSessionConfig.setCertDir("etc/certs/ca");
    gridSessionConfig.setUserKeyPass(password);
    return gridSessionConfig;
}

private static VOMSServerInfo generateVOMSServerInfo() {
    VOMSServerInfo vomsServerInfo = new VOMSServerInfo();
    vomsServerInfo.setHostDn("/DC=es/DC=irisgrid/O=ceta-ciemat/CN=voms.ceta-ciemat.es");
    vomsServerInfo.setHostName("voms.ceta-ciemat.es");
    vomsServerInfo.setPort(15010);
    vomsServerInfo.setVoName("ceta");
    return vomsServerInfo;
}

MyProxy examples

Creating MyProxy component

MyProxy proxyServer = new MyProxy();
proxyServer.setHost("px-ceta-test.ceta-ciemat.es");
proxyServer.setPort(7512);

MyProxyService myProxyService = new MyProxyService(
        proxyServer,
        "MyProxyUser",
        "MyProxyPassword");

Registering a certificate

myProxyService.registerProxy(gliteProxy, 7 * 24 * 3600);

Retrieving a certificate

GlobusCredential cred = myProxyService.retrieveProxy(7 * 24 * 3600);

CREAM examples

Creating CREAM component

CREAMService creamService = new CREAMService("https://ce-test.ceta-ciemat.es:8443/ce-cream/services");

Delegating proxy

String delegationId = creamService.delegateProxy(gliteProxy, 3600 * 1000 * 6);

Registering a job

JobDescription jobDescription = new JobDescription();
jobDescription.setDelegationId(delegationId);
jobDescription.setJDL(jdlAsString);
    
JobId jobId = creamService.registerJob(jobDescription);

Starting a job

Result resulstStartJob = creamService.startJob(jobId, delegationId);

Pausing a job

Result resulstPauseJob = creamService.pauseJob(jobId, delegationId);

Resuming a job

Result resultsResumeJob = creamService.resumeJob(jobId, delegationId);

Getting job status

Status jobStatus = creamService.jobStatus(jobId, delegationId).getJobStatus();
    
System.out.println("statusDescription=" + jobStatus.getDescription());
System.out.println("statusName=" + jobStatus.getName());
System.out.println("statusFailure=" + jobStatus.getFailureReason());
System.out.println("statusExitCode=" + jobStatus.getExitCode());

GridFTP examples

Creating a GridFTP component

GridFTPService gridFTP = new GridFTPService("se-test.ceta-ciemat.es", 2811);

Uploading data

gridFTP.upload(gliteProxy, new byte[] {1, 2, 3, 4, 5} , "/tmp/destino");

Downloading data

byte[] content = gridFTP.download(gliteProxy, "/tmp/origen");

Other examples

Uploading all job inputs using a JDL

List<String> inputsToUpload = JDLCREAMUtils.getInputToUpload(jdlAsString);
for (String input : inputsToUpload) {
    gridFTP.upload(gliteProxy, byteArray.get(input), input);
}

Downloading all job outputs using a JDL

List<String> outputsToUpload = JDLCREAMUtils.getOutputToDownload(jdlAsString);
for (String output : outputsToUpload) {
    byte[] content = gridFTP.download(gliteProxy, output);
}