@@ -0,0 +1,2241 @@
+/*%0A * Licensed to Elastic Search and Shay Banon under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership. Elastic Search licenses this%0A * file to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *    http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on an%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied.  See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A */%0A%0Apackage org.elasticsearch.test.stress.indexing;%0A%0Aimport org.elasticsearch.client.Client;%0Aimport org.elasticsearch.client.Requests;%0Aimport org.elasticsearch.client.action.bulk.BulkRequestBuilder;%0Aimport org.elasticsearch.common.settings.ImmutableSettings;%0Aimport org.elasticsearch.common.settings.Settings;%0Aimport org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom;%0Aimport org.elasticsearch.node.Node;%0Aimport org.elasticsearch.node.NodeBuilder;%0A%0A/**%0A */%0Apublic class BulkIndexingStressTest %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        final int NUMBER_OF_NODES = 4;%0A        final int NUMBER_OF_INDICES = 600;%0A        final int BATCH = 300;%0A%0A        final Settings nodeSettings = ImmutableSettings.settingsBuilder().put(%22index.number_of_shards%22, 2).build();%0A%0A        Node%5B%5D nodes = new Node%5BNUMBER_OF_NODES%5D;%0A        for (int i = 0; i %3C nodes.length; i++) %7B%0A            nodes%5Bi%5D = NodeBuilder.nodeBuilder().settings(nodeSettings).node();%0A        %7D%0A%0A        Client client = nodes.length == 1 ? nodes%5B0%5D.client() : nodes%5B1%5D.client();%0A%0A        while (true) %7B%0A            BulkRequestBuilder bulkRequest = client.prepareBulk();%0A            for (int i = 0; i %3C BATCH; i++) %7B%0A                bulkRequest.add(Requests.indexRequest(%22test%22 + ThreadLocalRandom.current().nextInt(NUMBER_OF_INDICES)).type(%22type%22).source(%22field%22, %22value%22));%0A            %7D%0A            bulkRequest.execute().actionGet();%0A        %7D%0A    %7D%0A%7D%0A

add bulk indexing stress test