Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [geclipse-dev] Job creation and submission code

Hi,

actually the libs are available here:
http://iwr-geclipse.fzk.de:8443/luntbuild/app.do

Then you need to setup up an eclipse PDE environment and extract the geclipse zip. Then you need to write a bundle containing the activator with the code bellow (plugin project).

Romain

PS the class code:

package fr.cemagref.simexplorer.ide.osgi.processors;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;


import java.net.URI;
import java.util.ArrayList;
import java.util.List;


import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.IJobChangeListener;

import eu.geclipse.core.ExtensionManager;
import eu.geclipse.core.Extensions;
import eu.geclipse.core.JobStatusUpdater;
import eu.geclipse.core.Preferences;
import eu.geclipse.core.auth.AbstractAuthTokenProvider;
import eu.geclipse.core.auth.AuthTokenRequest;
import eu.geclipse.core.auth.AuthenticationTokenManager;
import eu.geclipse.core.auth.CaCertManager;
import eu.geclipse.core.auth.CoreAuthTokenProvider;
import eu.geclipse.core.auth.IAuthenticationToken;
import eu.geclipse.core.auth.ICaCertificate;
import eu.geclipse.core.auth.ICaCertificateLoader;
import eu.geclipse.core.auth.PasswordManager;
import eu.geclipse.core.jobs.GridJob;
import eu.geclipse.core.jobs.GridJobID;
import eu.geclipse.core.model.GridModel;
import eu.geclipse.core.model.GridModelException;
import eu.geclipse.core.model.IGridComputing;
import eu.geclipse.core.model.IGridElement;
import eu.geclipse.core.model.IGridJob;
import eu.geclipse.core.model.IGridJobID;
import eu.geclipse.core.model.IGridJobService;
import eu.geclipse.core.model.IGridJobStatus;
import eu.geclipse.core.model.IGridJobStatusListener;
import eu.geclipse.core.model.IVirtualOrganization;
import eu.geclipse.core.reporting.ProblemException;
import eu.geclipse.jsdl.JSDLJobDescription;
import eu.geclipse.voms.auth.VomsProxy;
import eu.geclipse.voms.auth.VomsProxyDescription;
import eu.geclipse.voms.model.FullyQualifiedAttributeName;
import eu.geclipse.voms.vo.VomsVirtualOrganization;
import eu.geclipse.voms.vo.VomsVoCreator;
import fr.cemagref.simexplorer.ide.core.ApplicativeContext;
import fr.cemagref.simexplorer.ide.core.InternalProcessingError;
import fr.cemagref.simexplorer.ide.core.UserBadDataError;
import fr.cemagref.simexplorer.ide.core.processors.modular.Processor;



public class JobLauncherProcessor extends Processor {


   IProject project;

public JobLauncherProcessor(String description/*, EFSFile depot, String id*/) {
       super(description);
   }

