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.javacreed.examples.misc.Example.java
public static void main(final String[] args) throws Exception { final String link = "http://www.javacreed.com/"; final File screenShot = new File("screenshot.png").getAbsoluteFile(); Example.LOGGER.debug("Creating Firefox Driver"); final WebDriver driver = new FirefoxDriver(); try {//from w ww.j a va 2 s .com Example.LOGGER.debug("Opening page: {}", link); driver.get(link); Example.LOGGER.debug("Wait a bit for the page to render"); TimeUnit.SECONDS.sleep(5); Example.LOGGER.debug("Taking Screenshot"); final File outputFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(outputFile, screenShot); Example.LOGGER.debug("Screenshot saved: {}", screenShot); } finally { driver.close(); } Example.LOGGER.debug("done"); }
From source file:nats.client.spring.NatsApplicationEventTest.java
public static void main(String[] args) throws Exception { // TODO Make automated test that starts a NATS server and then runs test. // Nats server must running before running this test. final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "natsApplicationEventContext.xml"); try {/* ww w .j a v a2s . c o m*/ final Nats nats = context.getBean(Nats.class); Assert.assertNotNull(nats); final boolean invokedConnected = context.getBean("connected", ConnectListener.class).invoked.await(2, TimeUnit.SECONDS); Assert.assertTrue(invokedConnected, "The connected application event was never published."); final boolean invokedReady = context.getBean("ready", ReadyListener.class).invoked.await(2, TimeUnit.SECONDS); Assert.assertTrue(invokedReady, "The server ready application event was never published."); nats.close(); final boolean invokedClosed = context.getBean("closed", ClosedListener.class).invoked.await(2, TimeUnit.SECONDS); Assert.assertTrue(invokedClosed, "The closed application event was never published."); } finally { context.close(); } }
From source file:org.s1p.app2.S1pKafkaApplication.java
public static void main(String[] args) throws Exception { ConfigurableApplicationContext context = new SpringApplicationBuilder(S1pKafkaApplication.class).web(false) .run(args);/*from ww w. j a v a 2 s . c o m*/ TestBean testBean = context.getBean(TestBean.class); testBean.send("foo"); context.getBean(Listener.class).latch.await(60, TimeUnit.SECONDS); context.close(); }
From source file:org.s1p.app5.S1pKafkaApplication.java
public static void main(String[] args) throws Exception { ConfigurableApplicationContext context = new SpringApplicationBuilder(S1pKafkaApplication.class).web(false) .run(args);//from w w w . j av a2 s .co m TestBean testBean = context.getBean(TestBean.class); testBean.send(new Foo("foo", "bar")); context.getBean(Listener.class).latch.await(60, TimeUnit.SECONDS); context.close(); }
From source file:org.s1p.app7.S1pKafkaApplication.java
public static void main(String[] args) throws Exception { ConfigurableApplicationContext context = new SpringApplicationBuilder(S1pKafkaApplication.class).web(false) .run(args);//from www.j a v a2 s.c om TestBean testBean = context.getBean(TestBean.class); testBean.send("foo"); testBean.send("bar"); testBean.send("baz"); context.getBean(Listener.class).latch.await(60, TimeUnit.SECONDS); context.close(); }
From source file:com.curso.ejemplotareaplanificada.Principal.java
/** * @param args the command line arguments *///from w ww . j a v a 2s. c o m public static void main(String[] args) { //solo estamos usando anotaciones //en esta clase no hay nada de los metodos planificados porque esos ya los llama spring solito //esta clase es para pegarnos con los servicios asincronos ApplicationContext ctx = new AnnotationConfigApplicationContext(Configuracion.class); System.out.println("Contexto cargado"); ServicioAsincrono sa = ctx.getBean(ServicioAsincrono.class); System.out.println("Hilo principal " + Thread.currentThread()); //Este metodo devuelve void asi que el hilo arranca un nuevo hilo pero continua sin esperar ni ahora ni a un futuro sa.metodoUno(); //Este metodo devuelve un futuro, y cuando llamemos a get espera 5 segundos a ver si termina el nuevo hilo //Si sobre pasa esos 5 segundos lanza una excepcion Future<Double> numero = sa.factorial(100); try { System.out.println("El factorial es desde un Future:" + numero.get(5L, TimeUnit.SECONDS)); } catch (InterruptedException | ExecutionException | TimeoutException ex) { Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex); } //Este metodo devuelve un escuchable ListenableFuture<Double> valor = sa.factorialLf(100); //Al metodo escuchable le aadimos una clase anonima de tipo llamable con dos metodos, uno que se ejecutara cuando acabe con exito //y otro si no acaba correctamente valor.addCallback(new ListenableFutureCallback<Double>() { @Override public void onSuccess(Double result) { System.out.println("El resultado es desde un ListenableFuture: " + result); } @Override public void onFailure(Throwable ex) { LOG.log(Level.SEVERE, "Ha ocurrido un error:", ex); } }); }
From source file:ddf.metrics.reporting.internal.rrd4j.RrdDumper.java
public static void main(String[] args) throws Exception { // String rrdFilename = args[0]; String[] rrdFilenames = new String[] { "C:/DDF/jvmUptime.rrd" }; for (String rrdFilename : rrdFilenames) { RrdDb rrdDb = new RrdDb(rrdFilename, true); long endTime = System.currentTimeMillis() / 1000; long duration = TimeUnit.SECONDS.convert(24L, TimeUnit.DAYS); long startTime = endTime - duration; //// w w w . j a va 2 s . c om // Calendar cal = Calendar.getInstance(); // cal.set(2013, 7, 21, 15, 40); // long startTime = cal.getTimeInMillis()/1000; // cal.set(2013, 7, 22, 8, 0); // long endTime = cal.getTimeInMillis()/1000; System.out.println( "\n\n>>>>>>>>>>>>>>>>>>> RRD File: " + rrdFilename + " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n"); dumpData(ConsolFun.TOTAL, "TOTAL", rrdDb, "COUNTER", startTime, endTime); displayGraph("Metric Name", rrdFilename, startTime, endTime, "Y-Axis Label", "Graph Title"); } }
From source file:com.jejking.hh.nord.gazetteer.osm.poi.WritePointsOfInterest.java
/** * @param args/* w ww . j a v a2s . co m*/ */ public static void main(String[] args) { Stopwatch stopwatch = Stopwatch.createStarted(); GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); GraphDatabaseService graph = new GraphDatabaseFactory().newEmbeddedDatabase(args[0]); registerShutdownHook(graph); WritePointsOfInterest.writePointsOfInterest(geometryFactory, graph); System.out.println( "Wrote points of interest. Elapsed time: " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds"); }
From source file:org.s1p.app3.S1pKafkaApplication.java
public static void main(String[] args) throws Exception { ConfigurableApplicationContext context = new SpringApplicationBuilder(S1pKafkaApplication.class).web(false) .run(args);/* ww w . jav a2s .c o m*/ TestBean testBean = context.getBean(TestBean.class); for (int i = 0; i < 10; i++) { testBean.send("foo"); } context.getBean(Listener.class).latch.await(60, TimeUnit.SECONDS); context.close(); }
From source file:com.jejking.hh.nord.gazetteer.osm.streets.WriteStreets.java
/** * Imports an extract from Open Street Map into Neo4j. * /*from www .ja v a 2 s . c o m*/ * @param args * directory in which the Neo4j database exists. */ public static void main(String[] args) { Stopwatch stopwatch = Stopwatch.createStarted(); GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); GraphDatabaseService graph = new GraphDatabaseFactory().newEmbeddedDatabase(args[0]); registerShutdownHook(graph); WriteStreets.writeStreets(geometryFactory, graph); System.out.println("Wrote streets. Elapsed time: " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds"); }