Package org.apache.airavata.core.gfac.exception

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


                        ((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
                    }

                }
            } catch (URISyntaxException e) {
                throw new ProviderException(e.getMessage(), e, invocationContext);
            } catch (ToolsException e) {
                throw new ProviderException(e.getMessage(), e, invocationContext);
            }
            outputNew.add(paramName, actualParameter);
        }
        invocationContext.setOutput(outputNew);
    }
View Full Code Here


        /*
         * Validation
         */
        if (access_key == null || access_key.isEmpty())
            throw new ProviderException("EC2 Access Key is empty", invocationContext);
        if (secret_key == null || secret_key.isEmpty())
            throw new ProviderException("EC2 Secret Key is empty", invocationContext);
        if ((ami_id == null && ins_id == null) || (ami_id != null && ami_id.isEmpty()) || (ins_id != null && ins_id.isEmpty()))
            throw new ProviderException("EC2 AMI or Instance ID is empty", invocationContext);
        if (this.username == null || this.username.isEmpty())
            throw new ProviderException("EC2 Username is empty", invocationContext);

        /*
         * Need to start EC2 instance before running it
         */
        AWSCredentials credential = new BasicAWSCredentials(access_key, secret_key);
        AmazonEC2Client ec2client = new AmazonEC2Client(credential);

        try {
            /*
             * Build key pair before start instance
             */
            buildKeyPair(ec2client);

            // right now, we can run it on one host
            if (ami_id != null)
                this.instance = startInstances(ec2client, ami_id, ins_type, execContext).get(0);
            else {

                // 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());


            /*
             * 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) {
            throw new ProviderException("Invalied Request",e,invocationContext);
        }

        SSHSecurityContextImpl sshContext = ((SSHSecurityContextImpl) invocationContext.getSecurityContext(SSH_SECURITY_CONTEXT));
        if (sshContext == null) {
            sshContext = new SSHSecurityContextImpl();
View Full Code Here

            commandString.append(app.getOutputDataDirectory());

            Command cmd = session.exec(commandString.toString());
            cmd.join(COMMAND_EXECUTION_TIMEOUT, TimeUnit.SECONDS);
        } catch (ConnectionException e) {
            throw new ProviderException(e.getMessage(), e, context);
        } catch (TransportException e) {
            throw new ProviderException(e.getMessage(), e, context);
        } catch (IOException e) {
            throw new ProviderException(e.getMessage(), e, context);
        } finally {
            closeSession(session);
        }
    }
View Full Code Here

            } else {
                log.info("Process finished with return value of zero.");
            }

        } catch (ConnectionException e) {
            throw new  ProviderException(e.getMessage(), e, context);
        } catch (TransportException e) {
            throw new ProviderException(e.getMessage(), e, context);
        } catch (IOException e) {
            throw new ProviderException(e.getMessage(), e, context);
        } finally {
            closeSession(session);
        }
    }
View Full Code Here

            String stdErrStr = GfacUtils.readFileToString(localStdErrFile.getAbsolutePath());

            return OutputUtils.fillOutputFromStdout(context.<ActualParameter> getOutput(), stdOutStr,stdErrStr);

        } catch (XmlException e) {
            throw new ProviderException("Cannot read output:" + e.getMessage(), e, context);
        } catch (ConnectionException e) {
            throw new ProviderException(e.getMessage(), e, context);
        } catch (TransportException e) {
            throw new ProviderException(e.getMessage(), e, context);
        } catch (IOException e) {
            throw new ProviderException(e.getMessage(), e, context);
        }
    }
View Full Code Here

        /*
         * Validation
         */
        if (access_key == null || access_key.isEmpty())
            throw new ProviderException("Access Key is empty");
        if (secret_key == null || secret_key.isEmpty())
            throw new ProviderException("Secret Key is empty");
        if ((ami_id == null && ins_id == null) || (ami_id != null && ami_id.isEmpty()) || (ins_id != null && ins_id.isEmpty()))
            throw new ProviderException("AMI or Instance ID is empty");
        if (this.username == null || this.username.isEmpty())
            throw new ProviderException("Username is empty");

        /*
         * Need to start EC2 instance before running it
         */
        AWSCredentials credential = new BasicAWSCredentials(access_key, secret_key);
        AmazonEC2Client ec2client = new AmazonEC2Client(credential);

        try {
            /*
             * Build key pair before start instance
             */
            buildKeyPair(ec2client);

            // right now, we can run it on one host
            if (ami_id != null)
                this.instance = startInstances(ec2client, ami_id, ins_type, execContext).get(0);
            else {

                // 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());


            /*
             * 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) {
            throw new ProviderException("Invalied Request",e);
        }

        SSHSecurityContextImpl sshContext = ((SSHSecurityContextImpl) invocationContext.getSecurityContext(SSH_SECURITY_CONTEXT));
        if (sshContext == null) {
            sshContext = new SSHSecurityContextImpl();
View Full Code Here

            commandString.append(app.getOutputDataDirectory());

            Command cmd = session.exec(commandString.toString());
            cmd.join(COMMAND_EXECUTION_TIMEOUT, TimeUnit.SECONDS);
        } catch (ConnectionException e) {
            throw new ProviderException(e.getMessage(), e);
        } catch (TransportException e) {
            throw new ProviderException(e.getMessage(), e);
        } catch (IOException e) {
            throw new ProviderException(e.getMessage(), e);
        } finally {
            closeSession(session);
        }
    }
View Full Code Here

            } else {
                log.info("Process finished with return value of zero.");
            }

        } catch (ConnectionException e) {
            throw new  ProviderException(e.getMessage(), e);
        } catch (TransportException e) {
            throw new ProviderException(e.getMessage(), e);
        } catch (IOException e) {
            throw new ProviderException(e.getMessage(), e);
        } finally {
            closeSession(session);
        }
    }
View Full Code Here

            String stdErrStr = GfacUtils.readFileToString(localStdErrFile.getAbsolutePath());

            return OutputUtils.fillOutputFromStdout(context.<ActualParameter> getOutput(), stdOutStr);

        } catch (XmlException e) {
            throw new ProviderException("Cannot read output:" + e.getMessage(), e);
        } catch (ConnectionException e) {
            throw new ProviderException(e.getMessage(), e);
        } catch (TransportException e) {
            throw new ProviderException(e.getMessage(), e);
        } catch (IOException e) {
            throw new ProviderException(e.getMessage(), e);
        }
    }
View Full Code Here

    private void makeFileSystemDir(String dir) throws ProviderException {
        File f = new File(dir);
        if (f.isDirectory() && f.exists()) {
            return;
        } else if (!new File(dir).mkdir()) {
            throw new ProviderException("Cannot make directory");
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.core.gfac.exception.ProviderException

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.