List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:de.nware.app.hsDroid.logic.LoginThread.java
License:asdf
public boolean login() { // warten bis threadHandler bereit ist while (mThreadHandler == null) { // int count = 0; // FIXME geht erst im zweiten Durchlauf der Schleife???? // Log.e("login", "handler empty: " + count); try {/* w w w . j a va2s . c om*/ sleep(1); // count += 1; } catch (InterruptedException e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); } } return this.mThreadHandler.sendEmptyMessage(HANLDER_MSG_LOGIN); }
From source file:hivemall.mix.server.MixServerTest.java
@Test public void test2ClientsZeroOneSparseModel() throws InterruptedException { final int port = NetUtils.getAvailablePort(); CommandLine cl = CommandLineUtils.parseOptions( new String[] { "-port", Integer.toString(port), "-sync_threshold", "30" }, MixServer.getOptions()); MixServer server = new MixServer(cl); ExecutorService serverExec = Executors.newSingleThreadExecutor(); serverExec.submit(server);//w w w .j a v a 2 s . co m waitForState(server, ServerState.RUNNING); final ExecutorService clientsExec = Executors.newCachedThreadPool(); for (int i = 0; i < 2; i++) { clientsExec.submit(new Runnable() { @Override public void run() { try { invokeClient01("test2ClientsZeroOne", port, false, false); } catch (InterruptedException e) { Assert.fail(e.getMessage()); } } }); } clientsExec.awaitTermination(30, TimeUnit.SECONDS); clientsExec.shutdown(); serverExec.shutdown(); }
From source file:hivemall.mix.server.MixServerTest.java
@Test public void test2ClientsZeroOneDenseModel() throws InterruptedException { final int port = NetUtils.getAvailablePort(); CommandLine cl = CommandLineUtils.parseOptions( new String[] { "-port", Integer.toString(port), "-sync_threshold", "30" }, MixServer.getOptions()); MixServer server = new MixServer(cl); ExecutorService serverExec = Executors.newSingleThreadExecutor(); serverExec.submit(server);//from w ww . j a v a 2 s . c o m waitForState(server, ServerState.RUNNING); final ExecutorService clientsExec = Executors.newCachedThreadPool(); for (int i = 0; i < 2; i++) { clientsExec.submit(new Runnable() { @Override public void run() { try { invokeClient01("test2ClientsZeroOne", port, true, false); } catch (InterruptedException e) { Assert.fail(e.getMessage()); } } }); } clientsExec.awaitTermination(30, TimeUnit.SECONDS); clientsExec.shutdown(); serverExec.shutdown(); }
From source file:hivemall.mix.server.MixServerTest.java
@Test public void test2ClientsZeroOneSparseModelWithMixCanceling() throws InterruptedException { final int port = NetUtils.getAvailablePort(); CommandLine cl = CommandLineUtils.parseOptions( new String[] { "-port", Integer.toString(port), "-sync_threshold", "30" }, MixServer.getOptions()); MixServer server = new MixServer(cl); ExecutorService serverExec = Executors.newSingleThreadExecutor(); serverExec.submit(server);/* ww w.j av a 2 s . c om*/ waitForState(server, ServerState.RUNNING); final ExecutorService clientsExec = Executors.newCachedThreadPool(); for (int i = 0; i < 2; i++) { clientsExec.submit(new Runnable() { @Override public void run() { try { invokeClient01("test2ClientsZeroOne", port, false, true); } catch (InterruptedException e) { Assert.fail(e.getMessage()); } } }); } clientsExec.awaitTermination(30, TimeUnit.SECONDS); clientsExec.shutdown(); serverExec.shutdown(); }
From source file:hivemall.mix.server.MixServerTest.java
@Test public void test2ClientsZeroOneDenseModelWithMixCanceling() throws InterruptedException { final int port = NetUtils.getAvailablePort(); CommandLine cl = CommandLineUtils.parseOptions( new String[] { "-port", Integer.toString(port), "-sync_threshold", "30" }, MixServer.getOptions()); MixServer server = new MixServer(cl); ExecutorService serverExec = Executors.newSingleThreadExecutor(); serverExec.submit(server);/* ww w .j a v a 2 s.c om*/ waitForState(server, ServerState.RUNNING); final ExecutorService clientsExec = Executors.newCachedThreadPool(); for (int i = 0; i < 2; i++) { clientsExec.submit(new Runnable() { @Override public void run() { try { invokeClient01("test2ClientsZeroOne", port, true, true); } catch (InterruptedException e) { Assert.fail(e.getMessage()); } } }); } clientsExec.awaitTermination(30, TimeUnit.SECONDS); clientsExec.shutdown(); serverExec.shutdown(); }
From source file:com.sm.connector.server.ExecMapReduce.java
/** * each thread will process 3 of record (end -begin) /noOfThread * @param store -name of store/*from ww w. j a va 2s.c o m*/ * @param noOfThread how many thread to run concurrently * @param begin record# for this node * @param end record# for this node * @return by reducer */ public Object execute(String store, int noOfThread, int begin, int end) { logger.info("execute " + store + " threads " + noOfThread + " begin " + begin + " end " + end); if (noOfThread <= 0 || begin >= end) throw new RuntimeException( "number of thread " + noOfThread + " must be > 0 or begin " + begin + " >= end " + end); serverStore = serverStoreMap.get(store); if (serverStore == null) throw new RuntimeException("can not find ServerStore " + store); //how many record need to be process int totalRec = end - begin; int blockSize = (totalRec % noOfThread == 0 ? totalRec / noOfThread : (totalRec / noOfThread) + 1); CountDownLatch countDownLatch = new CountDownLatch(noOfThread); ExecutorService executor = Executors.newFixedThreadPool(noOfThread, new ThreadPoolFactory("exec")); List<Runnable> runnableList = new ArrayList<Runnable>(noOfThread); logger.info("start to run " + noOfThread + " threads block size " + blockSize + " for " + store + " total " + totalRec); for (int i = 0; i < noOfThread; i++) { try { //T t = tClass.newInstance(); T t = (T) QueryUtils.createInstance(tClass); if (i < noOfThread - 1) { RunThread runThread = new RunThread(countDownLatch, begin + blockSize * i, begin + blockSize * (i + 1), t, i, store); runnableList.add(runThread); executor.submit(runThread); } else { //the last block RunThread runThread = new RunThread(countDownLatch, begin + blockSize * i, begin + totalRec, t, i, store); runnableList.add(runThread); executor.submit(runThread); } } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } try { countDownLatch.await(timeout * 10, TimeUnit.MILLISECONDS); } catch (InterruptedException ex) { logger.warn(ex.getMessage(), ex); } finally { executor.shutdown(); return mapReduce.reduce(list); } }
From source file:hivemall.mix.server.MixServerTest.java
@Test public void testMultipleClients() throws InterruptedException { final int port = NetUtils.getAvailablePort(); CommandLine cl = CommandLineUtils.parseOptions( new String[] { "-port", Integer.toString(port), "-sync_threshold", "3" }, MixServer.getOptions()); MixServer server = new MixServer(cl); ExecutorService serverExec = Executors.newSingleThreadExecutor(); serverExec.submit(server);// ww w . ja va 2 s . c om waitForState(server, ServerState.RUNNING); final int numClients = 5; final ExecutorService clientsExec = Executors.newCachedThreadPool(); for (int i = 0; i < numClients; i++) { clientsExec.submit(new Runnable() { @Override public void run() { try { invokeClient("testMultipleClients", port); } catch (InterruptedException e) { Assert.fail(e.getMessage()); } } }); } clientsExec.awaitTermination(10, TimeUnit.SECONDS); clientsExec.shutdown(); serverExec.shutdown(); }
From source file:fr.ortolang.diffusion.seo.SeoServiceBean.java
@Override public String prerenderSiteMap() throws SeoServiceException, ParserConfigurationException, TransformerException { LOGGER.log(Level.INFO, "Start prerendering Site Map"); Document document = generateSiteMapDocument(); NodeList nodes = document.getElementsByTagNameNS(SITEMAP_NS_URI, "loc"); Runnable command = () -> { int errors = 0; for (int i = 0; i < nodes.getLength(); i++) { String url = nodes.item(i).getTextContent(); LOGGER.log(Level.FINE, "Prerendering url: " + url); Response response = client.target(url).request().header("User-Agent", ORTOLANG_USER_AGENT).get(); response.close();//from w w w . java 2 s. co m if (response.getStatusInfo().getStatusCode() != 200 && response.getStatusInfo().getStatusCode() != 304) { LOGGER.log(Level.SEVERE, "An unexpected issue occurred while prerendering the url " + url + " : " + response.getStatusInfo().getStatusCode() + " " + response.getStatusInfo().getReasonPhrase()); errors++; } try { Thread.sleep(200); } catch (InterruptedException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } } if (errors > 0) { LOGGER.log(Level.SEVERE, "Site Map prerendering done with " + errors + " errors."); } else { LOGGER.log(Level.INFO, "Site Map prerendering done"); } }; executor.execute(command); return generateSiteMap(document); }
From source file:com.cm.beer.util.DrawableManager.java
/** * /*w w w . java 2 s .com*/ * @param urlString * @param imageView */ public void fetchDrawableOnThread(final String urlString, final ImageView imageView) { if (mDrawableCache.containsKey(urlString)) { if (Logger.isLogEnabled()) Logger.log("Returning Drawable from Cache:" + urlString); SoftReference<Drawable> softReference = mDrawableCache.get(urlString); if ((softReference == null) || (softReference.get() == null)) { mDrawableCache.remove(urlString); if (Logger.isLogEnabled()) Logger.log("fetchDrawableOnThread():Soft Reference has been Garbage Collected:" + urlString); } else { imageView.setImageDrawable(softReference.get()); return; } } final Handler handler = new Handler() { @Override public void handleMessage(Message message) { imageView.setImageDrawable((Drawable) message.obj); } }; 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) { // TODO Auto-generated catch block Log.e(this.getClass().getName(), e.getMessage()); } } Drawable drawable = fetchDrawable(urlString); Message message = handler.obtainMessage(1, drawable); handler.sendMessage(message); } }; thread.start(); }
From source file:com.piketec.jenkins.plugins.tpt.TptPluginSingleJobExecutor.java
/** * It looks for the tpt installation . Then prepares the test- and data directories. After that it * creates a command ( @see buildCommand ) in order to execute Tpt from the commandline. Then it * runs that command through the launcher and publish the Junit XML if necessary. * //from w ww . j a v a 2s. c om * @return true if the execution from the tpt file was successful. */ boolean execute() { boolean success = true; FilePath workspace = build.getWorkspace(); File workspaceDir; try { workspaceDir = Utils.getWorkspaceDir(workspace, logger); } catch (InterruptedException e) { logger.interrupt(e.getMessage()); return false; } // use first found (existing) TPT installation FilePath exeFile = null; for (FilePath f : exePaths) { try { if (f.exists()) { exeFile = f; break; } } catch (IOException e) { // NOP, just try next file } catch (InterruptedException e) { logger.interrupt(e.getMessage()); return false; } } if (exeFile == null) { logger.error("No TPT installation found"); return false; } // execute the sub-configuration for (JenkinsConfiguration ec : executionConfigs) { if (ec.isEnableTest()) { String testdataDir = Utils.getGeneratedTestDataDir(ec); FilePath testDataPath = new FilePath(build.getWorkspace(), testdataDir); String reportDir = Utils.getGeneratedReportDir(ec); FilePath reportPath = new FilePath(build.getWorkspace(), reportDir); File tptFile = Utils.getAbsolutePath(workspaceDir, new File(ec.getTptFile())); String configurationName = ec.getConfiguration(); String tesSet = ec.getTestSet(); logger.info("*** Running TPT-File \"" + tptFile + // "\" with configuration \"" + configurationName + "\" now. ***"); if (Utils.createParentDir(new File(testdataDir), workspace) && Utils.createParentDir(new File(reportDir), workspace)) { String cmd = buildCommand(exeFile, arguments, tptFile, testDataPath.getRemote(), reportPath.getRemote(), configurationName, tesSet); try { // run the test... boolean successOnlyForOneConfig = launchTPT(launcher, listener, cmd, ec.getTimeout()); success &= successOnlyForOneConfig; if (successOnlyForOneConfig) { TPTBuildStepEntries.addEntry(ec, build); } if (enableJunit) { // transform TPT results into JUnit results logger.info("*** Publishing results now ***"); Utils.publishAsJUnitResults(workspace, ec, testDataPath, jUnitXmlPath, jUnitLogLevel, logger); } } catch (IOException e) { logger.error(e.getMessage()); success = false; // continue with next config in case of I/O error } catch (InterruptedException e) { logger.interrupt(e.getMessage()); return false; } } else { logger.error("Failed to create parent directories for " + testdataDir + " and/or " + reportDir); success = false; } } } return success; }