Package org.globus.workspace.client_core

Examples of org.globus.workspace.client_core.ExecutionProblem


            final Integer retCode = (Integer) task.get();
            if (retCode.intValue() != BaseClient.SUCCESS_EXIT_CODE) {
                throw new ExitNow(retCode.intValue());
            }
        } catch (InterruptedException e) {
            throw new ExecutionProblem(e.getMessage(), e);
        } catch (ExecutionException e) {
            throw new ExecutionProblem(e.getMessage(), e);
        }
    }
View Full Code Here


            final Integer retCode = (Integer) task.get();
            if (retCode.intValue() != BaseClient.SUCCESS_EXIT_CODE) {
                throw new ExitNow(retCode.intValue());
            }
        } catch (InterruptedException e) {
            throw new ExecutionProblem(e.getMessage(), e);
        } catch (ExecutionException e) {
            throw new ExecutionProblem(e.getMessage(), e);
        }
    }
View Full Code Here

            final File newdir3 = new File(newdirPath, "reports-ctx");
            ctxReportsDirPath = newdir3.getAbsolutePath();
            if (newdir3.mkdir()) {
                print.debugln("Created directory: " + ctxReportsDirPath);
            } else {
                throw new ExecutionProblem(
                        "Could not create directory '" + ctxReportsDirPath + "'");
            }

            final File newdir4 = new File(newdirPath, "ctx-tmp");
            final String ctxTempDirPath = newdir4.getAbsolutePath();
            if (newdir4.mkdir()) {
                print.debugln("Created directory: " + ctxTempDirPath);
            } else {
                throw new ExecutionProblem(
                        "Could not create directory '" + ctxTempDirPath + "'");
            }


            try {
                brokerContact = this.createCtx(brokerURL,
                                               brokerIdentityAuthorization,
                                               ctxEprPath,
                                               newdir4,
                                               false,
                                               print);
            } catch (Exception e) {
                throw new ExecutionProblem("Problem creating new context at " +
                        "the context broker: " + e.getMessage(), e);
            }
        }

        final String[] ensembleEprPaths =
            new String[deploys.size()];

        // Ensemble requests won't get time assignments, remove the
        // "will be set after lease is secured" messages when registering
        print.getOpts().codeRemove(
                PrCodes.CREATE__INSTANCE_CREATING_INIITIAL_START_TIME);
        print.getOpts().codeRemove(
                PrCodes.CREATE__INSTANCE_CREATING_INIITIAL_SHUTDOWN_TIME);
        print.getOpts().codeRemove(
                PrCodes.CREATE__INSTANCE_CREATING_INIITIAL_TERMINATION_TIME);
        print.getOpts().codeRemove(PrCodes.CREATE__GROUP_ID_PRINT);
        print.getOpts().codeRemove(PrCodes.ENSMONITOR__SINGLE_REPORT_NAMES);
        print.getOpts().codeRemove(PrCodes.CTXMONITOR__SINGLE_REPORT_NAMES);

        for (int i = 0; i < clouds.length; i++) {
            CloudDeployment cloud = clouds[i];
            final File cloudDir = new File(newdir,
                "cloud-" + cloud.getCloud().getName());
            final String cloudDirPath = cloudDir.getAbsolutePath();
            if (cloudDir.mkdir()) {
                print.debugln("Created directory: " + cloudDirPath);
            } else {
                throw new ExecutionProblem(
                    "Could not create directory '" + cloudDirPath + "'");
            }

            final RunTask[] runTasks = cloud.generateRunTasks(brokerContact,
                cloudDirPath, sshKeyPath, durationMinutes, print);
View Full Code Here

                    final File newdir6 = new File(newdirPath, "knownhosts-dir");
                    knownHostsDirPath = newdir6.getAbsolutePath();
                    if (newdir6.mkdir()) {
                        print.debugln("Created directory: " + knownHostsDirPath);
                    } else {
                        throw new ExecutionProblem(
                                "Could not create directory '" +
                                        knownHostsDirPath + "'");
                    }
                    break;
                }
            }
        }

        // see comments inside loop about ensemble and context EPRs
        final File ensFile = new File(newdir,
                                      HistoryUtil.ENSEMBLE_EPR_FILE_NAME);
        final String ensembleEprPath = ensFile.getAbsolutePath();

        // do we need to handle contextualization?
        boolean usingContextBroker = false;
        for (Cloudcluster_Type oneclusta : clustersForUserData) {
            if (oneclusta != null) {
                usingContextBroker = true;
                break;
            }
        }

       
        final String ctxEprPath;
        final String ctxReportsDirPath;
        final String[] ctxUserDataPaths = new String[metadatas.length];

        if (!usingContextBroker) {
            ctxEprPath = null;
            ctxReportsDirPath = null;
        } else {

            final File ctxFile = new File(newdir,
                                          HistoryUtil.CONTEXT_EPR_FILE_NAME);
            ctxEprPath = ctxFile.getAbsolutePath();

            final File newdir3 = new File(newdirPath, "reports-ctx");
            ctxReportsDirPath = newdir3.getAbsolutePath();
            if (newdir3.mkdir()) {
                print.debugln("Created directory: " + ctxReportsDirPath);
            } else {
                throw new ExecutionProblem(
                        "Could not create directory '" + ctxReportsDirPath + "'");
            }

            final File newdir4 = new File(newdirPath, "ctx-tmp");
            final String ctxTempDirPath = newdir4.getAbsolutePath();
            if (newdir4.mkdir()) {
                print.debugln("Created directory: " + ctxTempDirPath);
            } else {
                throw new ExecutionProblem(
                        "Could not create directory '" + ctxTempDirPath + "'");
            }

            if (brokerURL == null) {
                int dx = workspaceFactoryURL.indexOf("WorkspaceFactoryService");
                brokerURL = workspaceFactoryURL.substring(0,dx);
                brokerURL += "NimbusContextBroker";
                print.debugln("No context broker URL was explicitly supplied," +
                        " so it has been deduced from the nimbus factory URL." +
                        " Using: " + brokerURL);

                // and so ID scheme for service must be copied
                if (brokerIdentityAuthorization == null
                        && identityAuthorization != null) {
                    brokerIdentityAuthorization = identityAuthorization;
                }
            }

            final BrokerContactType brokerContact;
            try {
                brokerContact = this.createCtx(brokerURL,
                                               brokerIdentityAuthorization,
                                               ctxEprPath,
                                               newdir4,
                                               !doContextLock,
                                               print);
            } catch (Exception e) {
                throw new ExecutionProblem("Problem creating new context at " +
                        "the context broker: " + e.getMessage(), e);
            }

            // prepare user data
            for (int i = 0; i < clustersForUserData.length; i++) {
View Full Code Here

        final File newDir = new File(parentDir, name);
        final String newdir2Path = newDir.getAbsolutePath();
        if (newDir.mkdir()) {
            print.debugln("Created directory: " + newdir2Path);
        } else {
            throw new ExecutionProblem(
                    "Could not create directory '" + newdir2Path + "'");
        }
        return newdir2Path;
    }
View Full Code Here

        final File topdir;
        try {
            topdir = CloudClientUtil.getHistoryDir(historyDir);
        } catch (ParameterProblem e) {
            throw new ExecutionProblem(e.getMessage(), e);
        }

        final int nextnum = HistoryUtil.findNextNumber(topdir, prefix, print);

        final String suffix = HistoryUtil.format.format(nextnum);
        final String newDirName = prefix + suffix;

        print.debugln("Next directory: " + newDirName);

        final File newdir = new File(topdir, newDirName);
        final String path = newdir.getAbsolutePath();
        if (newdir.mkdir()) {
            print.debugln("Created directory: " + path);
        } else {
            // could be a race condition on the name, or odd perm problem
            // (note we checked parent dir was writeable)
            throw new ExecutionProblem(
                    "Could not create directory '" + path + "'");
        }
        return newdir;
    }
