List of usage examples for java.util.concurrent TimeUnit SECONDS
TimeUnit SECONDS
To view the source code for java.util.concurrent TimeUnit SECONDS.
Click Source Link
From source file:com.pepaproch.gtswsdl.client.RateLimitTest.java
@Test public void testCOnsumeSLotAsync() { RateLimit rate = new RateLimit(5, 10, ChronoUnit.SECONDS); ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(10); final AtomicInteger cc = new AtomicInteger(0); Instant start = Instant.now(); final Instant[] end = new Instant[1]; Runnable r = () -> {//from w w w . j ava2 s. co m for (int i = 0; i < 21; i++) { addTask(cc, scheduler, rate, end); } }; Runnable r1 = () -> { for (int i = 0; i < 9; i++) { addTask(cc, scheduler, rate, end); } }; r1.run(); r.run(); try { scheduler.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(Duration.between(start, end[0]).toMillis()); }
From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.MultiplePatterns.CS572LoginAndClickHandler.java
public void processDriver(WebDriver driver) { try {/* www . j a v a 2 s . com*/ Configuration conf = NutchConfiguration.create(); driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); currentURL = driver.getCurrentUrl(); if (currentURL.contains("buyusedguns") && (currentURL.contains("login") || currentURL.contains("Login"))) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptIDIDID(conf, driver, "username", "password", "submit", false); } else if (currentURL.contains("gunlistings") && (currentURL.contains("login") || currentURL.contains("Login"))) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptNameNameXPath(conf, driver, "email_login", "password", "//input[@value='Login']", true); } else if (currentURL.contains("recycler") && (currentURL.contains("login") || currentURL.contains("Login"))) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptIDIDXPath(conf, driver, "login", "password", "//input[@value='Login']", true); } else if (currentURL.contains("slickguns") && (currentURL.contains("user"))) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptIDIDID(conf, driver, "edit-name", "edit-pass", "edit-submit", false); // } else if (currentURL.contains("shooting.org") && (currentURL.contains("login"))) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptIDIDXPath(conf, driver, "UserEmail", "UserPassword", "//input[@value='Sign in']", true); // } else if (currentURL.contains("wantaddigest.com") && (currentURL.contains("LogOn"))) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptIDIDXPath(conf, driver, "Email", "Password", "//input[@value='Sign in']", true); // } else if (currentURL.contains("floridagunclassifieds.com") && (currentURL.contains("login"))) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptIDIDID(conf, driver, "login_username", "login_password", "login", false); // } else if (currentURL.contains("gunidaho.com") && (currentURL.contains("login"))) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptIDIDXPath(conf, driver, "User_email", "User_password", "//input[@value='Sign in']", true); // } else if (currentURL.equals("http://www.iwanna.com/")) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptIDIDID(conf, driver, "welcome_username", "welcome_password", "welcome_login", false); // } else if (currentURL.contains("carolinabargaintrader.net/index.php") && currentURL.contains("a=10")) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptIDIDXPath(conf, driver, "username", "password", "//input[@value='Login']", false); // } else if (currentURL.contains("floridaguntrader.com/index.php") && currentURL.contains("a=10")) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptIDIDXPath(conf, driver, "username", "password", "//input[@value='Login >>']", false); // } else if (currentURL.contains("hawaiiguntrader.com") && currentURL.contains("login")) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptIDIDID(conf, driver, "login_username", "login_password", "login", false); // } else if (currentURL.contains("theoutdoorstrader.com")) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); WebElement username1 = driver.findElement(By.id("LoginControl")); WebElement password1 = driver.findElement(By.id("ctrl_password")); WebElement username2 = driver.findElement(By.id("ctrl_pageLogin_login")); WebElement password2 = driver.findElement(By.id("ctrl_pageLogin_password")); WebElement submitElement = driver.findElement(By.xpath("//input[@value='Log in']")); if (username1 != null && password1 != null && submitElement != null) { loginScriptIDIDXPath(conf, driver, "LoginControl", "ctrl_password", "//input[@value='Log in']", false); } else if (username2 != null && password2 != null && submitElement != null) { loginScriptIDIDXPath(conf, driver, "ctrl_pageLogin_login", "ctrl_pageLogin_password", "//input[@value='Log in']", false); } // } else if (currentURL.contains("zidaho.com/index.php") && currentURL.contains("a=10")) { System.out.println("[Interactiveselenium]: Interactive login \"" + currentURL + "\""); loginScriptIDIDXPath(conf, driver, "username", "password", "//input[@value='Login >>']", false); // } else if ((currentURL.equals("http://www.budsgunshop.com/catalog/index.php")) || (currentURL.equals("http://tennesseegunexchange.com/")) || (currentURL.contains("gunidaho.com")) || (currentURL.contains("hawaiiguntrader.com")) || (currentURL.contains("slickguns.com")) || (currentURL.contains("buyusedguns.net")) ) { System.out.println("[Interactiveselenium]: Interactive click \"" + currentURL + "\""); // Click link and record dynamic content clickAllAjaxLinks(conf, driver); } else { System.out.println("[Interactiveselenium]: Selenium only \"" + currentURL + "\""); } } catch (Exception e) { LOG.info(StringUtils.stringifyException(e)); } }
From source file:io.orchestrate.client.integration.FetchTest.java
@Test public void fetchObject() throws InterruptedException, ExecutionException, TimeoutException { final String key = generateString(); final String value = "{}"; KvStoreOperation kvStoreOp = new KvStoreOperation(TEST_COLLECTION, key, value); Future<KvMetadata> future_1 = client().execute(kvStoreOp); KvMetadata kvMetadata = future_1.get(3, TimeUnit.SECONDS); KvFetchOperation<String> kvFetchOp = new KvFetchOperation<String>(TEST_COLLECTION, key, String.class); KvObject<String> result = result(kvFetchOp); assertNotNull(kvMetadata);//from w ww . j a va2s .c o m assertNotNull(result); assertEquals(key, result.getKey()); assertEquals(value, result.getValue()); assertEquals(kvMetadata.getRef(), result.getRef()); }
From source file:org.osiam.configuration.JacksonConfig.java
private Module metricsModule() { return new MetricsModule(TimeUnit.SECONDS, TimeUnit.SECONDS, false); }
From source file:com.app.util.SearchResultUtil.java
public static void performSearch() throws DatabaseConnectionException, SQLException { long startTime = System.nanoTime(); ExecutorService executor = Executors.newFixedThreadPool(_THREAD_POOL_SIZE); List<Integer> userIds = UserUtil.getUserIds(true); for (int userId : userIds) { SearchResultRunnable searchResultRunnable = new SearchResultRunnable(userId); executor.execute(searchResultRunnable); }/*from w ww . j a va 2s.c o m*/ executor.shutdown(); try { executor.awaitTermination(_THREAD_TIMEOUT_SECONDS, TimeUnit.SECONDS); } catch (InterruptedException ie) { _log.error("The executor encountered an exception", ie); } long endTime = System.nanoTime(); _log.info("Performing searches for {} users took {} milliseconds", userIds.size(), (endTime - startTime) / 1000000); }
From source file:io.joynr.messaging.MessagingModule.java
@Provides @Named(MessageScheduler.SCHEDULEDTHREADPOOL) ScheduledExecutorService provideMessageSchedulerThreadPoolExecutor( @Named(ConfigurableMessagingSettings.PROPERTY_MESSAGING_MAXIMUM_PARALLEL_SENDS) int maximumParallelSends) { ThreadFactory schedulerNamedThreadFactory = new ThreadFactoryBuilder() .setNameFormat("joynr.MessageScheduler-scheduler-%d").build(); ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(maximumParallelSends, schedulerNamedThreadFactory); scheduler.setKeepAliveTime(100, TimeUnit.SECONDS); scheduler.allowCoreThreadTimeOut(true); return scheduler; }
From source file:org.copperengine.core.test.persistent.BaseSpringTxnPersistentWorkflowTest.java
public void testSpringTxnUnitTestWorkflow(String dsContext) throws Exception { assumeFalse(skipTests());//from w ww . j a v a2 s . c o m final ConfigurableApplicationContext context = createContext(dsContext); cleanDB(context.getBean(DataSource.class)); final PersistentScottyEngine engine = context.getBean(PersistentScottyEngine.class); final BackChannelQueue backChannelQueue = context.getBean(BackChannelQueue.class); try { engine.startup(); engine.run("org.copperengine.core.test.persistent.springtxn.SpringTxnUnitTestWorkflow", "TestData"); WorkflowResult x = backChannelQueue.dequeue(60, TimeUnit.SECONDS); assertNotNull(x); assertNotNull(x.getResult()); assertNull(x.getException()); // check new RetryingTransaction<Void>(context.getBean(DataSource.class)) { @Override protected Void execute() throws Exception { Statement stmt = getConnection().createStatement(); ResultSet rs = stmt.executeQuery("select count(*) from COP_AUDIT_TRAIL_EVENT"); assertTrue(rs.next()); int c = rs.getInt(1); assertEquals(7, c); rs.close(); stmt.close(); return null; } }.run(); } finally { closeContext(context); } assertEquals(EngineState.STOPPED, engine.getEngineState()); assertEquals(0, engine.getNumberOfWorkflowInstances()); }
From source file:apiserver.services.pdf.service.ExtractPdfFormFieldsCFService.java
public Object execute(Message<?> message) throws ColdFusionException { ExtractPdfFormResult props = (ExtractPdfFormResult) message.getPayload(); try {/* www.ja va 2 s .co m*/ long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<MapResult> future = exec.submit(new ExtractFormFieldsCallable(props.getFile().getFileBytes())); MapResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getData()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:apiserver.services.pdf.service.GetPdfInfoCFService.java
public Object execute(Message<?> message) throws ColdFusionException { PdfGetInfoResult props = (PdfGetInfoResult) message.getPayload(); try {/*w ww. ja v a 2 s. c o m*/ long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<MapResult> future = exec .submit(new GetInfoCallable(props.getFile().getFileBytes(), props.getOptions())); MapResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getData()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:apiserver.services.pdf.service.SetPdfInfoCFService.java
public Object execute(Message<?> message) throws ColdFusionException { PdfSetInfoResult props = (PdfSetInfoResult) message.getPayload(); try {/* w ww . j a v a 2 s . co m*/ long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<MapResult> future = exec .submit(new SetInfoCallable(props.getFile().getFileBytes(), props.getOptions())); MapResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getData()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }