List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:eu.optimis.ip.gui.client.resources.DbServerThread.java
public void stopServer() { server.shutdown();//www .ja v a 2 s.c om while (!isShutdown()) { try { Thread.sleep(500); } catch (InterruptedException ex) { Logger.getLogger(Accounting.class.getName()).log(Level.WARNING, "Error when Thread.sleep(): " + ex.getMessage()); } } }
From source file:edu.xiyou.fruits.WebCrawler.fetcher.Fetcher.java
public void fetch() { before();/*from ww w.ja va 2 s . c o m*/ FetcherThread[] threads = new FetcherThread[Config.THREAD_COUNT]; for (int i = 0; i < Config.THREAD_COUNT; i++) { threads[i] = new FetcherThread(fetchCount); threadPool.execute(threads[i]); } if (runState == STOP) { for (int i = 0; i < Config.THREAD_COUNT; i++) { threads[i].stop(); } } if (activeThread.get() > 0) { try { Thread.sleep(20 * 60 * 1000); } catch (InterruptedException e) { logger.error(e.getMessage()); } } }
From source file:com.datis.irc.kryo.KryoSerializerTest.java
public void testPerformance() { //pojo vs kryo test it User user1 = getUserObj();//from w w w . jav a 2 s . c om long startTime = System.currentTimeMillis(); for (int i = 0; i < SERDE_NUM; i++) { KryoSerializer ks = new KryoSerializer(); ser = ks.serialize("topic1", user1); byteToFile(ser, "kryo/Byte" + i + ".bin"); } long endTime = System.currentTimeMillis(); benchmarkOutput("Kryo Serializer Test:", startTime, endTime); benchLog.append("EveryFile is:" + ser.length + " Byte\n\n"); try { Thread.sleep(3000); } catch (InterruptedException ex) { System.out.println("EXCEPTION " + ex.getMessage()); } startTime = System.currentTimeMillis(); for (int i = 0; i < SERDE_NUM; i++) { JsonPOJOSerializer jpojos1 = new JsonPOJOSerializer(); ser = jpojos1.serialize("topic1", user1); byteToFile(ser, "pojo/Byte" + i + ".bin"); } endTime = System.currentTimeMillis(); benchmarkOutput("Pojo Serializer Test:", startTime, endTime); benchLog.append("EveryFile is:" + ser.length + " Byte\n\n"); System.out.println(benchLog.toString()); }
From source file:gsn.wrappers.SystemTime.java
public void run() { timer.start();// w w w . j ava 2s . co m if (delayPostingElements) { logger.debug("Starting <" + getWrapperName() + "> with delayed elements."); while (isActive()) { synchronized (objectLock) { while (streamElementBuffer.isEmpty()) { try { objectLock.wait(); } catch (InterruptedException e) { logger.error(e.getMessage(), e); } } } try { int nextInt = RandomUtils.nextInt(maximumDelay); Thread.sleep(nextInt); // System.out.println("next delay : " + nextInt + " --> buffer size : " + streamElementBuffer.size()); } catch (InterruptedException e) { logger.error(e.getMessage(), e); } if (!streamElementBuffer.isEmpty()) { StreamElement nextStreamElement = (StreamElement) streamElementBuffer.remove(); postStreamElement(nextStreamElement); } } } }
From source file:com.quancheng.saluki.core.config.RpcServiceConfig.java
public synchronized void export() { Map<GrpcURL, Object> providerUrls = Maps.newHashMap(); for (RpcServiceSingleConfig<Object> singleServiceConfig : singleServiceConfigs) { String serviceName = singleServiceConfig.getServiceName(); Object serviceRef = singleServiceConfig.getRef(); Map<String, String> params = Maps.newHashMap(); this.addGroup(singleServiceConfig, params); this.addVersion(singleServiceConfig, params); this.addApplication(params); this.addInterval(params); this.addRegistryRpcPort(params); this.addHttpPort(params); GrpcURL providerUrl = new GrpcURL(Constants.REMOTE_PROTOCOL, super.getHost(), super.getRealityRpcPort(), serviceName, params);// ww w . jav a 2 s . c om providerUrls.put(providerUrl, serviceRef); } try { internalServer = super.getGrpcEngine().getServer(providerUrls, super.getRealityRpcPort()); Thread awaitThread = new Thread() { @Override public void run() { try { internalServer.start(); internalServer.awaitTermination(); } catch (InterruptedException e) { throw new IllegalStateException(e.getMessage(), e); } catch (IOException e) { throw new IllegalStateException(e.getMessage(), e); } } }; awaitThread.setDaemon(false); awaitThread.start(); } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
From source file:com.googlecode.ehcache.annotations.integration.TriggersRemoveAfterMethodInvocationTest.java
/** * //ww w .ja v a2s . co m */ @Test public void testHarness() { Cache cache = cacheManager.getCache("triggersRemoveAfterInvocationTestCache"); Assert.assertEquals(0, cache.getSize()); // place an element in the cache so we can tell when removeAll was called cache.put(new Element("key", "value")); Assert.assertEquals(1, cache.getSize()); ThreadGroupRunner groupRunner = new ThreadGroupRunner("triggersRemoveAfterMethodInvocationTest", true); groupRunner.addTask(new Runnable() { public void run() { //2 triggersRemoveTestImpl.afterMethodInvocation("foo"); try { // 6 triggersRemoveTestImpl.getCyclicBarrier().await(); } catch (InterruptedException e) { Assert.fail(e.getMessage()); e.printStackTrace(); } catch (BrokenBarrierException e) { Assert.fail(e.getMessage()); e.printStackTrace(); } } }); // 1 groupRunner.start(); try { // 2 triggersRemoveTestImpl.getCyclicBarrier().await(); } catch (InterruptedException e) { Assert.fail(e.getMessage()); e.printStackTrace(); } catch (BrokenBarrierException e) { Assert.fail(e.getMessage()); e.printStackTrace(); } // 4: child thread inside TriggersRemove annotated method Assert.assertEquals(1, cache.getSize()); // 5a triggersRemoveTestImpl.getProceedLatch().countDown(); // TriggersRemove annotated method invocation complete try { // 6 triggersRemoveTestImpl.getCyclicBarrier().await(); } catch (InterruptedException e) { Assert.fail(e.getMessage()); e.printStackTrace(); } catch (BrokenBarrierException e) { Assert.fail(e.getMessage()); e.printStackTrace(); } // at this point the removeAll has been called, verify cache is empty Assert.assertEquals(0, cache.getSize()); try { groupRunner.join(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:org.openbaton.autoscaling.core.execution.ExecutionManagement.java
@Async public Future<Boolean> stop(String nsr_id, String vnfr_id) { log.debug("Stopping ExecutionTask/CooldownTask for VNFR with id: " + vnfr_id); int i = 60;/*w w w. j a va 2 s . co m*/ while (!actionMonitor.isTerminated(vnfr_id) && actionMonitor.getAction(vnfr_id) != Action.INACTIVE && i >= 0) { actionMonitor.terminate(vnfr_id); log.debug( "Waiting for finishing ExecutionTask/Cooldown for VNFR with id: " + vnfr_id + " (" + i + "s)"); log.debug(actionMonitor.toString()); try { Thread.sleep(1_000); } catch (InterruptedException e) { log.error(e.getMessage(), e); } i--; if (i <= 0) { actionMonitor.removeId(vnfr_id); log.error("Were not able to wait until ExecutionTask finished for VNFR with id: " + vnfr_id); return new AsyncResult<>(false); } } actionMonitor.removeId(vnfr_id); log.info("Stopped ExecutionTask for VNFR with id: " + vnfr_id); return new AsyncResult<>(true); }
From source file:com.clustercontrol.monitor.util.ScopeSearchRunUtil.java
@SuppressWarnings("unchecked") public ArrayList<ArrayList<Object>> searchInfo(List<String> managerList) { ArrayList<ArrayList<Object>> dispList = new ArrayList<ArrayList<Object>>(); Map<String, String> errMsgs = new ConcurrentHashMap<>(); long start = System.currentTimeMillis(); try {/* w w w .j a va 2s .c o m*/ String threadName = Thread.currentThread().getName() + "-ScopeSearch"; List<RepositorySearchTask> searchList = new ArrayList<RepositorySearchTask>(); for (String managerName : managerList) { RepositorySearchTask task = null; task = new RepositorySearchTask(threadName, managerName, ContextProvider.getContext()); searchList.add(task); } List<Future<Map<String, List<?>>>> retList = getExecutorService().invokeAll(searchList); for (Future<Map<String, List<?>>> future : retList) { if (future == null || future.get() == null) { continue; } Map<String, List<?>> map = future.get(); for (Map.Entry<String, List<?>> entry : map.entrySet()) { //?1?? String managerName = entry.getKey(); List<?> ret = entry.getValue(); if (ret.get(POS_INFO) != null && ret.get(POS_INFO) instanceof ArrayList) { ArrayList<ArrayList<Object>> infoList = (ArrayList<ArrayList<Object>>) ret.get(POS_INFO); for (ArrayList<Object> l : infoList) { dispList.add(l); } } if (ret.get(POS_ERROR) != null && ret.get(POS_ERROR) instanceof String) { errMsgs.put(managerName, (String) ret.get(POS_ERROR)); } } } } catch (InterruptedException e) { m_log.error(e.getMessage()); } catch (ExecutionException e) { m_log.error(e.getMessage()); } // if (0 < errMsgs.size()) { UIManager.showMessageBox(errMsgs, true); } long end = System.currentTimeMillis(); m_log.debug("time=" + (end - start)); return dispList; }
From source file:com.qwazr.connectors.TableRealmConnector.java
private Account authenticationFailure(String msg) { logger.warn(msg);//from w w w. j av a 2s. c o m try { Thread.sleep(2000); } catch (InterruptedException e) { if (logger.isWarnEnabled()) logger.warn(e.getMessage(), e); } return null; }
From source file:fr.aliasource.webmail.common.cache.CacheManager.java
public void refreshAll() { long time = System.currentTimeMillis(); grabRefreshLock();//w ww.ja va2s . com SubscribedFolderCache fc = cache.getSubscribedFolderCache(); SummaryCache sc = cache.getSummaryCache(); try { List<IFolder> folders = fc.update(); for (IFolder folder : folders) { if (folder.getName().equalsIgnoreCase("INBOX") || ((skipCount % 5) == 0)) { refreshUnlocked(folder); } } skipCount++; sc.update(); } catch (InterruptedException e) { logger.error(e.getMessage(), e); } time = System.currentTimeMillis() - time; logger.info("[" + account.getUserId() + "] refreshAll in " + time + "ms."); releaseRefreshLock(); firstIndexingRoundLock.release(); }