List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:de.ingrid.iplug.web.WebContainer.java
/** * Starts the web container./*from www . ja v a 2 s. co m*/ * * @throws IOException */ public void startContainer() throws IOException { int i = 3; start(); while ((null == fServer) || (!fServer.isStarted())) { i--; try { Thread.sleep(3000); } catch (InterruptedException ie) { log.error(ie.getMessage(), ie); } if (0 == i) { throw new IOException("Could not start web container"); } } }
From source file:horriblev3.Cloudflare.java
public List<HttpCookie> scrape() { if (strUrl == null) { System.out.println("URL == NULL"); return null; }/* w w w.j a va2 s. c o m*/ try { CookieManager manager = new CookieManager(); manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(manager); URL url = new URL(strUrl); HttpURLConnection con; con = (HttpURLConnection) url.openConnection(); con.setRequestProperty("User-Agent", USERAGENT); InputStream _is; if (con.getResponseCode() == 200) { return retrieveCookies(manager); } else { _is = con.getErrorStream(); StringBuilder result = new StringBuilder(); try (BufferedReader rd = new BufferedReader(new InputStreamReader(_is))) { String line; while ((line = rd.readLine()) != null) { result.append(line); } } String source = result.toString(); //extract challenge String challenge = regex(source, "name=\"jschl_vc\" value=\"(\\w+)\""); String challenge_pass = regex(source, "name=\"pass\" value=\"(.+?)\""); //prepare String builder = regex(source, "setTimeout\\(function\\(\\)\\{\\s+(var s,t,o,p,b,r,e,a,k,i,n,g,f.+?\\r?[\\s\\S]+?a\\.value =.+?)\\r?\\s+';"); builder = builder.replaceFirst("\\s{3,}[a-z](?: = ).+form'\\);\\s+;", "").replaceFirst( "a\\.value = parseInt\\(.+?\\).+", regex(builder, "a\\.value = (parseInt\\(.+?\\)).+")); //Execute&solve System.out.println(builder); long solved = Long.parseLong(solveJS2(builder)); solved += url.getHost().length(); System.out.println("SOLVED: " + solved); try { Thread.sleep(3000); } catch (InterruptedException e) { System.out.println(e.getMessage()); } URI tmp = UrlToUri(url); List<NameValuePair> qparams = new ArrayList<>(); qparams.add(new BasicNameValuePair("jschl_vc", challenge)); qparams.add(new BasicNameValuePair("jschl_answer", String.valueOf(solved))); qparams.add(new BasicNameValuePair("pass", challenge_pass)); URIBuilder uriBuilder = new URIBuilder().setScheme(tmp.getScheme()).setPath("/cdn-cgi/l/chk_jschl") .setHost(tmp.getHost()).setParameters(qparams); HttpURLConnection cookie_req = (HttpURLConnection) new URL(uriBuilder.toString()).openConnection(); cookie_req.setRequestProperty("Referer", url.toString()); cookie_req.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:48.0) Gecko/20100101 Firefox/48.0"); HttpURLConnection.setFollowRedirects(false); cookie_req.connect(); System.out.println("ResponseCode: " + cookie_req.getResponseCode()); if (cookie_req.getResponseCode() == 200) { return retrieveCookies(manager); } else { System.out.println("Something went wrong!"); return null; } } } catch (IOException e1) { System.out.println(e1.getMessage()); return null; } }
From source file:com.nts.alphamale.handler.ExecutorHandler.java
/** * parallel execute synchronous commandline * @param cmdList//from w ww.j a v a 2s . c om * @param timeoutSecond * @return */ public List<Map<String, Object>> executeParallel(List<CommandLine> cmdList, int timeoutSecond) { ExecutorService executor = Executors.newCachedThreadPool(); List<Future<Map<String, Object>>> resultList; List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); List<SynchronousTask> taskList = new ArrayList<SynchronousTask>(); for (CommandLine cmd : cmdList) { taskList.add(new SynchronousTask(cmd, timeoutSecond * 1000)); } try { resultList = executor.invokeAll(taskList, timeoutSecond + 10, TimeUnit.SECONDS); for (Future<Map<String, Object>> result : resultList) { results.add(result.get()); } } catch (InterruptedException e) { log.error(e.getMessage()); } catch (ExecutionException e) { log.error(e.getMessage()); } if (!executor.isShutdown()) { executor.shutdown(); } return results; }
From source file:com.zhaimi.message.kafka.KafkaReceiver.java
/** * ? MessageReceiver?topic?//from w ww.jav a 2 s . c om */ @Override public void start() { if (consumer == null) { //sync init synchronized (lock) { init(); } } String topicString = buildTopicsString(); Whitelist topicFilter = new Whitelist(topicString); List<KafkaStream<byte[], byte[]>> streamList = consumer.createMessageStreamsByFilter(topicFilter, partitions); if (org.apache.commons.collections.CollectionUtils.isEmpty(streamList)) try { TimeUnit.MILLISECONDS.sleep(1); } catch (InterruptedException e) { log.warn(e.getMessage(), e); } processStreamsByTopic(topicString, streamList); }
From source file:com.nextep.designer.ui.wizards.ResolveProblemsWizard.java
@Override public boolean performFinish() { try {/*from ww w .j a v a2s .co m*/ getContainer().run(false, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(UIMessages.getString("wizard.problems.applyHints"), markers.size() + 1); //$NON-NLS-1$ for (IMarker marker : markers) { final Object markedObj = marker.getRelatedObject(); monitor.subTask( MessageFormat.format(UIMessages.getString("wizard.problems.processingElemnt"), //$NON-NLS-1$ NameHelper.getQualifiedName(markedObj))); if (marker.getSelectedHint() != null) { marker.getSelectedHint().execute(marker.getRelatedObject()); } monitor.worked(1); while (Display.getDefault().readAndDispatch()) { } } // Refreshing viewer monitor.done(); } }); } catch (InterruptedException e) { LOGGER.error(MessageFormat.format(UIMessages.getString("wizard.problems.interruptedException"), //$NON-NLS-1$ e.getMessage()), e); return false; } catch (InvocationTargetException e) { LOGGER.error(MessageFormat.format(UIMessages.getString("wizard.problems.targetException"), e //$NON-NLS-1$ .getMessage()), e); return false; } return true; }
From source file:org.jtheque.ui.impl.UIUtilsImpl.java
@Override public boolean askUserForConfirmation(final String text, final String title) { boolean yes = false; Window parent = null;/*from ww w. ja va2 s. c om*/ if (SimplePropertiesCache.get(MAIN_VIEW_CACHE, Window.class) != null) { parent = SimplePropertiesCache.get(MAIN_VIEW_CACHE, Window.class); } final Window p = parent; final int[] response = new int[1]; if (SwingUtilities.isEventDispatchThread()) { response[0] = JOptionPane.showConfirmDialog(parent, text, title, JOptionPane.YES_NO_OPTION); } else { try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { response[0] = JOptionPane.showConfirmDialog(p, text, title, JOptionPane.YES_NO_OPTION); } }); } catch (InterruptedException e) { LoggerFactory.getLogger(getClass()).error(e.getMessage(), e); } catch (InvocationTargetException e) { LoggerFactory.getLogger(getClass()).error(e.getMessage(), e); } } if (response[0] == JOptionPane.YES_OPTION) { yes = true; } return yes; }
From source file:com.thinkbiganalytics.nifi.security.ApplySecurityPolicy.java
protected FileSystem getFileSystemAsUser(final Configuration config, UserGroupInformation ugi) throws IOException { try {//from w w w. j a v a 2 s. com return ugi.doAs(new PrivilegedExceptionAction<FileSystem>() { @Override public FileSystem run() throws Exception { return FileSystem.get(config); } }); } catch (InterruptedException e) { throw new IOException("Unable to create file system: " + e.getMessage()); } }
From source file:edu.berkeley.sparrow.api.SparrowFrontendClient.java
public boolean submitRequest(TSchedulingRequest request) { try {// w w w .j a va 2 s.c o m Client client = clients.take(); client.submitJob(request); clients.put(client); } catch (InterruptedException e) { LOG.fatal(e); } catch (TException e) { LOG.error("Thrift exception when submitting job: " + e.getMessage()); return false; } catch (IncompleteRequestException e) { LOG.error(e); } return true; }
From source file:br.com.ingenieux.mojo.aws.util.BeanstalkerS3Client.java
@Override public PutObjectResult putObject(PutObjectRequest req) throws AmazonClientException, AmazonServiceException { if (!multipartUpload) { return super.putObject(req); }/* w ww .j a v a2s . c o m*/ final long contentLen = TransferManagerUtils.getContentLength(req); String tempFilename = req.getKey() + ".tmp"; String origFilename = req.getKey(); req.setKey(tempFilename); XProgressListener progressListener = new XProgressListener(); req.setGeneralProgressListener(new ProgressListenerChain(progressListener)); progressListener.setContentLen(contentLen); progressListener.setUpload(transferManager.upload(req)); progressListener.setSilentUpload(silentUpload); try { progressListener.getUpload().waitForCompletion(); } catch (InterruptedException e) { throw new AmazonClientException(e.getMessage(), e); } CopyObjectRequest copyReq = new CopyObjectRequest(req.getBucketName(), tempFilename, req.getBucketName(), origFilename); copyObject(copyReq); deleteObject(new DeleteObjectRequest(req.getBucketName(), tempFilename)); return null; }
From source file:io.fabric8.tooling.archetype.commands.ArchetypeCreateAction.java
/** * Fetches archetype from the configured repositories * TODO: make this code available to hawt.io/JMX too * * @param archetype/* ww w .j a v a 2 s . c om*/ * @return */ private InputStream fetchArchetype(Archetype archetype) throws IOException { MavenConfigurationImpl config = new MavenConfigurationImpl( new PropertiesPropertyResolver(System.getProperties()), "org.ops4j.pax.url.mvn"); config.setSettings(new MavenSettingsImpl(config.getSettingsFileUrl(), config.useFallbackRepositories())); DownloadManager dm = new DownloadManager(config, Executors.newSingleThreadExecutor()); final CountDownLatch latch = new CountDownLatch(1); DownloadFuture df = dm.download( String.format("mvn:%s/%s/%s", archetype.groupId, archetype.artifactId, archetype.version)); df.addListener(new FutureListener<DownloadFuture>() { @Override public void operationComplete(DownloadFuture future) { latch.countDown(); } }); try { latch.await(30, TimeUnit.SECONDS); } catch (InterruptedException e) { System.err.println("Failed to download " + archetype); throw new IOException(e.getMessage(), e); } System.out.println("Downloaded archetype (" + df.getFile() + ")"); return new FileInputStream(df.getFile()); }