cog-center

Document Sample
cog-center Powered By Docstoc
					                                                                                     Simple to Program

        public class COG implements StatusListener{                              public void statusChanged (StatusEvent event) {
          public void create() { … }                                                                                                                      CoG Kit Patterns
          public void submit () { … }                                                Status status = event.getStatus( );
          public void statusChanged (StatusEvent e) { … }
                                                                                                                                                               The philosophy behind the Java CoG Kit is
          public static void main (String arg[]){                                    logger.debug(``Status changed to '' + status.getStatusCode());            based on object-oriented programming
                                            try {                                                                                                              patterns. One of these patterns is the “task”
                COG cog = new COG();                                                 if (status.getStatusCode( ) == Status.COMPLETED) {
                cog.create();                                                           logger.info(``Task Done'');                                            pattern to help conducting a workflow in the
                cog.submit();                                                        elsif (status.getStatusCode( ) == Status.FAILED) {                        Grid. An implementation can be achieved by
             catch (Exception e) {                                                      logger.info(``Task Failed'');
                                                                                                                                                               reusing the interfaces and implementations
                logger.error(“Something went wrong:”, e);                                System.exit(1);
          }                                                                          }                                                                         provided by the Java CoG Kit.
        }                                                                        }

                                                                                                                                                            A simple COG
                                    Task 3
                                                                                                                                                                 We show an example of a class named
                      Task 1                      Task 4
                                                                                                                                                                 COG that is based on our task pattern. The
                                    Task 2                                                                                                                       task pattern always contains a method to
                                                                                                                                                                 create and submit tasks, and a method that
       TaskGraph tg = new TaskGraphImpl();                                                                                                                       reports on status changes.
       public void create () {
         // define tasks
                                                                                                                                                            Completing the COG
         …..                                                                                                                                                     The Java CoG Kit contains interfaces and
         /* Add the tasks to the TaskGraph */
         tg.add(task1);
                                                                                                                                                                 methods that simplify the definition and use
         tg.add(task2);                                                                                                                                          of task graphs and tasks based on our
         tg.add(task3);                                                                                                                                          abstraction model. Defining a handler that
         tg.add(task4);
         tg.addDependency(task1, task2);
                                                                                                                                                                 deals with the submission of the job
         tg.addDependency(task1, task3);                                                                                                                         becomes as simple as our example
         tg.addDependency(task2, task4);
                                                                                       try {
                                                                                                                                                                 demonstrates. A comparable C program
         tg.addDependency(task3, task4);
       }                                                                                    handler.submit (cog);                                                would consume many more lines.
                                                                                          } catch (InvalidSecurityContextException ise) {
       public void submit() {                                                               logger.error(``Security Exception'', ise);
                                                                                            System.exit(1);
                                                                                                                                                                 More sophisticated handlers can be custom
         TaskGraphHandler handler = new
                              TaskGraphHandlerImpl();                                     } catch (TaskSubmissionException tse) {                                designed.
           try {                                                                            logger.error(``TaskSubmission Exception'', tse);
             handler.submit(tg);                                                            System.exit(1);
           } catch (Exception e) {                                                        } catch (IllegalSpecException ispe) {
                                                                                                                                                                 Tasks are specified through a simple task
             logger.error(``Some Error occured'', e);                                       logger.error(``Specification Exception'', ispe);                     specification.
             System.exit(1);                                                                System.exit(1);

       }
           }                                                                              } catch (InvalidServiceContactException isce){
                                                                                            logger.error(``Service Contact Exception'', isce);
                                                                                                                                                           Providers & Binding
                                                                                            System.exit(1);                                                     Providers for various Grid toolkits can be
                                                                                          }                                                                     seamlessly integrated and a task can be
                                                                                                                                                                bound to a particular Grid resource.
                                                                                                                                                                Through this process late binding is
                                                                                                                                                                possible.
             Task task4 = new Task();

                   Task task3 = new Task();
            JobSpecification spec = new JobSpecificationImpl();
            spec.setExecutable(“/share/climate”);
                           Task task2 = new Task();
                   JobSpecification spec = new JobSpecificationImpl();
            spec.addArguments(“-dimension 512 512”);
                   spec.setExecutable(“/share/climate”);
                                    Task task1
                           JobSpecification = new Task();
            spec.setStdOutput(“output.txt”); spec = new JobSpecificationImpl();
                   spec.addArguments(“-dimension 512 512”);
                           spec.setExecutable(“/share/climate”);
            task4.setSpecification(spec);
                   spec.setStdOutput(“output.txt”); spec = new JobSpecificationImpl();
                                    JobSpecification
                           spec.addArguments(“-dimension 512 512”);
       Task 4                       spec.setExecutable(“/share/bin/climate”);
                   task3.setSpecification(spec);
                           spec.setStdOutput(“output.txt”);                                                                                               Even simpler
                                    spec.addArguments(“-dimension 512 512 512 –task 1”);
                           task2.setSpecification(spec);
              Task 3                                                                                                                                           The same example can be formulated even
                                    spec.setStdOutput(“output1.txt”);
                      Task 2        task1.setSpecification(spec);                                                                                              simpler through our Java CoG Kit workflow
                                   Task 1                                                                                                                      language. Karajan, our workflow engine, will
     Provider 4
                                                                                                                                                               take care of the rest.
             Provider 3
                                                                                                                                                      <project>
                      Provider 2
                                                                                                                                                           <include file="sysdefaults.xml"/>
                                 Provider 1                                                                                                                <sequential>
                                                                                                                                                                <gridExecute executable="/share/bin/climate"
                                                                                                                                                                     arguments="-dimension 512 512 512 -task 1"
                                                                                                                                                                     host="hot.mcs.anl.gov"
Service service = new ServiceImpl(Service.JOB_SUBMISSION);                                                                                                           provider="gt3.2.1"
                                                                                                                                                                     stdout="output1.txt"/>
        Service service = new ServiceImpl(Service.JOB_SUBMISSION);
service.setProvider(``GT3_2_1'');                                                                                                                               <parallel>
                 Service service = new ServiceImpl(Service.JOB_SUBMISSION);                                                                                          <gridExecute executable="/share/bin/climate"
        service.setProvider(``GT3_2_1'');
// Set Security Context – e.g. certificates and such                                                                                                                       arguments="-dimension 512 512 512 -task 2"
                  securityContextservice = new ServiceImpl(Service.JOB_SUBMISSION);
                         Service = CoreFactory.newSecurityContext(``GT3_2_1'');
SecurityContextservice.setProvider(``GT3_2_1'');and such                                                                                                                   host="cold.mcs.anl.gov"
        // Set Security Context – e.g. certificates
securityContext.setCredentials(null); // e.g.CoreFactory.newSecurityContext(``GT3_2_1'');                                                                                  provider="gt2"
        SecurityContext securityContext = set it to default in ./globus
                 // Set Security Context – e.g.
                         service.setProvider(``GT3_2_1'');                                                                                                                 stdout="output2.txt"/>
        securityContext.setCredentials(null); certificates and such
service.setSecurityContext(securityContext); // e.g. set it to default in ./globus
// Set Contact – SecurityContext securityContext = CoreFactory.newSecurityContext(``GT3_2_1'');
                  e.g. where to go to                                                                                                                                <gridExecute executable="/share/bin/climate"
        service.setSecurityContext(securityContext);
                         // Set Security Context – e.g. certificates and such
ServiceContact securityContext.setCredentials(null); // e.g. set it to default in ./globus
                 serviceContact =                                                                                                                                          arguments="-dimension 512 512 512 -task 3"
        // Set Contact – e.g. where to go to
                         SecurityContext securityContext = CoreFactory.newSecurityContext(``GT3_2_1'');
                 service.setSecurityContext(securityContext);
   new ServiceContactImpl( http://hot.mcs.anl.gov:8080/ogsa/services/base/gram/,                                                                                           host="hot.mcs.anl.gov"
        ServiceContact serviceContact =
                 // Set Contact – e.g. where to
                         securityContext.setCredentials(null); // e.g. set it to default in ./globus
   MasterForkManagedJobFactoryService”); go to                                                                                                                             provider="gt3.2.1"
           new ServiceContactImpl( http://hot.mcs.anl.gov:8080/ogsa/services/base/gram/,
                         service.setSecurityContext(securityContext);
                 ServiceContact serviceContact =
service.setServiceContact(serviceContact);                                                                                                                                 stdout="output3.txt"/>
           MasterForkManagedJobFactoryService”);
                         // Set Contact – e.g. where to go to
                    new ServiceContactImpl( http://hot.mcs.anl.gov:8080/ogsa/services/base/gram/,                                                               </parallel>
        service.setServiceContact(serviceContact);
                    MasterForkManagedJobFactoryService”);
                         ServiceContact serviceContact =
tas2.setService(Service.JOB_SUBMISSION_SERVICE, service);                                                                                                       <gridExecute executable="/share/bin/climate"
                            new ServiceContactImpl( http://hot.mcs.anl.gov:8080/ogsa/services/base/gram/,
                 service.setServiceContact(serviceContact);                                                                                                          arguments="-dimension 512 512 512 -task 4"
        tas2.setService(Service.JOB_SUBMISSION_SERVICE, service);
                            MasterForkManagedJobFactoryService”);                                                                                                    host="blue.mcs.anl.gov"
                         service.setServiceContact(serviceContact);
                 tas2.setService(Service.JOB_SUBMISSION_SERVICE, service);                                                                                           provider="gt4"
                                                                                                                                                                     stdout="output4.txt"/>
                       task1.setService(Service.JOB_SUBMISSION_SERVICE, service);                                                                          </sequential>
                                                                                                                                                      </project>




                                                                                        U.S. Department of Energy


                                   g      the globus alliance
                                                    www.globus.org




                       The Java CoG Kit Project is part of the Globus Alliance
                                                                                         Office of Science

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:3
posted:4/8/2012
language:
pages:1