View Full Code Here

                               String tempDirPath,
                               Print print)
        throws ExecutionProblem, ExitNow {

        if (clusterMembers == null || clusterMembers.length == 0) {
            throw new ExecutionProblem("no clusterMembers");
        }

        final boolean usingContextBroker =
                needsContextualization(clusterMembers);

        if (!usingContextBroker) {
            throw new ExecutionProblem("cluster doesn't need contextualization!");
        }

        File tempDir = new File(tempDirPath);
        if (!(tempDir.exists() && tempDir.isDirectory() && tempDir.canWrite())) {
            throw new ExecutionProblem("tempdir must exist and be writeable");
        }


        final File ctxFile = new File(tempDir,
                                          HistoryUtil.CONTEXT_EPR_FILE_NAME);
        final String ctxEprPath = ctxFile.getAbsolutePath();
        final String[] ctxUserDataPaths = new String[clusterMembers.length];

        final File manifestFile = new File(tempDir, "manifest.txt");

        createCtxAndUserdata(clusterMembers,
                    brokerURL,
                    brokerID,
                    doContextLock,
                    ctxEprPath,
                    ctxUserDataPaths,
                    tempDir,
                    print);

        // TODO arbitary!
        // This method needs to either Go Away or a better
        // serialization scheme needs to be used.

        StringBuilder sb = new StringBuilder();
        for (int i=0; i < clusterMembers.length; i++) {
            sb.append(clusterMembers[i].getImageName());
            sb.append("\t");
            sb.append(clusterMembers[i].getQuantity());
            sb.append("\t");
            sb.append(ctxUserDataPaths[i]);
            sb.append("\n");
        }

        try {
            FileUtils.writeStringToFile(sb.toString(),
                    manifestFile.getAbsolutePath());
        } catch (Exception e) {
            throw new ExecutionProblem("Problem writing cluster manifest",e);
        }

    }
