Package org.elasticsearch.cluster

Examples of org.elasticsearch.cluster.ClusterState.metaData()


    private void executeBulk(final BulkRequest bulkRequest, final long startTime, final ActionListener<BulkResponse> listener) {
        ClusterState clusterState = clusterService.state();
        for (ActionRequest request : bulkRequest.requests) {
            if (request instanceof IndexRequest) {
                IndexRequest indexRequest = (IndexRequest) request;
                indexRequest.routing(clusterState.metaData().resolveIndexRouting(indexRequest.routing(), indexRequest.index()));
                indexRequest.index(clusterState.metaData().concreteIndex(indexRequest.index()));
                if (allowIdGeneration) {
                    if (indexRequest.id() == null) {
                        indexRequest.id(UUID.randomBase64UUID());
                        // since we generate the id, change it to CREATE
View Full Code Here


        ClusterState clusterState = clusterService.state();
        for (ActionRequest request : bulkRequest.requests) {
            if (request instanceof IndexRequest) {
                IndexRequest indexRequest = (IndexRequest) request;
                indexRequest.routing(clusterState.metaData().resolveIndexRouting(indexRequest.routing(), indexRequest.index()));
                indexRequest.index(clusterState.metaData().concreteIndex(indexRequest.index()));
                if (allowIdGeneration) {
                    if (indexRequest.id() == null) {
                        indexRequest.id(UUID.randomBase64UUID());
                        // since we generate the id, change it to CREATE
                        indexRequest.opType(IndexRequest.OpType.CREATE);
View Full Code Here

                        indexRequest.opType(IndexRequest.OpType.CREATE);
                    }
                }
            } else if (request instanceof DeleteRequest) {
                DeleteRequest deleteRequest = (DeleteRequest) request;
                deleteRequest.index(clusterState.metaData().concreteIndex(deleteRequest.index()));
            }
        }
        final BulkItemResponse[] responses = new BulkItemResponse[bulkRequest.requests.size()];

View Full Code Here

        for (int i = 0; i < bulkRequest.requests.size(); i++) {
            ActionRequest request = bulkRequest.requests.get(i);
            if (request instanceof IndexRequest) {
                IndexRequest indexRequest = (IndexRequest) request;
                // handle routing
                MappingMetaData mappingMd = clusterState.metaData().index(indexRequest.index()).mapping(indexRequest.type());
                if (mappingMd != null) {
                    try {
                        indexRequest.processRouting(mappingMd);
                    } catch (ElasticSearchException e) {
                        responses[i] = new BulkItemResponse(i, indexRequest.opType().toString().toLowerCase(),
View Full Code Here

                    requestsByShard.put(shardId, list);
                }
                list.add(new BulkItemRequest(i, request));
            } else if (request instanceof DeleteRequest) {
                DeleteRequest deleteRequest = (DeleteRequest) request;
                MappingMetaData mappingMd = clusterState.metaData().index(deleteRequest.index()).mapping(deleteRequest.type());
                if (mappingMd != null && mappingMd.routing().required() && deleteRequest.routing() == null) {
                    // if routing is required, and no routing on the delete request, we need to broadcast it....
                    GroupShardsIterator groupShards = clusterService.operationRouting().broadcastDeleteShards(clusterState, deleteRequest.index());
                    for (ShardIterator shardIt : groupShards) {
                        List<BulkItemRequest> list = requestsByShard.get(shardIt.shardId());
View Full Code Here

        logger.info("add another replica");
        routingNodes = clusterState.routingNodes();
        prevRoutingTable = routingTable;
        routingTable = RoutingTable.builder().routingTable(routingTable).updateNumberOfReplicas(2).build();
        metaData = MetaData.newMetaDataBuilder().metaData(clusterState.metaData()).updateNumberOfReplicas(2).build();
        clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).metaData(metaData).build();

        assertThat(clusterState.metaData().index("test").numberOfReplicas(), equalTo(2));

        assertThat(prevRoutingTable != routingTable, equalTo(true));
View Full Code Here

        prevRoutingTable = routingTable;
        routingTable = RoutingTable.builder().routingTable(routingTable).updateNumberOfReplicas(2).build();
        metaData = MetaData.newMetaDataBuilder().metaData(clusterState.metaData()).updateNumberOfReplicas(2).build();
        clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).metaData(metaData).build();

        assertThat(clusterState.metaData().index("test").numberOfReplicas(), equalTo(2));

        assertThat(prevRoutingTable != routingTable, equalTo(true));
        assertThat(routingTable.index("test").shards().size(), equalTo(1));
        assertThat(routingTable.index("test").shard(0).size(), equalTo(3));
        assertThat(routingTable.index("test").shard(0).primaryShard().state(), equalTo(STARTED));
View Full Code Here

        logger.info("now remove a replica");
        routingNodes = clusterState.routingNodes();
        prevRoutingTable = routingTable;
        routingTable = RoutingTable.builder().routingTable(routingTable).updateNumberOfReplicas(1).build();
        metaData = MetaData.newMetaDataBuilder().metaData(clusterState.metaData()).updateNumberOfReplicas(1).build();
        clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).metaData(metaData).build();

        assertThat(clusterState.metaData().index("test").numberOfReplicas(), equalTo(1));

        assertThat(prevRoutingTable != routingTable, equalTo(true));
View Full Code Here

        prevRoutingTable = routingTable;
        routingTable = RoutingTable.builder().routingTable(routingTable).updateNumberOfReplicas(1).build();
        metaData = MetaData.newMetaDataBuilder().metaData(clusterState.metaData()).updateNumberOfReplicas(1).build();
        clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).metaData(metaData).build();

        assertThat(clusterState.metaData().index("test").numberOfReplicas(), equalTo(1));

        assertThat(prevRoutingTable != routingTable, equalTo(true));
        assertThat(routingTable.index("test").shards().size(), equalTo(1));
        assertThat(routingTable.index("test").shard(0).size(), equalTo(2));
        assertThat(routingTable.index("test").shard(0).primaryShard().state(), equalTo(STARTED));
View Full Code Here

        logger.info("add another replica");
        routingNodes = clusterState.routingNodes();
        prevRoutingTable = routingTable;
        routingTable = RoutingTable.builder().routingTable(routingTable).updateNumberOfReplicas(2).build();
        metaData = MetaData.newMetaDataBuilder().metaData(clusterState.metaData()).updateNumberOfReplicas(2).build();
        clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).metaData(metaData).build();

        assertThat(clusterState.metaData().index("test").numberOfReplicas(), equalTo(2));

        assertThat(prevRoutingTable != routingTable, equalTo(true));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.