List of usage examples for java.lang InterruptedException getLocalizedMessage
public String getLocalizedMessage()
From source file:io.pivotal.cf.service.connector.KafkaConnectionCreator.java
@Override public KafkaRepository create(KafkaServiceInfo serviceInfo, ServiceConnectorConfig serviceConnectorConfig) { log.info("creating kafka repo wth service info: " + serviceInfo); try {/* w w w . jav a 2 s . c o m*/ return new KafkaRepositoryFactory().create(serviceInfo); } catch (InterruptedException e) { log.error(e.getLocalizedMessage(), e); return null; } }
From source file:org.opencms.util.CmsWaitHandle.java
/** * Waits for a maximum of waitTime, but returns if another thread calls release().<p> * * @param waitTime the maximum wait time *//*from www .java 2s . com*/ public synchronized void enter(long waitTime) { try { wait(waitTime); } catch (InterruptedException e) { // should never happen, but log it just in case... LOG.error(e.getLocalizedMessage(), e); } }
From source file:com.serena.rlc.provider.schedule.client.ScheduleWaiter.java
@Override public void run() { logger.debug("ScheduleWaiter is sleeping for " + waitTime + " milliseconds, until " + endDate); try {// w w w. j a v a 2 s. com Thread.sleep(waitTime); } catch (InterruptedException ex) { logger.error("ScheduleWaiter was interrupted: " + ex.getLocalizedMessage()); } catch (CancellationException ex) { logger.error("ScheduleWaiter thread has been cancelled: ", ex.getLocalizedMessage()); } synchronized (executionId) { logger.debug("ScheduleWaiter has finished sleeping at " + new Date()); try { String uri = callbackUrl + executionId + "/COMPLETED"; logger.info("Start executing RLC PUT request to url=\"{}\"", uri); DefaultHttpClient rlcParams = new DefaultHttpClient(); HttpPut put = new HttpPut(uri); UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(callbackUsername, callbackPassword); put.addHeader(BasicScheme.authenticate(credentials, "US-ASCII", false)); //put.addHeader("Content-Type", "application/x-www-form-urlencoded"); //put.addHeader("Accept", "application/json"); logger.info(credentials.toString()); HttpResponse response = rlcParams.execute(put); if (response.getStatusLine().getStatusCode() != 200) { logger.error("HTTP Status Code: " + response.getStatusLine().getStatusCode()); } } catch (IOException ex) { logger.error(ex.getLocalizedMessage()); } executionId.notify(); } }
From source file:org.opencms.search.solr.spellchecking.CmsSpellcheckingModuleAction.java
/** * @see org.opencms.module.I_CmsModuleAction#initialize(org.opencms.file.CmsObject, org.opencms.configuration.CmsConfigurationManager, org.opencms.module.CmsModule) *//*from w ww .java2s .co m*/ public void initialize(final CmsObject adminCms, final CmsConfigurationManager configurationManager, final CmsModule module) { final Runnable r = new Runnable() { public void run() { // Although discouraged, use polling to make sure the indexing process does not start // before OpenCms has reached runlevel 4 while (OpenCms.getRunLevel() == OpenCms.RUNLEVEL_2_INITIALIZING) { try { // Repeat check every five seconds Thread.sleep(5 * 1000); } catch (InterruptedException e) { LOG.warn(e.getLocalizedMessage(), e); // maybe OpenCms is being shutdown, just return return; } } // Check whether indexing is needed if not running the shell if ((OpenCms.getRunLevel() == OpenCms.RUNLEVEL_4_SERVLET_ACCESS) && CmsSpellcheckDictionaryIndexer.updatingIndexNecessesary(adminCms)) { CmsSolrSpellchecker spellchecker = OpenCms.getSearchManager().getSolrDictionary(adminCms); if (spellchecker != null) { spellchecker.parseAndAddDictionaries(adminCms); } } } }; m_indexingThread = new Thread(r, "CmsSpellcheckingModuleIndexingThread"); m_indexingThread.start(); }
From source file:com.clough.android.adbv.manager.IOManager.java
private String waitForResult(Data requestingData) throws IOManagerException { this.requestingData = requestingData; String result = ""; if (stayAlive) { while (respondingData == null || respondingData.getStatus() != requestingData.getStatus() || (requestingData.getStatus() == Data.QUERY && !requestingData.getQuery().equals(respondingData.getQuery()))) { this.requestingData = requestingData; try { Thread.sleep(10); } catch (InterruptedException ex) { throw new IOManagerException(ex.getLocalizedMessage()); }// ww w . ja va 2 s . c om } result = respondingData.getResult(); this.requestingData = defaultData; return result; } else { throw new IOManagerException("Connection being disconnected"); } }
From source file:org.orekit.bodies.CelestialBodyFactoryTest.java
private void checkMultiThread(final int threads, final int runs) throws OrekitException { final AtomicReference<OrekitException> caught = new AtomicReference<OrekitException>(); ExecutorService executorService = Executors.newFixedThreadPool(threads); List<Future<?>> results = new ArrayList<Future<?>>(); for (int i = 0; i < threads; i++) { Future<?> result = executorService.submit(new Runnable() { public void run() { try { for (int run = 0; run < runs; run++) { CelestialBody mars = CelestialBodyFactory.getBody(CelestialBodyFactory.MARS); Assert.assertNotNull(mars); CelestialBodyFactory.clearCelestialBodyLoaders(); }//from w w w. ja va 2 s .c o m } catch (OrekitException oe) { caught.set(oe); } } }); results.add(result); } try { executorService.shutdown(); executorService.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException ie) { Assert.fail(ie.getLocalizedMessage()); } for (Future<?> result : results) { Assert.assertTrue("Not all threads finished -> possible deadlock", result.isDone()); } if (caught.get() != null) { throw caught.get(); } }
From source file:de.micmun.android.workdaystarget.DaysLeftService.java
/** * Updates the days to target./*from www .j a v a 2 s . co m*/ */ private void updateDays() { AppWidgetManager appManager = AppWidgetManager.getInstance(this); ComponentName cName = new ComponentName(getApplicationContext(), DaysLeftProvider.class); int[] appIds = appManager.getAppWidgetIds(cName); DayCalculator dayCalc = new DayCalculator(); if (!isOnline()) { try { Thread.sleep(60000); } catch (InterruptedException e) { Log.e(TAG, "Interrupted: " + e.getLocalizedMessage()); } } for (int appId : appIds) { PrefManager pm = new PrefManager(this, appId); Calendar target = pm.getTarget(); boolean[] chkDays = pm.getCheckedDays(); int days = pm.getLastDiff(); if (isOnline()) { try { days = dayCalc.getDaysLeft(target.getTime(), chkDays); Map<String, Object> saveMap = new HashMap<String, Object>(); Long diff = Long.valueOf(days); saveMap.put(PrefManager.KEY_DIFF, diff); pm.save(saveMap); } catch (JSONException e) { Log.e(TAG, "ERROR holidays: " + e.getLocalizedMessage()); } } else { Log.e(TAG, "No internet connection!"); } RemoteViews rv = new RemoteViews(this.getPackageName(), R.layout.appwidget_layout); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); String targetStr = df.format(target.getTime()); rv.setTextViewText(R.id.target, targetStr); String dayStr = String.format(Locale.getDefault(), "%d %s", days, getResources().getString(R.string.unit)); rv.setTextViewText(R.id.dayCount, dayStr); // put widget id into intent Intent configIntent = new Intent(this, ConfigActivity.class); configIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); configIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId); configIntent.setData(Uri.parse(configIntent.toUri(Intent.URI_INTENT_SCHEME))); PendingIntent pendIntent = PendingIntent.getActivity(this, 0, configIntent, PendingIntent.FLAG_UPDATE_CURRENT); rv.setOnClickPendingIntent(R.id.widgetLayout, pendIntent); // update widget appManager.updateAppWidget(appId, rv); } }
From source file:com.anrisoftware.prefdialog.dialogaction.AbstractDialogActionLogger.java
DialogActionException errorCreateDialogInterrupted(AbstractDialogAction<?, ?> action, InterruptedException e) { return logException(new DialogActionException(create_dialog_interrupted).add(action, action), create_dialog_interrupted_message, e.getLocalizedMessage()); }
From source file:org.opencms.workplace.threads.CmsModuleReplaceThread.java
/** * @see java.lang.Runnable#run()/*ww w . java 2s.c o m*/ */ public void run() { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_REPLACE_THREAD_START_DELETE_0)); } // phase 1: delete the existing module m_phase = 1; m_deleteThread.start(); try { m_deleteThread.join(); } catch (InterruptedException e) { // should never happen if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } } // get remaining report contents m_reportContent = m_deleteThread.getReportUpdate(); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_REPLACE_THREAD_START_IMPORT_0)); } // phase 2: import the new module m_phase = 2; m_importThread.start(); try { m_importThread.join(); } catch (InterruptedException e) { // should never happen if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_REPLACE_THREAD_FINISHED_0)); } }
From source file:org.jboss.tools.common.launcher.ui.wizard.NewLauncherProjectWizardController.java
private IStatus createMavenProject(IProgressMonitor monitor) { IStatus status = Status.OK_STATUS;//from w ww .j a va 2 s . com MavenPluginActivator mavenPlugin = MavenPluginActivator.getDefault(); IProjectConfigurationManager configurationManager = mavenPlugin.getProjectConfigurationManager(); MavenModelManager modelManager = mavenPlugin.getMavenModelManager(); LocalProjectScanner scanner = new LocalProjectScanner( ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toFile(), model.getLocation().toOSString(), false, modelManager); try { scanner.run(monitor); ProjectImportConfiguration projectImportConfiguration = new ProjectImportConfiguration(); configurationManager.importProjects(collect(scanner.getProjects()), projectImportConfiguration, monitor); } catch (InterruptedException e) { status = new Status(IStatus.ERROR, LauncherUIPlugin.PLUGIN_ID, e.getLocalizedMessage(), e); } catch (CoreException e) { status = e.getStatus(); } return status; }