List of usage examples for java.lang InterruptedException toString
public String toString()
From source file:org.apache.pig.piggybank.storage.HiveColumnarLoader.java
@Override public Tuple getNext() throws IOException { Tuple tuple = null;// w w w . ja v a 2s.c o m try { if (reader.nextKeyValue()) { BytesRefArrayWritable buff = reader.getCurrentValue(); ColumnarStruct struct = readColumnarStruct(buff); tuple = readColumnarTuple(struct, reader.getSplitPath()); } } catch (InterruptedException e) { throw new IOException(e.toString(), e); } return tuple; }
From source file:org.apache.hadoop.hdfs.MiniAvatarCluster.java
private static void sleep(long time) throws IOException { try {// ww w . j a va2 s.c o m Thread.sleep(time); } catch (InterruptedException e) { LOG.fatal("Thread interrupted"); throw new IOException(e.toString()); } }
From source file:com.nubits.nubot.trading.wrappers.AltsTradeWrapper.java
@Override public String query(String base, String method, AbstractMap<String, String> args, boolean needAuth, boolean isGet) { String queryResult = TOKEN_BAD_RETURN; //Will return this string in case it fails if (exchange.getLiveData().isConnected()) { if (exchange.isFree()) { exchange.setBusy();// ww w. j a v a 2 s .c o m queryResult = service.executeQuery(base, method, args, needAuth, isGet); exchange.setFree(); } else { //Another thread is probably executing a query. Init the retry procedure long sleeptime = Settings.RETRY_SLEEP_INCREMENT * 1; int counter = 0; long startTimeStamp = System.currentTimeMillis(); LOG.debug(method + " blocked, another call is being processed "); boolean exit = false; do { counter++; sleeptime = counter * Settings.RETRY_SLEEP_INCREMENT; //Increase sleep time sleeptime += (int) (Math.random() * 200) - 100;// Add +- 100 ms random to facilitate competition LOG.debug( "Retrying for the " + counter + " time. Sleep for " + sleeptime + "; Method=" + method); try { Thread.sleep(sleeptime); } catch (InterruptedException e) { LOG.error(e.toString()); } //Try executing the call if (exchange.isFree()) { LOG.debug("Finally the exchange is free, executing query after " + counter + " attempt. Method=" + method); exchange.setBusy(); queryResult = service.executeQuery(base, method, args, needAuth, isGet); exchange.setFree(); break; //Exit loop } else { LOG.debug("Exchange still busy : " + counter + " .Will retry soon; Method=" + method); exit = false; } if (System.currentTimeMillis() - startTimeStamp >= Settings.TIMEOUT_QUERY_RETRY) { exit = true; LOG.error( "Method=" + method + " failed too many times and timed out. attempts = " + counter); } } while (!exit); } } else { LOG.error("The bot will not execute the query, there is no connection with" + exchange.getName()); queryResult = TOKEN_BAD_RETURN; } return queryResult; }
From source file:com.nubits.nubot.trading.wrappers.ComkortWrapper.java
@Override public String query(String base, String method, AbstractMap<String, String> args, boolean needAuth, boolean isGet) { String queryResult = TOKEN_BAD_RETURN; //Will return this string in case it fails if (exchange.getLiveData().isConnected()) { if (exchange.isFree()) { exchange.setBusy();//ww w. ja va 2s .c o m queryResult = service.executeQuery(base, method, args, needAuth, isGet); exchange.setFree(); } else { //Another thread is probably executing a query. Init the retry procedure long sleeptime = Settings.RETRY_SLEEP_INCREMENT * 1; int counter = 0; long startTimeStamp = System.currentTimeMillis(); LOG.debug(method + " blocked, another call is being processed "); boolean exit = false; do { counter++; sleeptime = counter * Settings.RETRY_SLEEP_INCREMENT; //Increase sleep time sleeptime += (int) (Math.random() * 200) - 100;// Add +- 100 ms random to facilitate competition LOG.debug( "Retrying for the " + counter + " time. Sleep for " + sleeptime + "; Method=" + method); try { Thread.sleep(sleeptime); } catch (InterruptedException e) { LOG.error(e.toString()); } //Try executing the call if (exchange.isFree()) { LOG.debug("Finally the exchange is free, executing query after " + counter + " attempt. Method=" + method); exchange.setBusy(); queryResult = service.executeQuery(base, method, args, needAuth, isGet); exchange.setFree(); break; //Exit loop } else { LOG.debug("Exchange still busy : " + counter + " .Will retry soon; Method=" + method); exit = false; } if (System.currentTimeMillis() - startTimeStamp >= Settings.TIMEOUT_QUERY_RETRY) { exit = true; LOG.error("The bot will not execute the query, there is no connection with" + exchange.getName()); } } while (!exit); } } else { LOG.error("The bot will not execute the query, there is no connection to BitcoinCoId"); queryResult = TOKEN_BAD_RETURN; } return queryResult; }
From source file:uk.co.modularaudio.service.samplecaching.impl.SampleCache.java
public void destroy() { try {//w w w. j a v a 2 s .c o m cacheAccessMutex.lock(); if (cachePopulatorThread != null) { try { cachePopulatorThread.halt(); // Will "wake" any sleeping thread cachePopulatorThread.addOneJobToDo(); cachePopulatorThread.join(); } catch (final InterruptedException e) { final String msg = "InterruptedException whilst joining cache populator: " + e.toString(); log.error(msg, e); } } temperatureBufferBlockMap.destroy(); } finally { cacheAccessMutex.unlock(); } }
From source file:com.facebook.FacebookActivityTestCase.java
protected void closeBlockerAndAssertSuccess() { TestBlocker blocker;//w ww. ja v a2 s . com synchronized (this) { blocker = getTestBlocker(); testBlocker = null; } blocker.quit(); boolean joined = false; while (!joined) { try { blocker.join(); joined = true; } catch (InterruptedException e) { } } try { blocker.assertSuccess(); } catch (Exception e) { fail(e.toString()); } }
From source file:com.nubits.nubot.tasks.PriceMonitorTriggerTask.java
private void unableToUpdatePrice(ArrayList<LastPrice> priceList) { count++;/*from ww w. j a v a 2s . c o m*/ try { Thread.sleep(count * 60 * 1000); } catch (InterruptedException ex) { LOG.error(ex.toString()); } try { executeUpdatePrice(count); } catch (FeedPriceException ex) { LOG.error(ex.toString()); } }
From source file:com.googlecode.android_scripting.facade.bluetooth.BluetoothSocketConnFacade.java
/** * Kill the connect thread//from w ww . j ava2 s . co m */ @Rpc(description = "Kill thread") public void bluetoothSocketConnKillConnThread() { try { mConnectThread.cancel(); mConnectThread.join(5000); } catch (InterruptedException e) { Log.e("Interrupted Exception: " + e.toString()); } }
From source file:com.nubits.nubot.trading.wrappers.BtceWrapper.java
@Override public ApiResponse clearOrders(CurrencyPair pair) { //Since there is no API entry point for that, this call will iterate over actie ApiResponse toReturn = new ApiResponse(); boolean ok = true; ApiResponse activeOrdersResponse = getActiveOrders(); if (activeOrdersResponse.isPositive()) { ArrayList<Order> orderList = (ArrayList<Order>) activeOrdersResponse.getResponseObject(); for (int i = 0; i < orderList.size(); i++) { Order tempOrder = orderList.get(i); ApiResponse deleteOrderResponse = cancelOrder(tempOrder.getId(), null); if (deleteOrderResponse.isPositive()) { boolean deleted = (boolean) deleteOrderResponse.getResponseObject(); if (deleted) { LOG.warn("Order " + tempOrder.getId() + " deleted succesfully"); } else { LOG.warn("Could not delete order " + tempOrder.getId() + ""); ok = false;/*from w ww . j av a 2 s .c o m*/ } } else { LOG.error(deleteOrderResponse.getError().toString()); } try { Thread.sleep(500); } catch (InterruptedException ex) { LOG.error(ex.toString()); } } toReturn.setResponseObject(ok); } else { LOG.error(activeOrdersResponse.getError().toString()); toReturn.setError(activeOrdersResponse.getError()); return toReturn; } return toReturn; }
From source file:org.openhab.binding.stiebelheatpump.internal.StiebelHeatPumpBinding.java
/** * This method sets the time in the heat pump. * I case of the time the time is initially verified and set to * actual time./*from w ww. j a va2s.c o m*/ * * @return true if heat pump time could be successfully set */ public boolean setTime() { CommunicationService communicationService = null; try { int retry = 0; while (communicationInUse) { try { Thread.sleep(CommunicationService.WAITING_TIME_BETWEEN_REQUESTS); retry++; if (retry > DEFAULT_SERIAL_TIMEOUT) { return false; } } catch (InterruptedException e) { logger.error("could not access Heat pump for has version {}", version); } } communicationInUse = true; communicationService = new CommunicationService(connector, heatPumpConfiguration); communicationService.setTime(); return true; } catch (StiebelHeatPumpException e) { logger.error("Stiebel heatpump time could not be set on heat pump! " + e.toString()); } finally { communicationInUse = false; if (communicationService != null) { communicationService.finalizer(); } } return false; }