List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:io.fabric8.msg.jnatsd.TestProtocol.java
@Test public void testSyncReplyArg() { String replyExpected = "bar"; try (Connection c = connectionFactory.createConnection()) { try (SyncSubscription s = c.subscribeSync("foo")) { try { sleep(500);//from w w w .j a v a 2 s . c om } catch (InterruptedException e) { } c.publish("foo", replyExpected, (byte[]) null); Message m = null; try { m = s.nextMessage(1000); } catch (Exception e) { fail("Received an err on nextMsg(): " + e.getMessage()); } assertEquals(replyExpected, m.getReplyTo()); } } catch (IOException | TimeoutException e) { fail(e.getMessage()); } }
From source file:iddb.core.IDDBService.java
public void confirmRemoteEvent(List<Entry<Long, String>> list) { try {// w w w. j av a2 s. co m TaskManager.getInstance().execute(new ConfirmRemoteEventTask(list)); } catch (InterruptedException e) { log.error(e.getMessage()); } }
From source file:iddb.core.IDDBService.java
public void updatePenaltyHistory(List<PenaltyHistory> list) { try {// w w w .j a v a 2 s .co m TaskManager.getInstance().execute(new UpdatePenaltyStatusTask(list, PenaltyHistory.ST_WAITING)); } catch (InterruptedException e) { log.error(e.getMessage()); } }
From source file:com.bt.aloha.stack.SimpleSipStack.java
private void sleepBeforeSending() { if (sleepIntervalBeforeSending > 0) { LOG.debug(String.format("sleeping for %d ms", sleepIntervalBeforeSending)); try {/*from ww w . ja v a2 s. co m*/ Thread.sleep(sleepIntervalBeforeSending); } catch (InterruptedException e) { LOG.warn(e.getMessage(), e); } } }
From source file:cai.flow.collector.Collector.java
/** * /*from w w w .j a v a2 s . c om*/ * */ void go() { ServiceThread rdr = new ServiceThread(this, "Reader at " + (localHost == null ? "any" : "" + localHost) + ":" + localPort, "REader") { public void exec() throws Throwable { ((Collector) o).reader_loop(); } }; rdr.setName(rdr.getName() + "-Reader"); rdr.setPriority(Thread.MAX_PRIORITY); rdr.setDaemon(true); rdr.start(); ServiceThread statistics; /** */ if (stat_interval != 0) { statistics = new ServiceThread(this, "Statistics over " + Util.toInterval(stat_interval), "Statistics") { public void exec() throws Throwable { ((Collector) o).statistics_loop(); } }; statistics.setName(statistics.getName() + "-Statistics"); statistics.setDaemon(true); statistics.start(); } ServiceThread[] cols = new ServiceThread[collector_thread]; for (int i = 0; i < collector_thread; i++) { String title = new String("Collector" + (i + 1)); ServiceThread col = new ServiceThread(this, title, title) { public void exec() { ((Collector) o).collector_loop(); } }; cols[i] = col; col.setName(col.getName() + "-" + title); col.start(); } try { for (int i = 0; i < collector_thread; i++) cols[i].join(); } catch (InterruptedException e) { logger.fatal("Collector - InterruptedException in main thread, exit"); logger.debug(e.getMessage()); } }
From source file:io.selendroid.standalone.android.impl.AbstractDevice.java
private void sleep(int millis) { try {/* w ww .ja va 2 s.co m*/ Thread.sleep(millis); } catch (InterruptedException e) { Thread.currentThread().interrupt(); log.log(Level.SEVERE, e.getMessage(), e); } }
From source file:com.amazon.sqs.javamessaging.SQSSessionCallbackScheduler.java
@Override public void run() { CallbackEntry callbackEntry = null;/*from w w w. j a v a 2s . c om*/ try { while (true) { try { if (closed) { break; } synchronized (callbackQueue) { callbackEntry = callbackQueue.pollFirst(); if (callbackEntry == null) { try { callbackQueue.wait(); } catch (InterruptedException e) { /** * Will be retried on the next loop, and * break if the callback scheduler is closed. */ if (LOG.isDebugEnabled()) { LOG.debug("wait on empty callback queue interrupted: " + e.getMessage()); } } continue; } } MessageListener messageListener = callbackEntry.getMessageListener(); MessageManager messageManager = callbackEntry.getMessageManager(); SQSMessage message = (SQSMessage) messageManager.getMessage(); SQSMessageConsumer messageConsumer = messageManager.getPrefetchManager().getMessageConsumer(); if (messageConsumer.isClosed()) { nackReceivedMessage(message); continue; } try { // this takes care of start and stop session.startingCallback(messageConsumer); } catch (JMSException e) { if (LOG.isDebugEnabled()) { LOG.debug("Not running callback: " + e.getMessage()); } break; } try { /** * Notifying consumer prefetch thread so that it can * continue to prefetch */ messageManager.getPrefetchManager().messageDispatched(); int ackMode = acknowledgeMode.getOriginalAcknowledgeMode(); boolean tryNack = true; try { if (messageListener != null) { if (ackMode != Session.AUTO_ACKNOWLEDGE) { acknowledger.notifyMessageReceived(message); } boolean callbackFailed = false; try { messageListener.onMessage(message); } catch (Throwable ex) { LOG.info("Exception thrown from onMessage callback for message " + message.getSQSMessageId(), ex); callbackFailed = true; } finally { if (!callbackFailed) { if (ackMode == Session.AUTO_ACKNOWLEDGE) { message.acknowledge(); } tryNack = false; } } } } catch (JMSException ex) { LOG.warn("Unable to complete message dispatch for the message " + message.getSQSMessageId(), ex); } finally { if (tryNack) { nackReceivedMessage(message); } } /** * The consumer close is delegated to the session thread * if consumer close is called by its message listener's * onMessage method on its own consumer. */ if (consumerCloseAfterCallback != null) { consumerCloseAfterCallback.doClose(); consumerCloseAfterCallback = null; } } finally { session.finishedCallback(); } } catch (Throwable ex) { LOG.error("Unexpected exception thrown during the run of the scheduled callback", ex); } } } finally { if (callbackEntry != null) { nackReceivedMessage((SQSMessage) callbackEntry.getMessageManager().getMessage()); } nackQueuedMessages(); } }
From source file:it.infn.ct.futuregateway.apiserver.inframanager.Monitor.java
@Override public final void run() { Task task;//from w w w . j a v a 2 s . c o m while ((task = getNext()) != null) { final long remainingTime = this.checkInterval - System.currentTimeMillis() + task.getLastStatusCheckTime().getTime(); if (remainingTime > 0) { try { Thread.sleep(remainingTime); } catch (InterruptedException ex) { this.log.warn("Monitoring thread interrupted while waiting " + "for next check"); } } if (task.getApplicationDetail().getOutcome().equals(Application.TYPE.JOB)) { this.log.debug("Monitoring Task: " + task.getId()); try { final TaskState taskState = task.getStateManager(); taskState.action(null, this.bQueue, null); } catch (TaskException ex) { task.setState(Task.STATE.ABORTED); this.log.error(ex.getMessage()); } } if (task.getApplicationDetail().getOutcome().equals(Application.TYPE.RESOURCE)) { throw new UnsupportedOperationException("Not implemented yet"); } } }
From source file:com.cloud.agent.AgentShell.java
public void start() { try {/* www . ja v a2 s .co m*/ System.setProperty("java.net.preferIPv4Stack", "true"); String instance = getProperty(null, "instance"); if (instance == null) { if (Boolean.parseBoolean(getProperty(null, "developer"))) { instance = UUID.randomUUID().toString(); } else { instance = ""; } } else { instance += "."; } String pidDir = getProperty(null, "piddir"); final String run = "agent." + instance + "pid"; s_logger.debug("Checking to see if " + run + " exists."); ProcessUtil.pidCheck(pidDir, run); launchAgent(); // // For both KVM & Xen-Server hypervisor, we have switched to // VM-based console proxy solution, disable launching // of console proxy here // // launchConsoleProxy(); // try { while (!_exit) Thread.sleep(1000); } catch (InterruptedException e) { } } catch (final ConfigurationException e) { s_logger.error("Unable to start agent: " + e.getMessage()); System.out.println("Unable to start agent: " + e.getMessage()); System.exit(ExitStatus.Configuration.value()); } catch (final Exception e) { s_logger.error("Unable to start agent: ", e); System.out.println("Unable to start agent: " + e.getMessage()); System.exit(ExitStatus.Error.value()); } }
From source file:io.openvidu.server.kurento.core.KurentoParticipant.java
public String receiveMediaFrom(Participant sender, String sdpOffer) { final String senderName = sender.getParticipantPublicId(); log.info("PARTICIPANT {}: Request to receive media from {} in room {}", this.getParticipantPublicId(), senderName, this.session.getSessionId()); log.trace("PARTICIPANT {}: SdpOffer for {} is {}", this.getParticipantPublicId(), senderName, sdpOffer); if (senderName.equals(this.getParticipantPublicId())) { log.warn("PARTICIPANT {}: trying to configure loopback by subscribing", this.getParticipantPublicId()); throw new OpenViduException(Code.USER_NOT_STREAMING_ERROR_CODE, "Can loopback only when publishing media"); }/*from w ww .j a va2 s.c o m*/ KurentoParticipant kSender = (KurentoParticipant) sender; if (kSender.getPublisher() == null) { log.warn("PARTICIPANT {}: Trying to connect to a user without " + "a publishing endpoint", this.getParticipantPublicId()); return null; } log.debug("PARTICIPANT {}: Creating a subscriber endpoint to user {}", this.getParticipantPublicId(), senderName); SubscriberEndpoint subscriber = getNewOrExistingSubscriber(senderName); try { CountDownLatch subscriberLatch = new CountDownLatch(1); SdpEndpoint oldMediaEndpoint = subscriber.createEndpoint(subscriberLatch); try { if (!subscriberLatch.await(KurentoSession.ASYNC_LATCH_TIMEOUT, TimeUnit.SECONDS)) { throw new OpenViduException(Code.MEDIA_ENDPOINT_ERROR_CODE, "Timeout reached when creating subscriber endpoint"); } } catch (InterruptedException e) { throw new OpenViduException(Code.MEDIA_ENDPOINT_ERROR_CODE, "Interrupted when creating subscriber endpoint: " + e.getMessage()); } if (oldMediaEndpoint != null) { log.warn( "PARTICIPANT {}: Two threads are trying to create at " + "the same time a subscriber endpoint for user {}", this.getParticipantPublicId(), senderName); return null; } if (subscriber.getEndpoint() == null) { throw new OpenViduException(Code.MEDIA_ENDPOINT_ERROR_CODE, "Unable to create subscriber endpoint"); } String subscriberEndpointName = this.getParticipantPublicId() + "_" + kSender.getPublisherStreamId(); subscriber.setEndpointName(subscriberEndpointName); subscriber.getEndpoint().setName(subscriberEndpointName); subscriber.setStreamId(kSender.getPublisherStreamId()); endpointConfig.addEndpointListeners(subscriber, "subscriber"); } catch (OpenViduException e) { this.subscribers.remove(senderName); throw e; } log.debug("PARTICIPANT {}: Created subscriber endpoint for user {}", this.getParticipantPublicId(), senderName); try { String sdpAnswer = subscriber.subscribe(sdpOffer, kSender.getPublisher()); log.trace("PARTICIPANT {}: Subscribing SdpAnswer is {}", this.getParticipantPublicId(), sdpAnswer); log.info("PARTICIPANT {}: Is now receiving video from {} in room {}", this.getParticipantPublicId(), senderName, this.session.getSessionId()); if (!ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(this.getParticipantPublicId())) { endpointConfig.getCdr().recordNewSubscriber(this, this.session.getSessionId(), sender.getPublisherStreamId(), sender.getParticipantPublicId(), subscriber.createdAt()); } return sdpAnswer; } catch (KurentoServerException e) { // TODO Check object status when KurentoClient sets this info in the object if (e.getCode() == 40101) { log.warn("Publisher endpoint was already released when trying " + "to connect a subscriber endpoint to it", e); } else { log.error("Exception connecting subscriber endpoint " + "to publisher endpoint", e); } this.subscribers.remove(senderName); releaseSubscriberEndpoint(senderName, subscriber, null); } return null; }