Package org.elasticsearch.common

Examples of org.elasticsearch.common.StopWatch$TaskInfo


        Thread.sleep(10000);
        try {
            client.admin().indices().create(createIndexRequest("test")).actionGet();

            StopWatch stopWatch = new StopWatch().start();

            System.out.println("--> Indexing [" + COUNT + "] ...");
            long ITERS = COUNT / BATCH;
            long i = 1;
            int counter = 0;
            for (; i <= ITERS; i++) {
                BulkRequestBuilder request = client.prepareBulk();
                for (int j = 0; j < BATCH; j++) {
                    counter++;

                    XContentBuilder builder = jsonBuilder().startObject();
                    builder.field("id", Integer.toString(counter));
                    builder.field("l_value", lValues[counter % lValues.length]);

                    builder.endObject();

                    request.add(Requests.indexRequest("test").type("type1").id(Integer.toString(counter))
                            .source(builder));
                }
                BulkResponse response = request.execute().actionGet();
                if (response.hasFailures()) {
                    System.err.println("--> failures...");
                }
                if (((i * BATCH) % 10000) == 0) {
                    System.out.println("--> Indexed " + (i * BATCH) + " took " + stopWatch.stop().lastTaskTime());
                    stopWatch.start();
                }
            }
            System.out.println("--> Indexing took " + stopWatch.totalTime() + ", TPS " + (((double) (COUNT)) / stopWatch.totalTime().secondsFrac()));
        } catch (Exception e) {
            System.out.println("--> Index already exists, ignoring indexing phase, waiting for green");
            ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().setTimeout("10m").execute().actionGet();
            if (clusterHealthResponse.timedOut()) {
                System.err.println("--> Timed out waiting for cluster health");
View Full Code Here


    /**
     * Are timings off in JUnit?
     */
    @Test public void testValidUsage() throws Exception {
        StopWatch sw = new StopWatch();
        long int1 = 166L;
        long int2 = 45L;
        String name1 = "Task 1";
        String name2 = "Task 2";

        long fudgeFactor = 5L;
        assertThat(sw.isRunning(), equalTo(false));
        sw.start(name1);
        Thread.sleep(int1);
        assertThat(sw.isRunning(), equalTo(true));
        sw.stop();

        // TODO are timings off in JUnit? Why do these assertions sometimes fail
        // under both Ant and Eclipse?

        //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() >= int1);
        //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() <= int1 + fudgeFactor);
        sw.start(name2);
        Thread.sleep(int2);
        sw.stop();
        //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() >= int1 + int2);
        //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() <= int1 + int2 + fudgeFactor);

        assertThat(sw.taskCount(), equalTo(2));
        String pp = sw.prettyPrint();
        assertThat(pp.indexOf(name1) != -1, equalTo(true));
        assertThat(pp.indexOf(name2) != -1, equalTo(true));

        StopWatch.TaskInfo[] tasks = sw.taskInfo();
        assertThat(tasks.length, equalTo(2));
        assertThat(tasks[0].getTaskName(), equalTo(name1));
        assertThat(tasks[1].getTaskName(), equalTo(name2));
        sw.toString();
    }
View Full Code Here

        assertThat(tasks[1].getTaskName(), equalTo(name2));
        sw.toString();
    }

    @Test public void testValidUsageNotKeepingTaskList() throws Exception {
        StopWatch sw = new StopWatch().keepTaskList(false);
        long int1 = 166L;
        long int2 = 45L;
        String name1 = "Task 1";
        String name2 = "Task 2";

        long fudgeFactor = 5L;
        assertThat(sw.isRunning(), equalTo(false));
        sw.start(name1);
        Thread.sleep(int1);
        assertThat(sw.isRunning(), equalTo(true));
        sw.stop();

        // TODO are timings off in JUnit? Why do these assertions sometimes fail
        // under both Ant and Eclipse?

        //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() >= int1);
        //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() <= int1 + fudgeFactor);
        sw.start(name2);
        Thread.sleep(int2);
        sw.stop();
        //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() >= int1 + int2);
        //assertTrue("Unexpected timing " + sw.getTotalTime(), sw.getTotalTime() <= int1 + int2 + fudgeFactor);

        assertThat(sw.taskCount(), equalTo(2));
        String pp = sw.prettyPrint();
        assertThat(pp.indexOf("kept"), not(equalTo(-1)));
        sw.toString();

        try {
            sw.taskInfo();
            assertThat(false, equalTo(true));
        } catch (UnsupportedOperationException ex) {
            // Ok
        }
    }
View Full Code Here

            // Ok
        }
    }

    @Test public void testFailureToStartBeforeGettingTimings() {
        StopWatch sw = new StopWatch();
        try {
            sw.lastTaskTime();
            assertThat("Can't get last interval if no tests run", false, equalTo(true));
        } catch (IllegalStateException ex) {
            // Ok
        }
    }
