Package org.ggf.schemas.bes.x2006.x08.besFactory

Examples of org.ggf.schemas.bes.x2006.x08.besFactory.CreateActivityDocument


        GetActivityStatusesDocument stats = GetActivityStatusesDocument.Factory.newInstance();

        stats.addNewGetActivityStatuses().setActivityIdentifierArray(new EndpointReferenceType[] { activityEpr });

        GetActivityStatusesResponseDocument resDoc = fc.getActivityStatuses(stats);

        ActivityStatusType activityStatus = resDoc.getGetActivityStatusesResponse().getResponseArray()[0]
                .getActivityStatus();
        return activityStatus;
    }
View Full Code Here


    String applicationNameNs = method.getApplication().getApplicationName().getTargetNamespace();
    return new QName(applicationNameNs, applicationName);
  }

  public static GlobusGatekeeperType findGateKeeper(ExecutionContext appExecContext, boolean wsgram) throws GfacException {
    WorkflowContextHeader header = appExecContext.getWorkflowHeader();
    boolean isSpruceEnabled = false;
    if (header != null) {
      isSpruceEnabled = (appExecContext.getWorkflowHeader().getURGENCY() != null);
      ResourceMapping resourceMapping = appExecContext.getWorkflowHeader().getResourceMappings().getResourceMappingArray()[0];
      if (resourceMapping != null) {
View Full Code Here

        String outputDataDir = GFacConstants.OUTPUT_DATA_DIR;
        if(!outputDataDir.isEmpty()){
    jobAttr.addEnvVariable(outputDataDir, appExecContext.getExecutionModel().getOutputDataDir());
        }
    ApplicationDescriptionType app = appExecContext.getExecutionModel().getAplicationDesc();
    WorkflowContextHeader contextHeader = appExecContext.getWorkflowHeader();
    ResourceMapping resourceMapping = null;
    if (contextHeader != null) {
      resourceMapping = contextHeader.getResourceMappings().getResourceMappingArray(0);
    }

    log.info("Configure using App Desc = " + app.xmlText());
    if (resourceMapping != null && resourceMapping.getMaxWallTime() > 0) {
      log.info("Header Setting Max Wall Time" + resourceMapping.getMaxWallTime());
View Full Code Here

  public static GlobusGatekeeperType findGateKeeper(ExecutionContext appExecContext, boolean wsgram) throws GfacException {
    WorkflowContextHeader header = appExecContext.getWorkflowHeader();
    boolean isSpruceEnabled = false;
    if (header != null) {
      isSpruceEnabled = (appExecContext.getWorkflowHeader().getURGENCY() != null);
      ResourceMapping resourceMapping = appExecContext.getWorkflowHeader().getResourceMappings().getResourceMappingArray()[0];
      if (resourceMapping != null) {
        URI gatekeeperfromResourceMapping = null;
        try {
          gatekeeperfromResourceMapping = new URI(resourceMapping.getGatekeeperEpr());
        } catch (URISyntaxException e) {
          throw new GfacException(e.getLocalizedMessage(), e);
        }
        if (gatekeeperfromResourceMapping != null) {
          log.info("Gate keeper selected from resource mapping");
          GlobusGatekeeperType gatekeeper = GlobusGatekeeperType.Factory.newInstance();

          if (!resourceMapping.getWsgramPreferred()) {
            if (resourceMapping.getJobManager() != null) {
              throw new GfacException("Job Manager parameter must not defined for Pre-WSGram in Resource Mapping, " + "include it with your gatekeepr EPR in resource mapping", FaultCode.InternalServiceError);
            }
          } else {
            if (resourceMapping.getJobManager() != null) {
              gatekeeper.setJobmanagertype(GlobusJobManagerType.Enum.forString(resourceMapping.getJobManager()));
            }
          }
          gatekeeper.setEndPointReference(gatekeeperfromResourceMapping.toString());
          return gatekeeper;
        }
View Full Code Here

        if(!outputDataDir.isEmpty()){
    jobAttr.addEnvVariable(outputDataDir, appExecContext.getExecutionModel().getOutputDataDir());
        }
    ApplicationDescriptionType app = appExecContext.getExecutionModel().getAplicationDesc();
    WorkflowContextHeader contextHeader = appExecContext.getWorkflowHeader();
    ResourceMapping resourceMapping = null;
    if (contextHeader != null) {
      resourceMapping = contextHeader.getResourceMappings().getResourceMappingArray(0);
    }

    log.info("Configure using App Desc = " + app.xmlText());
    if (resourceMapping != null && resourceMapping.getMaxWallTime() > 0) {
      log.info("Header Setting Max Wall Time" + resourceMapping.getMaxWallTime());
      jobAttr.setMaxWallTime(resourceMapping.getMaxWallTime());

    } else if (app.getMaxWallTime() > 0) {
      log.info("Setting max wall clock time to " + app.getMaxWallTime());

      if (app.getMaxWallTime() > 30 && app.getQueue() != null && app.getQueue().equals("debug")) {
        throw new GfacException("NCSA debug Queue only support jobs < 30 minutes", FaultCode.InvalidConfig);
      }

      jobAttr.setMaxWallTime(app.getMaxWallTime());
      jobAttr.set("proxy_timeout", "1");
    } else {
      jobAttr.setMaxWallTime(29);
    }

    if (appExecContext.getExecutionModel().getStdIn() != null) {
      jobAttr.setStdin(appExecContext.getExecutionModel().getStdIn());
    } else {
      Iterator<String> values = appExecContext.getExecutionModel().getInputParameters().iterator();
      while (values.hasNext()) {
        jobAttr.addArgument(values.next());
      }
    }
   
    if (resourceMapping != null && resourceMapping.getNodeCount() > 0) {
      log.info("Setting number of procs to " + resourceMapping.getNodeCount());
      jobAttr.set("hostCount", String.valueOf(resourceMapping.getNodeCount()));
    }else if (app.getHostCount() > 1) {
      jobAttr.set("hostCount", String.valueOf(app.getHostCount()));
    }
    if (resourceMapping != null && resourceMapping.getCpuCount() > 0) {
      log.info("Setting host count to " + resourceMapping.getCpuCount());
      jobAttr.setNumProcs(resourceMapping.getCpuCount());
     
    } else if (app.getCount() > 1) {
      log.info("Setting number of procs to " + app.getCount());
      jobAttr.setNumProcs(app.getCount());
    }

    if (app.getProject() != null && app.getProject().getProjectName() != null) {
      log.info("Setting project to " + app.getProject());
      jobAttr.setProject(app.getProject().getProjectName());
    }

    if (resourceMapping != null && resourceMapping.getQueueName() != null) {
      jobAttr.setQueue(resourceMapping.getQueueName());
    } else if (app.getQueue() != null && app.getQueue().getQueueName() != null) {
      log.info("Setting job queue to " + app.getQueue());
      jobAttr.setQueue(app.getQueue().getQueueName());
    }
    String jobType = JobType.SINGLE.toString() ;
View Full Code Here

      throws GFacProviderException {
    UnicoreHostType host = (UnicoreHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType();
       
        String factoryUrl = host.getUnicoreHostAddressArray()[0];

        EndpointReferenceType eprt = EndpointReferenceType.Factory.newInstance();
        eprt.addNewAddress().setStringValue(factoryUrl);

        CreateActivityDocument cad = CreateActivityDocument.Factory
                .newInstance();
       
        try {
      cad.addNewCreateActivity().addNewActivityDocument()
              .setJobDefinition(JSDLGenerator.buildJSDLInstance(jobExecutionContext).getJobDefinition());
    } catch (Exception e1) {
      throw new GFacProviderException("Cannot generate JSDL instance from the JobExecutionContext.",e1);
    }
       
        FactoryClient factory = null;
        try {
            factory = new FactoryClient(eprt, secProperties);
        } catch (Exception e) {
            throw new GFacProviderException("");
        }
        CreateActivityResponseDocument response = null;
        try {
            log.info(String.format("Activity Submitting to %s ... \n", factoryUrl));
            response = factory.createActivity(cad);
            log.info(String.format("Activity Submitted to %s \n", factoryUrl));
        } catch (Exception e) {
          e.printStackTrace();
            throw new GFacProviderException("Cannot create activity.", e);
        }
        EndpointReferenceType activityEpr = response
                .getCreateActivityResponse().getActivityIdentifier();
       
        log.debug("Activity EPR: "+activityEpr);
       
        log.info("Activity: "+activityEpr.getAddress().getStringValue()" Submitted.");
       
        //factory.waitWhileActivityIsDone(activityEpr, 1000);
        jobId = WSUtilities.extractResourceID(activityEpr);
        if (jobId == null) {
            jobId = new Long(Calendar.getInstance().getTimeInMillis())
                    .toString();
        }
       
        log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(), factory.getActivityStatus(activityEpr)
                .toString()));
       
       
        //TODO publish the status messages to the message bus
        while ((factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FINISHED) &&
                (factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FAILED)){
         
            ActivityStatusType activityStatus = null;
        try {
          activityStatus = getStatus(factory, activityEpr);
          log.info (subStatusAsString(activityStatus));
        } catch (UnknownActivityIdentifierFault e) {
          throw new GFacProviderException(e.getMessage(), e.getCause());
        }
 
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
            continue;
        }
       
        ActivityStatusType activityStatus = null;
    try {
      activityStatus = getStatus(factory, activityEpr);
    } catch (UnknownActivityIdentifierFault e) {
      throw new GFacProviderException(e.getMessage(), e.getCause());
    }
       
        log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(), activityStatus.getState().toString()));
       
    if ((activityStatus.getState() == ActivityStateEnumeration.FAILED)) {
        log.info(activityStatus.getFault().getFaultcode().getLocalPart()
            + "\n" + activityStatus.getFault().getFaultstring());
        log.info("EXITCODE: "+activityStatus.getExitCode());
View Full Code Here

            /*
             * Set Security
             */
            securityProperties = initSecurityProperties();
            String factoryUrl = job.getFactoryUrl();
            EndpointReferenceType eprt = EndpointReferenceType.Factory
                    .newInstance();
            eprt.addNewAddress().setStringValue(factoryUrl);
            System.out.println("========================================");
            System.out.println(String.format("Job Submitted to %s.\n", factoryUrl));
            FactoryClient factory = null;
            try {
                factory = new FactoryClient(eprt, securityProperties);
            } catch (Exception e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
            CreateActivityDocument cad = CreateActivityDocument.Factory
                    .newInstance();
            cad.addNewCreateActivity().addNewActivityDocument()
                    .setJobDefinition(job.getJobDoc().getJobDefinition());
            CreateActivityResponseDocument response = null;
            try {
                response = factory.createActivity(cad);
            } catch (NotAcceptingNewActivitiesFault notAcceptingNewActivitiesFault) {
                notAcceptingNewActivitiesFault.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            } catch (InvalidRequestMessageFault invalidRequestMessageFault) {
                invalidRequestMessageFault.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            } catch (UnsupportedFeatureFault unsupportedFeatureFault) {
                unsupportedFeatureFault.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
            EndpointReferenceType activityEpr = response
                    .getCreateActivityResponse().getActivityIdentifier();
            //factory.waitWhileActivityIsDone(activityEpr, 1000);
            jobId = WSUtilities.extractResourceID(activityEpr);
            if (jobId == null) {
                jobId = new Long(Calendar.getInstance().getTimeInMillis())
                        .toString();
            }
            ActivityStateEnumeration.Enum state = factory.getActivityStatus(activityEpr);

            String status;

            status = String.format("Job %s is %s.\n", activityEpr.getAddress()
                    .getStringValue(), factory.getActivityStatus(activityEpr)
                    .toString()).toString();


            while ((factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FINISHED) &&
                    (factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FAILED)){
                status = String.format("Job %s is %s.\n", activityEpr.getAddress()
                        .getStringValue(), factory.getActivityStatus(activityEpr)
                        .toString()).toString();
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                }
                continue;
            }

            status = String.format("Job %s is %s.\n", activityEpr.getAddress()
                    .getStringValue(), factory.getActivityStatus(activityEpr)
                    .toString()).toString();

            log.debug("Request to contact:" + unicoreHost);

View Full Code Here

      throws GFacProviderException {
    UnicoreHostType host = (UnicoreHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType();
       
        String factoryUrl = host.getUnicoreBESEndPointArray()[0];

        EndpointReferenceType eprt = EndpointReferenceType.Factory.newInstance();
        eprt.addNewAddress().setStringValue(factoryUrl);

        CreateActivityDocument cad = CreateActivityDocument.Factory
                .newInstance();
       
    JobDefinitionType jobDefinition = null;
        try {
            //FIXME: Replace by a native client
//      jobDefinition = JSDLGenerator.buildJSDLInstance(jobExecutionContext).getJobDefinition();
//      cad.addNewCreateActivity().addNewActivityDocument().setJobDefinition(jobDefinition);
      System.out.println("REMOVE ME");
    } catch (Exception e1) {
      throw new GFacProviderException("Cannot generate JSDL instance from the JobExecutionContext.",e1);
    }
       
        FactoryClient factory = null;
        try {
            factory = new FactoryClient(eprt, secProperties);
        } catch (Exception e) {
            throw new GFacProviderException("");
        }
        CreateActivityResponseDocument response = null;
        try {
            log.info(String.format("Activity Submitting to %s ... \n", factoryUrl));
            response = factory.createActivity(cad);
            log.info(String.format("Activity Submitted to %s \n", factoryUrl));
        } catch (Exception e) {
          e.printStackTrace();
            throw new GFacProviderException("Cannot create activity.", e);
        }
        EndpointReferenceType activityEpr = response
                .getCreateActivityResponse().getActivityIdentifier();
       
        log.debug("Activity EPR: "+activityEpr);
       
        log.info("Activity: "+activityEpr.getAddress().getStringValue()" Submitted.");
       
        //factory.waitWhileActivityIsDone(activityEpr, 1000);
        jobId = WSUtilities.extractResourceID(activityEpr);
        if (jobId == null) {
            jobId = new Long(Calendar.getInstance().getTimeInMillis())
                    .toString();
        }
    saveApplicationJob(jobExecutionContext, jobDefinition);
        log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(), factory.getActivityStatus(activityEpr)
                .toString()));
       
       
        //TODO publish the status messages to the message bus
        while ((factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FINISHED) &&
                (factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FAILED)){
         
            ActivityStatusType activityStatus = null;
        try {
          activityStatus = getStatus(factory, activityEpr);
          GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobId, getApplicationJobStatus(activityStatus));
          log.info (subStatusAsString(activityStatus));
        } catch (UnknownActivityIdentifierFault e) {
          throw new GFacProviderException(e.getMessage(), e.getCause());
        }
 
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
            continue;
        }
       
        ActivityStatusType activityStatus = null;
    try {
      activityStatus = getStatus(factory, activityEpr);
    } catch (UnknownActivityIdentifierFault e) {
      throw new GFacProviderException(e.getMessage(), e.getCause());
    }
       
        log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(), activityStatus.getState().toString()));
       
    if ((activityStatus.getState() == ActivityStateEnumeration.FAILED)) {
        log.info(activityStatus.getFault().getFaultcode().getLocalPart()
            + "\n" + activityStatus.getFault().getFaultstring());
        log.info("EXITCODE: "+activityStatus.getExitCode());
View Full Code Here

      throws GFacProviderException {
    UnicoreHostType host = (UnicoreHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType();
       
        String factoryUrl = host.getUnicoreBESEndPointArray()[0];

        EndpointReferenceType eprt = EndpointReferenceType.Factory.newInstance();
        eprt.addNewAddress().setStringValue(factoryUrl);

        CreateActivityDocument cad = CreateActivityDocument.Factory
                .newInstance();
       
    JobDefinitionType jobDefinition = null;
        try {
            //FIXME: Replace by a native client
//      jobDefinition = JSDLGenerator.buildJSDLInstance(jobExecutionContext).getJobDefinition();
//      cad.addNewCreateActivity().addNewActivityDocument().setJobDefinition(jobDefinition);
      System.out.println("REMOVE ME");
    } catch (Exception e1) {
      throw new GFacProviderException("Cannot generate JSDL instance from the JobExecutionContext.",e1);
    }
       
        FactoryClient factory = null;
        try {
            factory = new FactoryClient(eprt, secProperties);
        } catch (Exception e) {
            throw new GFacProviderException("");
        }
        CreateActivityResponseDocument response = null;
        try {
            log.info(String.format("Activity Submitting to %s ... \n", factoryUrl));
            response = factory.createActivity(cad);
            log.info(String.format("Activity Submitted to %s \n", factoryUrl));
        } catch (Exception e) {
          e.printStackTrace();
            throw new GFacProviderException("Cannot create activity.", e);
        }
        EndpointReferenceType activityEpr = response
                .getCreateActivityResponse().getActivityIdentifier();
       
        log.debug("Activity EPR: "+activityEpr);
       
        log.info("Activity: "+activityEpr.getAddress().getStringValue()" Submitted.");
       
        //factory.waitWhileActivityIsDone(activityEpr, 1000);
        jobId = WSUtilities.extractResourceID(activityEpr);
        if (jobId == null) {
            jobId = new Long(Calendar.getInstance().getTimeInMillis())
                    .toString();
        }
    saveApplicationJob(jobExecutionContext, jobDefinition);
        log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(), factory.getActivityStatus(activityEpr)
                .toString()));
       
       
        //TODO publish the status messages to the message bus
        while ((factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FINISHED) &&
                (factory.getActivityStatus(activityEpr) != ActivityStateEnumeration.FAILED)){
         
            ActivityStatusType activityStatus = null;
        try {
          activityStatus = getStatus(factory, activityEpr);
          GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobId, getApplicationJobStatus(activityStatus));
          log.info (subStatusAsString(activityStatus));
        } catch (UnknownActivityIdentifierFault e) {
          throw new GFacProviderException(e.getMessage(), e.getCause());
        }
 
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
            continue;
        }
       
        ActivityStatusType activityStatus = null;
    try {
      activityStatus = getStatus(factory, activityEpr);
    } catch (UnknownActivityIdentifierFault e) {
      throw new GFacProviderException(e.getMessage(), e.getCause());
    }
       
        log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(), activityStatus.getState().toString()));
       
    if ((activityStatus.getState() == ActivityStateEnumeration.FAILED)) {
        log.info(activityStatus.getFault().getFaultcode().getLocalPart()
            + "\n" + activityStatus.getFault().getFaultstring());
        log.info("EXITCODE: "+activityStatus.getExitCode());
View Full Code Here

        envelope.addNewBody();
        Header header = envelope.addNewHeader();
        XmlObject toElem;
        XmlObject actionElem;
        org.xmlsoap.schemas.ws.x2004.x08.addressing.ToDocument toDoc = org.xmlsoap.schemas.ws.x2004.x08.addressing.ToDocument.Factory.newInstance();
        AttributedURI attributedURI = toDoc.addNewTo();
        attributedURI.setStringValue(address);
        toElem = toDoc;
        org.xmlsoap.schemas.ws.x2004.x08.addressing.ActionDocument actionDoc = org.xmlsoap.schemas.ws.x2004.x08.addressing.ActionDocument.Factory.newInstance();
        AttributedURI actionType = actionDoc.addNewAction();
        actionType.setStringValue( MetadataExchangeConstants.ACTION_GET );
        actionElem = actionDoc;

        XmlBeanUtils.addChildElement( header, toElem );
        XmlBeanUtils.addChildElement( header, actionElem );
        if (endpointReferenceType.getReferenceProperties() != null)
View Full Code Here

TOP

Related Classes of org.ggf.schemas.bes.x2006.x08.besFactory.CreateActivityDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.