Examples of IndexResponse


Examples of org.elasticsearch.action.index.IndexResponse

        }

        assert indexRequest.versionType().validateVersionForWrites(indexRequest.version());


        IndexResponse indexResponse = new IndexResponse(request.index(), indexRequest.type(), indexRequest.id(), version, created);
        return new WriteResult(indexResponse, mappingTypeToUpdate, op);
    }
View Full Code Here

Examples of org.elasticsearch.action.index.IndexResponse

            replicaNode = nodes.get(0);
        }
        logger.info("--> primary shard is on {}", primaryNode);

        // Index a document to make sure everything works well
        IndexResponse resp = internalCluster().client(primaryNode).prepareIndex(INDEX, "doc").setSource("foo", "bar").get();
        assertThat("document exists on primary node",
                internalCluster().client(primaryNode).prepareGet(INDEX, "doc", resp.getId()).setPreference("_only_local").get().isExists(),
                equalTo(true));
        assertThat("document exists on replica node",
                internalCluster().client(replicaNode).prepareGet(INDEX, "doc", resp.getId()).setPreference("_only_local").get().isExists(),
                equalTo(true));

        // Disrupt the network so indexing requests fail to replicate
        logger.info("--> preventing index/replica operations");
        TransportService mockTransportService = internalCluster().getInstance(TransportService.class, primaryNode);
        ((MockTransportService) mockTransportService).addFailToSendNoConnectRule(
                internalCluster().getInstance(Discovery.class, replicaNode).localNode(),
                ImmutableSet.of(IndexAction.NAME + "[r]")
        );
        mockTransportService = internalCluster().getInstance(TransportService.class, replicaNode);
        ((MockTransportService) mockTransportService).addFailToSendNoConnectRule(
                internalCluster().getInstance(Discovery.class, primaryNode).localNode(),
                ImmutableSet.of(IndexAction.NAME + "[r]")
        );

        logger.info("--> indexing into primary");
        // the replica shard should now be marked as failed because the replication operation will fail
        resp = internalCluster().client(primaryNode).prepareIndex(INDEX, "doc").setSource("foo", "baz").get();
        // wait until the cluster reaches an exact yellow state, meaning replica has failed
        assertBusy(new Runnable() {
            @Override
            public void run() {
                assertThat(client().admin().cluster().prepareHealth().get().getStatus(), equalTo(ClusterHealthStatus.YELLOW));
            }
        });
        assertThat("document should still be indexed and available",
                client().prepareGet(INDEX, "doc", resp.getId()).get().isExists(), equalTo(true));

        state = getNodeClusterState(randomFrom(nodes.toArray(Strings.EMPTY_ARRAY)));
        RoutingNodes rn = state.routingNodes();
        logger.info("--> counts: total: {}, unassigned: {}, initializing: {}, relocating: {}, started: {}",
                rn.shards(new Predicate<MutableShardRouting>() {
View Full Code Here

Examples of org.elasticsearch.action.index.IndexResponse

        id = in.readVInt();
        opType = in.readSharedString();

        byte type = in.readByte();
        if (type == 0) {
            response = new IndexResponse();
            response.readFrom(in);
        } else if (type == 1) {
            response = new DeleteResponse();
            response.readFrom(in);
        } else if (type == 3) { // make 3 instead of 2, because 2 is already in use for 'no responses'
View Full Code Here

Examples of org.elasticsearch.action.index.IndexResponse

     * @param requestBuilder
     * @return
     */
    public static IndexResponse index(IndexRequestBuilder requestBuilder) {

        IndexResponse indexResponse = requestBuilder.execute().actionGet();

        if (Logger.isDebugEnabled()) {
            Logger.debug("ElasticSearch : Index " + requestBuilder.toString());
        }
        return indexResponse;
View Full Code Here

Examples of org.elasticsearch.action.index.IndexResponse

     * @param indexPath
     * @param indexable
     * @return
     */
    public static IndexResponse index(IndexQueryPath indexPath, String id, Index indexable) {
        IndexResponse indexResponse = getIndexRequestBuilder(indexPath, id, indexable)
                .execute()
                .actionGet();
        if (Logger.isDebugEnabled()) {
            Logger.debug("ElasticSearch : Index : " + indexResponse.getIndex() + "/" + indexResponse.getType() + "/" + indexResponse.getId() + " from " + indexable.toString());
        }
        return indexResponse;
    }
View Full Code Here

Examples of org.elasticsearch.action.index.IndexResponse

        createIndex();
        NumShards numShards = getNumShards(getConcreteIndexName());
        logger.info("Running Cluster Health");
        ensureGreen();
        logger.info("Indexing [type1/1]");
        IndexResponse indexResponse = client().prepareIndex().setIndex("test").setType("type1").setId("1").setSource(source("1", "test")).setRefresh(true).execute().actionGet();
        assertThat(indexResponse.getIndex(), equalTo(getConcreteIndexName()));
        assertThat(indexResponse.getId(), equalTo("1"));
        assertThat(indexResponse.getType(), equalTo("type1"));
        logger.info("Refreshing");
        RefreshResponse refreshResponse = refresh();
        assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));

        logger.info("--> index exists?");
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.