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:dk.clarin.tools.create.java

/**
* Timeout for the process to assist workflow
* @param delay time in milliseconds/*from  ww w. j  a v a  2 s.c  om*/
*/
private static void wait(int delay) {
    try {
        Thread.sleep(delay);
    } catch (InterruptedException ex) {
        logger.error(ex.getMessage());
    }
}

From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.google.GoogleProviderUtils.java

static private void ensureSshKeysExist() {
    File sshKeyFile = new File(getSshKeyFile());
    if (!sshKeyFile.exists()) {
        if (!sshKeyFile.getParentFile().exists()) {
            sshKeyFile.getParentFile().mkdirs();
        }/*from w  ww.  jav a  2 s . c o  m*/

        log.info("Generating a new ssh key file...");
        JobExecutor jobExecutor = DaemonTaskHandler.getJobExecutor();
        List<String> command = new ArrayList<>();
        command.add("ssh-keygen");
        command.add("-N"); // no password
        command.add("");
        command.add("-t"); // rsa key
        command.add("rsa");
        command.add("-f"); // path to keyfile
        command.add(getSshKeyFile());
        command.add("-C"); // username sshing into machine
        command.add("ubuntu");

        JobRequest request = new JobRequest().setTokenizedCommand(command);

        JobStatus status;
        try {
            status = jobExecutor.backoffWait(jobExecutor.startJob(request));
        } catch (InterruptedException e) {
            throw new DaemonTaskInterrupted(e);
        }

        if (status.getResult() == JobStatus.Result.FAILURE) {
            throw new HalException(FATAL, "ssh-keygen failed: " + status.getStdErr());
        }

        try {
            File sshPublicKeyFile = new File(getSshPublicKeyFile());
            String sshKeyContents = IOUtils.toString(new FileInputStream(sshPublicKeyFile));

            if (!sshKeyContents.startsWith("ubuntu:")) {
                sshKeyContents = "ubuntu:" + sshKeyContents;
                FileUtils.writeByteArrayToFile(sshPublicKeyFile, sshKeyContents.getBytes());
            }
        } catch (IOException e) {
            throw new HalException(FATAL,
                    "Cannot reformat ssh key to match google key format expectation: " + e.getMessage(), e);
        }

        command = new ArrayList<>();
        command.add("chmod");
        command.add("400");
        command.add(getSshKeyFile());

        request = new JobRequest().setTokenizedCommand(command);
        try {
            status = jobExecutor.backoffWait(jobExecutor.startJob(request));
        } catch (InterruptedException e) {
            throw new DaemonTaskInterrupted(e);
        }

        if (status.getResult() == JobStatus.Result.FAILURE) {
            throw new HalException(FATAL, "chmod failed: " + status.getStdErr() + status.getStdOut());
        }
    }
}

From source file:com.microsoft.tfs.client.common.ui.compare.UserPreferenceExternalCompareHandler.java

/**
 * {@inheritDoc}//from  www  .  java  2 s  .  c  om
 *
 * Runs the external program (if one is configured) as another job, in order
 * to return control quickly.
 */
@Override
public boolean onCompare(final boolean threeWay, final IProgressMonitor monitor, final Object modified,
        final Object original, final Object ancestor) {
    if (!(modified instanceof ExternalComparable) || !(original instanceof ExternalComparable)
            || (threeWay && !(ancestor instanceof ExternalComparable))) {
        return false;
    }

    final ExternalComparable modifiedEC = (ExternalComparable) modified;
    final ExternalComparable originalEC = (ExternalComparable) original;
    final ExternalComparable ancestorEC = threeWay ? (ExternalComparable) ancestor : null;

    /*
     * Load the correct external compare toolset, using the preference key
     * contributed by the running product.
     */
    final ExternalToolset compareToolset = ExternalToolset.loadFromMemento(
            new MementoRepository(DefaultPersistenceStoreProvider.INSTANCE.getConfigurationPersistenceStore())
                    .load(ExternalToolPreferenceKey.COMPARE_KEY));

    /*
     * Determine the comparison tool type for directories, or for this
     * particular file.
     */
    final ExternalTool tool;

    if (ITypedElement.FOLDER_TYPE == modifiedEC.getType()) {
        tool = compareToolset.findToolForDirectory();
    } else {
        tool = compareToolset.findTool(modifiedEC.getName());
    }

    /*
     * No tool configured, so we can't handle it externally.
     */
    if (tool == null) {
        return false;
    }

    monitor.beginTask(Messages.getString("UserPreferenceExternalCompareHandler.ProgressPrepareCompare"), //$NON-NLS-1$
            threeWay ? 300 : 200);

    try {
        final String modifiedPath = modifiedEC
                .getExternalCompareFile(
                        new SubProgressMonitor(monitor, 100, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK))
                .getAbsolutePath();

        final String originalPath = originalEC
                .getExternalCompareFile(
                        new SubProgressMonitor(monitor, 100, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK))
                .getAbsolutePath();

        final String ancestorPath = threeWay ? ancestorEC
                .getExternalCompareFile(
                        new SubProgressMonitor(monitor, 100, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK))
                .getAbsolutePath() : null;

        final String modifiedLabel = CompareUtils.getLabel(modified);
        final String originalLabel = CompareUtils.getLabel(original);
        final String ancestorLabel = threeWay ? CompareUtils.getLabel(ancestor) : null;

        final String messageFormat = "Beginning external compare for {0} and {1}"; //$NON-NLS-1$
        final String message = MessageFormat.format(messageFormat, modifiedPath, originalPath);
        log.debug(message);

        final LaunchExternalCompareToolCommand compareCommand = new LaunchExternalCompareToolCommand(tool,
                originalPath, modifiedPath, ancestorPath, originalLabel, modifiedLabel, ancestorLabel);

        /*
         * These commands run at least as long as the external tool runs (if
         * it starts successfully), so use a job executor and job options to
         * hide it in the progress UI.
         */
        final JobOptions options = new JobOptions();
        options.setSystem(true);

        final ICommandExecutor executor = UICommandExecutorFactory.newUIJobCommandExecutor(shell, options);
        executor.execute(compareCommand);
    } catch (final InterruptedException e) {
        return true;
    } catch (final IOException e) {
        throw new RuntimeException(e.getMessage());
    } finally {
        monitor.done();
    }

    return true;
}

