List of usage examples for java.util.concurrent TimeUnit MINUTES
TimeUnit MINUTES
To view the source code for java.util.concurrent TimeUnit MINUTES.
Click Source Link
From source file:Main.java
public static void main(String[] argv) throws Exception { int capacity = 10; ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity); for (int i = 0; i < 10; i++) { queue.add(i);//from ww w . j a va 2s . c o m } queue.offer(9999, 10, TimeUnit.MINUTES); System.out.println(queue); }
From source file:Main.java
public static void main(String[] argv) throws Exception { int capacity = 10; ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity); for (int i = 0; i < 10; i++) { queue.add(i);/*from w ww .j a v a2 s .co m*/ } System.out.println(queue.poll(10, TimeUnit.MINUTES)); }
From source file:at.tfr.securefs.client.SecurefsClient.java
public static void main(String[] args) throws Exception { SecurefsClient client = new SecurefsClient(); try {/*from w w w . java 2 s . c o m*/ client.parse(args); if (client.asyncTest) { ExecutorService executor = Executors.newFixedThreadPool(client.threads); for (int i = 0; i < client.threads; i++) { executor.submit(client); } executor.shutdown(); executor.awaitTermination(10, TimeUnit.MINUTES); } else { client.run(); } } catch (Throwable e) { HelpFormatter hf = new HelpFormatter(); hf.printHelp(SecurefsClient.class.getSimpleName(), client.options); e.printStackTrace(); } }
From source file:ch.rasc.wampspring.demo.client.CallClient.java
public static void main(String[] args) throws InterruptedException { WebSocketClient webSocketClient = new StandardWebSocketClient(); JsonFactory jsonFactory = new MappingJsonFactory(new ObjectMapper()); CountDownLatch latch = new CountDownLatch(1_000_000); TestTextWebSocketHandler handler = new TestTextWebSocketHandler(jsonFactory, latch); Long[] start = new Long[1]; ListenableFuture<WebSocketSession> future = webSocketClient.doHandshake(handler, "ws://localhost:8080/wamp"); future.addCallback(wss -> {//from w w w .ja v a 2 s . c om start[0] = System.currentTimeMillis(); for (int i = 0; i < 1_000_000; i++) { CallMessage callMessage = new CallMessage(UUID.randomUUID().toString(), "testService.sum", i, i + 1); try { wss.sendMessage(new TextMessage(callMessage.toJson(jsonFactory))); } catch (Exception e) { System.out.println("ERROR SENDING CALLMESSAGE" + e); latch.countDown(); } } }, t -> { System.out.println("DO HANDSHAKE ERROR: " + t); System.exit(1); }); if (!latch.await(3, TimeUnit.MINUTES)) { System.out.println("SOMETHING WENT WRONG"); } System.out.println((System.currentTimeMillis() - start[0]) / 1000 + " seconds"); System.out.println("SUCCESS: " + handler.getSuccess()); System.out.println("ERROR : " + handler.getError()); }
From source file:com.stehno.sanctuary.core.Sanctuary.java
public static void main(String[] args) throws Exception { log.info("Starting run..."); JdbcTemplate jdbcTemplate = new JdbcTemplate(createDataSource()); // FIXME: AndroidLocalStore LocalStore localStore = new JdbcLocalStore(jdbcTemplate); localStore.init();/* w w w.j ava 2s .c o m*/ // FIXME: FileSystemRemoteStore, S3RemoteStore, AndroidS3LocalStore? // FIXME: remote keys RemoteStore remoteStore = new S3RemoteStore("yourkey", "yourotherkey"); remoteStore.init(); DirectoryScanner scanner = new DefaultDirectoryScanner(localStore); ExecutorService executor = new ThreadPoolExecutor(2, 2, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>()); FileArchiver archiver = new DefaultFileArchiver(executor, localStore, remoteStore); ChangeSet changeSet = scanner.scanDirectory(WORKING_DIR); // FIXME: allow review of changeset here (confirm/cancel) log.info("Changes: " + changeSet); MessageSet messageSet = archiver.archiveChanges(changeSet); // FIXME: allow review of messages here log.info("Messages" + messageSet); remoteStore.destroy(); localStore.destroy(); }
From source file:com.pinterest.terrapin.thrift.TerrapinThriftMain.java
public static void main(String[] args) throws Exception { final PropertiesConfiguration config = TerrapinUtil.readPropertiesExitOnFailure( System.getProperties().getProperty("terrapin.config", "thrift.properties")); OstrichStatsReceiver statsReceiver = new OstrichStatsReceiver(Stats.get("")); int listenPort = config.getInt("thrift_port", 9090); TerrapinServiceImpl serviceImpl = new TerrapinServiceImpl(config, (List) config.getList("cluster_list")); Service<byte[], byte[]> service = new TerrapinService.Service(serviceImpl, new TBinaryProtocol.Factory()); Server server = ServerBuilder.safeBuild(service, ServerBuilder.get().name("TERRAPIN_THRIFT").codec(ThriftServerFramedCodec.get()) .hostConnectionMaxIdleTime(Duration.apply(1, TimeUnit.MINUTES)).maxConcurrentRequests(3000) .reportTo(statsReceiver).bindTo(new InetSocketAddress(listenPort))); new OstrichAdminService(config.getInt(Constants.OSTRICH_METRICS_PORT, 9999)).start(); LOG.info("\n#######################################" + "\n# Ready To Serve Requests. #" + "\n#######################################"); }
From source file:ch.rasc.wampspring.demo.client.Subscriber.java
public static void main(String[] args) throws InterruptedException { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( Subscriber.class)) { if (!latch.await(3, TimeUnit.MINUTES)) { System.out.println("SOMETHING WENT WRONG"); }// w w w . j av a 2 s .c o m System.out.println("THE END"); } }
From source file:net.sf.sessionAnalysis.SessionAnalyzer.java
public static void main(String[] args) throws IOException { final SessionDatReader sessionDatReader = new SessionDatReader(INPUT_SESSIONS_DAT_FN); final SessionVisitorSessionLengthNumActionsStatistics sessionVisitorSessionLengthStatistics = new SessionVisitorSessionLengthNumActionsStatistics(); sessionDatReader.registerVisitor(sessionVisitorSessionLengthStatistics); final SessionVisitorSessionLengthNanosStatistics sessionVisitorSessionLengthNanosStatistics = new SessionVisitorSessionLengthNanosStatistics(); sessionDatReader.registerVisitor(sessionVisitorSessionLengthNanosStatistics); final SessionVisitorMinMaxTimeStamp sessionVisitorMinMaxTimeStamp = new SessionVisitorMinMaxTimeStamp(); sessionDatReader.registerVisitor(sessionVisitorMinMaxTimeStamp); final SessionVisitorResponseTimes sessionVisitorResponseTimes = new SessionVisitorResponseTimes(); sessionDatReader.registerVisitor(sessionVisitorResponseTimes); final SessionVisitorArrivalAndCompletionRate sessionVisitorArrivalAndCompletionRate = new SessionVisitorArrivalAndCompletionRate( 1, TimeUnit.MINUTES); sessionDatReader.registerVisitor(sessionVisitorArrivalAndCompletionRate); SessionVisitorRequestTypeCounter sessionVisitorRequestTypeCounter = new SessionVisitorRequestTypeCounter(); sessionDatReader.registerVisitor(sessionVisitorRequestTypeCounter); final SessionVisitorDistinctSessions sessionVisitorDistinctSessions = new SessionVisitorDistinctSessions(); sessionDatReader.registerVisitor(sessionVisitorDistinctSessions); final SessionVisitorBehaviorMix sessionVisitorBehaviorMix = new SessionVisitorBehaviorMix(); sessionDatReader.registerVisitor(sessionVisitorBehaviorMix); sessionDatReader.read();//from ww w .j av a2 s.c o m /* * Session length histogram. Results can be compared analysis on raw * data: cat * ../evaluation/SPECjEnterprise-data/kieker-20110929-14382537- * UTC-blade3-KIEKER-SPECjEnterprise2010-20-min-excerpt-sessions.dat | * awk -F ";" '{print NF-1}' | sort -n | uniq -c | wc -l */ System.out.println( "Num sessions: " + sessionVisitorArrivalAndCompletionRate.getCompletionTimestamps().length); System.out.println("Num distinct sessions: " + sessionVisitorDistinctSessions.numDistinctSessions()); System.out .println("Length histogram: " + sessionVisitorSessionLengthStatistics.getSessionLengthHistogram()); sessionVisitorSessionLengthStatistics.writeSessionsOverTime(OUTPUT_DIR); //System.out.println("Length vector: " + ArrayUtils.toString(sessionVisitorSessionLengthStatistics.computeLengthVector())); System.out.println("Mean length (# user actions): " + sessionVisitorSessionLengthStatistics.computeSessionLengthMean()); System.out.println("Standard dev (# user actions): " + sessionVisitorSessionLengthStatistics.computeSessionLengthStdDev()); sessionVisitorSessionLengthNanosStatistics.writeSessionsOverTime(OUTPUT_DIR); System.out.println("Mean length (milliseconds): " + TimeUnit.MILLISECONDS.convert( (long) sessionVisitorSessionLengthNanosStatistics.computeSessionLengthMean(), TimeUnit.NANOSECONDS)); System.out.println("Standard dev (milliseconds): " + TimeUnit.MILLISECONDS.convert( (long) sessionVisitorSessionLengthNanosStatistics.computeSessionLengthStdDev(), TimeUnit.NANOSECONDS)); System.out.println( "Average Session Duration: " + sessionVisitorMinMaxTimeStamp.getAverageSessionTimeLength()); System.out.println("Timespan (nanos since epoche): " + sessionVisitorMinMaxTimeStamp.getMinTimeStamp() + " - " + sessionVisitorMinMaxTimeStamp.getMaxTimeStamp()); System.out.println("Timespan (local date/time): " + sessionVisitorMinMaxTimeStamp.getMinDateTime() + " - " + sessionVisitorMinMaxTimeStamp.getMaxDateTime()); { System.out.println("Arrival rates: " + ArrayUtils.toString(sessionVisitorArrivalAndCompletionRate.getArrivalRates())); System.out.println("Session duration rates: " + ArrayUtils.toString(sessionVisitorArrivalAndCompletionRate.getSessionDuration())); System.out.println("User action rates: " + ArrayUtils.toString(sessionVisitorArrivalAndCompletionRate.getUserActionRates())); System.out.println("Completion rates: " + ArrayUtils.toString(sessionVisitorArrivalAndCompletionRate.getCompletionRates())); System.out.println("Max number of sessions per time interval: " + ArrayUtils.toString(sessionVisitorArrivalAndCompletionRate.getMaxNumSessionsPerInterval())); sessionVisitorArrivalAndCompletionRate.writeArrivalCompletionRatesAndMaxNumSessions(OUTPUT_DIR); } { //System.out.println("Concurrent number of sessions over time" + sessionVisitorArrivalAndCompletionRate.getNumConcurrentSessionsOverTime()); sessionVisitorArrivalAndCompletionRate.writeSessionsOverTime(OUTPUT_DIR); } { sessionVisitorRequestTypeCounter.writeCallFrequencies(OUTPUT_DIR); } { sessionVisitorDistinctSessions.writeDistinctSessions(OUTPUT_DIR); } sessionVisitorResponseTimes.printResponseTimes(); sessionVisitorBehaviorMix.printRequestTypes(); }
From source file:at.tfr.securefs.client.SecurefsFileServiceClient.java
public static void main(String[] args) throws Exception { SecurefsFileServiceClient client = new SecurefsFileServiceClient(); try {/* ww w. j a v a2s . c om*/ client.parse(args); if (client.asyncTest) { ExecutorService executor = Executors.newFixedThreadPool(client.threads); for (int i = 0; i < client.threads; i++) { executor.submit(client); } executor.shutdown(); executor.awaitTermination(10, TimeUnit.MINUTES); } else { client.run(); } } catch (Throwable e) { HelpFormatter hf = new HelpFormatter(); hf.printHelp(SecurefsFileServiceClient.class.getSimpleName(), client.options); e.printStackTrace(); } }
From source file:fi.vrk.xroad.catalog.collector.XRoadCatalogCollector.java
public static void main(String[] args) throws Exception { ApplicationContext context = SpringApplication.run(XRoadCatalogCollector.class, args); ActorSystem system = context.getBean(ActorSystem.class); final LoggingAdapter log = Logging.getLogger(system, "Application"); Long collectorInterval = (Long) context.getBean("getCollectorInterval"); log.info("Starting up catalog collector with collector interval of {}", collectorInterval); SpringExtension ext = context.getBean(SpringExtension.class); // Use the Spring Extension to create props for a named actor bean ActorRef supervisor = system.actorOf(ext.props("supervisor")); system.scheduler().schedule(Duration.Zero(), Duration.create(collectorInterval, TimeUnit.MINUTES), supervisor, Supervisor.START_COLLECTING, system.dispatcher(), null); }