List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:com.ebay.jetstream.event.processor.esper.raw.EsperTest.java
@Ignore public void multithreadingTest() { Configuration configuration = new Configuration(); configuration.configure(//from w ww .j a va 2 s. c o m new File("src/test/java/com/ebay/jetstream/event/processor/esper/raw/EsperTestConfig.xml")); EPServiceProvider epService = EPServiceProviderManager.getProvider("EsperTest", configuration); EsperTestStatement esperStmt = new EsperTestStatement(epService.getEPAdministrator()); EsperTestSubscriber subscriber = new EsperTestSubscriber(); EsperTestListener listener = new EsperTestListener(); esperStmt.setSubscriber(subscriber); esperStmt.addListener(listener); ExecutorService threadPool = Executors.newCachedThreadPool(new EsperTestThreadFactory()); EsperTestRunnable runnables[] = new EsperTestRunnable[THREADS_NUM]; try { for (int i = 0; i < THREADS_NUM; i++) { runnables[i] = new EsperTestRunnable(epService, i); threadPool.submit(runnables[i]); } threadPool.shutdown(); threadPool.awaitTermination(200, TimeUnit.SECONDS); } catch (InterruptedException e) { fail("InterruptedException: " + e.getMessage()); } assertTrue("ExecutorService failed to shut down properly", threadPool.isShutdown()); log.info("[" + subscriber.getIds().first() + "," + subscriber.getIds().last() + "]"); assertEquals(THREADS_NUM, subscriber.getCount()); log.info("[" + listener.getIds().first() + "," + listener.getIds().last() + "]"); assertEquals(THREADS_NUM, listener.getCount()); assertEquals(THREADS_NUM, listener.getNewCount()); assertEquals(0, listener.getOldCount()); }
From source file:info.pancancer.arch3.jobGenerator.JobGenerator.java
private void generateAndQueueJob(String iniFile, String workflowName, String workflowVersion, String workflowPath) {//from ww w . j av a 2 s. c o m // keep track of the iterations currIterations++; log.info("\ngenerating new jobs, iteration " + currIterations + "\n"); // TODO: this is fake, in a real program this is being read from JSONL file or web service // check to see if new results are available and/or if the work queue is empty Order o = generateNewJob(iniFile, workflowName, workflowVersion, workflowPath); // enqueue new job if (o != null) { enqueueNewJobs(o.toJSON()); } try { // pause Thread.sleep(ONE_SECOND_IN_MILLISECONDS); } catch (InterruptedException ex) { log.error(ex.getMessage(), ex); } }
From source file:com.athena.peacock.agent.netty.PeacockClient.java
/** * <pre>//from w w w. j av a 2s .c om * Bean ? ? Server? ? . * </pre> * @throws Exception */ @PostConstruct public void start() throws Exception { final Bootstrap b = new Bootstrap().group(group).channel(NioSocketChannel.class) .handler(new LoggingHandler(LogLevel.WARN)).handler(initializer); // Start the connection attempt. final ChannelFuture connectFuture = b.connect(host, port); connectFuture.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { future.sync(); } else { if (count.incrementAndGet() <= maxretries) { logger.debug("Attempt to reconnect within {} seconds.", frequency / 1000); try { Thread.sleep(frequency); } catch (InterruptedException e) { // nothing to do. logger.error(e.getMessage()); } b.connect(host, port).addListener(this); } else { // Stop the agent daemon if the connection attempt has failed. System.exit(-1); } } } }); }
From source file:ThreadTester.java
public void run() { try {// w w w.ja v a 2 s . c om while (true) { process(q.take()); } } catch (InterruptedException e) { out.printf("%s interrupted: %s", getName(), e.getMessage()); } }
From source file:ThreadTester.java
public void run() { try {/*from ww w .j ava2s. c o m*/ while (true) { q.put(produce()); } } catch (InterruptedException e) { out.printf("%s interrupted: %s", getName(), e.getMessage()); } }
From source file:org.yamj.filescanner.service.SystemInfoCore.java
/** * Attempt to connect to the core server using the specified retries and timeout * * @param retries// ww w .j a v a 2s . co m * @param timeout * @return */ public boolean check(int retries, int timeout) { boolean checkConnected = pingCore(); int retryCount = 0; while (!checkConnected && (retryCount++ < retries)) { LOG.info("Attempt #{}/{}: Waiting {} seconds for server to become available.", retryCount, retries, timeout); try { TimeUnit.SECONDS.sleep(timeout); checkConnected = pingCore(); } catch (InterruptedException ex) { LOG.info("Interrupted whilst waiting for connection to core server: {}", ex.getMessage()); break; } } LOG.info(status()); return checkConnected; }
From source file:edu.gmu.isa681.client.model.ClientImpl.java
@Override public void run() { try {/*from ww w . j a v a 2 s . c o m*/ while (true) { synchronized (shutdownLock) { if (shuttingDown) break; } Encodeable packet = chnl.read(); if (packet instanceof Response) { notifyResponseListeners((Response) packet); } else { notifyExceptionListeners(new UnexpectedTypeException(packet.toString())); } } } catch (InterruptedException ex) { synchronized (shutdownLock) { if (!shuttingDown) { log.warn(ex.getMessage(), ex); } } } finally { disconnect(); } }
From source file:com.liferay.portal.servlet.LuceneServlet.java
public void destroy() { // Wait for indexer to be gracefully interrupted if ((_indexer != null) && (!_indexer.isFinished()) && (_indexerThread != null)) { _log.warn("Waiting for Lucene indexer to shutdown"); _indexer.halt();/* w w w . j a v a 2 s .co m*/ try { _indexerThread.join(THREAD_TIMEOUT); } catch (InterruptedException e) { _log.error("Lucene indexer shutdown interrupted", e); Logger.error(this, e.getMessage(), e); } } // Parent super.destroy(); }
From source file:org.apache.manifoldcf.connectorcommon.common.InterruptibleSocketFactory.java
protected Socket fireOffThread(InetAddress address, int port, InetAddress localHost, int localPort) throws IOException { SocketCreateThread thread = new SocketCreateThread(wrappedFactory, address, port, localHost, localPort); thread.start();/*from ww w . ja va 2 s. c o m*/ try { // Wait for thread to complete for only a certain amount of time! thread.join(connectTimeoutMilliseconds); // If join() times out, then the thread is going to still be alive. if (thread.isAlive()) { // Kill the thread - not that this will necessarily work, but we need to try thread.interrupt(); throw new ConnectTimeoutException("Secure connection timed out"); } // The thread terminated. Throw an error if there is one, otherwise return the result. Throwable t = thread.getException(); if (t != null) { if (t instanceof java.net.SocketTimeoutException) throw (java.net.SocketTimeoutException) t; else if (t instanceof ConnectTimeoutException) throw (ConnectTimeoutException) t; else if (t instanceof InterruptedIOException) throw (InterruptedIOException) t; else if (t instanceof IOException) throw (IOException) t; else if (t instanceof Error) throw (Error) t; else if (t instanceof RuntimeException) throw (RuntimeException) t; throw new Error("Received an unexpected exception: " + t.getMessage(), t); } return thread.getResult(); } catch (InterruptedException e) { throw new InterruptedIOException("Interrupted: " + e.getMessage()); } }
From source file:ch.epfl.eagle.daemon.nodemonitor.TaskScheduler.java
protected void makeTaskRunnable(TaskSpec task) { try {//from www .ja v a 2s . co m LOG.debug("Putting reservation for request " + task.requestId + " in runnable queue"); runnableTaskQueue.put(task); } catch (InterruptedException e) { LOG.fatal("Unable to add task to runnable queue: " + e.getMessage()); } }