View Full Code Here

            // Ok
        }
    }

    @Test public void testFailureToStartBeforeStop() {
        StopWatch sw = new StopWatch();
        try {
            sw.stop();
            assertThat("Can't stop without starting", false, equalTo(true));
        } catch (IllegalStateException ex) {
            // Ok
        }
    }
View Full Code Here

            // Ok
        }
    }

    @Test public void testRejectsStartTwice() {
        StopWatch sw = new StopWatch();
        try {
            sw.start("");
            sw.stop();
            sw.start("");
            assertThat(sw.isRunning(), equalTo(true));
            sw.start("");
            assertThat("Can't start twice", false, equalTo(true));
        } catch (IllegalStateException ex) {
            // Ok
        }
    }
View Full Code Here

                            .endObject())
                    .setRefresh(true)
                    .execute().actionGet();
        }

        StopWatch stopWatch = new StopWatch().start();
        System.out.println("Percolating [" + COUNT + "] ...");
        int i = 1;
        for (; i <= COUNT; i++) {
            PercolateResponse percolate = client1.preparePercolate("test", "type1").setSource(source(Integer.toString(i), "value"))
                    .execute().actionGet();
            if (percolate.matches().size() != QUERIES) {
                System.err.println("No matching number of queries");
            }
            if ((i % 10000) == 0) {
                System.out.println("Percolated " + i + " took " + stopWatch.stop().lastTaskTime());
                stopWatch.start();
            }
        }
        System.out.println("Percolation took " + stopWatch.totalTime() + ", TPS " + (((double) COUNT) / stopWatch.totalTime().secondsFrac()));

        client.close();

        for (Node node : nodes) {
            node.close();
View Full Code Here

            percolatorExecutor.addQuery("test" + i, termQuery("field3", "quick"));
        }


        System.out.println("Warming Up (1000)");
        StopWatch stopWatch = new StopWatch().start();
        System.out.println("Running " + 1000);
        for (long i = 0; i < 1000; i++) {
            percolate = percolatorExecutor.percolate(new PercolatorExecutor.SourceRequest("type1", source));
        }
        System.out.println("[Warmup] Percolated in " + stopWatch.stop().totalTime() + " TP Millis " + (NUMBER_OF_ITERATIONS / stopWatch.totalTime().millisFrac()));

        System.out.println("Percolating using " + NUMBER_OF_THREADS + " threads with " + NUMBER_OF_ITERATIONS + " iterations, and " + NUMBER_OF_QUERIES + " queries");
        final CountDownLatch latch = new CountDownLatch(NUMBER_OF_THREADS);
        Thread[] threads = new Thread[NUMBER_OF_THREADS];
        for (int i = 0; i < threads.length; i++) {
            threads[i] = new Thread(new Runnable() {
                @Override public void run() {
                    for (long i = 0; i < NUMBER_OF_ITERATIONS; i++) {
                        PercolatorExecutor.Response percolate = percolatorExecutor.percolate(new PercolatorExecutor.SourceRequest("type1", source));
                    }
                    latch.countDown();
                }
            });
        }
        stopWatch = new StopWatch().start();
        for (Thread thread : threads) {
            thread.start();
        }
        latch.await();
        stopWatch.stop();
        System.out.println("Percolated in " + stopWatch.totalTime() + " TP Millis " + ((NUMBER_OF_ITERATIONS * NUMBER_OF_THREADS) / stopWatch.totalTime().millisFrac()));

    }
