List of usage examples for org.springframework.util StopWatch getLastTaskTimeMillis
public long getLastTaskTimeMillis() throws IllegalStateException
From source file:test.node.TestNodeWorker.java
public static void main(String[] args) { try {//from ww w. j ava2 s . co m log.info("GridNode Starting..."); StopWatch sw = new StopWatch(); sw.start(); // Start Grid Node GridNode node = Grid.startGridNode(); sw.stop(); log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]"); log.info("GridNode ID : " + node.getId()); log.debug("Press any key to unregister GridNode and terminate"); System.in.read(); node.getNodeRegistrationService().unregister(); log.info("Unregistered, Terminating..."); System.exit(0); } catch (Exception e) { e.printStackTrace(); } }
From source file:test.node.TestUnboudedJobRunner.java
public static void main(String[] args) { // Test Job//from ww w . j a va 2 s . co m TestUnboundedJob testJob = new TestUnboundedJob(); try { log.info("GridNode Starting..."); StopWatch sw = new StopWatch(); sw.start(); GridNode node = Grid.startGridNode(); log.info("GridNode ID : " + node.getId()); sw.stop(); log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]"); // Submit Job log.debug("Submitting Job"); sw.start(); GridJobFuture future = node.getJobSubmissionService().submitJob(testJob, new ResultCallback() { public void onResult(Serializable result) { System.err.println(result); } }); while (!future.isJobFinished()) { Thread.sleep(1000); } sw.stop(); log.info("GridJob Finished. Duration " + sw.getLastTaskTimeMillis() + " ms"); log.debug("Press any key to unregister GridNode and terminate"); System.in.read(); node.getNodeRegistrationService().unregister(); log.info("Unregistered, Terminating..."); System.exit(0); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:test.node.TestNodeNARRunner.java
public static void main(String[] args) { try {/*www . j a v a2 s .c o m*/ log.info("GridNode Starting..."); StopWatch sw = new StopWatch(); sw.start(); GridNode node = Grid.startGridNode(); log.info("GridNode ID : " + node.getId()); sw.stop(); log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]"); // Submit Job log.debug("Reading NAR"); sw.start(); GridArchive archive; archive = GridArchive.fromFile(new File("simpletestjob.nar")); log.debug("Submitting NAR"); GridJobFuture future = (GridJobFuture) node.getJobSubmissionService().submitArchive(archive).values() .toArray()[0]; try { log.info("RESULT : " + future.getResult()); } catch (RemoteInvocationFailureException e) { e.getCause().printStackTrace(); } sw.stop(); log.info("GridJob Finished. Duration " + sw.getLastTaskTimeMillis() + " ms"); log.debug("Press any key to unregister GridNode and terminate"); System.in.read(); node.getNodeRegistrationService().unregister(); log.info("Unregistered, Terminating..."); System.exit(0); } catch (GridArchiveException e) { log.fatal("GridArchiveException", e); } catch (GridExecutionException e) { log.fatal("Execution Failed", e); } catch (IOException e) { log.error("IOException", e); } }
From source file:test.node.TestNodeRunner.java
public static void main(String[] args) { // Test Job/* w w w .jav a 2s . c om*/ TestJob testJob = new TestJob(); try { log.info("GridNode Starting..."); StopWatch sw = new StopWatch(); sw.start(); GridNode node = Grid.startGridNode(); log.info("GridNode ID : " + node.getId()); sw.stop(); log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]"); // Submit Job log.debug("Submitting Job"); sw.start(); GridJobFuture future = node.getJobSubmissionService().submitJob(testJob, new ResultCallback() { public void onResult(Serializable result) { System.err.println(result); } }); try { log.info("Job Result : " + future.getResult()); } catch (RemoteInvocationFailureException e) { e.getCause().printStackTrace(); } sw.stop(); log.info("GridJob Finished. Duration " + sw.getLastTaskTimeMillis() + " ms"); log.debug("Press any key to unregister GridNode and terminate"); System.in.read(); node.getNodeRegistrationService().unregister(); log.info("Unregistered, Terminating..."); System.exit(0); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:test.mandelbrot.SequentialMandelbrotApp.java
public static void main(String[] args) { log.info("Starting Sequential Mandelbrot Application"); // Create App Instance SequentialMandelbrotApp app = new SequentialMandelbrotApp(); app.requestFocus();//w w w. j a v a2 s . c om StopWatch sw = new StopWatch(); log.info("Starting Computation..."); sw.start(); // Start Rendering app.startRendering(); sw.stop(); log.info("Computation Complete... " + sw.getLastTaskTimeMillis() + "ms"); //System.exit(0); }
From source file:test.mandelbrot.MandelbrotApp.java
public static void main(String[] args) { try {/*from w w w. ja v a 2 s. com*/ log.info("GridNode Starting..."); StopWatch sw = new StopWatch(); sw.start(); GridNode node = Grid.startLightGridNode(); log.info("GridNode ID : " + node.getId()); sw.stop(); log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]"); // Create App Instance final MandelbrotApp app = new MandelbrotApp(node); app.requestFocus(); // Create Mandelbrot Job MandelbrotJob mandelbrotJob = new MandelbrotJob(app.getWidth(), app.getHeight()); // Start Job Submission sw.start(); GridJobFuture future = node.getJobSubmissionService().submitJob(mandelbrotJob, new ResultCallback() { public void onResult(Serializable result) { MandelbrotResult mResult = (MandelbrotResult) result; app.displayResult(mResult); app.setProgress(app.getProgress() + mResult.getLines()); } }); app.setFuture(future); // Block till job finishes future.getResult(); app.setDone(true); sw.stop(); log.info("GridJob Finished. Duration " + sw.getLastTaskTimeMillis() + " ms"); log.debug("Press any key to unregister GridNode and terminate"); System.in.read(); node.getNodeRegistrationService().unregister(); } catch (Exception e) { e.printStackTrace(); } }
From source file:test.buddhabrot.BuddhabrotApp.java
public static void main(String[] args) { log.info("GridNode Starting..."); StopWatch sw = new StopWatch(); sw.start();/* w w w . java2s. co m*/ GridNode node = Grid.startLightGridNode(); log.info("GridNode ID : " + node.getId()); log.info("Registered in Cluster : " + node.getNodeRegistrationService().getRegistration().getClusterId()); sw.stop(); log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis() + " ms]"); // Create App Instance final BuddhabrotApp app = new BuddhabrotApp(node); app.requestFocus(); // Create Buddhabrot Job BuddhabrotJob buddhabrotJob = new BuddhabrotJob(WIDTH, HEIGHT); // Start Job Submission sw.start(); System.err.println(new Date()); GridJobFuture future = node.getJobSubmissionService().submitJob(buddhabrotJob, new ResultCallback() { public void onResult(Serializable result) { log.debug("CALLBACK"); if (result == null) return; if (result instanceof int[][]) { app.onResult((int[][]) result); } } }); app.setFuture(future); }
From source file:org.tommy.stationery.moracle.core.client.load.StompWebSocketLoadTestClient.java
public static void main(String[] args) throws Exception { // Modify host and port below to match wherever StompWebSocketServer.java is running!! // When StompWebSocketServer starts it prints the selected available String host = "localhost"; if (args.length > 0) { host = args[0];/* w ww. j a v a 2 s. co m*/ } int port = 59984; if (args.length > 1) { port = Integer.valueOf(args[1]); } String url = "http://" + host + ":" + port + "/home"; logger.debug("Sending warm-up HTTP request to " + url); HttpStatus status = new RestTemplate().getForEntity(url, Void.class).getStatusCode(); Assert.state(status == HttpStatus.OK); final CountDownLatch connectLatch = new CountDownLatch(NUMBER_OF_USERS); final CountDownLatch subscribeLatch = new CountDownLatch(NUMBER_OF_USERS); final CountDownLatch messageLatch = new CountDownLatch(NUMBER_OF_USERS); final CountDownLatch disconnectLatch = new CountDownLatch(NUMBER_OF_USERS); final AtomicReference<Throwable> failure = new AtomicReference<Throwable>(); Executor executor = Executors.newFixedThreadPool(THREAD_POOL_SIZE); org.eclipse.jetty.websocket.client.WebSocketClient jettyClient = new WebSocketClient(executor); JettyWebSocketClient webSocketClient = new JettyWebSocketClient(jettyClient); webSocketClient.start(); HttpClient jettyHttpClient = new HttpClient(); jettyHttpClient.setMaxConnectionsPerDestination(1000); jettyHttpClient.setExecutor(new QueuedThreadPool(1000)); jettyHttpClient.start(); List<Transport> transports = new ArrayList<>(); transports.add(new WebSocketTransport(webSocketClient)); transports.add(new JettyXhrTransport(jettyHttpClient)); SockJsClient sockJsClient = new SockJsClient(transports); try { URI uri = new URI("ws://" + host + ":" + port + "/stomp"); WebSocketStompClient stompClient = new WebSocketStompClient(uri, null, sockJsClient); stompClient.setMessageConverter(new StringMessageConverter()); logger.debug("Connecting and subscribing " + NUMBER_OF_USERS + " users "); StopWatch stopWatch = new StopWatch("STOMP Broker Relay WebSocket Load Tests"); stopWatch.start(); List<ConsumerStompMessageHandler> consumers = new ArrayList<>(); for (int i = 0; i < NUMBER_OF_USERS; i++) { consumers.add(new ConsumerStompMessageHandler(BROADCAST_MESSAGE_COUNT, connectLatch, subscribeLatch, messageLatch, disconnectLatch, failure)); stompClient.connect(consumers.get(i)); } if (failure.get() != null) { throw new AssertionError("Test failed", failure.get()); } if (!connectLatch.await(5000, TimeUnit.MILLISECONDS)) { logger.info("Not all users connected, remaining: " + connectLatch.getCount()); } if (!subscribeLatch.await(5000, TimeUnit.MILLISECONDS)) { logger.info("Not all users subscribed, remaining: " + subscribeLatch.getCount()); } stopWatch.stop(); logger.debug("Finished: " + stopWatch.getLastTaskTimeMillis() + " millis"); logger.debug("Broadcasting " + BROADCAST_MESSAGE_COUNT + " messages to " + NUMBER_OF_USERS + " users "); stopWatch.start(); ProducerStompMessageHandler producer = new ProducerStompMessageHandler(BROADCAST_MESSAGE_COUNT, failure); stompClient.connect(producer); if (failure.get() != null) { throw new AssertionError("Test failed", failure.get()); } if (!messageLatch.await(1 * 60 * 1000, TimeUnit.MILLISECONDS)) { for (ConsumerStompMessageHandler consumer : consumers) { if (consumer.messageCount.get() < consumer.expectedMessageCount) { logger.debug(consumer); } } } if (!messageLatch.await(1 * 60 * 1000, TimeUnit.MILLISECONDS)) { logger.info("Not all handlers received every message, remaining: " + messageLatch.getCount()); } producer.session.disconnect(); if (!disconnectLatch.await(5000, TimeUnit.MILLISECONDS)) { logger.info("Not all disconnects completed, remaining: " + disconnectLatch.getCount()); } stopWatch.stop(); logger.debug("Finished: " + stopWatch.getLastTaskTimeMillis() + " millis"); System.out.println("\nPress any key to exit..."); System.in.read(); } catch (Throwable t) { t.printStackTrace(); } finally { webSocketClient.stop(); jettyHttpClient.stop(); } logger.debug("Exiting"); System.exit(0); }
From source file:org.nebulaframework.grid.Grid.java
/** * Starts a {@link GridNode} with default settings, read from * default properties file.//from ww w.j av a 2 s. co m * * @param useConfigDiscovery indicates whether to use information * from configuration to discover * * @return GridNode * * @throws IllegalStateException if a Grid Member (Cluster / Node) has * already started with in the current VM. Nebula supports only one Grid * Member per VM. */ public synchronized static GridNode startGridNode(boolean useConfigDiscovery) throws IllegalStateException { if (isInitialized()) { // A Grid Member has already started in this VM throw new IllegalStateException("A Grid Memeber Already Started in VM"); } initializeDefaultExceptionHandler(); StopWatch sw = new StopWatch(); try { sw.start(); // Set Security Manager System.setSecurityManager(new SecurityManager()); // Detect Configuration Properties config = ConfigurationSupport.detectNodeConfiguration(); log.info("GridNode Attempting Discovery..."); // Discover Cluster If Needed GridNodeDiscoverySupport.discover(config, useConfigDiscovery); checkJMSBroker(config.getProperty(ConfigurationKeys.CLUSTER_SERVICE.value())); log.debug("Starting up Spring Container..."); applicationContext = new NebulaApplicationContext(GRIDNODE_CONTEXT, config); log.debug("Spring Container Started"); node = true; sw.stop(); log.info("GridNode Started Up. " + sw.getLastTaskTimeMillis() + " ms"); return (GridNode) applicationContext.getBean("localNode"); } finally { if (sw.isRunning()) { sw.stop(); } } }
From source file:org.nebulaframework.grid.Grid.java
/** * Starts {@link ClusterManager} instance with default settings, * read from default properties file./*from w w w.j a va 2 s . co m*/ * * @return ClusterManager * * @throws IllegalStateException if a Grid Member (Cluster / Node) has * already started with in the current VM. Nebula supports only one Grid * Member per VM. */ public synchronized static ClusterManager startClusterManager() throws IllegalStateException { if (isInitialized()) { // A Grid Member has already started in this VM throw new IllegalStateException("A Grid Memeber Already Started in VM"); } initializeDefaultExceptionHandler(); StopWatch sw = new StopWatch(); try { sw.start(); log.info("ClusterManager Starting..."); // Set Security Manager System.setSecurityManager(new SecurityManager()); // Detect Configuration Properties config = ConfigurationSupport.detectClusterConfiguration(); // Register with any Colombus Servers ClusterDiscoverySupport.registerColombus(config); clusterManager = true; log.debug("Starting up Spring Container..."); applicationContext = new NebulaApplicationContext(CLUSTER_SPRING_CONTEXT, config); log.debug("Spring Container Started"); return (ClusterManager) applicationContext.getBean("clusterManager"); } finally { sw.stop(); log.info("ClusterManager Started Up. " + sw.getLastTaskTimeMillis() + " ms"); } }