List of usage examples for java.lang InterruptedException toString
public String toString()
From source file:org.powertac.samplebroker.core.BrokerPauseTest.java
/** * Pause within ts. Msg sequence is tsu - pause - tc - release *///from w ww . j av a2 s . c om @Test public void normalPause() { try { Thread.sleep(2001); // 2.001 seconds // it's now the start of ts1 TimeslotUpdate tsu = new TimeslotUpdate(baseTime.plus(2000), 2, 12); broker.handleMessage(tsu); Thread.sleep(500); // short delay SimPause sp = new SimPause(); broker.handleMessage(sp); Thread.sleep(1000); // 1000 msec pause TimeslotComplete tc = new TimeslotComplete(1); broker.handleMessage(tc); assertEquals("correct timeslot index", 1, broker.getTimeslotCompleted()); SimResume sr = new SimResume(baseTime.plus(1000)); broker.handleMessage(sr); assertEquals("correct timeslot index", 1, broker.getTimeslotCompleted()); } catch (InterruptedException e) { fail("interrupted " + e.toString()); } }
From source file:org.powertac.samplebroker.core.BrokerPauseTest.java
/** * Pause into next ts. Msg sequence is tsu - pause - tc - release *//*from w w w . j ava2 s . co m*/ @Test public void longPause() { try { Thread.sleep(2001); // 2.001 seconds // it's now the start of ts1 TimeslotUpdate tsu = new TimeslotUpdate(baseTime.plus(2000), 2, 12); broker.handleMessage(tsu); Thread.sleep(1100); // short delay SimPause sp = new SimPause(); broker.handleMessage(sp); Thread.sleep(3000); // 3000 msec pause TimeslotComplete tc = new TimeslotComplete(1); broker.handleMessage(tc); assertEquals("correct timeslot index", 1, broker.getTimeslotCompleted()); SimResume sr = new SimResume(baseTime.plus(3000)); broker.handleMessage(sr); assertEquals("correct timeslot index", 1, broker.getTimeslotCompleted()); } catch (InterruptedException e) { fail("interrupted " + e.toString()); } }
From source file:Main.java
public void run() { try {// w w w. ja v a 2 s.c o m System.out.print(Thread.currentThread().getName()); System.out.println(" executing..."); while (true) { Thread.sleep(500); } } catch (InterruptedException e) { Thread currThread = Thread.currentThread(); System.out.print(currThread.getName()); System.out.println(" interrupted:" + e.toString()); // rethrow the exception throw new RuntimeException(e.getMessage()); } }
From source file:org.springframework.beans.ConcurrentBeanWrapperTests.java
@Test public void testConcurrent() { for (int i = 0; i < 10; i++) { TestRun run = new TestRun(this); set.add(run);/*from w w w .j a v a 2s.co m*/ Thread t = new Thread(run); t.setDaemon(true); t.start(); } logger.info("Thread creation over, " + set.size() + " still active."); synchronized (this) { while (!set.isEmpty() && ex == null) { try { wait(); } catch (InterruptedException e) { logger.info(e.toString()); } logger.info(set.size() + " threads still active."); } } if (ex != null) { fail(ex.getMessage()); } }
From source file:com.datatorrent.demos.samplestream.YahooFinanceCSVInputOperator.java
@Override public void run() { while (true) { try {// w ww . ja va2 s.com int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { System.err.println("Method failed: " + method.getStatusLine()); } else { InputStream istream; istream = method.getResponseBodyAsStream(); // Process response InputStreamReader isr = new InputStreamReader(istream); CSVReader reader = new CSVReader(isr); List<String[]> myEntries; myEntries = reader.readAll(); for (String[] stringArr : myEntries) { ArrayList<String> al = new ArrayList<String>(Arrays.asList(stringArr)); outputPort.emit(al); // send out one symbol at a time } } Thread.sleep(readIntervalMillis); } catch (InterruptedException ex) { logger.debug(ex.toString()); } catch (IOException ex) { logger.debug(ex.toString()); } } }
From source file:com.datatorrent.demos.yahoofinance.YahooFinanceCSVInputOperator.java
@Override public void run() { while (true) { try {//from w ww . j a v a 2s . co m int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { logger.error("Method failed: " + method.getStatusLine()); } else { InputStream istream; istream = method.getResponseBodyAsStream(); // Process response InputStreamReader isr = new InputStreamReader(istream); CSVReader reader = new CSVReader(isr); List<String[]> myEntries; myEntries = reader.readAll(); for (String[] stringArr : myEntries) { HashMap<String, Object> hm = new HashMap<String, Object>(); for (int i = 0; i < parameterList.size(); i++) { hm.put(parameterList.get(i), stringArr[i]); } outputPort.emit(hm); // send out one symbol at a time } } Thread.sleep(readIntervalMillis); } catch (InterruptedException ex) { logger.debug(ex.toString()); } catch (IOException ex) { logger.debug(ex.toString()); } } }
From source file:org.springframework.beans.factory.ConcurrentBeanFactoryTests.java
@Test public void testConcurrent() { for (int i = 0; i < 100; i++) { TestRun run = new TestRun(); run.setDaemon(true);//from ww w . j a v a 2 s .co m set.add(run); } for (Iterator<TestRun> it = new HashSet<>(set).iterator(); it.hasNext();) { TestRun run = it.next(); run.start(); } logger.info("Thread creation over, " + set.size() + " still active."); synchronized (set) { while (!set.isEmpty() && ex == null) { try { set.wait(); } catch (InterruptedException e) { logger.info(e.toString()); } logger.info(set.size() + " threads still active."); } } if (ex != null) { fail(ex.getMessage()); } }
From source file:de.dal33t.powerfolder.test.transfer.BandwidthLimitText.java
public void testProvider() { BandwidthLimiter bl = BandwidthLimiter.LAN_INPUT_BANDWIDTH_LIMITER; bl.setAvailable(0);/*from w w w. j a va 2 s . com*/ provider.start(); provider.setLimitBPS(bl, 1000); try { Thread.sleep(2000); } catch (InterruptedException e) { fail(e.toString()); } provider.removeLimiter(bl); provider.shutdown(); assertEquals(1000, bl.getAvailable()); }
From source file:io.confluent.support.metrics.submitters.KafkaSubmitter.java
protected void submit(byte[] bytes, Producer<byte[], byte[]> producer) { if (bytes != null && bytes.length > 0) { Future<RecordMetadata> response = producer.send(new ProducerRecord<byte[], byte[]>(topic, bytes)); producer.flush();//from w w w .java 2s. c o m producer.close(); // Block until Kafka acknowledged the receipt of the message try { if (response != null) { response.get(); } else { log.error("Failed to submit metrics to Kafka topic {}: null response", topic); } log.info("Successfully submitted metrics to Kafka topic {}", topic); } catch (InterruptedException e) { log.error("Failed to submit metrics to Kafka topic {} (canceled request): {}", topic, e.toString()); } catch (ExecutionException e) { log.error("Failed to submit metrics to Kafka topic {} (due to exception): {}", topic, e.toString()); } } else { log.error("Could not submit metrics to Kafka (metrics data missing)"); } }
From source file:com.cisco.oss.foundation.http.jetty.JettyHttpClient.java
@Override public HttpResponse executeDirect(HttpRequest request) { Request httpRequest = prepareRequest(request); try {/* w w w . jav a 2 s .co m*/ ContentResponse contentResponse = httpRequest.send(); return new JettyHttpResponse(contentResponse, httpRequest.getURI()); } catch (InterruptedException e) { throw new ClientException(e.toString(), e); } catch (TimeoutException e) { throw new RequestTimeoutException(e.toString(), e); } catch (ExecutionException e) { throw new ClientException(e.toString(), e); } }