Procházet zdrojové kódy

Benchmark api: removed leftovers

Closes #10182
Closes #10184
javanna před 10 roky
rodič
revize
65b9a94baa

+ 1 - 1
dev-tools/build_release.py

@@ -437,7 +437,7 @@ def smoke_test_release(release, files, expected_hash, plugins):
     else:
       background = '-d'
     print('  Starting elasticsearch deamon from [%s]' % os.path.join(tmp_dir, 'elasticsearch-%s' % release))
-    run('%s; %s -Des.node.name=smoke_tester -Des.cluster.name=prepare_release -Des.discovery.zen.ping.multicast.enabled=false -Des.node.bench=true -Des.script.disable_dynamic=false %s'
+    run('%s; %s -Des.node.name=smoke_tester -Des.cluster.name=prepare_release -Des.discovery.zen.ping.multicast.enabled=false -Des.script.disable_dynamic=false %s'
          % (java_exe(), es_run_path, background))
     conn = HTTPConnection('127.0.0.1', 9200, 20);
     wait_for_node_startup()

+ 0 - 222
src/main/java/org/elasticsearch/cluster/metadata/BenchmarkMetaData.java

@@ -1,222 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.elasticsearch.cluster.metadata;
-
-import com.google.common.collect.ImmutableList;
-import org.elasticsearch.ElasticsearchIllegalArgumentException;
-import org.elasticsearch.common.io.stream.StreamInput;
-import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.common.xcontent.ToXContent;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.common.xcontent.XContentParser;
-
-import java.io.IOException;
-
-/**
- * Meta data about benchmarks that are currently executing
- */
-public class BenchmarkMetaData implements MetaData.Custom {
-    public static final String TYPE = "benchmark";
-
-    public static final Factory FACTORY = new Factory();
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        BenchmarkMetaData that = (BenchmarkMetaData) o;
-
-        if (!entries.equals(that.entries)) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        return entries.hashCode();
-    }
-
-    public static class Entry {
-        private final State state;
-        private final String benchmarkId;
-        private final String[] nodeids;
-
-        public Entry(Entry e, State state) {
-            this(e.benchmarkId(), state, e.nodes());
-        }
-
-        public Entry(String benchmarkId, State state, String[] nodeIds) {
-            this.state = state;
-            this.benchmarkId = benchmarkId;
-            this.nodeids =  nodeIds;
-        }
-
-        public String benchmarkId() {
-            return this.benchmarkId;
-        }
-
-        public State state() {
-            return state;
-        }
-
-        public String[] nodes() {
-            return nodeids;
-        }
-
-
-        @Override
-        public boolean equals(Object o) {
-            if (this == o) return true;
-            if (o == null || getClass() != o.getClass()) return false;
-
-            Entry entry = (Entry) o;
-
-            if (!benchmarkId.equals(entry.benchmarkId)) return false;
-            if (state != entry.state) return false;
-
-            return true;
-        }
-
-        @Override
-        public int hashCode() {
-            int result = state.hashCode();
-            result = 31 * result + benchmarkId.hashCode();
-            return result;
-        }
-    }
-
-    public static enum State {
-        STARTED((byte) 0),
-        SUCCESS((byte) 1),
-        FAILED((byte) 2),
-        ABORTED((byte) 3);
-
-        private static final State[] STATES = new State[State.values().length];
-
-        static {
-            for (State state : State.values()) {
-                assert state.id() < STATES.length && state.id() >= 0;
-                STATES[state.id()] = state;
-            }
-        }
-
-        private final byte id;
-
-        State(byte id) {
-            this.id = id;
-        }
-
-        public byte id() {
-            return id;
-        }
-
-        public boolean completed() {
-            return this == SUCCESS || this == FAILED;
-        }
-
-        public static State fromId(byte id) {
-            if (id < 0 || id >= State.values().length) {
-                throw new ElasticsearchIllegalArgumentException("No benchmark state for value [" + id + "]");
-            }
-            return STATES[id];
-        }
-    }
-
-    private final ImmutableList<Entry> entries;
-
-
-    public BenchmarkMetaData(ImmutableList<Entry> entries) {
-        this.entries = entries;
-    }
-
-    public BenchmarkMetaData(Entry... entries) {
-        this.entries = ImmutableList.copyOf(entries);
-    }
-
-    public ImmutableList<Entry> entries() {
-        return this.entries;
-    }
-
-
-    public static class Factory extends MetaData.Custom.Factory<BenchmarkMetaData> {
-
-        @Override
-        public String type() {
-            return TYPE;
-        }
-
-        @Override
-        public BenchmarkMetaData readFrom(StreamInput in) throws IOException {
-            Entry[] entries = new Entry[in.readVInt()];
-            for (int i = 0; i < entries.length; i++) {
-                String benchmarkId = in.readString();
-                State state = State.fromId(in.readByte());
-                String[] nodes = in.readStringArray();
-                entries[i] = new Entry(benchmarkId, state, nodes);
-            }
-            return new BenchmarkMetaData(entries);
-        }
-
-        @Override
-        public void writeTo(BenchmarkMetaData repositories, StreamOutput out) throws IOException {
-            out.writeVInt(repositories.entries().size());
-            for (Entry entry : repositories.entries()) {
-                out.writeString(entry.benchmarkId());
-                out.writeByte(entry.state().id());
-                out.writeStringArray(entry.nodes());
-            }
-        }
-
-        @Override
-        public BenchmarkMetaData fromXContent(XContentParser parser) throws IOException {
-            throw new UnsupportedOperationException();
-        }
-
-        @Override
-        public void toXContent(BenchmarkMetaData customIndexMetaData, XContentBuilder builder, ToXContent.Params params) throws IOException {
-            builder.startArray("benchmarks");
-            for (Entry entry : customIndexMetaData.entries()) {
-                toXContent(entry, builder, params);
-            }
-            builder.endArray();
-        }
-
-        public void toXContent(Entry entry, XContentBuilder builder, ToXContent.Params params) throws IOException {
-            builder.startObject();
-            builder.field("id", entry.benchmarkId());
-            builder.field("state", entry.state());
-            builder.startArray("on_nodes");
-            for (String nodeid : entry.nodes()) {
-                builder.value(nodeid);
-            }
-            builder.endArray();
-            builder.endObject();
-        }
-    }
-
-    public boolean contains(String benchmarkId) {
-        for (Entry e : entries) {
-           if (e.benchmarkId.equals(benchmarkId)) {
-               return true;
-           }
-        }
-        return false;
-    }
-}