View Full Code Here

        }

        ESLogger logger = Loggers.getLogger(Node.class, settings.get("name"));
        logger.info("{{}}[{}]: closing ...", Version.full(), JvmInfo.jvmInfo().pid());

        StopWatch stopWatch = new StopWatch("node_close");
        stopWatch.start("http");
        if (settings.getAsBoolean("http.enabled", true)) {
            injector.getInstance(HttpServer.class).close();
        }
        stopWatch.stop().start("client");
        injector.getInstance(Client.class).close();
        stopWatch.stop().start("indices_cluster");
        injector.getInstance(IndicesClusterStateService.class).close();
        stopWatch.stop().start("indices");
        injector.getInstance(IndicesNodeFilterCache.class).close();
        injector.getInstance(IndexingMemoryBufferController.class).close();
        injector.getInstance(IndicesService.class).close();
        stopWatch.stop().start("routing");
        injector.getInstance(RoutingService.class).close();
        stopWatch.stop().start("cluster");
        injector.getInstance(ClusterService.class).close();
        stopWatch.stop().start("discovery");
        injector.getInstance(DiscoveryService.class).close();
        stopWatch.stop().start("monitor");
        injector.getInstance(MonitorService.class).close();
        stopWatch.stop().start("gateway");
        injector.getInstance(GatewayService.class).close();
        stopWatch.stop().start("search");
        injector.getInstance(SearchService.class).close();
        stopWatch.stop().start("indexers");
        injector.getInstance(RiversManager.class).close();
        stopWatch.stop().start("rest");
        injector.getInstance(RestController.class).close();
        stopWatch.stop().start("transport");
        injector.getInstance(TransportService.class).close();

        for (Class<? extends LifecycleComponent> plugin : pluginsService.services()) {
            stopWatch.stop().start("plugin(" + plugin.getName() + ")");
            injector.getInstance(plugin).close();
        }

        stopWatch.stop().start("node_cache");
        injector.getInstance(NodeCache.class).close();

        stopWatch.stop().start("script");
        injector.getInstance(ScriptService.class).close();

        stopWatch.stop().start("thread_pool");
        injector.getInstance(ThreadPool.class).shutdown();
        try {
            injector.getInstance(ThreadPool.class).awaitTermination(10, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            // ignore
        }
        stopWatch.stop().start("thread_pool_force_shutdown");
        try {
            injector.getInstance(ThreadPool.class).shutdownNow();
        } catch (Exception e) {
            // ignore
        }
        stopWatch.stop();

        CacheRecycler.clear();
        CachedStreams.clear();
        ThreadLocals.clearReferencesThreadLocals();

        if (logger.isTraceEnabled()) {
            logger.trace("Close times for each service:\n{}", stopWatch.prettyPrint());
        }

        injector.getInstance(NodeEnvironment.class).close();
        Injectors.close(injector);
View Full Code Here

    @Override public void performStateRecovery(final GatewayStateRecoveredListener listener) throws GatewayException {
        threadPool.cached().execute(new Runnable() {
            @Override public void run() {
                logger.debug("reading state from gateway {} ...", this);
                StopWatch stopWatch = new StopWatch().start();
                MetaData metaData;
                try {
                    metaData = read();
                    logger.debug("read state from gateway {}, took {}", this, stopWatch.stop().totalTime());
                    if (metaData == null) {
                        logger.debug("no state read from gateway");
                        listener.onSuccess(ClusterState.builder().build());
                    } else {
                        listener.onSuccess(ClusterState.builder().metaData(metaData).build());
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.StopWatch$TaskInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.