   @Override
public void process(ApplicativeContext application) throws UserBadDataError, InternalProcessingError {
       try {

           //Preferences.setUpdateJobsStatus(true);

           VomsVoCreator crea = new VomsVoCreator();
           crea.setVoHost("voms-biomed.in2p3.fr");
           crea.setVoPort(15000);
crea.setVoHostDN("/O=GRID-FR/C=FR/O=CNRS/OU=CC-LYON/CN=cclcgvomsli01.in2p3.fr"); crea.setVoInfoService(URI.create("ldap://lappbdii.in2p3.fr:2170";));

           crea.setVoName("biomed");
// crea.addCustomService(new GliteJobService(URI.create("https://wms01.egee-see.org:9000";))); // GliteJobSubmissionService wms = new GliteJobSubmissionService(URI.create("https://wms01.egee-see.org:9000";));

           VomsVirtualOrganization biomed = new VomsVirtualOrganization();
           crea.apply(biomed);

IGridJobService[] jss = biomed.getJobSubmissionServices( null );


           IWorkspace ws = ResourcesPlugin.getWorkspace();
           IWorkspaceRoot swRoot = ws.getRoot();
           IProject project = swRoot.getProject( "myproject" );

           if ( ! project.exists() ) {
               project.create( null );
           }

           project.open( null );

           IFolder jsdlFolder = project.getFolder("jsdl");

           if(!jsdlFolder.exists()) {
               jsdlFolder.create(true,true,null);
           }

           IFolder jobsFolder = project.getFolder("jobs");

           if(!jobsFolder.exists()) {
               jobsFolder.create(true,true,null);
           }

           IFile file = jsdlFolder.getFile( "myjsld.jsdl" );

if(!file.exists()){ FileOutputStream tempOutStream= new FileOutputStream(file.getRawLocation().toOSString());
               tempOutStream.close();

FileInputStream tempInStream = new FileInputStream(file.getRawLocation().toOSString());
               file.create( tempInStream, true, null );
               tempInStream.close();
           }

           JSDLJobDescription jsdl = null;
           IGridElement element = GridModel.getRoot().findElement( file );

           if (element instanceof JSDLJobDescription){
               jsdl = ( JSDLJobDescription )element;
           }

           jsdl.createRoot();
           jsdl.addJobDescription();
           jsdl.addApplication();

//jsdl.addPOSIXApplicationDetails("hostname", "/bin/hostname", null, null, "stdout", "stdout", "stderr", "stderr"); jsdl.addPOSIXApplicationDetails("hostname", "/bin/echo", null, null, null, null, null, null);
           jsdl.addArgument("Coucou");
//            jsdl.getDataStagingOutStrings().
           jsdl.save(file);

final String EUGRIDPMA_NAME = "European Policy Management Authority for Grid Authentication";

           ExtensionManager manager = new ExtensionManager();
List< IConfigurationElement > elements = manager.getConfigurationElements(
                   Extensions.CA_CERT_LOADER_POINT,
                   Extensions.CA_CERT_LOADER_ELEMENT
           );

           ICaCertificateLoader loader = null;
           for ( IConfigurationElement elt : elements ) {
               String name = elt.getAttribute(
                       Extensions.CA_CERT_LOADER_NAME_ATTRIBUTE );
               if ( EUGRIDPMA_NAME.equals( name ) ) {
loader = ( ICaCertificateLoader ) elt.createExecutableExtension(
                           Extensions.CA_CERT_LOADER_CLASS_ATTRIBUTE );
                   break;
               }
           }

           ICaCertificate[] certs = null;
           if ( loader != null ) {
               URI[] uris = loader.getPredefinedRemoteLocations();
               if ( ( uris != null ) && ( uris.length > 0 ) ) {
String[] certnames = loader.getCertificateList( uris[ 0 ], null );
                   if ( certnames != null ) {
                       certs = new ICaCertificate[ certnames.length ];
                       for ( int i = 0 ; i < certnames.length ; i++ ) {
certs[ i ] = loader.getCertificate( uris[ 0 ], certnames[ i ], null );
                       }
                   }
               }
           }

           CaCertManager.getManager().addCertificates(certs);

           VomsProxyDescription desc = new VomsProxyDescription (
                   new IVirtualOrganization[] { biomed },
                   new File("/home/reuillon/.globus/usercert.pem"),
                   new File("/home/reuillon/.globus/userkey.pem")

           );

desc.addFqan(FullyQualifiedAttributeName.getFqan(biomed, new String[] {"lcg1"}, null));

PasswordManager.registerPassword("/home/reuillon/.globus/userkey.pem", "");
           desc.setLifetime( 86400 ); // In second, so one day here

VomsProxy proxy = ( VomsProxy ) AuthenticationTokenManager.getManager().createToken( desc );


           if ( ! proxy.isValid() ) {
               proxy.validate( new NullProgressMonitor() );
           }
           if ( ! proxy.isActive() ) {
               proxy.setActive( true, null );
               System.out.println("Proxy has been activated");
           }

           AuthenticationTokenManager.getManager().setDefaultToken(proxy);


           AuthTokenRequest req = new AuthTokenRequest(desc,"","");
IAuthenticationToken tok = CoreAuthTokenProvider.staticRequestToken(req);


           IGridJob job = null;
           //    ArrayList<IGridJob> jobs = new ArrayList<IGridJob>();

           for(IGridJobService js : jss) {
               if(js.canSubmit(jsdl)) {
                   try{
IGridJobID id = js.submitJob(jsdl, new NullProgressMonitor()); job = GridJob.createJobStructure(jobsFolder, (GridJobID) id, js, jsdl, "test");
                       break;
                   }
                   catch(ProblemException e) {
                       e.printStackTrace();
                   }

               }
           }




           while( job.getJobStatus().canChange() ) {
               try {
                   Thread.sleep(5000);
                   job.updateJobStatus();
System.out.println(job.getJobStatus().getName() + ": " + job.getJobStatus().getReason());
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           }

long duration = (System.currentTimeMillis() - job.getSubmissionTime().getTime()) / 1000;

System.out.println( duration + " s for executing a 'hello world' !!!! That's HPC !!!" );


       } catch (GridModelException e) {
           e.printStackTrace();
       } catch (CoreException e) {
           e.printStackTrace();
       }
       catch (IOException e) {
           e.printStackTrace();
       }






   }


}



POD69@xxxxxxx a écrit :
hi

could you please post a whole package that contains the libs etc.?

thx pod


-------- Or

iginal-Nachricht --------
Datum: Wed, 21 May 2008 17:44:42 +0200
Von: Romain <reuillon@xxxxxxxx>
An: Developer mailing list <geclipse-dev@xxxxxxxxxxx>
Betreff: [geclipse-dev] Job creation and submission code

Hi again all,

for info, you will find a code for creating and submitting a job using gEclipse bundles at this address:
http://mann.clermont.cemagref.fr/projets/SimExplorer/wiki/HPC/gEcpliseJobsSubmission

Any comment is of course very welcome,
Cheers,
Romain.
_______________________________________________
geclipse-dev mailing list
geclipse-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/geclipse-dev




Back to the top