+ 0 - 1
src/main/java/org/elasticsearch/cluster/metadata/MetaData.java

@@ -102,7 +102,6 @@ public class MetaData implements Iterable<IndexMetaData> {
         registerFactory(RepositoriesMetaData.TYPE, RepositoriesMetaData.FACTORY);
         registerFactory(SnapshotMetaData.TYPE, SnapshotMetaData.FACTORY);
         registerFactory(RestoreMetaData.TYPE, RestoreMetaData.FACTORY);
-        registerFactory(BenchmarkMetaData.TYPE, BenchmarkMetaData.FACTORY);
     }
 
     /**

+ 0 - 2
src/main/java/org/elasticsearch/threadpool/ThreadPool.java

@@ -78,7 +78,6 @@ public class ThreadPool extends AbstractComponent {
         public static final String WARMER = "warmer";
         public static final String SNAPSHOT = "snapshot";
         public static final String OPTIMIZE = "optimize";
-        public static final String BENCH = "bench";
     }
 
     public static final String THREADPOOL_GROUP = "threadpool.";
@@ -126,7 +125,6 @@ public class ThreadPool extends AbstractComponent {
                 .put(Names.WARMER, settingsBuilder().put("type", "scaling").put("keep_alive", "5m").put("size", halfProcMaxAt5).build())
                 .put(Names.SNAPSHOT, settingsBuilder().put("type", "scaling").put("keep_alive", "5m").put("size", halfProcMaxAt5).build())
                 .put(Names.OPTIMIZE, settingsBuilder().put("type", "fixed").put("size", 1).build())
-                .put(Names.BENCH, settingsBuilder().put("type", "scaling").put("keep_alive", "5m").put("size", halfProcMaxAt5).build())
                 .build();
 
         Map<String, ExecutorHolder> executors = Maps.newHashMap();

+ 0 - 5
src/test/java/org/elasticsearch/test/CompositeTestCluster.java

@@ -216,11 +216,6 @@ public class CompositeTestCluster extends TestCluster {
         return runningNodes().size() + cluster.numDataAndMasterNodes();
     }
 
-    @Override
-    public int numBenchNodes() {
-        return cluster.numBenchNodes();
-    }
-
     @Override
     public InetSocketAddress[] httpAddresses() {
         return cluster.httpAddresses();

+ 1 - 12
src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java

@@ -1485,12 +1485,6 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
          */
         int numClientNodes() default InternalTestCluster.DEFAULT_NUM_CLIENT_NODES;
 
