Using JSAGA on EGEE¶
Define a "VOMS" security context¶
Context ctx = ContextFactory.createContext(); //Define the voms server ctx.setAttribute(Context.SERVER,"voms://voms-biomed.in2p3.fr:15000/O=GRID-FR/C=FR/O=CNRS/OU=CC-LYON/CN=cclcgvomsli01.in2p3.fr"); //Define your VO ctx.setAttribute(Context.USERVO, "biomed"); //Define your proxy life time ctx.setAttribute(Context.LIFETIME, "PT12H"); //The path of the proxy generated by JSAGA ctx.setAttribute(Context.USERPROXY, "/tmp/x509up_u4922"); //The path of your user certificate ctx.setAttribute(Context.USERCERT, "/iscpif/users/reuillon/.globus/usercert.pem"); //The path of your user key ctx.setAttribute(Context.USERKEY, "/iscpif/users/reuillon/.globus/userkey.pem"); //The password of your user key ctx.setAttribute(Context.USERPASS, "*******"); //A directory containing the CA certificates (http://dist.eugridpma.info/distribution/igtf/current/accredited/tgz/) ctx.setAttribute(Context.CERTREPOSITORY, "/iscpif/users/reuillon/tmp/ceert/"); //Needed ??? Might be leaved empty ctx.setAttribute(VOMSContext.VOMSDIR, ""); ctx.setAttribute(Context.TYPE, "VOMS"); Session session = SessionFactory.createSession(false); session.addContext(ctx);
Submit a simple job¶
URL url = URLFactory.createURL("wms://node27.datagrid.cea.fr:7443/glite_wms_wmproxy_server"); JobDescription desc = JobFactory.createJobDescription(); desc.setAttribute(JobDescription.EXECUTABLE, "/bin/echo"); desc.setVectorAttribute(JobDescription.ARGUMENTS, new String[]{"Hello"}); desc.setAttribute(JobDescription.OUTPUT, "out.txt"); //Get the output desc.setVectorAttribute(JobDescription.FILETRANSFER, new String[]{"/iscpif/users/reuillon/tmp/out/out.txt" + "<" + "out.txt"}); JobService service = JobFactory.createJobService(session, url); Job job = service.createJob(desc); job.run(); if(s != State.DONE || s != State.FAILED) { BufferedReader reader = new BufferedReader(new InputStreamReader(job.getStdout())); String line; while((line = reader.readLine()) != null) { System.out.println(line); } }
List a directory¶
URL url = URLFactory.createURL("srm://node12.datagrid.cea.fr:8446/dpm/datagrid.cea.fr/home/biomed/"); NSFactory.createNSDirectory(session, url); Task<?,List<URL>> task = dir.list(TaskMode.ASYNC); for(URL chUrl : task.get(timeout, TimeUnit.MILLISECONDS)) { ret.add(chUrl.toString()); }