List of usage examples for java.lang InterruptedException toString
public String toString()
From source file:org.cryptable.zap.mavenplugin.ProcessMojo.java
/** * Scan all pages found at url/*w w w . j a va 2s . co m*/ * * @param url the url to scan * @throws ClientApiException */ private void scanURL(String url) throws ClientApiException { zapClientAPI.ascan.scan(apiKEY, url, "true", "false", "", "", ""); while (statusToInt(zapClientAPI.ascan.status("scanid")) < 100) { try { Thread.sleep(1000); } catch (InterruptedException e) { getLog().error(e.toString()); } } }
From source file:hws.core.JobMaster.java
public void runMainLoop() throws Exception { AMRMClientAsync<ContainerRequest> rmClient = AMRMClientAsync.createAMRMClientAsync(100, this); rmClient.init(getConfiguration());//from w w w .ja v a 2 s .c o m rmClient.start(); // Register with ResourceManager Logger.info("[AM] registerApplicationMaster 0"); rmClient.registerApplicationMaster("", 0, ""); Logger.info("[AM] registerApplicationMaster 1"); // Priority for worker containers - priorities are intra-application Priority priority = Records.newRecord(Priority.class); priority.setPriority(0); // Resource requirements for worker containers Resource capability = Records.newRecord(Resource.class); capability.setMemory(128); capability.setVirtualCores(1); final CountDownLatch doneLatch = new CountDownLatch(this.modulePipeline.size()); // Make container requests to ResourceManager for (ModuleInfo moduleInfo : this.modulePipeline) { //create containers for each instance of each module zk.createPersistent("/hadoop-watershed/" + this.appIdStr + "/" + moduleInfo.filterInfo().name(), ""); zk.createPersistent( "/hadoop-watershed/" + this.appIdStr + "/" + moduleInfo.filterInfo().name() + "/finish", ""); zk.createPersistent( "/hadoop-watershed/" + this.appIdStr + "/" + moduleInfo.filterInfo().name() + "/halted", ""); zk.subscribeChildChanges( "/hadoop-watershed/" + this.appIdStr + "/" + moduleInfo.filterInfo().name() + "/finish", createFinishListener(moduleInfo.filterInfo().name(), moduleInfo.numFilterInstances(), doneLatch)); for (int i = 0; i < moduleInfo.numFilterInstances(); i++) { this.numContainersToWaitFor++; ContainerRequest containerAsk = new ContainerRequest(capability, null, null, priority); Logger.info("[AM] Making res-req for " + moduleInfo.filterInfo().name() + " " + i); rmClient.addContainerRequest(containerAsk); } } //TODO: process for starting the whole application //create containers // -> create instances // -> start output channels and filters // -> start input channels in reversed topological order (considering that there is no cycle) // * if there is cycle, then inicially start in any order //TODO "send" the start signal via ZooKeeper Logger.info("[AM] waiting for containers to finish"); try { doneLatch.await(); //await the input threads to finish } catch (InterruptedException e) { Logger.fatal(e.toString()); //e.printStackTrace(); } /*while(!doneWithContainers()) { Thread.sleep(50); }*/ zk.createPersistent("/hadoop-watershed/" + appIdStr + "/done", ""); Logger.info("[AM] unregisterApplicationMaster 0"); // Un-register with ResourceManager rmClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED, "", ""); Logger.info("[AM] unregisterApplicationMaster 1"); }
From source file:com.nubits.nubot.bot.NuBotBase.java
/** * execute the NuBot based on a configuration */// ww w.ja va 2 s . co m public void execute(NuBotOptions opt) throws NuBotRunException { LOG.info("Setting up NuBot version : " + VersionInfo.getVersionName()); if (opt.isExecuteOrders()) { liveTrading = true; LOG.info("Live mode : Trades will be executed"); } else { LOG.info("Demo mode: Trades will not be executed [executetrade:false]"); liveTrading = false; } Global.options = opt; setupAllConfig(); LOG.debug("Create a TaskManager "); Global.taskManager = new TaskManager(); Global.taskManager.setTasks(); if (Global.options.isSubmitliquidity()) { Global.taskManager.setupNuRPCTask(); Global.taskManager.startTaskNu(); } LOG.debug("Starting task : Check connection with exchange"); Global.taskManager.getCheckConnectionTask().start(Settings.DELAY_CONN); LOG.info("Waiting a for the connectionThreads to detect connection"); try { Thread.sleep(Settings.WAIT_CHECK_INTERVAL); } catch (InterruptedException ex) { LOG.error(ex.toString()); } //For a 0 tx fee market, force a price-offset of 0.1% ApiResponse txFeeResponse = Global.exchange.getTrade().getTxFee(Global.options.getPair()); if (txFeeResponse.isPositive()) { double txfee = (Double) txFeeResponse.getResponseObject(); if (txfee == 0) { LOG.warn("The bot detected a 0 TX fee : forcing a priceOffset of 0.1% [if required]"); double maxOffset = 0.1; if (Global.options.getSpread() < maxOffset) { Global.options.setSpread(maxOffset); } } } testExchange(); //Start task to check orders try { Global.taskManager.getSendLiquidityTask().start(Settings.DELAY_LIQUIIDITY); } catch (Exception e) { throw new NuBotRunException("" + e); } if (Global.options.isSubmitliquidity()) { try { checkNuConn(); } catch (NuBotConnectionException e) { MainLaunch.exitWithNotice("can't connect to Nu " + e); } } LOG.info("Start trading Strategy specific for " + Global.options.getPair().toString()); LOG.info("Options loaded : " + Global.options.toString()); // Set the frozen balance manager in the global variable Global.frozenBalancesManager = new FrozenBalancesManager(Global.options.getExchangeName(), Global.options.getPair()); try { configureStrategy(); } catch (Exception e) { throw new NuBotRunException("" + e); } notifyOnline(); }
From source file:edu.biu.scapi.comm.CommunicationSetup.java
/** * This function serves as a barrier. It is called from the prepareForCommunication function. The idea * is to let all the threads finish running before proceeding. *///w w w. j a va 2 s .c o m private void verifyConnectingStatus() { boolean allConnected = false; //while the thread has not been stopped and not all the channels are connected while (!bTimedOut && !(allConnected = establishedConnections.areAllConnected())) { try { Thread.sleep(500); } catch (InterruptedException e) { Logging.getLogger().log(Level.FINEST, e.toString()); } } //If we already know that all the connectios were established we can stop the watchdog. if (allConnected) watchdog.stop(); }
From source file:com.opentransport.rdfmapper.nmbs.ScrapeTrip.java
private void requestJsons(Map trainDelays) { String trainName;/*from w ww . j a v a 2 s .com*/ Iterator iterator = trainDelays.entrySet().iterator(); ExecutorService pool = Executors.newFixedThreadPool(NUMBER_OF_CONNECTIONS_TO_IRAIL_API); while (iterator.hasNext()) { Map.Entry mapEntry = (Map.Entry) iterator.next(); trainName = returnCorrectTrainFormat((String) mapEntry.getKey()); url = "https://api.irail.be/vehicle/?id=BE.NMBS." + trainName + "&format=json"; System.out.println("HTTP GET - " + url); countConnections++; pool.submit(new DownloadDelayedTrains(trainName, url)); } pool.shutdown(); try { pool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); // all tasks have now finished (unless an exception is thrown abo } catch (InterruptedException ex) { Logger.getLogger(ScrapeTrip.class.getName()).log(Level.SEVERE, null, ex); errorWriter.writeError(ex.toString()); } }
From source file:org.cerberus.engine.execution.impl.SeleniumServerService.java
@Override public boolean stopServer(Session session) { if (session.isStarted()) { try {// ww w.java 2 s .c o m // Wait 2 sec till HAR is exported Thread.sleep(2000); } catch (InterruptedException ex) { LOG.error(ex.toString()); } LOG.info("Stop execution session"); session.quit(); return true; } return false; }
From source file:ffx.numerics.fft.Real3DCuda.java
/** * Blocking free method./*from ww w. j a v a 2 s . co m*/ * * @return A status flag (0 for success, -1 for failure). */ public int free() { if (dead || doConvolution) { return -1; } free = true; // Notify the CUDA thread and then block until it notifies us back. synchronized (this) { notify(); while (!dead) { try { wait(); } catch (InterruptedException e) { logger.severe(e.toString()); } } } return 0; }
From source file:ffx.numerics.fft.Real3DCuda.java
/** * Blocking convolution method.//from ww w .j a va2 s . c o m * * @param data an array of float. * @return A status flag (0 for success, -1 for failure). */ public int convolution(float data[]) { // This would be a programming error. if (dead || doConvolution) { return -1; } this.data = data; doConvolution = true; // Notify the CUDA thread and then block until it notifies us back. synchronized (this) { notify(); while (doConvolution) { try { wait(); } catch (InterruptedException e) { logger.severe(e.toString()); } } } return 0; }
From source file:com.khoahuy.phototag.HomeActivity.java
public String TestGet(Context context) { HttpGetAsyncTask hat = new HttpGetAsyncTask(context, ConstantUtils.WAITINGITEM_URL, "IDBTS853", null); try {//ww w . j av a 2 s. com String text = hat.execute().get(); Log.d("Huy", text); } catch (InterruptedException e) { // TODO Auto-generated catch block Log.d("Huy", e.toString()); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d("Huy", "Test 2"); return ""; }
From source file:com.khoahuy.phototag.HomeActivity.java
public String TestPost(Context context) { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("nfc", "1s")); Log.d("Huy", "Test 1"); HttpPostAsyncTask rat = new HttpPostAsyncTask(context, ConstantUtils.WAITINGITEM_URL, nameValuePairs); rat.execute();/*w ww. j a v a 2 s . com*/ try { String text = rat.get(); Log.d("Huy", text); } catch (InterruptedException e) { // TODO Auto-generated catch block Log.d("Huy", e.toString()); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d("Huy", "Test 2"); return ""; }