-        /**
-         * Returns whether the ability to randomly have benchmark (client) nodes as part of the cluster needs to be enabled.
-         * Default is {@link InternalTestCluster#DEFAULT_ENABLE_RANDOM_BENCH_NODES}.
-         */
-        boolean enableRandomBenchNodes() default InternalTestCluster.DEFAULT_ENABLE_RANDOM_BENCH_NODES;
-
         /**
          * Returns the transport client ratio. By default this returns <code>-1</code> which means a random
          * ratio in the interval <code>[0..1]</code> is used.
@@ -1597,11 +1591,6 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
         return annotation == null ? InternalTestCluster.DEFAULT_NUM_CLIENT_NODES : annotation.numClientNodes();
     }
 
-    private boolean enableRandomBenchNodes() {
-        ClusterScope annotation = getAnnotation(this.getClass());
-        return annotation == null ? InternalTestCluster.DEFAULT_ENABLE_RANDOM_BENCH_NODES : annotation.enableRandomBenchNodes();
-    }
-
     private boolean randomDynamicTemplates() {
         ClusterScope annotation = getAnnotation(this.getClass());
         return annotation == null || annotation.randomDynamicTemplates();
@@ -1696,7 +1685,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
 
         return new InternalTestCluster(seed, minNumDataNodes, maxNumDataNodes,
                 clusterName(scope.name(), Integer.toString(CHILD_JVM_ID), seed), settingsSource, getNumClientNodes(),
-                enableRandomBenchNodes(), InternalTestCluster.DEFAULT_ENABLE_HTTP_PIPELINING, CHILD_JVM_ID, nodePrefix);
+                InternalTestCluster.DEFAULT_ENABLE_HTTP_PIPELINING, CHILD_JVM_ID, nodePrefix);
     }
 
     /**

+ 0 - 11
src/test/java/org/elasticsearch/test/ExternalTestCluster.java

@@ -63,7 +63,6 @@ public final class ExternalTestCluster extends TestCluster {
 
     private final int numDataNodes;
     private final int numMasterAndDataNodes;
-    private final int numBenchNodes;
 
     public ExternalTestCluster(TransportAddress... transportAddresses) {
         super(0);
@@ -79,7 +78,6 @@ public final class ExternalTestCluster extends TestCluster {
         httpAddresses = new InetSocketAddress[nodeInfos.getNodes().length];
         this.clusterName = nodeInfos.getClusterName().value();
         int dataNodes = 0;
-        int benchNodes = 0;
         int masterAndDataNodes = 0;
         for (int i = 0; i < nodeInfos.getNodes().length; i++) {
             NodeInfo nodeInfo = nodeInfos.getNodes()[i];
@@ -90,12 +88,8 @@ public final class ExternalTestCluster extends TestCluster {
             } else if (DiscoveryNode.masterNode(nodeInfo.getSettings())) {
                 masterAndDataNodes++;
             }
-            if (nodeInfo.getSettings().getAsBoolean("node.bench", false)) {
-                benchNodes++;
-            }
         }
         this.numDataNodes = dataNodes;
-        this.numBenchNodes = benchNodes;
         this.numMasterAndDataNodes = masterAndDataNodes;
         logger.info("Setup ExternalTestCluster [{}] made of [{}] nodes", nodeInfos.getClusterName().value(), size());
     }
@@ -125,11 +119,6 @@ public final class ExternalTestCluster extends TestCluster {
         return numMasterAndDataNodes;
     }
 
-    @Override
-    public int numBenchNodes() {
-        return numBenchNodes;
-    }
-
     @Override
     public InetSocketAddress[] httpAddresses() {
         return httpAddresses;

+ 3 - 29
src/test/java/org/elasticsearch/test/InternalTestCluster.java

@@ -161,7 +161,6 @@ public final class InternalTestCluster extends TestCluster {
     static final int DEFAULT_MIN_NUM_CLIENT_NODES = 0;
     static final int DEFAULT_MAX_NUM_CLIENT_NODES = 1;
 
-    static final boolean DEFAULT_ENABLE_RANDOM_BENCH_NODES = true;
     static final boolean DEFAULT_ENABLE_HTTP_PIPELINING = true;
 
     public static final String NODE_MODE = nodeMode();
@@ -188,8 +187,6 @@ public final class InternalTestCluster extends TestCluster {
 
     private final int numSharedClientNodes;
 
-    private final boolean enableRandomBenchNodes;
-
     private final SettingsSource settingsSource;
 
     private final ExecutorService executor;
@@ -201,15 +198,14 @@ public final class InternalTestCluster extends TestCluster {
 
     private ServiceDisruptionScheme activeDisruptionScheme;
 
-    public InternalTestCluster(long clusterSeed, int minNumDataNodes, int maxNumDataNodes, String clusterName, int numClientNodes, boolean enableRandomBenchNodes,
+    public InternalTestCluster(long clusterSeed, int minNumDataNodes, int maxNumDataNodes, String clusterName, int numClientNodes,
                                boolean enableHttpPipelining, int jvmOrdinal, String nodePrefix) {
-        this(clusterSeed, minNumDataNodes, maxNumDataNodes, clusterName, DEFAULT_SETTINGS_SOURCE, numClientNodes, enableRandomBenchNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
+        this(clusterSeed, minNumDataNodes, maxNumDataNodes, clusterName, DEFAULT_SETTINGS_SOURCE, numClientNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
     }
 
     public InternalTestCluster(long clusterSeed,
                                int minNumDataNodes, int maxNumDataNodes, String clusterName, SettingsSource settingsSource, int numClientNodes,
-                               boolean enableRandomBenchNodes, boolean enableHttpPipelining,
-                               int jvmOrdinal, String nodePrefix) {
+                                boolean enableHttpPipelining, int jvmOrdinal, String nodePrefix) {
         super(clusterSeed);
         this.clusterName = clusterName;
 
@@ -238,8 +234,6 @@ public final class InternalTestCluster extends TestCluster {
         }
         assert this.numSharedClientNodes >= 0;
 
-        this.enableRandomBenchNodes = enableRandomBenchNodes;
-
         this.nodePrefix = nodePrefix;
 
         assert nodePrefix != null;
@@ -938,10 +932,6 @@ public final class InternalTestCluster extends TestCluster {
             if (nodeAndClient == null) {
                 changed = true;
                 Builder clientSettingsBuilder = ImmutableSettings.builder().put("node.client", true);
-                if (enableRandomBenchNodes && usually(random)) {
-                    //client nodes might also be bench nodes
-                    clientSettingsBuilder.put("node.bench", true);
-                }
                 nodeAndClient = buildNode(i, sharedNodesSeeds[i], clientSettingsBuilder.build(), Version.CURRENT);
                 nodeAndClient.node.start();
                 logger.info("Start Shared Node [{}] not shared", nodeAndClient.name);
@@ -1486,11 +1476,6 @@ public final class InternalTestCluster extends TestCluster {
         return dataAndMasterNodes().size();
     }
 
-    @Override
-    public int numBenchNodes() {
-        return benchNodeAndClients().size();
-    }
-
     public void setDisruptionScheme(ServiceDisruptionScheme scheme) {
         clearDisruptionScheme();
         scheme.applyToCluster(this);
@@ -1576,17 +1561,6 @@ public final class InternalTestCluster extends TestCluster {
         }
     }
 
-    private synchronized Collection<NodeAndClient> benchNodeAndClients() {
-        return Collections2.filter(nodes.values(), new BenchNodePredicate());
-    }
-
-    private static final class BenchNodePredicate implements Predicate<NodeAndClient> {
-        @Override
-        public boolean apply(NodeAndClient nodeAndClient) {
-            return nodeAndClient.node.settings().getAsBoolean("node.bench", false);
-        }
-    }
-
     private static final class EntryNodePredicate implements Predicate<Map.Entry<String, NodeAndClient>> {
         private final Predicate<NodeAndClient> delegateNodePredicate;
 

+ 0 - 5
src/test/java/org/elasticsearch/test/TestCluster.java

@@ -111,11 +111,6 @@ public abstract class TestCluster implements Iterable<Client>, Closeable {
      */
     public abstract int numDataAndMasterNodes();
 
