List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:io.github.retz.executor.FileManager.java
private static void decompress(File file, String dir) throws IOException { LOG.info("{} needs decompression: starting", file); String[] cmd = { "tar", "xf", file.getAbsolutePath(), "-C", dir }; ProcessBuilder pb = new ProcessBuilder().command(cmd).inheritIO(); try {/*from w w w .j a v a 2 s. co m*/ Process p = pb.start(); int r = p.waitFor(); if (r == 0) { LOG.info("file {} successfully decompressed", file); } else { LOG.error("Failed decompression of file {}: {}", file, r); } } catch (InterruptedException e) { LOG.error(e.getMessage()); } }
From source file:com.tomtom.speedtools.json.ImageSerializer.java
@Nonnull private static BufferedImage convertToBufferedImage(@Nonnull final Image image) throws IOException { assert image != null; if (image instanceof BufferedImage) { return (BufferedImage) image; }//from w ww . j a v a 2 s . c om /** * Load the image in the background and wait * until is is downloaded. */ final MediaTracker tracker = new MediaTracker(new Component() { // Empty. }); tracker.addImage(image, 0); try { tracker.waitForAll(); } catch (final InterruptedException e) { throw new IOException(e.getMessage(), e); } /** * Create a buffered image with the right dimensions. */ final BufferedImage bufImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); /** * Draw the image in the buffer and return it as base64 data. */ final Graphics g = bufImage.createGraphics(); g.drawImage(image, 0, 0, null); return bufImage; }
From source file:com.bt.aloha.batchtest.BatchTestScenarioBase.java
protected static <T> T waitForScenarioData(String eventCallId, Map<String, T> map) { for (int i = 0; i < 20; i++) { T data = map.get(eventCallId);// w w w.j a v a 2s .c o m if (data != null) return data; try { Thread.sleep(1000); } catch (InterruptedException e) { LOG.error(e.getMessage(), e); } } return null; }
From source file:api.startup.PDFIndexer.java
/** * Indexes all the documents in the CSV file * @param writer - index writer/* w w w. j a v a 2 s . c om*/ * @param indexConfiguration - the configuration for all the indexable documents * @throws IOException */ static void indexDocs(final IndexWriter writer, String indexConfiguration) throws IOException { Reader in = new FileReader(indexConfiguration); CSVParser parser = CSVFormat.RFC4180.withHeader().parse(in); List<Callable<Object>> tasks = new ArrayList<>(); int threadPoolSize = Runtime.getRuntime().availableProcessors(); log.info("Indexing with " + threadPoolSize + " processors"); ExecutorService pool = Executors.newFixedThreadPool(threadPoolSize); for (CSVRecord record : parser) { DocumentMetadata meta = new DocumentMetadata(record); tasks.add(() -> { indexDoc(writer, meta); return null; }); } try { pool.invokeAll(tasks); } catch (InterruptedException e) { log.error("Indexing was interrupted " + e.getMessage()); } }
From source file:io.github.retz.executor.FileManager.java
private static void fetchHDFSFile(String file, String dest) throws IOException { LOG.debug("Downloading {} to {} as HDFS file", file, dest); // TODO: make 'hadoop' command arbitrarily specifiable, but given that mesos-agent (slave) can fetch hdfs:// files, it should be also available, too String[] hadoopCmd = { "hadoop", "fs", "-copyToLocal", file, dest }; LOG.debug("Command: {}", String.join(" ", hadoopCmd)); ProcessBuilder pb = new ProcessBuilder(); pb.command(hadoopCmd).inheritIO();/* w w w. j a v a2 s . c om*/ Process p = pb.start(); while (true) { try { int result = p.waitFor(); if (result != 0) { LOG.error("Downloading {} failed: {}", file, result); } else { LOG.info("Download finished: {}", file); } return; } catch (InterruptedException e) { LOG.error("Download process interrupted: {}", e.getMessage()); // TODO: debug? } } }
From source file:br.eti.kinoshita.selenium.util.Utils.java
/** * Wait for determined select index in a select (combo) box in a determined period * /* w ww. j a v a 2 s. co m*/ * @param select * @param index * @param timeout */ public static void waitForSelectIndex(Select select, Integer index, Long timeout) { Long end = System.currentTimeMillis() + timeout; while (System.currentTimeMillis() < end) { if (select.getOptions().size() < index) { try { Thread.sleep(1000); } catch (InterruptedException e) { LOGGER.debug(e.getMessage(), e); } } else { break; } } }
From source file:com.yahoo.storm.yarn.TestIntegration.java
private static void sleep(int i) { try {// w ww.j a v a 2 s. c o m Thread.sleep(i); } catch (InterruptedException e) { LOG.info("setup thread sleep interrupted. message=" + e.getMessage()); } }
From source file:com.yahoo.athenz.example.zts.tls.client.ZTSAWSCredsClient.java
private static boolean retrieveAWSTempCreds(AWSCredentialsProvider awsCredProvider) { try {/*from ww w . j av a2 s. c o m*/ // just for testing purposes we're going to run this code // for 2 hours and keep asking for credentials every minute // to make sure zts client is caching the creds and giving // us new ones when they're about to expire for (int i = 0; i < 120; i++) { AWSCredentials awsCreds = awsCredProvider.getCredentials(); if (awsCreds == null) { System.out.println("Error: AWS Credentials are not available"); return false; } System.out.println("AWS Temporary Credentials:\n"); System.out.println("\tAccess Key Id : " + awsCreds.getAWSAccessKeyId()); System.out.println("\tSecret Key : " + awsCreds.getAWSSecretKey()); try { Thread.sleep(60000); } catch (InterruptedException ex) { } } } catch (ZTSClientException ex) { System.out.println("Unable to retrieve AWS credentials: " + ex.getMessage()); return false; } return true; }
From source file:br.eti.kinoshita.selenium.util.Utils.java
/** * Wait for assync content in a determined period * // w w w . j av a 2 s. c o m * @param driver Selenium web driver. * @param by Selenium By expression. * @param timeout Selenium time out. * @return a WebElement asynchronously loaded. * @throws NoSuchElementException */ public static WebElement waitForAssyncContent(WebDriver driver, By by, Long timeout) throws NoSuchElementException { long end = System.currentTimeMillis() + (timeout); WebElement renderedWebElement = null; while (System.currentTimeMillis() < end) { try { renderedWebElement = driver.findElement(by); } catch (NoSuchElementException nsee) { LOGGER.debug(nsee.getMessage(), nsee); } if (renderedWebElement != null && renderedWebElement.isEnabled() && renderedWebElement.isDisplayed()) { return renderedWebElement; } try { Thread.sleep(1000); } catch (InterruptedException ie) { LOGGER.debug(ie.getMessage(), ie); } } if (renderedWebElement == null) { throw new NoSuchElementException("Could not locate assync content"); } try { if (renderedWebElement.isDisplayed()) { throw new NoSuchElementException("Element is not being displayed"); } } catch (Throwable t) { LOGGER.debug(t.getMessage(), t); } return renderedWebElement; }
From source file:gridool.db.partitioning.phihash.csv.normal.CsvPartitioningTask.java
private static void runShuffleJob(final GridKernel kernel, final PartitioningJobConf conf, final Map<GridNode, MutableLong> recMap, final String deploymentGroup) { PartitioningJobType jobType = conf.getJobConf().getJobType(); Class<? extends GridJob<PartitioningJobConf, Map<GridNode, MutableInt>>> jobClass = jobType .getFirstPartitioningJobClass(); //final GridJobFuture<Map<GridNode, MutableInt>> future = kernel.execute(CsvHashPartitioningJob.class, conf); //final GridJobFuture<Map<GridNode, MutableInt>> future = kernel.execute(GlobalCsvHashPartitioningJob.class, conf); final GridJobFuture<Map<GridNode, MutableInt>> future = kernel.execute(jobClass, conf); final Map<GridNode, MutableInt> map; try {/*from ww w .j a v a 2 s . co m*/ map = future.get(); // wait for execution } catch (InterruptedException ie) { LOG.error(ie.getMessage(), ie); throw new IllegalStateException(ie); } catch (ExecutionException ee) { LOG.error(ee.getMessage(), ee); throw new IllegalStateException(ee); } synchronized (recMap) { for (final Map.Entry<GridNode, MutableInt> e : map.entrySet()) { GridNode node = e.getKey(); MutableInt assigned = e.getValue(); long v = assigned.longValue(); MutableLong prev = recMap.get(node); if (prev == null) { recMap.put(node, new MutableLong(v)); } else { prev.add(v); } } } }