Package org.ogce.schemas.gfac.documents

Examples of org.ogce.schemas.gfac.documents.HostDescriptionType


    }

    public static void removeHostDesc(RegistryService registryService, String hostDescAsStr)
            throws GfacException {
        try {
            HostDescriptionType appDesc = HostDescriptionDocument.Factory.parse(hostDescAsStr)
                    .getHostDescription();
            registryService.removeHostDesc(appDesc.getHostName());
        } catch (XmlException e) {
            throw new GfacException(e,FaultCode.LocalError);
        }
    }
View Full Code Here


*/
public class HostUtils {

  public static HostBean simpleHostBeanRequest(String hostDescStr)
      throws XmlException {
    HostDescriptionType hostDesc = HostDescriptionDocument.Factory.parse(
        hostDescStr).getHostDescription();

    HostBean hostBean = new HostBean();

    hostBean.setHostName(hostDesc.getHostName());
    hostBean.setGFacPath(hostDesc.getHostConfiguration().getGFacPath());

    PortRangeType portRange = hostDesc.getHostConfiguration()
        .getPortRange();
    if (portRange != null) {
      hostBean.setPortRangeStart(portRange.getStart());
      hostBean.setPortRangeEnd(portRange.getEnd());
    }
    PackageType[] java = hostDesc.getHostConfiguration().getJavaArray();
    if (java.length > 0) {
      hostBean.setJdkPath(java[0].getHome());
    }
    hostBean.setTmpDir(hostDesc.getHostConfiguration().getTmpDir());
    NameValuePairType[] hostEnvs = hostDesc.getHostConfiguration()
        .getHostEnvArray();
    if (hostEnvs.length > 0) {
      StringBuffer buf = new StringBuffer();
      String prefix = "";
      for (NameValuePairType envVal : hostEnvs) {
        buf.append(prefix);
        buf.append(envVal.getName()).append("=").append(
            envVal.getValue());
        prefix = ",";
      }
      hostBean.setHostEnv(buf.toString());
    }
    hostBean.setSshEnabled(hostDesc.getHostConfiguration().getSshEnabled());
    if (hostDesc.getHostConfiguration().getGlobusGatekeeperArray().length > 0) {
      hostBean
          .setGateKeeperJobManager(hostDesc.getHostConfiguration()
              .getGlobusGatekeeperArray(0).getJobmanagertype()
              .toString());
      // We are taking 1st value for now
      hostBean.setGateKeeperendPointReference(hostDesc
          .getHostConfiguration().getGlobusGatekeeperArray(0)
          .getEndPointReference().toString());
      hostBean.setGateKeeperName(hostDesc.getHostConfiguration()
          .getGlobusGatekeeperArray(0).getName());
      hostBean.setWsGram(hostDesc.getHostConfiguration()
          .getGlobusGatekeeperArray(0).getWsGram());
    }
    if (hostDesc.getHostConfiguration().getGridFTPArray().length > 0) {
      hostBean.setGridFtpName(hostDesc.getHostConfiguration()
          .getGridFTPArray(0).getName());
      hostBean.setGridFtpendPointReference(hostDesc
          .getHostConfiguration().getGridFTPArray(0)
          .getEndPointReference());
    }

    return hostBean;
View Full Code Here

  public static String simpleHostXMLRequest(HostBean host)
      throws GFacSchemaException {

    HostDescriptionDocument hostDescDoc = HostDescriptionDocument.Factory.newInstance();
    HostDescriptionType hostDesc = hostDescDoc.addNewHostDescription();
   
    hostDesc.setHostName(host.getHostName().trim());
    HostConfigurationType hostConf = hostDesc.getHostConfiguration();
    if (hostConf == null) {
      hostConf = hostDesc.addNewHostConfiguration();
    }
    // Added to support extra fields
    if (!host.getGateKeeperendPointReference().isEmpty()) {
      GlobusGatekeeperType gatekeeperType;
      if (hostConf.sizeOfGlobusGatekeeperArray() == 0) {
        gatekeeperType = hostConf.addNewGlobusGatekeeper();
      } else {
        gatekeeperType = hostConf.getGlobusGatekeeperArray(0);
      }
      gatekeeperType.setEndPointReference(host
          .getGateKeeperendPointReference());
      gatekeeperType.setWsGram(host.isWsGram());
      gatekeeperType.setName(host.getGateKeeperName());
      if (host.getGateKeeperJobManager() != null) {
        String jobmanager = host.getGateKeeperJobManager();
        if (jobmanager.equals(GlobusJobManagerType.CONDOR.toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.CONDOR);
        } else if (jobmanager.equals(GlobusJobManagerType.FORK
            .toString())) {
          gatekeeperType.setJobmanagertype(GlobusJobManagerType.SGE);
        } else if (jobmanager.equals(GlobusJobManagerType.SGE
            .toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.LOADLEVELER);
        } else if (jobmanager.equals(GlobusJobManagerType.LOADLEVELER
            .toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.LOADLEVELER);
        } else if (jobmanager.equals(GlobusJobManagerType.LSF
            .toString())) {
          gatekeeperType.setJobmanagertype(GlobusJobManagerType.LSF);
        } else if (jobmanager.equals(GlobusJobManagerType.MULTI
            .toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.MULTI);
        } else if (jobmanager.equals(GlobusJobManagerType.PBS
            .toString())) {
          gatekeeperType.setJobmanagertype(GlobusJobManagerType.PBS);
        } else if (jobmanager.equals(GlobusJobManagerType.SPRUCE
            .toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.SPRUCE);
        }

      }
    }
    if (!host.getGridFtpendPointReference().isEmpty()) {
      GridFTPType gridFTPType;
      if (hostConf.sizeOfGridFTPArray() == 0) {
        gridFTPType = hostConf.addNewGridFTP();
      } else {
        gridFTPType = hostConf.getGridFTPArray(0);
      }
      gridFTPType
          .setEndPointReference(host.getGridFtpendPointReference());
      gridFTPType.setName(host.getGridFtpName());
    }

    hostConf.setGFacPath(host.getGFacPath());
    hostConf.setTmpDir(host.getTmpDir());

    PortRangeType portRangeType = hostConf.getPortRange();
    if (portRangeType == null) {
      portRangeType = hostConf.addNewPortRange();
    }
    if (host.getPortRangeStart() > 0 && host.getPortRangeEnd() > 0) {
      portRangeType.setStart(Integer.valueOf(host.getPortRangeStart()));
      portRangeType.setEnd(Integer.valueOf(host.getPortRangeEnd()));
    }

    PackageType javaInstallation;
    if (hostConf.getJavaArray() != null
        && hostConf.getJavaArray().length > 0) {
      javaInstallation = hostConf.getJavaArray(0);
    } else {
      javaInstallation = hostConf.addNewJava();
    }
    String jdkName = host.getJdkName();
    javaInstallation.setName(jdkName);
    javaInstallation.setHome(host.getJdkPath());
    // FIXME: hostBean should not be needed
    javaInstallation.setVersion(jdkName.replaceAll("java", ""));

    if (host.getHostEnv() != null) {
      HashMap<String, NameValuePairType> envMap = new HashMap<String, NameValuePairType>();
      if (hostConf.getHostEnvArray() != null) {
        for (NameValuePairType pair : hostConf.getHostEnvArray()) {
          envMap.put(pair.getName(), pair);
        }
      }

      StringTokenizer tokernizer = new StringTokenizer(host.getHostEnv(),
          ";");
      while (tokernizer.hasMoreTokens()) {
        String nameVal = tokernizer.nextToken();

        int index = nameVal.indexOf('=');
        if (index <= 0) {
          throw new GFacSchemaException("Illegal Name value Pairs "
              + host.getHostEnv() + " at parsing " + nameVal);
        }
        String name = nameVal.substring(0, index);
        NameValuePairType nmPair = envMap.get(name);
        if (nmPair == null) {
          nmPair = hostConf.addNewHostEnv();
        }
        nmPair.setName(name);
        nmPair.setValue(nameVal.substring(index + 1));
      }
    }
    if (host.isSshEnabled()) {
      hostDesc.getHostConfiguration().setSshEnabled(true);
    }
   
    SchemaValidator validator = new SchemaValidator(hostDesc);
    validator.validate();
View Full Code Here

                    in.close();
                }
                System.out.println("File upload called for "+ documentType );
              if(documentType.equals(ServiceConstants.SEARCH_HOST)){
                HostUtils.createObject(context.getRegService(), sb.toString());
                HostDescriptionType hostDesc = HostDescriptionDocument.Factory.parse(
                    sb.toString()).getHostDescription();
                documentName = hostDesc.getHostName();
                }else if(documentType.equals(ServiceConstants.SEARCH_APPLICATION)){
                ApplicationUtils.createObject(context.getRegService(), sb.toString());
                ApplicationDescriptionType appType = ApplicationDescriptionDocument.Factory.parse(sb.toString()).getApplicationDescription();
                documentName = appType.getApplicationName().getStringValue();
                }else if(documentType.equals(ServiceConstants.SEARCH_SERVICE)){
View Full Code Here

    }


    public static HostDescriptionType parseHostDescirption(String hostDescStr) throws GFacSchemaException {
        try {
            HostDescriptionType hostDesc = HostDescriptionDocument.Factory.parse(hostDescStr)
                    .getHostDescription();
            SchemaValidator validator = new SchemaValidator(hostDesc);
            validator.validate();
            return hostDesc;
        } catch (XmlException e) {
View Full Code Here

   */
  public Object getBeanObjectInfo(RegistryService registryService,
      String hostName) throws GfacException {
    String hostDescStr = registryService.getHostDesc(hostName);
    if (hostDescStr != null) {
      HostDescriptionType hostDescriptionType = GfacUtils
          .parseHostDescirption(hostDescStr);
      return new HostBean(hostDescriptionType);
    } else {
      throw new GfacException("Host of name " + hostName
          + " does not exist", FaultCode.InvaliedLocalArgumnet);
View Full Code Here

   */
  private static String hostXMLRequest(HostBean host,
      HostDescriptionDocument template) throws GfacException {
    try {
      HostDescriptionDocument hostDescDoc = template;
      HostDescriptionType hostDesc;
      if (hostDescDoc == null) {
        hostDescDoc = HostDescriptionDocument.Factory.newInstance();
        hostDesc = hostDescDoc.addNewHostDescription();
      } else {
        hostDesc = hostDescDoc.getHostDescription();
      }
      hostDesc.setHostName(host.getHostName().trim());
      HostConfigurationType hostConf = hostDesc.getHostConfiguration();
      if (hostConf == null) {
        hostConf = hostDesc.addNewHostConfiguration();
      }
      // Added to support extra fields
      if(!host.getGateKeeperendPointReference().isEmpty()){
      GlobusGatekeeperType gatekeeperType;
      if (hostConf.sizeOfGlobusGatekeeperArray() == 0) {
        gatekeeperType = hostConf.addNewGlobusGatekeeper();
      } else {
        gatekeeperType = hostConf.getGlobusGatekeeperArray(0);
      }
      gatekeeperType.setEndPointReference(host
          .getGateKeeperendPointReference());
      gatekeeperType.setWsGram(host.isWsGram());
      gatekeeperType.setName(host.getGateKeeperName());
      if (host.getGateKeeperJobManager() != null) {
        String jobmanager = host.getGateKeeperJobManager();
        if (jobmanager.equals(GlobusJobManagerType.CONDOR.toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.CONDOR);
        } else if (jobmanager.equals(GlobusJobManagerType.FORK
            .toString())) {
          gatekeeperType.setJobmanagertype(GlobusJobManagerType.FORK);
        } else if (jobmanager.equals(GlobusJobManagerType.LOADLEVELER
            .toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.LOADLEVELER);
        } else if (jobmanager.equals(GlobusJobManagerType.LSF
            .toString())) {
          gatekeeperType.setJobmanagertype(GlobusJobManagerType.LSF);
        } else if (jobmanager.equals(GlobusJobManagerType.MULTI
            .toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.MULTI);
        } else if (jobmanager.equals(GlobusJobManagerType.PBS
            .toString())) {
          gatekeeperType.setJobmanagertype(GlobusJobManagerType.PBS);
        } else if (jobmanager.equals(GlobusJobManagerType.SPRUCE
            .toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.SPRUCE);
        }

      }
      }
      if(!host.getGridFtpendPointReference().isEmpty()){
      GridFTPType gridFTPType;
      if (hostConf.sizeOfGridFTPArray() == 0) {
        gridFTPType = hostConf.addNewGridFTP();
      } else {
        gridFTPType = hostConf.getGridFTPArray(0);
      }
      gridFTPType
          .setEndPointReference(host.getGridFtpendPointReference());
      gridFTPType.setName(host.getGridFtpName());
      }
     
      hostConf.setGFacPath(host.getGFacPath());
      hostConf.setTmpDir(host.getTmpDir());

      PortRangeType portRangeType = hostConf.getPortRange();
      if (portRangeType == null) {
        portRangeType = hostConf.addNewPortRange();
      }
      if (host.getPortRangeStart() > 0 && host.getPortRangeEnd() > 0) {
        portRangeType.setStart(Integer
            .valueOf(host.getPortRangeStart()));
        portRangeType.setEnd(Integer.valueOf(host.getPortRangeEnd()));
      }

      PackageType javaInstallation;
      if (hostConf.getJavaArray() != null
          && hostConf.getJavaArray().length > 0) {
        javaInstallation = hostConf.getJavaArray(0);
      } else {
        javaInstallation = hostConf.addNewJava();
      }
      String jdkName = host.getJdkName();
      javaInstallation.setName(jdkName);
      javaInstallation.setHome(host.getJdkPath());
      //FIXME: this should not be needed
      javaInstallation.setVersion(jdkName.replaceAll("java", ""));

      if (host.getHostEnv() != null) {
        HashMap<String, NameValuePairType> envMap = new HashMap<String, NameValuePairType>();
        if (hostConf.getHostEnvArray() != null) {
          for (NameValuePairType pair : hostConf.getHostEnvArray()) {
            envMap.put(pair.getName(), pair);
          }
        }

        StringTokenizer tokernizer = new StringTokenizer(host
            .getHostEnv(), ";");
        while (tokernizer.hasMoreTokens()) {
          String nameVal = tokernizer.nextToken();

          int index = nameVal.indexOf('=');
          if (index <= 0) {
            throw new GfacException("Illegal Name value Pairs "
                + host.getHostEnv() + " at parsing " + nameVal,
                FaultCode.InvaliedLocalArgumnet);
          }
          String name = nameVal.substring(0, index);
          NameValuePairType nmPair = envMap.get(name);
          if (nmPair == null) {
            nmPair = hostConf.addNewHostEnv();
          }
          nmPair.setName(name);
          nmPair.setValue(nameVal.substring(index + 1));
        }
      }
      if(host.isSshEnabled()){
      hostDesc.getHostConfiguration().setSshEnabled(true);
      }
      // Validates correctness of XML message
      try {
        SchemaValidator validator = new SchemaValidator(hostDesc);
        validator.validate();
View Full Code Here

  }
 
  public static String simpleHostXMLRequest(HostBean host) throws GfacException {
    try {
      HostDescriptionDocument hostDescDoc = null;
      HostDescriptionType hostDesc;
      if (hostDescDoc == null) {
        hostDescDoc = HostDescriptionDocument.Factory.newInstance();
        hostDesc = hostDescDoc.addNewHostDescription();
      } else {
        hostDesc = hostDescDoc.getHostDescription();
      }
      hostDesc.setHostName(host.getHostName().trim());
      HostConfigurationType hostConf = hostDesc.getHostConfiguration();
      if (hostConf == null) {
        hostConf = hostDesc.addNewHostConfiguration();
      }
      // Added to support extra fields
      if(!host.getGateKeeperendPointReference().isEmpty()){
      GlobusGatekeeperType gatekeeperType;
      if (hostConf.sizeOfGlobusGatekeeperArray() == 0) {
        gatekeeperType = hostConf.addNewGlobusGatekeeper();
      } else {
        gatekeeperType = hostConf.getGlobusGatekeeperArray(0);
      }
      gatekeeperType.setEndPointReference(host
          .getGateKeeperendPointReference());
      gatekeeperType.setWsGram(host.isWsGram());
      gatekeeperType.setName(host.getGateKeeperName());
      if (host.getGateKeeperJobManager() != null) {
        String jobmanager = host.getGateKeeperJobManager();
        if (jobmanager.equals(GlobusJobManagerType.CONDOR.toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.CONDOR);
        } else if (jobmanager.equals(GlobusJobManagerType.FORK
            .toString())) {
          gatekeeperType.setJobmanagertype(GlobusJobManagerType.FORK);
        } else if (jobmanager.equals(GlobusJobManagerType.LOADLEVELER
            .toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.LOADLEVELER);
        } else if (jobmanager.equals(GlobusJobManagerType.LSF
            .toString())) {
          gatekeeperType.setJobmanagertype(GlobusJobManagerType.LSF);
        } else if (jobmanager.equals(GlobusJobManagerType.MULTI
            .toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.MULTI);
        } else if (jobmanager.equals(GlobusJobManagerType.PBS
            .toString())) {
          gatekeeperType.setJobmanagertype(GlobusJobManagerType.PBS);
        } else if (jobmanager.equals(GlobusJobManagerType.SPRUCE
            .toString())) {
          gatekeeperType
              .setJobmanagertype(GlobusJobManagerType.SPRUCE);
        }

      }
      }
      if(!host.getGridFtpendPointReference().isEmpty()){
      GridFTPType gridFTPType;
      if (hostConf.sizeOfGridFTPArray() == 0) {
        gridFTPType = hostConf.addNewGridFTP();
      } else {
        gridFTPType = hostConf.getGridFTPArray(0);
      }
      gridFTPType
          .setEndPointReference(host.getGridFtpendPointReference());
      gridFTPType.setName(host.getGridFtpName());
      }
     
      hostConf.setGFacPath(host.getGFacPath());
      hostConf.setTmpDir(host.getTmpDir());

      PortRangeType portRangeType = hostConf.getPortRange();
      if (portRangeType == null) {
        portRangeType = hostConf.addNewPortRange();
      }
      if (host.getPortRangeStart() > 0 && host.getPortRangeEnd() > 0) {
        portRangeType.setStart(Integer
            .valueOf(host.getPortRangeStart()));
        portRangeType.setEnd(Integer.valueOf(host.getPortRangeEnd()));
      }

      PackageType javaInstallation;
      if (hostConf.getJavaArray() != null
          && hostConf.getJavaArray().length > 0) {
        javaInstallation = hostConf.getJavaArray(0);
      } else {
        javaInstallation = hostConf.addNewJava();
      }
      String jdkName = host.getJdkName();
      javaInstallation.setName(jdkName);
      javaInstallation.setHome(host.getJdkPath());
      //FIXME: this should not be needed
      javaInstallation.setVersion(jdkName.replaceAll("java", ""));

      if (host.getHostEnv() != null) {
        HashMap<String, NameValuePairType> envMap = new HashMap<String, NameValuePairType>();
        if (hostConf.getHostEnvArray() != null) {
          for (NameValuePairType pair : hostConf.getHostEnvArray()) {
            envMap.put(pair.getName(), pair);
          }
        }

        StringTokenizer tokernizer = new StringTokenizer(host
            .getHostEnv(), ";");
        while (tokernizer.hasMoreTokens()) {
          String nameVal = tokernizer.nextToken();

          int index = nameVal.indexOf('=');
          if (index <= 0) {
            throw new GfacException("Illegal Name value Pairs "
                + host.getHostEnv() + " at parsing " + nameVal,
                FaultCode.InvaliedLocalArgumnet);
          }
          String name = nameVal.substring(0, index);
          NameValuePairType nmPair = envMap.get(name);
          if (nmPair == null) {
            nmPair = hostConf.addNewHostEnv();
          }
          nmPair.setName(name);
          nmPair.setValue(nameVal.substring(index + 1));
        }
      }
      if(host.isSshEnabled()){
      hostDesc.getHostConfiguration().setSshEnabled(true);
      }
      // Validates correctness of XML message
      try {
        SchemaValidator validator = new SchemaValidator(hostDesc);
        validator.validate();
View Full Code Here

        String appDesc = registryService.getAppDesc(appName.toString(), hostName);
        ApplicationDescriptionType appDescType = ApplicationDescriptionDocument.Factory.parse(appDesc).getApplicationDescription();

        // host desc
        String hostDesc = registryService.getHostDesc(hostName);
        HostDescriptionType hostDescType = HostDescriptionDocument.Factory.parse(hostDesc).getHostDescription();

        // application deployment
        DeploymentDescriptionType deploymentDesc = appDescType.getDeploymentDescription();
        String tmpDir = deploymentDesc.getTmpDir();
        if (tmpDir == null && hostDescType != null) {
          tmpDir = hostDescType.getHostConfiguration().getTmpDir();
        }

        if (tmpDir == null) {
          tmpDir = "/tmp";
        }

        String date = new Date().toString();
        date = date.replaceAll(" ", "_");
        date = date.replaceAll(":", "_");

        tmpDir = tmpDir + File.separator + appDescType.getApplicationName().getStringValue() + "_" + date + "_" + UUID.randomUUID();

        String workingDir = deploymentDesc.getWorkDir();
        if (workingDir == null || workingDir.trim().length() == 0) {
          workingDir = tmpDir;
        }

        String stdOut = tmpDir + File.separator + appDescType.getApplicationName().getStringValue() + ".stdout";
        String stderr = tmpDir + File.separator + appDescType.getApplicationName().getStringValue() + ".stderr";
        String executable = deploymentDesc.getExecutable();
        String host = deploymentDesc.getHostName();

        NameValuePairType[] env = deploymentDesc.getApplicationEnvArray();
        Map<String, String> envMap = new HashMap<String, String>();
        if (env != null) {
          for (int i = 0; i < env.length; i++) {
            envMap.put(env[i].getName(), env[i].getValue());
          }
        }

        String inputDataDir = tmpDir + File.separator + "inputData";
        String outputDataDir = tmpDir + File.separator + "outputData";

        GlobusGatekeeperType[] gatekeepers = hostDescType.getHostConfiguration().getGlobusGatekeeperArray();

        ExecutionModel model = new ExecutionModel();
        model.setHost(host);
        model.setExecutable(executable);
        model.setTmpDir(tmpDir);
View Full Code Here

    }
  }

  public static HostDescriptionType parseHostDescirption(String hostDescStr) throws GfacException {
    try {
      HostDescriptionType hostDesc = HostDescriptionDocument.Factory.parse(hostDescStr).getHostDescription();
      SchemaValidator validator = new SchemaValidator(hostDesc);
      validator.validate();
      return hostDesc;
    } catch (Exception e) {
      throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
View Full Code Here

TOP

Related Classes of org.ogce.schemas.gfac.documents.HostDescriptionType

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.