-    /**
-     * Returns the number of bench nodes in the cluster.
-     */
-    public abstract int numBenchNodes();
-
     /**
      * Returns the http addresses of the nodes within the cluster.
      * Can be used to run REST tests against the test cluster.

+ 0 - 3
src/test/java/org/elasticsearch/test/rest/support/Features.java

@@ -45,9 +45,6 @@ public final class Features {
      */
     public static boolean areAllSupported(List<String> features) {
         for (String feature : features) {
-            if ("benchmark".equals(feature) && ElasticsearchIntegrationTest.cluster().numBenchNodes() > 0) {
-                continue;
-            }
             if ("requires_replica".equals(feature) && ElasticsearchIntegrationTest.cluster().numDataNodes() >= 2) {
                 continue;
             }

+ 4 - 5
src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java

@@ -54,8 +54,8 @@ public class InternalTestClusterTests extends ElasticsearchTestCase {
         int jvmOrdinal = randomIntBetween(0, 10);
         String nodePrefix = randomRealisticUnicodeOfCodepointLengthBetween(1, 10);
 
-        InternalTestCluster cluster0 = new InternalTestCluster(clusterSeed, minNumDataNodes, maxNumDataNodes, clusterName, settingsSource, numClientNodes, enableRandomBenchNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
-        InternalTestCluster cluster1 = new InternalTestCluster(clusterSeed, minNumDataNodes, maxNumDataNodes, clusterName, settingsSource, numClientNodes, enableRandomBenchNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
+        InternalTestCluster cluster0 = new InternalTestCluster(clusterSeed, minNumDataNodes, maxNumDataNodes, clusterName, settingsSource, numClientNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
+        InternalTestCluster cluster1 = new InternalTestCluster(clusterSeed, minNumDataNodes, maxNumDataNodes, clusterName, settingsSource, numClientNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
         assertClusters(cluster0, cluster1, true);
 
     }
@@ -65,7 +65,6 @@ public class InternalTestClusterTests extends ElasticsearchTestCase {
         Settings defaultSettings1 = cluster1.getDefaultSettings();
         assertSettings(defaultSettings0, defaultSettings1, assertClusterName);
         assertThat(cluster0.numDataNodes(), equalTo(cluster1.numDataNodes()));
-        assertThat(cluster0.numBenchNodes(), equalTo(cluster1.numBenchNodes()));
         if (assertClusterName) {
             assertThat(cluster0.getClusterName(), equalTo(cluster1.getClusterName()));
         }
@@ -99,8 +98,8 @@ public class InternalTestClusterTests extends ElasticsearchTestCase {
         int jvmOrdinal = randomIntBetween(0, 10);
         String nodePrefix = "foobar";
 
-        InternalTestCluster cluster0 = new InternalTestCluster(clusterSeed, minNumDataNodes, maxNumDataNodes, clusterName, settingsSource, numClientNodes, enableRandomBenchNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
-        InternalTestCluster cluster1 = new InternalTestCluster(clusterSeed, minNumDataNodes, maxNumDataNodes, clusterName1, settingsSource, numClientNodes, enableRandomBenchNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
+        InternalTestCluster cluster0 = new InternalTestCluster(clusterSeed, minNumDataNodes, maxNumDataNodes, clusterName, settingsSource, numClientNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
+        InternalTestCluster cluster1 = new InternalTestCluster(clusterSeed, minNumDataNodes, maxNumDataNodes, clusterName1, settingsSource, numClientNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
 
         assertClusters(cluster0, cluster1, false);
         long seed = randomLong();

+ 0 - 1
src/test/java/org/elasticsearch/transport/ActionNamesTests.java

@@ -58,7 +58,6 @@ public class ActionNamesTests extends ElasticsearchIntegrationTest {
         for (String action : transportService.serverHandlers.keySet()) {
             assertThat("action doesn't belong to known category", action, either(startsWith("indices:admin")).or(startsWith("indices:monitor"))
                     .or(startsWith("indices:data/read")).or(startsWith("indices:data/write"))
-                    .or(startsWith("indices:data/benchmark"))
                     .or(startsWith("cluster:admin")).or(startsWith("cluster:monitor"))
                     .or(startsWith("internal:")));
         }

+ 1 - 1
src/test/java/org/elasticsearch/transport/netty/NettyTransportMultiPortIntegrationTests.java

@@ -37,7 +37,7 @@ import static org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
 import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope;
 import static org.hamcrest.Matchers.*;
 
-@ClusterScope(scope = Scope.SUITE, numDataNodes = 1, enableRandomBenchNodes = false, numClientNodes = 0)
+@ClusterScope(scope = Scope.SUITE, numDataNodes = 1, numClientNodes = 0)
 public class NettyTransportMultiPortIntegrationTests extends ElasticsearchIntegrationTest {
 
     private static int randomPort = -1;

+ 1 - 1
src/test/java/org/elasticsearch/tribe/TribeTests.java

@@ -69,7 +69,7 @@ public class TribeTests extends ElasticsearchIntegrationTest {
     public static void setupSecondCluster() throws Exception {
         ElasticsearchIntegrationTest.beforeClass();
         // create another cluster
-        cluster2 = new InternalTestCluster(randomLong(), 2, 2, Strings.randomBase64UUID(getRandom()), 0, false, false, CHILD_JVM_ID, SECOND_CLUSTER_NODE_PREFIX);
+        cluster2 = new InternalTestCluster(randomLong(), 2, 2, Strings.randomBase64UUID(getRandom()), 0, false, CHILD_JVM_ID, SECOND_CLUSTER_NODE_PREFIX);
         cluster2.beforeTest(getRandom(), 0.1);
         cluster2.ensureAtLeastNumDataNodes(2);
     }