List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:com.cm.beer.util.ContentManager.java
/** * /*from www . j av a2 s .c o m*/ * @param urlString * @param imageView */ public void fetchContentOnThread(final String urlString) { Thread thread = new Thread() { @Override public void run() { while (mLockCache.containsKey(urlString)) { if (Logger.isLogEnabled()) Logger.log("URI download request in progress:" + urlString); try { Thread.sleep(1000L); } catch (InterruptedException e) { Log.e(this.getClass().getName(), e.getMessage()); } } } }; thread.start(); }
From source file:es.udc.gii.rosamituscma.ConstrainedMotionEvolutionaryAlgorithm.java
@Override protected synchronized void replace(Population toPopulation) { //La "toPopulation" es una sub-poblacin de buffer_population: while (buffer_population.size() < this.getPopulation().getSize()) { try {/* w w w . j av a2 s . co m*/ wait(10); } catch (InterruptedException ex) { System.out.println( "Exception at CMARosaMitusEvolutionaryAlgorithm reproduce phase: " + ex.getMessage()); System.exit(0); } } //La poblacin buffer es la que tiene la informacin de la calidad: Population sub_population = new Population( this.buffer_population.subList(0, this.getPopulation().getSize())); if (this.getReplaceChain() != null) { super.replace(sub_population); } synchronized (this.buffer_population) { for (int i = 0; i < this.getPopulation().getSize(); i++) { this.buffer_population.remove(0); } System.gc(); } }
From source file:com.comcast.cats.vision.CATSVisionTest.java
protected void streamAndAllocateSettop(Window window) { Panel panel = window.getPanel("mainPanel"); Panel mainControlPanel = panel.getPanel("mainControlPanel"); Panel settopSelectionPanel = mainControlPanel.getPanel("settopSelectionPanel"); ToggleButton jStreamToggleButton = settopSelectionPanel.getToggleButton("jStreamToggleButton"); if (jStreamToggleButton.getAwtComponent().getText().equals("Stream")) { jStreamToggleButton.getAwtComponent().doClick(); }//from ww w .ja va2s . co m try { Thread.sleep(500); } catch (InterruptedException interruptedException) { fail(interruptedException.getMessage()); } /* * Locking Settop */ CheckBox checkBoxLock = settopSelectionPanel.getCheckBox("Lock"); assertTrue("Unable to lock settop", selectCheckBox(checkBoxLock)); }
From source file:jetbrains.buildServer.clouds.azure.asm.web.ProfileController.java
@Override protected void doPost(@NotNull final HttpServletRequest request, @NotNull final HttpServletResponse response, @NotNull final Element xmlResponse) { final ActionErrors errors = new ActionErrors(); final BasePropertiesBean propsBean = new BasePropertiesBean(null); PluginPropertiesUtil.bindPropertiesFromRequest(request, propsBean, true); final Map<String, String> props = propsBean.getProperties(); final String subscriptionId = props.get(AzureWebConstants.SUBSCRIPTION_ID); final String certificate = props.get("secure:" + AzureWebConstants.MANAGEMENT_CERTIFICATE); final AzureApiConnector apiConnector; try {/*from w w w. j a v a 2 s . c o m*/ apiConnector = new AzureApiConnector(subscriptionId, certificate); apiConnector.test(); } catch (InvalidCertificateException ex) { errors.addError("certificateError", "Invalid Management certificate. Please enter the Management Certificate exactly as it is presented in the subscription file."); errors.serialize(xmlResponse); LOG.warnAndDebugDetails("An error during initializing connection: " + ex.getMessage(), ex); return; } catch (CheckedCloudException ex) { errors.addError("pingError", "Error connecting to Microsoft Azure. Please check that your Management Certificate and Subscription ID are valid."); errors.serialize(xmlResponse); LOG.warnAndDebugDetails("An error during initializing connection: " + ex.getMessage(), ex); return; } final List<Promise<Content, Throwable, Void>> promises = new ArrayList<>(myHandlers.size()); for (final ResourceHandler handler : myHandlers) { try { final Promise<Content, Throwable, Void> promise = handler.handle(apiConnector) .fail(new FailCallback<Throwable>() { @Override public void onFail(Throwable result) { LOG.warn(String.format("Failed to execute handler %s: %s", handler.getName(), result), result); errors.addError(handler.getName(), result.getMessage()); } }); promises.add(promise); } catch (Throwable t) { LOG.warn(String.format("Failed to add handler %s: %s", handler.getName(), t.getMessage()), t); errors.addError(handler.getName(), t.getMessage()); } } if (promises.size() == 0) { if (errors.hasErrors()) { writeErrors(xmlResponse, errors); } return; } try { myManager.when(promises.toArray(new Promise[] {})) .always(new AlwaysCallback<MultipleResults, OneReject>() { @Override public void onAlways(Promise.State state, MultipleResults resolved, OneReject rejected) { if (errors.hasErrors()) { writeErrors(xmlResponse, errors); } else { for (OneResult oneResult : resolved) { xmlResponse.addContent((Content) oneResult.getResult()); } } } }).waitSafely(); } catch (InterruptedException e) { LOG.warn("Request executing has been interrupted: " + e.getMessage()); errors.addError("handler", e.getMessage()); writeErrors(xmlResponse, errors); } }
From source file:es.udc.gii.rosamituscma.ConstrainedMotionEvolutionaryAlgorithm.java
@Override protected synchronized void reproduce(Population population) { // super.reproduce(population); while (buffer_population.size() < this.getPopulation().getSize()) { try {//from w w w .ja v a2 s . com wait(10); } catch (InterruptedException ex) { System.out.println( "Exception at CMARosaMitusEvolutionaryAlgorithm reproduce phase: " + ex.getMessage()); System.exit(0); } } //La poblacin buffer es la que tiene la informacin de la calidad: List<Individual> sub_population = this.buffer_population.subList(0, this.getPopulation().getSize()); // for (int i = 0; i < sub_population.size(); i++) { // population.getIndividuals().set(i, (Individual) sub_population.get(i).clone()); // } if (this.getReproductionChain() != null) { super.reproduce(new Population(sub_population)); } synchronized (this.buffer_population) { for (int i = 0; i < this.getPopulation().getSize(); i++) { this.buffer_population.remove(0); } System.gc(); } }
From source file:dk.netarkivet.harvester.harvesting.controller.BnfHeritrixLauncher.java
/** * Initializes an Heritrix controller, then launches the Heritrix instance. * Then starts the crawl control loop://from w w w . j a v a2s . com * <ol> * <li>Waits the amount of time configured in * {@link HarvesterSettings#CRAWL_LOOP_WAIT_TIME}.</li> * <li>Obtains crawl progress information as a {@link CrawlProgressMessage} * from the Heritrix controller</li> * <li>Sends the progress message via JMS</li> * <li>If the crawl if reported as finished, end loop.</li> * </ol> */ public void doCrawl() throws IOFailure { setupOrderfile(getHeritrixFiles()); heritrixController = new BnfHeritrixController(getHeritrixFiles()); PeriodicTaskExecutor exec = null; try { // Initialize Heritrix settings according to the order.xml heritrixController.initialize(); log.debug("Starting crawl.."); heritrixController.requestCrawlStart(); // Schedule full frontier report generation exec = new PeriodicTaskExecutor( new PeriodicTask("CrawlControl", new CrawlControl(), CRAWL_CONTROL_WAIT_PERIOD, CRAWL_CONTROL_WAIT_PERIOD), new PeriodicTask("FrontierReportAnalyzer", new FrontierReportAnalyzer(heritrixController), FRONTIER_REPORT_GEN_FREQUENCY, FRONTIER_REPORT_GEN_FREQUENCY)); while (!crawlIsOver) { // Wait a bit try { synchronized (this) { wait(SLEEP_TIME_MS); } } catch (InterruptedException e) { log.trace("Waiting thread awoken: " + e.getMessage()); } } } catch (IOFailure e) { log.warn("Error during initialisation of crawl", e); throw (e); } catch (Exception e) { log.warn("Exception during crawl", e); throw new RuntimeException("Exception during crawl", e); } finally { // Stop the crawl control & frontier report analyzer if (exec != null) { exec.shutdown(); } if (heritrixController != null) { heritrixController.cleanup(getHeritrixFiles().getCrawlDir()); } } log.debug("Heritrix has finished crawling..."); }
From source file:com.mnxfst.testing.handler.exec.client.PTestPlanExecutorClient.java
/** * Executes the referenced test plan on all given hosts * @param threads//from w w w . j a v a2s . com * @param recurrences * @param recurrenceType * @param testplan * @param hosts * @param port * @return */ protected Map<String, String> executeTestplan(int threads, int recurrences, String recurrenceType, byte[] testplan, String[] hosts, int port) { StringBuffer buf = new StringBuffer("/planexec?action=execute"); buf.append("&threads=").append(threads); buf.append("&recurrences=").append(recurrences); buf.append("&recurrenceType=").append(recurrenceType); StringBuffer hn = new StringBuffer(); for (int i = 0; i < hosts.length; i++) { hn.append(hosts[i]); if (i < hosts.length - 1) hn.append(", "); } System.out.println("Execute testplan:"); System.out.println("\thostNames: " + hn.toString()); System.out.println("\tport: " + port); System.out.println("\tthreads: " + threads); System.out.println("\trecurrences: " + recurrences); System.out.println("\trecurrenceType: " + recurrenceType); System.out.println("\n\turi: " + buf.toString()); PTestPlanExecutorClientCallable callables[] = new PTestPlanExecutorClientCallable[hosts.length]; for (int i = 0; i < hosts.length; i++) { callables[i] = new PTestPlanExecutorClientCallable(hosts[i], port, buf.toString(), testplan); } ExecutorService executorService = Executors.newFixedThreadPool(hosts.length); List<Future<NameValuePair>> executionResults = new ArrayList<Future<NameValuePair>>(); try { executionResults = executorService.invokeAll(Arrays.asList(callables)); } catch (InterruptedException e) { System.out.println("Test execution interrupted: " + e.getMessage()); } // collect results from callables Map<String, String> result = new HashMap<String, String>(); for (Future<NameValuePair> r : executionResults) { try { NameValuePair nvp = r.get(); result.put(nvp.getName(), nvp.getValue()); } catch (InterruptedException e) { System.out.println("Interrupted while waiting for results. Error: " + e.getMessage()); e.printStackTrace(); } catch (ExecutionException e) { System.out.println("Interrupted while waiting for results. Error: " + e.getMessage()); e.printStackTrace(); } } return result; }
From source file:daveayan.gherkinsalad.AutomationObject.java
/** * Use this method to make the current running thread wait for the specified number of seconds * @param seconds Number of seconds to wait *//* w w w .j a va2 s . c om*/ protected void wait_for_seconds(int seconds) { if (seconds == 0) return; try { if (seconds >= 7) { action("User is waiting for " + seconds + " seconds"); } Thread.sleep(seconds * 1000); } catch (InterruptedException e) { error(e.getMessage()); } }
From source file:com.subgraph.vega.internal.http.proxy.ProxyRequestHandler.java
@Override public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException { final ProxyTransaction transaction = new ProxyTransaction(requestEngine, context); context.setAttribute(HttpProxy.PROXY_HTTP_TRANSACTION, transaction); try {//ww w . j a va 2s . c o m if (handleRequest(transaction, request) == false) { response.setStatusCode(503); transaction.signalComplete(false); return; } HttpUriRequest uriRequest = transaction.getRequest(); BasicHttpContext ctx = new BasicHttpContext(); transaction.signalForward(); IHttpResponse r = requestEngine.sendRequest(uriRequest, ctx); if (r == null) { response.setStatusCode(503); transaction.signalComplete(false); return; } if (handleResponse(transaction, r) == false) { response.setStatusCode(503); transaction.signalComplete(true); return; } HttpResponse httpResponse = copyResponse(r.getRawResponse()); removeHeaders(httpResponse); response.setStatusLine(httpResponse.getStatusLine()); response.setHeaders(httpResponse.getAllHeaders()); response.setEntity(httpResponse.getEntity()); transaction.signalForward(); } catch (InterruptedException e) { logger.log(Level.WARNING, "Error processing request: " + e.getMessage(), e); response.setStatusCode(503); } catch (RequestEngineException e) { logger.log(Level.WARNING, "Error processing request: " + e.getMessage()); response.setStatusCode(502); } catch (ProtocolException e) { logger.log(Level.WARNING, "Error processing request: " + e.getMessage(), e); response.setStatusCode(400); } catch (Exception e) { logger.log(Level.WARNING, "Error processing request: " + e.getMessage(), e); response.setStatusCode(500); } finally { transaction.signalComplete(false); } }