Package org.ogce.gfac.exception

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


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

                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

                          + 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

        // 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

          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

      OutputUtils.fillOutputFromStdout(invocationContext.getMessageContext("output"), context.getExecutionModel().getStdoutStr(), context.getExecutionModel().getStderrStr());

    } catch (IOException e) {     
      throw new JobSubmissionFault(e, "", "", buildCommand(cmdList), CurrentProviders.Local);
    } catch (InterruptedException e) {
      throw new GfacException(e, FaultCode.LocalError);
    }

  }
View Full Code Here

          break;
        } catch (Exception e) {
          String message = "Mkdir " + destURI + " with " + e.getMessage() + " (try " + tryCount + ") retrying at Gfac";
          tryCount++;
          if (tryCount >= 3) {
            throw new GfacException(e.getMessage(), e);
          }
          Thread.sleep(10000);
        }
      }
    } catch (ServerException e) {
View Full Code Here

          System.out.println("xregistryUrl=" + xregistryUrl);
          System.out.println("trustedCertificates=" + trustedCertificates);
          this.xregistryClient = new XRegistryClient(sessionCredentail, trustedCertificates, xregistryUrl);
        }
      } else {
        throw new GfacException("Neither host certificate of gss credential is set", FaultCode.ErrorAtDependentService);
      }
    } catch (XRegistryClientException e) {
      throw new GfacException(e, FaultCode.ErrorAtDependentService);
    }
  }
View Full Code Here

          System.out.println("hostcertsKeyFile=" + hostcertsKeyFile);
          System.out.println("trustedCertificates=" + trustedCertificates);
          this.xregistryClient = new XRegistryClient(hostcertsKeyFile, trustedCertificates, xregistryUrl);
        }
      } else {
        throw new GfacException("Neither host certificate of gss credential is set", FaultCode.ErrorAtDependentService);
      }
    } catch (XRegistryClientException e) {
      throw new GfacException(e, FaultCode.ErrorAtDependentService);
    }
  }
View Full Code Here

TOP

Related Classes of org.ogce.gfac.exception.GfacException

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.