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:Main.java

/**
 * Workaround for Java problem on Windows with releasing buffers for memory-mapped files.
 *
 * @see "http://stackoverflow.com/questions/3602783/file-access-synchronized-on-java-object"
 * @see "http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6354433"
 * @see "http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154"
 * @see "http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4469299"
 *//*from  w w w .  j av  a2  s  .co  m*/
private static FileOutputStream getFileOutputStreamWorkaround(java.io.File storeFile)
        throws FileNotFoundException {
    final int maxCount = 10;
    for (int i = 0; i <= maxCount; i++) {
        try {
            // there is no sleep on first round
            Thread.sleep(10 * i);
        } catch (InterruptedException e) {
            // restore interrupted status
            Thread.currentThread().interrupt();
        }
        try {
            return new FileOutputStream(storeFile);
        } catch (FileNotFoundException e) {
            // only apply workaround for the very specific exception
            if (i >= maxCount || !e.getMessage().contains(
                    "The requested operation cannot be performed on a file with a user-mapped section open")) { //$NON-NLS-1$
                throw e;
            }
            //            CCorePlugin.log(new Status(IStatus.INFO, CCorePlugin.PLUGIN_ID, "Workaround for concurrent access to memory-mapped files applied, attempt " + (i + 1), e)); //$NON-NLS-1$
        }
    }

    // will never get here
    return null;
}

From source file:cd.education.data.collector.android.utilities.FileUtils.java

public static String copyFile(File sourceFile, File destFile) {
    if (sourceFile.exists()) {
        String errorMessage = actualCopy(sourceFile, destFile);
        if (errorMessage != null) {
            try {
                Thread.sleep(500);
                Log.e(t, "Retrying to copy the file after 500ms: " + sourceFile.getAbsolutePath());
                errorMessage = actualCopy(sourceFile, destFile);
            } catch (InterruptedException e) {
                Log.e(t, e.getMessage(), e);
            }/*from w w w  .  ja va  2s.c om*/
        }
        return errorMessage;
    } else {
        String msg = "Source file does not exist: " + sourceFile.getAbsolutePath();
        Log.e(t, msg);
        return msg;
    }
}

From source file:TestFuseDFS.java

/**
 * Exec the given command and assert it executed successfully
 *//* w  w  w. j a  v a2 s  . com*/
private static void execWaitRet(String cmd) throws IOException {
    LOG.debug("EXEC " + cmd);
    Process p = r.exec(cmd);
    try {
        p.waitFor();
    } catch (InterruptedException ie) {
        fail("Process interrupted: " + ie.getMessage());
    }
}

From source file:TestFuseDFS.java

/**
 * Wait for the given process to return and check that it exited
 * as required. Log if the process failed.
 *///from   w  w  w  .  ja  va  2s  .  c  o m
private static void checkProcessRet(Process p, boolean expectPass) throws IOException {
    try {
        int ret = p.waitFor();
        if (ret != 0) {
            dumpInputStream(p.getErrorStream());
        }
        if (expectPass) {
            assertEquals(0, ret);
        } else {
            assertTrue(ret != 0);
        }
    } catch (InterruptedException ie) {
        fail("Process interrupted: " + ie.getMessage());
    }
}

From source file:dk.statsbiblioteket.doms.radiotv.extractor.transcoder.OutputFileUtil.java

public static boolean lookForFileInFolder(File fileLocation, final String filenameWithoutExt)
        throws ProcessorException {
    final FileFilter filter = new FileFilter() {
        @Override//from w w  w. java2  s.  co  m
        public boolean accept(File pathname) {
            return pathname.getName().startsWith(filenameWithoutExt);
        }
    };
    log.debug("Looking for file " + filenameWithoutExt + " in: " + fileLocation.getAbsolutePath());
    int i = 0;
    while ((fileLocation.listFiles(filter) == null) && (i < 5)) {
        try {
            log.warn("Unable to access : " + fileLocation.getAbsolutePath() + ". Retrying " + i + ". "
                    + new Date(System.currentTimeMillis()));
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            log.info("Got interrupted. Ignoring interruption. Cause: " + e.getMessage());
            // Do nothing...
        }
        i++;
    }
    if (fileLocation.listFiles(filter) == null) {
        log.error("Unable to access directory: " + fileLocation);
        throw new ProcessorException("Unable to access directories at storage.");
    }
    boolean hasFileInFinishedDir = fileLocation.listFiles(filter).length > 0;
    return hasFileInFinishedDir;
}

From source file:gridool.db.helpers.GridDbUtils.java

