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:core.com.qiniu.http.AmazonHttpClient.java

/**
 * Sleep for a period of time on failed request to avoid flooding a service
 * with retries./*from w w w  .ja  v  a  2 s. com*/
 *
 * @param originalRequest The original service request that is being
 *            executed.
 * @param previousException Exception information for the previous attempt,
 *            if any.
 * @param requestCount current request count (including the next attempt
 *            after the delay)
 * @param retryPolicy The retry policy configured in this http client.
 */
private long pauseBeforeNextRetry(AmazonWebServiceRequest originalRequest,
        AmazonClientException previousException, int requestCount, RetryPolicy retryPolicy) {
    final int retries = requestCount // including next attempt
            - 1 // number of attempted requests
            - 1; // number of attempted retries

    long delay = retryPolicy.getBackoffStrategy().delayBeforeNextRetry(originalRequest, previousException,
            retries);

    if (log.isDebugEnabled()) {
        log.debug("Retriable error detected, " + "will retry in " + delay + "ms, attempt number: " + retries);
    }

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

From source file:com.ephesoft.gxt.batchinstance.server.CopyTroubleshootingArtifacts.java

/**
 * This method creates the database dump after reading the database properties from the property file and writes it to the solution
 * folder./*from   w w w.j ava 2  s.co  m*/
 * 
 * @param dbPropertiesFileName {@link String} database property file hiddenPath
 */
public void createDBDump(final String downloadFolderPath) {
    if (!EphesoftStringUtil.isNullOrEmpty(downloadFolderPath)) {
        Properties dbProperties;
        Properties applicationProperties;
        try {
            dbProperties = ApplicationConfigProperties.getApplicationConfigProperties()
                    .getAllProperties(DCMA_DATA_ACCESS);
            String dbName = dbProperties.getProperty(DB_NAME);
            String username = dbProperties.getProperty(DB_USERNAME);
            String password = dbProperties.getProperty(DB_PASSWORD);
            String server = dbProperties.getProperty(DB_SERVER);
            String dialect = dbProperties.getProperty(DB_DIALECT);

            applicationProperties = ApplicationConfigProperties.getApplicationConfigProperties()
                    .getAllProperties(APPLICATION_PROPERTY_FILE_NAME);
            Process process;
            String dbDumpCommand = null;
            if (MYSQL_DIALECT.equals(dialect)) {
                dbDumpCommand = createDBDumpCommandForMySQL(downloadFolderPath, applicationProperties, dbName,
                        username, password, server);
            } else if (MSSQL_DIALECT.equals(dialect)) {
                dbDumpCommand = createDBDumpCommandForMsSQL(downloadFolderPath, applicationProperties, dbName,
                        username, password, server);
            } else {
                LOGGER.error("INCOMPATIBLE DATABASE");
                foldersNotCopied.append(EphesoftStringUtil.concatenate(DATABASE_DUMP_FOLDER, SEMI_COLON));
            }

            if (!EphesoftStringUtil.isNullOrEmpty(dbDumpCommand)) {
                LOGGER.debug("Creating dump.");
                LOGGER.debug(EphesoftStringUtil.concatenate("database dump command : ", dbDumpCommand));
                process = Runtime.getRuntime().exec(dbDumpCommand);
                try {
                    // makes the current thread wait for the completion of the process
                    int exitValue = process.waitFor();
                    if (exitValue != 0) {
                        LOGGER.debug("Error in creating database dump.");
                        foldersNotCopied
                                .append(EphesoftStringUtil.concatenate(DATABASE_DUMP_FOLDER, SEMI_COLON));
                    }
                } catch (InterruptedException interruptedException) {
                    LOGGER.error(EphesoftStringUtil.concatenate("Thread interrupted. ",
                            interruptedException.getMessage()));
                }
            }
        } catch (IOException e) {
            LOGGER.error(
                    EphesoftStringUtil.concatenate("Error in reading dcma-batch.properties. ", e.getMessage()));
        }
    }
}

From source file:com.alibaba.wasp.fserver.SplitTransaction.java

/**
 * Perform time consuming opening of the daughter entityGroups.
 *
 * @param server//from ww  w .  j  a  va 2 s.c o  m
 *          Hosting server instance. Can be null when testing (won't try and
 *          update in zk if a null server)
 * @param services
 *          Used to online/offline entityGroups.
 * @param a
 *          first daughter entityGroup
 * @param a
 *          second daughter entityGroup
 * @throws java.io.IOException
 *           If thrown, transaction failed. Call
 *           {@link #rollback(com.alibaba.wasp.Server, FServerServices)}
 */
void openDaughters(final Server server, final FServerServices services, EntityGroup a, EntityGroup b)
        throws IOException {
    boolean stopped = server != null && server.isStopped();
    boolean stopping = services != null && services.isStopping();
    if (stopped || stopping) {
        LOG.info("Not opening daughters " + b.getEntityGroupInfo().getEntityGroupNameAsString() + " and "
                + a.getEntityGroupInfo().getEntityGroupNameAsString() + " because stopping=" + stopping
                + ", stopped=" + stopped);
    } else {
        // Open daughters in parallel.
        DaughterOpener aOpener = new DaughterOpener(server, a);
        DaughterOpener bOpener = new DaughterOpener(server, b);
        aOpener.start();
        bOpener.start();
        try {
            aOpener.join();
            bOpener.join();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new IOException("Interrupted " + e.getMessage());
        }
        if (aOpener.getException() != null) {
            throw new IOException("Failed " + aOpener.getName(), aOpener.getException());
        }
        if (bOpener.getException() != null) {
            throw new IOException("Failed " + bOpener.getName(), bOpener.getException());
        }
        if (services != null) {
            // add 2nd daughter first
            services.postOpenDeployTasks(b, true);
            // Should add it to OnlineEntityGroups
            services.addToOnlineEntityGroups(b);
            services.postOpenDeployTasks(a, true);
            services.addToOnlineEntityGroups(a);
        }
    }
}

From source file:org.glowroot.central.SyntheticMonitorService.java

public SyntheticRunResult runJava(Constructor<?> defaultConstructor, Method testMethod, Object testArg,
        long startTick) throws Exception {
    try {//from   w  w w . j a  v a  2 s  .  com
        return runJavaInternal(defaultConstructor, testMethod, testArg, startTick);
    } catch (InterruptedException e) {
        // probably shutdown requested (see close method above)
        logger.debug(e.getMessage(), e);
        throw e;
    } catch (Throwable t) {
        // unexpected exception
        logger.error(t.getMessage(), t);
        throw t;
    }
}

From source file:au.org.ala.layers.dao.LayerIntersectDAOImpl.java

ArrayList<String> localSampling(IntersectionFile[] intersectionFiles, double[][] points,
        IntersectCallback callback) {//from w ww .j a  va2 s. c  o  m
    logger.info("begin LOCAL sampling, number of threads " + intersectConfig.getThreadCount()
            + ", number of layers=" + intersectionFiles.length + ", number of coordinates=" + points.length);
    long start = System.currentTimeMillis();
    int threadCount = intersectConfig.getThreadCount();
    SamplingThread[] threads = new SamplingThread[threadCount];
    LinkedBlockingQueue<Integer> lbq = new LinkedBlockingQueue();
    CountDownLatch cdl = new CountDownLatch(intersectionFiles.length);
    ArrayList<String> output = new ArrayList<String>();
    for (int i = 0; i < intersectionFiles.length; i++) {
        output.add("");
        lbq.add(i);
    }

    callback.setLayersToSample(intersectionFiles);
    logger.info("Initialising sampling threads: " + threadCount);
    for (int i = 0; i < threadCount; i++) {
        threads[i] = new SamplingThread(lbq, cdl, intersectionFiles, points, output,
                intersectConfig.getThreadCount(), intersectConfig.getShapeFileCache(),
                intersectConfig.getGridBufferSize(), callback);
        threads[i].start();
    }

    try {
        cdl.await();
    } catch (InterruptedException ex) {
        logger.error(ex.getMessage(), ex);
    } finally {
        for (int i = 0; i < threadCount; i++) {
            try {
                threads[i].interrupt();
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
        }
    }

    logger.info("End sampling, threads=" + threadCount + " layers=" + intersectionFiles.length + " in "
            + (System.currentTimeMillis() - start) + "ms");
    return output;
}

From source file:edu.stanford.cfuller.colocalization3d.Colocalization3DMain.java

private void checkAllRunningThreadsAndRemoveFinished(List<FittingThread> started,
        List<FittingThread> finished) {

    List<FittingThread> toMove = new java.util.ArrayList<FittingThread>();

    for (FittingThread ft : started) {
        try {//from w w  w.j  av  a 2 s  .  c o m
            ft.join(DEFAULT_THREAD_WAIT_MS);
        } catch (InterruptedException e) {
            java.util.logging.Logger.getLogger(LOGGER_NAME)
                    .severe("Interrupted while waiting for completion of fitting thread: " + e.getMessage());

        }

        if (!ft.isAlive()) {
            toMove.add(ft);
        }
    }

    started.removeAll(toMove);
    finished.addAll(toMove);

}

From source file:org.glowroot.central.SyntheticMonitorService.java

@Override
public void run() {
    while (!closed) {
        try {/*w  w w  .  java  2  s.  c o m*/
            long currMillis = clock.currentTimeMillis();
            long nextMillis = (long) Math.ceil(currMillis / 60000.0) * 60000;
            // scheduling for 5 seconds after the minute (just to avoid exactly on the minute)
            MILLISECONDS.sleep(nextMillis - currMillis + 5000);
            runInternal();
        } catch (InterruptedException e) {
            // probably shutdown requested (see close method below)
            logger.debug(e.getMessage(), e);
            continue;
        } catch (Throwable t) {
            logger.error(t.getMessage(), t);
        }
    }
}

From source file:cn.com.esrichina.gcloud.commons.LicenseContext.java

public void loadLicence(String licencePath, Boolean override) throws GeneralException {
    try {//w w  w.  ja v  a  2s. c o m
        File file = new File(licencePath);
        if (!file.exists()) {
            reason = "??";
            isAuthorized = false;
            return;
        }
        license.initLicense(licencePath);

        // validate static information.
        staticInfoValidate();

        // validate dynamic information
        if (!getLicense().isUnlimited() && isAuthorized) {
            Runnable r = new Runnable() {
                public void run() {
                    while (true) {
                        if (!isAuthorized)
                            break;
                        try {
                            // validate once every twenty-four hours.
                            Thread.sleep(24 * 60 * 60 * 1000L);
                            // for test
                            // Thread.sleep(60 * 1000L);
                            dynamicInfoValidate();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            };
            Thread t = new Thread(r, "license-validate");
            t.start();
        }

        if (override) {
            FileUtils.copyFile(file, new File(ConfigContext.getInstance().getString("license.path")));
        }

    } catch (Exception e) {
        logger.error("?", e);
        throw new GeneralException(Messages.getMessage("license_load_error", e.getMessage()), e);
    }
}

From source file:com.microsoft.azure.remote.AzureVMAgentSSHLauncher.java

private void copyFileToRemote(Session jschSession, InputStream stream, String remotePath) throws Exception {
    LOGGER.log(Level.INFO, "AzureVMAgentSSHLauncher: copyFileToRemote: Initiating file transfer to {0}",
            remotePath);/*from w ww .j  a v  a2 s .  c  o m*/
    ChannelSftp sftpChannel = null;

    try {
        sftpChannel = (ChannelSftp) jschSession.openChannel("sftp");
        sftpChannel.connect();
        sftpChannel.put(stream, remotePath);

        if (!sftpChannel.isClosed()) {
            try {
                LOGGER.warning(
                        "AzureVMAgentSSHLauncher: copyFileToRemote: Channel is not yet closed , waiting for 10 seconds");
                Thread.sleep(10 * 1000);
            } catch (InterruptedException e) {
                //ignore error
            }
        }
        LOGGER.log(Level.INFO, "AzureVMAgentSSHLauncher: copyFileToRemote: copied file Successfully to {0}",
                remotePath);
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE,
                "AzureVMAgentSSHLauncher: copyFileToRemote: Error occurred while copying file to remote host {0}",
                e.getMessage());
        throw e;
    } finally {
        try {
            if (sftpChannel != null) {
                sftpChannel.disconnect();
            }
        } catch (Exception e) {
            // ignore silently
        }
    }
}

From source file:net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicator.java

private void replicationThreadMain() {
    while (true) {
        // Wait for elements in the replicationQueue
        while (alive() && replicationQueue != null && replicationQueue.size() == 0) {
            try {

                Thread.sleep(asynchronousReplicationInterval);
            } catch (InterruptedException e) {
                LOG.debug("Spool Thread interrupted.");
                return;
            }/*from  www  . j a  va 2 s  . c o m*/
        }
        if (notAlive()) {
            return;
        }
        try {
            if (replicationQueue.size() != 0) {
                flushReplicationQueue();
            }
        } catch (Throwable e) {
            LOG.warn("Exception on flushing of replication queue: " + e.getMessage() + ". Continuing...", e);
        }
    }
}