From source file:tasly.greathealth.oms.order.facades.impl.DefaultPendingOrderFacade.java

/**
 * recreate failed orders for eventtype in EventType
 *
 * @param tid ??oid ? eventType EventType
 * @author vincent.yin/*  w ww  . jav  a  2  s.  co m*/
 */

@Override
public void restorePendingOrders(final String tid) {
    LOG.info("??pendingOrders, tid= " + tid);
    final List<PendingOrderData> pendingOrderDataList = omsOrderRetrieverService.loadPendingOrdersByTID(tid);

    final List<PendingOrder> pendingOrders = this.converters.convertAll(pendingOrderDataList,
            this.pendingOrderConverter);

    final List<PendingOrder> pendingOrderOrderCreateList = new ArrayList<PendingOrder>();

    final List<PendingOrder> pendingOrderOtherList = new ArrayList<PendingOrder>();

    // EventType.ORDERCREATE should be first processed.

    for (final PendingOrder pendingOrder : pendingOrders) {

        if (pendingOrder.getEventType().toString().equals(EventType.ORDERCREATE.toString())) {
            pendingOrderOrderCreateList.add(pendingOrder);
        }
        // now only process eventype= REFUNDCREATE
        else if (pendingOrder.getEventType().toString().equals(EventType.REFUNDCREATE.toString())) {
            pendingOrderOtherList.add(pendingOrder);
        }

    }

    // fist process EventType.ORDERCREATE
    for (final PendingOrder pendingOrder : pendingOrderOrderCreateList) {
        LOG.info("? EventType.ORDERCREATE  PendingOrders, oid = " + pendingOrder.getOid()
                + " ,eventType is ," + pendingOrder.getEventType().toString() + ",refund_fee is "
                + pendingOrder.getRefundFee());

        // first rest the stat from fail to success.

        omsOrderRetrieverService.saveSuccessPendingOrder(tid, pendingOrder.getOid(),
                pendingOrder.getEventType().toString());

        restorePendingOrders(pendingOrder);
    }

    // wait a little minutes

    try {
        Thread.sleep(5000);
    } catch (final InterruptedException e) {
        LOG.warn(e.getMessage(), e);
    }

    // then others

    for (final PendingOrder pendingOrder : pendingOrderOtherList) {
        LOG.info("?PendingOrders, oid = " + pendingOrder.getOid() + " ,eventType is ,"
                + pendingOrder.getEventType().toString() + ",refund_fee is " + pendingOrder.getRefundFee());

        // first rest the stat from fail to success.

        omsOrderRetrieverService.saveSuccessPendingOrder(tid, pendingOrder.getOid(),
                pendingOrder.getEventType().toString());

        restorePendingOrders(pendingOrder);
    }
}

From source file:JMeter.plugins.functional.samplers.geoevent.HttpJsonToStreamServiceSampler.java

public synchronized boolean getId(int id, int timeout) {
    boolean f = false;
    long endtime = System.currentTimeMillis() + timeout;

    while (!wsClient.hasId(id)) {
        try {/*from   ww w .  j  ava2 s. co  m*/
            System.out.println(id);
            wait();
        } catch (InterruptedException ex) {
            log.error(ex.getMessage());
        }
    }
    return f;
}

From source file:com.taobao.android.builder.tasks.manager.MtlParallelTask.java

