Examples of GfacException


Examples of edu.indiana.extreme.gfac.utils.GfacException

        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();
      } catch (GFacSchemaException e) {
        throw new GfacException(e,FaultCode.SchemaValidationError);
      }
      return hostDescDoc.xmlText();
    } catch (NumberFormatException e) {
      throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
    }
  }
View Full Code Here

Examples of edu.indiana.extreme.gfac.utils.GfacException

        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();
      } catch (GFacSchemaException e) {
        throw new GfacException(e,FaultCode.SchemaValidationError);
      }
      return hostDescDoc.xmlText();
    } catch (NumberFormatException e) {
      throw new GfacException(e, FaultCode.InvaliedLocalArgumnet);
    }
  }
View Full Code Here

Examples of org.apache.airavata.core.gfac.exception.GfacException

                // already running instance
                DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest();
                DescribeInstancesResult describeInstancesResult = ec2client.describeInstances(describeInstancesRequest.withInstanceIds(ins_id));

                if (describeInstancesResult.getReservations().size() == 0 || describeInstancesResult.getReservations().get(0).getInstances().size() == 0) {
                    throw new GfacException("Instance not found:" + ins_id);
                }

                this.instance = describeInstancesResult.getReservations().get(0).getInstances().get(0);

                // check instance keypair
                if (this.instance.getKeyName() == null || !this.instance.getKeyName().equals(KEY_PAIR_NAME))
                    throw new GfacException("Keypair for instance:" + ins_id + " is not valid");
            }

            //TODO send out instance id
            //execContext.getNotificationService().sendResourceMappingNotifications(this.instance.getPublicDnsName(), "EC2 Instance " + this.instance.getInstanceId() + " is running with public name " + this.instance.getPublicDnsName(), this.instance.getInstanceId());
View Full Code Here

Examples of org.apache.airavata.gfac.GFacException

    }

  public SecurityContext getSecurityContext(String name) throws GFacException{
    SecurityContext secContext = securityContext.get(name);
    if(secContext == null){
      throw new GFacException( name + " not set in security context");
    }
    return secContext;
  }
View Full Code Here

Examples of org.ogce.gfac.exception.GfacException

            String[] retryonErrors =  config.getProperty(GFacOptions.GFAC_RETRYONJOBERRORCODES,"").split(",");
           for (String retryonError : retryonErrors) {
        getRetryonErrorCodes().add(retryonError);
      }
        } catch (UnknownHostException e) {
            throw new GfacException(e,FaultCode.InitalizationError);
        } catch (IOException e) {
            throw new GfacException(e,FaultCode.InitalizationError);
        }

    }
View Full Code Here

Examples of org.ogce.gfac.exception.GfacException

    public GSSCredential getGssCredentails() throws GfacException {
        try {
            return null; // credentialContext.getProxyCredentails();
        } catch (Exception e) {
            throw new GfacException(e,FaultCode.InitalizationError);
        }
    }
View Full Code Here

Examples of org.ogce.gfac.exception.GfacException

                input = Thread.currentThread().getContextClassLoader().getResourceAsStream(gfacProfile);
            }
            ConfigurationDocument configurationDoc = ConfigurationDocument.Factory.parse(input);
            return configurationDoc.getConfiguration();
        } catch (FileNotFoundException e) {
            throw new GfacException(e,FaultCode.InitalizationError);
        } catch (XmlException e) {
            throw new GfacException(e,FaultCode.InitalizationError);
        } catch (IOException e) {
            throw new GfacException(e,FaultCode.InitalizationError);
        }
    }
View Full Code Here

Examples of org.ogce.gfac.exception.GfacException

                          + username + " with " + lifetime + " lifetime.");

              }
              return proxy;
          } catch (MyProxyException e) {
              throw new GfacException(e,FaultCode.ErrorAtDependentService);
          } catch (FileNotFoundException e) {
              throw new GfacException(e,FaultCode.LocalError);
          } catch (IOException e) {
              throw new GfacException(e,FaultCode.LocalError);
          }
      }
View Full Code Here

Examples of org.ogce.gfac.exception.GfacException

        // already running instance
        DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest();
        DescribeInstancesResult describeInstancesResult = ec2client.describeInstances(describeInstancesRequest.withInstanceIds(ins_id));

        if (describeInstancesResult.getReservations().size() == 0 || describeInstancesResult.getReservations().get(0).getInstances().size() == 0) {
          throw new GfacException("Instance not found:" + ins_id, FaultCode.InvalidRequest);
        }

        this.instance = describeInstancesResult.getReservations().get(0).getInstances().get(0);

        // check instance keypair
        if (this.instance.getKeyName() == null || !this.instance.getKeyName().equals(KEY_PAIR_NAME))
          throw new GfacException("Keypair for instance:" + ins_id + " is not valid", FaultCode.InvalidRequest);
      }
     
      //send out instance id
      invocationContext.getExecutionContext().getNotificationService().sendResourceMappingNotifications(this.instance.getPublicDnsName(), "EC2 Instance " + this.instance.getInstanceId() + " is running with public name " + this.instance.getPublicDnsName(), this.instance.getInstanceId());
     

      /*
       * Make sure port 22 is connectable
       */
      for (GroupIdentifier g : this.instance.getSecurityGroups()) {
        IpPermission ip = new IpPermission();
        ip.setIpProtocol("tcp");
        ip.setFromPort(22);
        ip.setToPort(22);
        AuthorizeSecurityGroupIngressRequest r = new AuthorizeSecurityGroupIngressRequest();
        r = r.withIpPermissions(ip.withIpRanges("0.0.0.0/0"));
        r.setGroupId(g.getGroupId());
        try {
          ec2client.authorizeSecurityGroupIngress(r);
        } catch (AmazonServiceException as) {
          /*
           * If exception is from duplicate room, ignore it.
           */
          if (!as.getErrorCode().equals("InvalidPermission.Duplicate"))
            throw as;
        }
      }   

    } catch (Exception e) {
      // TODO throw out
      e.printStackTrace();
      log.error(e.getMessage(), e);
      throw new GfacException(e, FaultCode.InvalidRequest);
    }   
       
    //set Host location
    model.setHost(this.instance.getPublicDnsName());
   
    /*
     * Make directory
     */
    SSHClient ssh = new SSHClient();
    try {
      ssh.loadKnownHosts();
      ssh.connect(this.instance.getPublicDnsName());

      ssh.authPublickey(privateKeyFilePath);
      final Session session = ssh.startSession();
      try {
        StringBuilder command = new StringBuilder();
        command.append("mkdir -p ");
        command.append(model.getTmpDir());
        command.append(" | ");
        command.append("mkdir -p ");
        command.append(model.getWorkingDir());
        command.append(" | ");
        command.append("mkdir -p ");
        command.append(model.getInputDataDir());
        command.append(" | ");
        command.append("mkdir -p ");
        command.append(model.getOutputDataDir());
        Command cmd = session.exec(command.toString());
        cmd.join(5, TimeUnit.SECONDS);
      } catch (Exception e) {
        throw e;
      } finally {
        try {
          session.close();
        } catch (Exception e) {
        }
      }
    } catch (Exception e) {
      throw new GfacException(e.getMessage(), e);
    } finally {
      try {
        ssh.disconnect();
      } catch (Exception e) {
      }
View Full Code Here

Examples of org.ogce.gfac.exception.GfacException

          session.close();
        } catch (Exception e) {
        }
      }
    } catch (Exception e) {
      throw new GfacException(e.getMessage(), e);
    } finally {
      try {
        ssh.disconnect();
      } catch (Exception e) {
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.