Package org.elasticsearch.cluster.metadata

Examples of org.elasticsearch.cluster.metadata.BenchmarkMetaData


        }

        @Override
        public ClusterState execute(ClusterState currentState) {
            MetaData metaData = currentState.getMetaData();
            BenchmarkMetaData bmd = metaData.custom(BenchmarkMetaData.TYPE);
            MetaData.Builder mdBuilder = MetaData.builder(metaData);
            if (bmd != null && !bmd.entries().isEmpty()) {
                ImmutableList.Builder<BenchmarkMetaData.Entry> builder = new ImmutableList.Builder<BenchmarkMetaData.Entry>();
                for (BenchmarkMetaData.Entry e : bmd.entries()) {
                    if (benchmarkId == null || match(e)) {
                        e = process(e);
                        instances.add(e);
                    }
                    // Don't keep finished benchmarks around in cluster state
                    if (e != null && (e.state() != BenchmarkMetaData.State.SUCCESS &&
                            e.state() != BenchmarkMetaData.State.ABORTED &&
                            e.state() != BenchmarkMetaData.State.FAILED)) {
                        builder.add(e);
                    }
                }
                if (instances.isEmpty()) {
                    throw new ElasticsearchException("No Benchmark found for id: [" + benchmarkId + "]");
                }
                bmd = new BenchmarkMetaData(builder.build());
            }
            if (bmd != null) {
                mdBuilder.putCustom(BenchmarkMetaData.TYPE, bmd);
            }
            return ClusterState.builder(currentState).metaData(mdBuilder).build();
View Full Code Here


        }

        @Override
        public ClusterState execute(ClusterState currentState) {
            MetaData metaData = currentState.getMetaData();
            BenchmarkMetaData bmd = metaData.custom(BenchmarkMetaData.TYPE);
            MetaData.Builder mdBuilder = MetaData.builder(metaData);
            ImmutableList.Builder<BenchmarkMetaData.Entry> builder = ImmutableList.builder();

            if (bmd != null) {
                for (BenchmarkMetaData.Entry entry : bmd.entries()) {
                    if (request.benchmarkName().equals(entry.benchmarkId())) {
                        if (entry.state() != BenchmarkMetaData.State.SUCCESS && entry.state() != BenchmarkMetaData.State.FAILED) {
                            throw new ElasticsearchException("A benchmark with ID [" + request.benchmarkName() + "] is already running in state [" + entry.state() + "]");
                        }
                        // just drop the entry it it has finished successfully or it failed!
                    } else {
                        builder.add(entry);
                    }
                }
            }
            List<DiscoveryNode> nodes = findNodes(request);
            String[] nodeIds = new String[nodes.size()];
            int i = 0;
            for (DiscoveryNode node : nodes) {
                nodeIds[i++] = node.getId();
            }
            BenchmarkMetaData.Entry entry = new BenchmarkMetaData.Entry(request.benchmarkName(), BenchmarkMetaData.State.STARTED, nodeIds);
            newBenchmark.add(entry);
            bmd = new BenchmarkMetaData(builder.add(entry).build());
            mdBuilder.putCustom(BenchmarkMetaData.TYPE, bmd);
            return ClusterState.builder(currentState).metaData(mdBuilder).build();
        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.cluster.metadata.BenchmarkMetaData

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.