View Full Code Here

    )

            throws ExecutionProblem, ExitNow {

        if (clusterMembers == null || clusterMembers.length == 0) {
            throw new ExecutionProblem("no clusterMembers");
        }

        final File topdir;
        try {
            topdir = CloudClientUtil.getHistoryDir(historyDir);
        } catch (ParameterProblem e) {
            throw new ExecutionProblem(e.getMessage(), e);
        }

        final int nextnum = HistoryUtil.findNextEc2ClusterNumber(topdir, print);

        final String suffix = HistoryUtil.format.format(nextnum);
        final String newDirName =
                HistoryUtil.historyEc2ClusterDirPrefix + suffix;
        final String clusterHandle = newDirName; // redundant, but clearer later

        print.debugln("Next directory: " + newDirName);

        final File newdir = new File(topdir, newDirName);
        final String newdirPath = newdir.getAbsolutePath();
        if (newdir.mkdir()) {
            print.debugln("Created directory: " + newdirPath);
        } else {
            // could be a race condition on the name, or odd perm problem
            // (note we checked parent dir was writeable)
            throw new ExecutionProblem(
                    "Could not create directory '" + newdirPath + "'");
        }

        final File runLog =
                HistoryUtil.newLogFile(newdir, RunTask.LOG_FILE_NAME, print);
        if (runLog != null) {
            try {
                print.getOpts().setInfoErrFile(runLog.getAbsolutePath());
            } catch (Exception e) {
                print.errln("Problem setting InfoErrFile: " + e.getMessage());
                // carry on
            }
        }

        final File debugLog =
               HistoryUtil.newLogFile(newdir, RunTask.DEBUG_LOG_FILE_NAME, print);
        if (debugLog != null) {
            try {
                print.getOpts().setAllOutFile(debugLog.getAbsolutePath());
            } catch (Exception e) {
                print.errln("Problem setting AllOutFile: " + e.getMessage());
                // carry on
            }
        }

        // do we need to handle contextualization?
        final boolean usingContextBroker =
                needsContextualization(clusterMembers);

        final String ctxEprPath;
        final String ctxReportsDirPath;
        final String[] ctxUserDataPaths = new String[clusterMembers.length];

        if (!usingContextBroker) {
            ctxEprPath = null;
            ctxReportsDirPath = null;
        } else {

            final File ctxFile = new File(newdir,
                                          HistoryUtil.CONTEXT_EPR_FILE_NAME);
            ctxEprPath = ctxFile.getAbsolutePath();

            final File ctxReportDir = new File(newdirPath, "reports-ctx");
            ctxReportsDirPath = ctxReportDir.getAbsolutePath();
            if (ctxReportDir.mkdir()) {
                print.debugln("Created directory: " + ctxReportsDirPath);
            } else {
                throw new ExecutionProblem(
                    "Could not create directory '" + ctxReportsDirPath + "'");
            }

            final File ctxTempDir = new File(newdirPath, "ctx-tmp");
            final String ctxTempDirPath = ctxTempDir.getAbsolutePath();
            if (ctxTempDir.mkdir()) {
                print.debugln("Created directory: " + ctxTempDirPath);
            } else {
                throw new ExecutionProblem(
                        "Could not create directory '" + ctxTempDirPath + "'");
            }


            createCtxAndUserdata(clusterMembers,
                    brokerURL,
                    brokerID,
                    doContextLock,
                                               ctxEprPath,
                    ctxUserDataPaths,
                    ctxTempDir,
                                               print);
        }

        // write the ec2 commands to both screen and a file

        final StringBuffer buf = new StringBuffer();

        for (int i = 0; i < clusterMembers.length; i++) {
            buf.append("\nec2-run-instances")
               .append(" --instance-count ")
               .append(clusterMembers[i].getQuantity());

            if (usingContextBroker && ctxUserDataPaths[i] != null) {
                buf.append(" --user-data-file ")
                   .append(ctxUserDataPaths[i]);
            }
           
            buf.append(" --kernel aki-a71cf9ce --ramdisk ari-a51cf9cc");

            // m1.small, m1.large, m1.xlarge, c1.medium, and c1.xlarge
            buf.append(" --instance-type m1.small ");
            buf.append(" --key default ");
            buf.append(clusterMembers[i].getImageName());
            buf.append("\n");
        }

        final String cmds = buf.toString();

        print.infoln("\n** Sample EC2 commands:\n" + cmds);

        if (ec2ScriptPath != null) {

            final String toFile = "#!/bin/sh\n\n" + cmds + "\n";

            try {
                FileUtils.writeStringToFile(toFile, ec2ScriptPath);
            } catch (Exception e) {
                throw new ExecutionProblem("Problem writing sample EC2 " +
                        "commands to file: " + e.getMessage(), e);
            }

            print.infoln("\n** Wrote sample EC2 commands to '" +
                    ec2ScriptPath + "'\n");
View Full Code Here

                    ctxEprPath,
                    ctxTempDir,
                    !doContextLock,
                    print);
        } catch (Exception e) {
            throw new ExecutionProblem("Problem creating new context at " +
                    "the context broker: " + e.getMessage(), e);
        }

        // prepare user data
        for (int i = 0; i < clusterMembers.length; i++) {
            ClusterMember member = clusterMembers[i];
            final Cloudcluster_Type oneCtx = member.getClusterForUserData();

            if (oneCtx == null) {
                ctxUserDataPaths[i] = null;
                continue;
            }

            final File datafile = new File(ctxTempDir, "userdata-" + i);

            ctxUserDataPaths[i] = datafile.getAbsolutePath();

            Nimbusctx_Type wrapper = new Nimbusctx_Type();
            wrapper.setCluster(oneCtx);
            wrapper.setContact(brokerContact);

            final QName qName = new QName("", "NIMBUS_CTX");

            try {
                final String data =
                        StringUtils.axisBeanToString(wrapper, qName);

                FileUtils.writeStringToFile(data, ctxUserDataPaths[i]);

            } catch (Exception e) {
                throw new ExecutionProblem("Problem turning the cluster " +
                        "information into text that the context agents " +
                        "on the VMs can consume: " + e.getMessage(), e);
            }
        }
    }
View Full Code Here

            } else {
                print.errln("\nProblem creating new context with broker.");
                throw new ExitNow(retCode.intValue());
            }
        } catch (InterruptedException e) {
            throw new ExecutionProblem(e.getMessage(), e);
        } catch (Exception e) {
            final String err = "Problem creating new context with " +
                    "broker: " + e.getMessage();
            throw new ExecutionProblem(err, e);
        }

        CommonPrint.printDebugSectionEnd(print, sectionTitle);

        return brokerContact;
View Full Code Here

TOP

Related Classes of org.globus.workspace.client_core.ExecutionProblem

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.