public static long invokeCsvLoadJob(final GridKernel kernel, final String csvFileName,
        final HashMap<GridNode, MutableLong> assignMap, final DBPartitioningJobConf jobConf) {
    String connectUrl = jobConf.getConnectUrl();
    String tableName = jobConf.getTableName();
    String createTableDDL = jobConf.getCreateTableDDL();
    String copyIntoQuery = generateCopyIntoQuery(tableName, jobConf);
    String alterTableDDL = jobConf.getAlterTableDDL();

    MonetDBCsvLoadOperation ops = new MonetDBCsvLoadOperation(connectUrl, tableName, csvFileName,
            createTableDDL, copyIntoQuery, alterTableDDL);
    ops.setAuth(jobConf.getUserName(), jobConf.getPassword());
    final Pair<MonetDBCsvLoadOperation, Map<GridNode, MutableLong>> pair = new Pair<MonetDBCsvLoadOperation, Map<GridNode, MutableLong>>(
            ops, assignMap);/*from   ww w.j  av a  2s  . co  m*/

    final GridJobFuture<Long> future = kernel.execute(MonetDBInvokeCsvLoadJob.class, pair);
    final Long numInserted;
    try {
        numInserted = future.get();
    } catch (InterruptedException ie) {
        LOG.error(ie.getMessage(), ie);
        throw new IllegalStateException(ie);
    } catch (ExecutionException ee) {
        LOG.error(ee.getMessage(), ee);
        throw new IllegalStateException(ee);
    }
    return (numInserted == null) ? -1L : numInserted.longValue();
}

From source file:com.socrata.datasync.job.MetadataJob.java

public static JobStatus addLogEntry(String logDatasetID, SocrataConnectionInfo connectionInfo, MetadataJob job,
        JobStatus status) {/*w w w. jav  a 2  s. com*/
    final Soda2Producer producer = Soda2Producer.newProducer(connectionInfo.getUrl(), connectionInfo.getUser(),
            connectionInfo.getPassword(), connectionInfo.getToken());

    List<Map<String, Object>> upsertObjects = new ArrayList<Map<String, Object>>();
    Map<String, Object> newCols = new HashMap<String, Object>();

    // add standard log data
    Date currentDateTime = new Date();
    newCols.put("Date", (Object) currentDateTime);
    newCols.put("DatasetID", (Object) job.getDatasetID());
    newCols.put("JobFile", (Object) job.getPathToSavedFile());
    if (status.isError()) {
        newCols.put("Errors", (Object) status.getMessage());
    } else {
        newCols.put("Success", (Object) true);
    }
    upsertObjects.add(ImmutableMap.copyOf(newCols));

    JobStatus logStatus = JobStatus.SUCCESS;
    String errorMessage = "";
    boolean noPublishExceptions = false;
    try {
        producer.upsert(logDatasetID, upsertObjects);
        noPublishExceptions = true;
    } catch (SodaError sodaError) {
        errorMessage = sodaError.getMessage();
    } catch (InterruptedException intrruptException) {
        errorMessage = intrruptException.getMessage();
    } catch (Exception other) {
        errorMessage = other.toString() + ": " + other.getMessage();
    } finally {
        if (!noPublishExceptions) {
            logStatus = JobStatus.PUBLISH_ERROR;
            logStatus.setMessage(errorMessage);
        }
    }
    return logStatus;
}

From source file:com.tascape.qa.th.Utils.java

public static void deleteFileAfterMinutes(final File file, final int minutes) {
    file.deleteOnExit();//  w  w w.  j a  va2s  .co  m
    Thread t = new Thread() {
        @Override
        public void run() {
            try {
                Thread.sleep(minutes * 60000);
                FileUtils.deleteQuietly(file);
            } catch (InterruptedException ex) {
                LOG.trace(ex.getMessage());
            }
        }
    };
    t.setDaemon(true);
    t.start();
}

From source file:com.servioticy.api.commons.data.CouchBase.java

public static void deleteSubscription(String subsKey) {
    try {//from w  w  w  .  j a v a2 s  .c o m
        // Asynchronous delete
        OperationFuture<Boolean> deleteOp = cli_subscriptions.delete(subsKey);
        if (!deleteOp.get().booleanValue()) {
            throw new ServIoTWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR,
                    "Error deleting subscription from CouchBase");
        }
    } catch (InterruptedException e) {
        LOG.error(e);
        throw new ServIoTWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
    } catch (ExecutionException e) {
        LOG.error(e);
        throw new ServIoTWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
    } catch (Exception e) {
        LOG.error(e);
        throw new ServIoTWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
    }
}

From source file:com.servioticy.api.commons.data.CouchBase.java

/** Set the OpId control flow.
 *
 * @param key/*from w w w.  j a  v  a  2s.  c  o m*/
 * @param exp -> expiration time
 */
public static void setOpId(String key, int exp) {
    // Do an asynchronous set
    OperationFuture<Boolean> setOp = cli_private.set(key, exp, "{}");
    // Check to see if our set succeeded
    try {
        if (!setOp.get().booleanValue())
            throw new ServIoTWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR,
                    "Error storing OpID Document");
    } catch (InterruptedException e) {
        LOG.error(e);
        throw new ServIoTWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
    } catch (ExecutionException e) {
        LOG.error(e);
        throw new ServIoTWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
    } catch (Exception e) {
        LOG.error(e);
        throw new ServIoTWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
    }
}