Example usage for java.lang InterruptedException getMessage

List of usage examples for java.lang InterruptedException getMessage

Introduction

In this page you can find the example usage for java.lang InterruptedException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.opencastproject.loadtest.impl.IngestJob.java

/** Waits for the start delay, changes the correct metadata for the mediapackage and ingests it. **/
@Override//w  ww.ja  v  a 2s.c  om
public void run() {
    ThreadCounter.add();
    try {
        Thread.sleep(startDelay * LoadTest.MILLISECONDS_IN_SECONDS * LoadTest.SECONDS_IN_MINUTES);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    logger.info("Starting to run " + id);
    String workingDirectory = loadTest.getWorkspaceLocation() + IOUtils.DIR_SEPARATOR + id + "/";
    // Create working directory
    try {
        FileUtils.forceMkdir(new File(workingDirectory));
    } catch (IOException e) {
        logger.error(
                "Had trouble creating working directory at " + workingDirectory + " because " + e.getMessage());
    }
    // Copy source media package
    logger.info("Beginning Copy of " + id);
    String copyCommand = "cp " + loadTest.getSourceMediaPackageLocation() + " " + workingDirectory + id
            + ".zip";
    Execute.launch(copyCommand);
    // Change id in manifest.xml
    updateManifestID(workingDirectory);
    // Change id in episode.xml
    updateEpisodeID(workingDirectory);
    // Update the new manifest.xml and episode.xml to the zip file.
    logger.info("Beginning update of zipfile " + id);
    updateZip(workingDirectory);
    ingestMediaPackageWithJava(workingDirectory, workingDirectory + id + ".zip", loadTest.getWorkflowID());
    logger.info("Finished ingesting " + id);
    ThreadCounter.subtract();
}

From source file:hudson.plugins.blazemeter.BzmBuild.java

@Override
public Result call() throws Exception {
    ProxyConfigurator.updateProxySettings(proxyConfiguration, isSlave);
    PrintStream logger = listener.getLogger();
    FilePath wsp = createWorkspaceDir(workspace);
    logger.println(BzmJobNotifier.formatMessage("BlazemeterJenkins plugin v." + Utils.version()));
    JenkinsBlazeMeterUtils utils = createBzmUtils(createLogFile(wsp));
    try {/*from  w ww . j  a  v a2s .c om*/
        build = createCiBuild(utils, wsp);
        try {
            master = build.start();
            if (master != null) {
                String runId = jobName + "-" + buildId + "-" + reportLinkId;
                EnvVars.masterEnvVars.put(runId, master.getId());
                EnvVars.masterEnvVars.put(runId + "-" + master.getId(), build.getPublicReport());
                putLinkName(runId);
                build.waitForFinish(master);
            } else {
                listener.error(BzmJobNotifier.formatMessage("Failed to start test"));
                return Result.FAILURE;
            }
        } catch (InterruptedException e) {
            EnvVars.masterEnvVars.put("isInterrupted-" + jobName + "-" + buildId, "false");
            utils.getLogger().warn("Wait for finish has been interrupted", e);
            interrupt(build, master, logger);
            EnvVars.masterEnvVars.put("isInterrupted-" + jobName + "-" + buildId, "true");
            return Result.ABORTED;
        } catch (Exception e) {
            utils.getLogger().warn("Caught exception while waiting for build", e);
            logger.println(BzmJobNotifier.formatMessage("Caught exception " + e.getMessage()));
            return Result.FAILURE;
        }

        BuildResult buildResult = build.doPostProcess(master);
        return mappedBuildResult(buildResult);
    } finally {
        utils.closeLogger();
    }
}

From source file:com.raddle.tools.ClipboardTransferMain.java

/**
 * ????/*from  ww  w.j av a2 s  .co  m*/
 * @param received
 */
private synchronized void setLocalClipboard(ClipResult received) {
    m.setEnabled(false);
    try {
        trayIcon.setImage(pasteImage);
        ClipboardUtils.setClipResult(received);
        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {
        }
        m.reset();
        iconQueue.add("paste");
    } catch (Exception e) {
        trayIcon.setImage(grayImage);
        updateMessage("?" + e.getMessage());
    } finally {
        m.setEnabled(autoChk.isSelected());
    }
}

From source file:com.amazon.s3.http.AmazonHttpClient.java

/**
 * Exponential sleep on failed request to avoid flooding a service with
 * retries.//from   w w w. j  a  v  a  2s  .c  o  m
 * 
 * @param retries
 *            Current retry count.
 * @param previousException
 *            Exception information for the previous attempt, if any.
 */
private void pauseExponentially(int retries, AmazonServiceException previousException,
        CustomBackoffStrategy backoffStrategy) {
    long delay = 0;
    if (backoffStrategy != null) {
        delay = backoffStrategy.getBackoffPeriod(retries);
    } else {
        long scaleFactor = 300;
        if (isThrottlingException(previousException)) {
            scaleFactor = 500 + random.nextInt(100);
        }
        delay = (long) (Math.pow(2, retries) * scaleFactor);
    }

    delay = Math.min(delay, MAX_BACKOFF_IN_MILLISECONDS);

    Log.d(TAG, "Retriable error detected, " + "will retry in " + delay + "ms, attempt number: " + retries);

    try {
        Thread.sleep(delay);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new AmazonClientException(e.getMessage(), e);
    }
}

From source file:JavaFiles.AbstractWsToolClient.java

/** Poll the job status until the job completes.
 * //w w  w  .  j  av a  2 s  .  c  o  m
 * @param jobid The job identifier.
 * @throws ServiceException
 */
public void clientPoll(String jobId) throws ServiceException {
    printDebugMessage("clientPoll", "Begin", 1);
    printDebugMessage("clientPoll", "jobId: " + jobId, 2);
    int checkInterval = 1000;
    String status = "PENDING";
    // Check status and wait if not finished
    while (status.equals("RUNNING") || status.equals("PENDING")) {
        try {
            status = this.checkStatus(jobId);
            printProgressMessage(status, 1);
            if (status.equals("RUNNING") || status.equals("PENDING")) {
                // Wait before polling again.
                printDebugMessage("clientPoll", "checkInterval: " + checkInterval, 2);
                Thread.sleep(checkInterval);
                checkInterval *= 2;
                if (checkInterval > this.maxCheckInterval)
                    checkInterval = this.maxCheckInterval;
            }
        } catch (InterruptedException ex) {
            // Ignore
        } catch (IOException ex) {
            // Report and continue
            System.err.println("Warning: " + ex.getMessage());
        }
    }
    printDebugMessage("clientPoll", "End", 1);
}

From source file:squash.booking.lambdas.core.PageManager.java

private void copyUpdatedBookingPageToS3(String pageBaseName, String page, String uidSuffix, boolean usePrefix)
        throws Exception {

    logger.log("About to copy booking page to S3");

    String pageBaseNameWithPrefix = usePrefix ? "NoScript/" + pageBaseName : pageBaseName;
    try {//from w w  w  .  j a va 2  s . c  o  m
        logger.log("Uploading booking page to S3 bucket: " + websiteBucketName + "s3websitebucketname"
                + " and key: " + pageBaseNameWithPrefix + uidSuffix + ".html");
        byte[] pageAsGzippedBytes = FileUtils.gzip(page.getBytes(StandardCharsets.UTF_8), logger);

        ByteArrayInputStream pageAsStream = new ByteArrayInputStream(pageAsGzippedBytes);
        ObjectMetadata metadata = new ObjectMetadata();
        metadata.setContentLength(pageAsGzippedBytes.length);
        metadata.setContentEncoding("gzip");
        metadata.setContentType("text/html");
        // Direct caches not to satisfy future requests with this data without
        // revalidation.
        metadata.setCacheControl("no-cache, must-revalidate");
        PutObjectRequest putObjectRequest = new PutObjectRequest(websiteBucketName,
                pageBaseNameWithPrefix + uidSuffix + ".html", pageAsStream, metadata);
        // Page must be public so it can be served from the website
        putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
        IS3TransferManager transferManager = getS3TransferManager();
        TransferUtils.waitForS3Transfer(transferManager.upload(putObjectRequest), logger);
        logger.log("Uploaded booking page to S3 bucket");

        if (uidSuffix.equals("")) {
            // Nothing to copy - so return
            logger.log("UidSuffix is empty - so not creating duplicate page");
            return;
        }

        // N.B. We copy from hashed key to non-hashed (and not vice versa)
        // to ensure consistency
        logger.log("Copying booking page in S3 bucket: " + websiteBucketName + " and key: "
                + pageBaseNameWithPrefix + ".html");
        CopyObjectRequest copyObjectRequest = new CopyObjectRequest(websiteBucketName,
                pageBaseNameWithPrefix + uidSuffix + ".html", websiteBucketName,
                pageBaseNameWithPrefix + ".html");
        copyObjectRequest.setCannedAccessControlList(CannedAccessControlList.PublicRead);
        // N.B. Copied object will get same metadata as the source (e.g. the
        // cache-control header etc.)
        TransferUtils.waitForS3Transfer(transferManager.copy(copyObjectRequest), logger);
        logger.log("Copied booking page successfully in S3");
    } catch (AmazonServiceException ase) {
        ExceptionUtils.logAmazonServiceException(ase, logger);
        throw new Exception("Exception caught while copying booking page to S3");
    } catch (AmazonClientException ace) {
        ExceptionUtils.logAmazonClientException(ace, logger);
        throw new Exception("Exception caught while copying booking page to S3");
    } catch (InterruptedException e) {
        logger.log("Caught interrupted exception: ");
        logger.log("Error Message: " + e.getMessage());
        throw new Exception("Exception caught while copying booking page to S3");
    }
}

From source file:io.hops.tensorflow.ApplicationMaster.java

private boolean finish() {
    // wait for completion. finish if any container fails
    while (!done && !(numCompletedWorkers.get() == numWorkers) && !(numFailedContainers.get() > 0)) {
        if (numAllocatedContainers.get() != numTotalContainers) {
            long timeLeft = appMasterStartTime + allocationTimeout - System.currentTimeMillis();
            LOG.info("Awaits container allocation, timeLeft=" + timeLeft);
            if (timeLeft < 0) {
                LOG.warn("Container allocation timeout. Finish application attempt");
                break;
            }//from w w  w.jav a2  s  . c o  m
        }
        try {
            Thread.sleep(200);
        } catch (InterruptedException ex) {
        }
    }

    if (timelineHandler.isClientNotNull()) {
        timelineHandler.publishApplicationAttemptEvent(YarntfEvent.YARNTF_APP_ATTEMPT_END);
    }

    // Join all launched threads
    // needed for when we time out
    // and we need to release containers
    for (Thread launchThread : launchThreads) {
        try {
            launchThread.join(10000);
        } catch (InterruptedException e) {
            LOG.info("Exception thrown in thread join: " + e.getMessage());
            e.printStackTrace();
        }
    }

    // When the application completes, it should stop all running containers
    LOG.info("Application completed. Stopping running containers");
    nmWrapper.getClient().stop();

    // When the application completes, it should send a finish application
    // signal to the RM
    LOG.info("Application completed. Signalling finish to RM");

    FinalApplicationStatus appStatus;
    String appMessage = null;
    boolean success = true;
    if (numFailedContainers.get() == 0 && numCompletedWorkers.get() == numWorkers) {
        appStatus = FinalApplicationStatus.SUCCEEDED;
    } else {
        appStatus = FinalApplicationStatus.FAILED;
        appMessage = "Diagnostics." + ", total=" + numTotalContainers + ", completed(workers)="
                + numCompletedContainers.get() + "(" + numCompletedWorkers.get() + "), allocated="
                + numAllocatedContainers.get() + ", failed=" + numFailedContainers.get();
        LOG.info(appMessage);
        success = false;
    }
    try {
        rmWrapper.getClient().unregisterApplicationMaster(appStatus, appMessage, null);
    } catch (YarnException ex) {
        LOG.error("Failed to unregister application", ex);
    } catch (IOException e) {
        LOG.error("Failed to unregister application", e);
    }

    rmWrapper.getClient().stop();

    // Stop Timeline Client
    if (timelineHandler.isClientNotNull()) {
        timelineHandler.stopClient();
    }

    return success;
}

From source file:com.dodo.wbbshoutbox.codebot.MainActivity.java

public void getRequest(String url) {
    Request.client.get(url, new AsyncHttpResponseHandler() {
        @Override//from w w  w.j ava 2s  .c o m
        public void onSuccess(String response) {
            try {
                read(response);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onFailure(Throwable e, String errorResponse) {
            Toast.makeText(getApplicationContext(), "Verbindung fehlgeschlagen. Fehler: " + e.getMessage(),
                    Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:msi.gama.gui.swt.WorkspaceModelsManager.java

private IFile findOutsideWorkspace(final IPath originalPath) {
    GuiUtils.debug("WorkspaceModelsManager.findOutsideWorkspace " + originalPath);
    final File modelFile = new File(originalPath.toOSString());
    // TODO If the file does not exist we return null (might be a good idea to check other locations)
    if (!modelFile.exists()) {
        return null;
    }//from w ww. jav a  2s . c  om

    // We try to find a folder containing the model file which can be considered as a project
    File projectFileBean = new File(modelFile.getPath());
    File dotFile = null;
    while (projectFileBean != null && dotFile == null) {
        projectFileBean = projectFileBean.getParentFile();
        if (projectFileBean != null) {
            /* parcours des fils pour trouver le dot file et creer le lien vers le projet */
            File[] children = projectFileBean.listFiles();
            for (int i = 0; i < children.length; i++) {
                if (children[i].getName().equals(".project")) {
                    dotFile = children[i];
                    break;
                }
            }
        }
    }

    if (dotFile == null || projectFileBean == null) {
        GuiUtils.tell("The model '" + modelFile.getAbsolutePath()
                + "' does not seem to belong to an existing GAML project. It will be imported as part of the 'Unclassified models' project.");
        return createUnclassifiedModelsProjectAndAdd(originalPath);
    }

    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    final IPath location = new Path(dotFile.getAbsolutePath());
    final String pathToProject = projectFileBean.getName();

    try {
        // We load the project description.
        final IProjectDescription description = workspace.loadProjectDescription(location);
        if (description != null) {
            WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {

                @Override
                protected void execute(final IProgressMonitor monitor)
                        throws CoreException, InvocationTargetException, InterruptedException {
                    // We try to get the project in the workspace
                    IProject proj = workspace.getRoot().getProject(pathToProject);
                    // If it does not exist, we create it
                    if (!proj.exists()) {
                        // If a project with the same name exists
                        IProject[] projects = workspace.getRoot().getProjects();
                        String name = description.getName();
                        for (IProject p : projects) {
                            if (p.getName().equals(name)) {
                                GuiUtils.tell(
                                        "A project with the same name already exists in the workspace. The model '"
                                                + modelFile.getAbsolutePath()
                                                + " will be imported as part of the 'Unclassified models' project.");
                                createUnclassifiedModelsProjectAndAdd(originalPath);
                                return;
                            }
                        }

                        proj.create(description, monitor);
                    } else {
                        // project exists but is not accessible, so we delete it and recreate it
                        if (!proj.isAccessible()) {
                            proj.delete(true, null);
                            proj = workspace.getRoot().getProject(pathToProject);
                            proj.create(description, monitor);
                        }
                    }
                    // We open the project
                    proj.open(IResource.NONE, monitor);
                    // And we set some properties to it
                    setValuesProjectDescription(proj, false);
                }
            };
            operation.run(new NullProgressMonitor() {

                // @Override
                // public void done() {
                // RefreshHandler.run();
                // // GuiUtils.tell("Project " + workspace.getRoot().getProject(pathToProject).getName() +
                // // " has been imported");
                // }

            });
        }
    } catch (InterruptedException e) {
        return null;
    } catch (InvocationTargetException e) {
        return null;
    } catch (CoreException e) {
        GuiUtils.error("Error wien importing project: " + e.getMessage());
    }
    IProject project = workspace.getRoot().getProject(pathToProject);
    String relativePathToModel = project.getName()
            + modelFile.getAbsolutePath().replace(projectFileBean.getPath(), "");
    return findInWorkspace(new Path(relativePathToModel));
}

From source file:at.ac.tuwien.dsg.rSybl.cloudInteractionUnit.enforcementPlugins.dryRun.DryRunEnforcementAPI.java

private void scaleInComponent(Node o) {

    DependencyGraph graph = new DependencyGraph();
    graph.setCloudService(controlledService);
    Node toBeScaled = graph.getNodeWithID(o.getId());
    Node toBeRemoved = null;/*from w w  w . j  av a2  s  .  c om*/
    if (toBeScaled.getAllRelatedNodesOfType(RelationshipType.HOSTED_ON_RELATIONSHIP, NodeType.ARTIFACT) != null
            && toBeScaled.getAllRelatedNodesOfType(RelationshipType.HOSTED_ON_RELATIONSHIP, NodeType.ARTIFACT)
                    .size() > 0) {
        Node artifact = toBeScaled
                .getAllRelatedNodesOfType(RelationshipType.HOSTED_ON_RELATIONSHIP, NodeType.ARTIFACT).get(0);
        if (artifact.getAllRelatedNodesOfType(RelationshipType.HOSTED_ON_RELATIONSHIP,
                NodeType.CONTAINER) != null
                && artifact
                        .getAllRelatedNodesOfType(RelationshipType.HOSTED_ON_RELATIONSHIP, NodeType.CONTAINER)
                        .size() > 0) {
            Node container = artifact
                    .getAllRelatedNodesOfType(RelationshipType.HOSTED_ON_RELATIONSHIP, NodeType.CONTAINER)
                    .get(0);
            toBeRemoved = container
                    .getAllRelatedNodesOfType(RelationshipType.HOSTED_ON_RELATIONSHIP, NodeType.VIRTUAL_MACHINE)
                    .get(0);
            RuntimeLogger.logger
                    .info("Trying to remove  " + toBeRemoved.getId() + " From " + toBeScaled.getId());
            String cmd = "";
            String ip = toBeRemoved.getId();
            String uuid = (String) toBeRemoved.getStaticInformation().get("UUID");
            RuntimeLogger.logger.info("Removing server with UUID" + uuid);
        } else {
            toBeRemoved = artifact
                    .getAllRelatedNodesOfType(RelationshipType.HOSTED_ON_RELATIONSHIP, NodeType.VIRTUAL_MACHINE)
                    .get(0);
            RuntimeLogger.logger
                    .info("Trying to remove  " + toBeRemoved.getId() + " From " + toBeScaled.getId());
            String cmd = "";
            String ip = toBeRemoved.getId();
            String uuid = (String) toBeRemoved.getStaticInformation().get("UUID");
            RuntimeLogger.logger.info("Removing server with UUID" + uuid);
        }

    } else {

        toBeRemoved = toBeScaled
                .getAllRelatedNodesOfType(RelationshipType.HOSTED_ON_RELATIONSHIP, NodeType.VIRTUAL_MACHINE)
                .get(0);
        RuntimeLogger.logger.info("Trying to remove  " + toBeRemoved.getId() + " From " + toBeScaled.getId());
        String cmd = "";
        String ip = toBeRemoved.getId();
        String uuid = (String) toBeRemoved.getStaticInformation().get("UUID");
        RuntimeLogger.logger.info("Removing server with UUID" + uuid);
    }
    //flexiantActions.removeServer(uuid);
    try {
        Thread.sleep(30000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        RuntimeLogger.logger.info(e.getMessage());
    }

    toBeScaled.removeNode(toBeRemoved);

    monitoring.refreshServiceStructure(controlledService);
}