org.elasticsearch.action.support.replication.ReplicationRequest Java Examples

The following examples show how to use org.elasticsearch.action.support.replication.ReplicationRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransportShardRefreshAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public TransportShardRefreshAction(Settings settings, TransportService transportService, ClusterService clusterService,
                                   IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
                                   MappingUpdatedAction mappingUpdatedAction, ActionFilters actionFilters,
                                   IndexNameExpressionResolver indexNameExpressionResolver) {
    super(settings, NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, mappingUpdatedAction,
            actionFilters, indexNameExpressionResolver, ReplicationRequest.class, ReplicationRequest.class, ThreadPool.Names.REFRESH);
}
 
Example #2
Source File: TransportShardRefreshAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected Tuple<ActionWriteResponse, ReplicationRequest> shardOperationOnPrimary(MetaData metaData, ReplicationRequest shardRequest) throws Throwable {
    IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.shardId().getIndex()).shardSafe(shardRequest.shardId().id());
    indexShard.refresh("api");
    logger.trace("{} refresh request executed on primary", indexShard.shardId());
    return new Tuple<>(new ActionWriteResponse(), shardRequest);
}
 
Example #3
Source File: TransportShardRefreshAction.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
protected void shardOperationOnReplica(ReplicationRequest request) {
    IndexShard indexShard = indicesService.indexServiceSafe(request.shardId().getIndex()).shardSafe(request.shardId().id());
    indexShard.refresh("api");
    logger.trace("{} refresh request executed on replica", indexShard.shardId());
}
 
Example #4
Source File: TransportRefreshAction.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
protected ReplicationRequest newShardRequest(RefreshRequest request, ShardId shardId) {
    return new ReplicationRequest(request, shardId);
}
 
Example #5
Source File: RequestUtils.java    From ranger with Apache License 2.0 4 votes vote down vote up
public static <Request extends ActionRequest> List<String> getIndexFromRequest(Request request) {
	List<String> indexs = new ArrayList<>();

	if (request instanceof SingleShardRequest) {
		indexs.add(((SingleShardRequest<?>) request).index());
		return indexs;
	}

	if (request instanceof ReplicationRequest) {
		indexs.add(((ReplicationRequest<?>) request).index());
		return indexs;
	}

	if (request instanceof InstanceShardOperationRequest) {
		indexs.add(((InstanceShardOperationRequest<?>) request).index());
		return indexs;
	}

	if (request instanceof CreateIndexRequest) {
		indexs.add(((CreateIndexRequest) request).index());
		return indexs;
	}

	if (request instanceof PutMappingRequest) {
		indexs.add(((PutMappingRequest) request).getConcreteIndex().getName());
		return indexs;
	}

	if (request instanceof SearchRequest) {
		return Arrays.asList(((SearchRequest) request).indices());
	}

	if (request instanceof IndicesStatsRequest) {
		return Arrays.asList(((IndicesStatsRequest) request).indices());
	}

	if (request instanceof OpenIndexRequest) {
		return Arrays.asList(((OpenIndexRequest) request).indices());
	}

	if (request instanceof DeleteIndexRequest) {
		return Arrays.asList(((DeleteIndexRequest) request).indices());
	}

	if (request instanceof BulkRequest) {
		@SuppressWarnings("rawtypes") List<DocWriteRequest<?>> requests = ((BulkRequest) request).requests();

		if (CollectionUtils.isNotEmpty(requests)) {
			for (DocWriteRequest<?> docWriteRequest : requests) {
				indexs.add(docWriteRequest.index());
			}
			return indexs;
		}
	}

	if (request instanceof MultiGetRequest) {
		List<Item> items = ((MultiGetRequest) request).getItems();
		if (CollectionUtils.isNotEmpty(items)) {
			for (Item item : items) {
				indexs.add(item.index());
			}
			return indexs;
		}
	}

	// No matched request type to find specific index , set default value *
	indexs.add("*");
	return indexs;
}