@TaskAction
void run() {/*from   ww  w . j a v  a2  s  .  c o m*/

    if (null == parallelTask || parallelTask.isEmpty()) {
        return;
    }

    if (concurrent) {

        String taskName = uniqueTaskName;
        if (StringUtils.isEmpty(taskName)) {
            taskName = parallelTask.get(0).getClass().getSimpleName();
        }

        ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper(taskName, getLogger(), 0);
        List<Runnable> runnables = new ArrayList<>();

        for (final DefaultTask task : parallelTask) {
            runnables.add(new Runnable() {
                @Override
                public void run() {
                    task.execute();
                }
            });
        }

        try {
            executorServicesHelper.execute(runnables);
        } catch (InterruptedException e) {
            throw new GradleException(e.getMessage(), e);
        }

    } else {
        for (final DefaultTask task : parallelTask) {
            task.execute();
        }
    }

}

From source file:com.bt.aloha.collections.memory.InMemoryCollectionImpl.java

public void remove(String infoId) {
    Semaphore semaphore = getSemaphores().get(infoId);
    if (semaphore == null)
        return;//from  w  ww  .ja  va2  s .c om

    try {
        semaphore.acquire();
    } catch (InterruptedException e) {
        log.error(String.format(FAILED_TO_REMOVE_OBJECT_MESSAGE, infoId, this.getClass().getSimpleName(),
                e.getMessage()));
        throw new CollectionAccessInterruptedException(String.format(FAILED_TO_REMOVE_OBJECT_MESSAGE, infoId,
                this.getClass().getSimpleName(), e.getMessage()), e);
    }
    try {
        if (infos.remove(infoId) != null) {
            getSemaphores().remove(infoId);
            log.info(String.format("Removed info %s", infoId));
        } else
            log.warn(String.format("Failed to find info %s", infoId));
    } finally {
        semaphore.release();
    }
}

From source file:copter.ServerConnection.java

@Override
public void run() {
    String ipAddress = null;/*from  w  w  w . ja va 2s  . c  om*/
    String serverResponse = null;
    while (true) {
        if (!InternetConnector.getInstance().checkInternetConnection()) {
            logger.log("internet is down! reconnecting...");
            break;
        }
        if (!InternetConnector.getInstance().checkConnectionToServer()) {
            logger.log("Internet is up, but server is down!");
        }
        ipAddress = getIpAddress();
        if (ipAddress == null || ipAddress.isEmpty()) {
            logger.log("can not obtain device IP address!!! start connection again...");
            break;
        }
        if (this.ip == null || !this.ip.equals(ipAddress)) {
            logger.log("device IP is changed!!! sending IP to server again...");
            this.ip = ipAddress;
            serverResponse = obtainIpAddressAndSendCopterInfoToServer();
            if (serverResponse == null || !serverResponse.equals("ok")) {
                logger.log(serverResponse);
                break;
            }
        }
        try {
            Thread.sleep(5000);
        } catch (InterruptedException ex) {
            logger.log(ex.getMessage());
        }

    }
    InternetConnector.getInstance().disconnectFromSakis3g();
    init();
}

From source file:octopus.teamcity.agent.OctopusBuildProcess.java

@NotNull
public BuildFinishedStatus waitFor() throws RunBuildException {
    int exitCode;

    try {/*from   w w  w .  j  a va  2s .  c o m*/
        exitCode = process.waitFor();

        standardError.join();
        standardOutput.join();

        logger.message("Octo.exe exit code: " + exitCode);
        logger.activityFinished("Octopus Deploy", DefaultMessagesInfo.BLOCK_TYPE_INDENTATION);

        isFinished = true;
    } catch (InterruptedException e) {
        isFinished = true;
        final String message = "Unable to wait for Octo.exe: " + e.getMessage();
        Logger.getInstance(getClass().getName()).error(message, e);
        throw new RunBuildException(message);
    }

    if (exitCode == 0)
        return BuildFinishedStatus.FINISHED_SUCCESS;

    runningBuild.getBuildLogger().progressFinished();

    String message = "Unable to create or deploy release. Please check the build log for details on the error.";

    if (runningBuild.getFailBuildOnExitCode()) {
        runningBuild.getBuildLogger().buildFailureDescription(message);
        return BuildFinishedStatus.FINISHED_FAILED;
    } else {
        runningBuild.getBuildLogger().error(message);
        return BuildFinishedStatus.FINISHED_SUCCESS;
    }
}

From source file:com.mobeelizer.mobile.android.MobeelizerRealConnectionManager.java

@Override
public boolean isNetworkAvailable() {
    ConnectivityManager connectivityManager = (ConnectivityManager) application.getContext()
            .getSystemService(Context.CONNECTIVITY_SERVICE);

    if (isConnected(connectivityManager)) {
        return true;
    }/*from  w  w  w.  j  a  v a 2  s.co  m*/

    for (int i = 0; i < 10; i++) {
        if (isConnecting(connectivityManager)) {
            // wait for connection
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                Log.w(TAG, e.getMessage(), e);
                break;
            }

            if (isConnected(connectivityManager)) {
                return true;
            }
        }
    }

    return false;
}