org.elasticsearch.action.support.IndicesOptions Java Examples
The following examples show how to use
org.elasticsearch.action.support.IndicesOptions.
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: SnapshotRestoreDDLDispatcher.java From Elasticsearch with Apache License 2.0 | 6 votes |
public ListenableFuture<Long> dispatch(final RestoreSnapshotAnalyzedStatement analysis) { final SettableFuture<Long> resultFuture = SettableFuture.create(); boolean waitForCompletion = analysis.settings().getAsBoolean(WAIT_FOR_COMPLETION.settingName(), WAIT_FOR_COMPLETION.defaultValue()); boolean ignoreUnavailable = analysis.settings().getAsBoolean(IGNORE_UNAVAILABLE.settingName(), IGNORE_UNAVAILABLE.defaultValue()); // ignore_unavailable as set by statement IndicesOptions indicesOptions = IndicesOptions.fromOptions(ignoreUnavailable, true, true, false, IndicesOptions.lenientExpandOpen()); RestoreSnapshotRequest request = new RestoreSnapshotRequest(analysis.repositoryName(), analysis.snapshotName()) .indices(analysis.indices()) .indicesOptions(indicesOptions) .settings(analysis.settings()) .waitForCompletion(waitForCompletion) .includeGlobalState(false) .includeAliases(true); ActionListener<RestoreSnapshotResponse> listener = ActionListeners.wrap(resultFuture, Functions.constant(1L)); transportActionProvider.transportRestoreSnapshotAction().execute(request, listener); return resultFuture; }
Example #2
Source File: SwapRelationsOperation.java From crate with Apache License 2.0 | 6 votes |
private void removeOccurrences(ClusterState state, ClusterBlocks.Builder blocksBuilder, RoutingTable.Builder routingBuilder, MetaData.Builder updatedMetaData, RelationName name) { String aliasOrIndexName = name.indexNameOrAlias(); String templateName = PartitionName.templateName(name.schema(), name.name()); for (Index index : indexNameResolver.concreteIndices( state, IndicesOptions.LENIENT_EXPAND_OPEN, aliasOrIndexName)) { String indexName = index.getName(); routingBuilder.remove(indexName); updatedMetaData.remove(indexName); blocksBuilder.removeIndexBlocks(indexName); } updatedMetaData.removeTemplate(templateName); }
Example #3
Source File: RestoreSnapshotRequest.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); snapshot = in.readString(); repository = in.readString(); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); renamePattern = in.readOptionalString(); renameReplacement = in.readOptionalString(); waitForCompletion = in.readBoolean(); includeGlobalState = in.readBoolean(); partial = in.readBoolean(); includeAliases = in.readBoolean(); settings = readSettingsFromStream(in); indexSettings = readSettingsFromStream(in); ignoreIndexSettings = in.readStringArray(); }
Example #4
Source File: RestoreService.java From Elasticsearch with Apache License 2.0 | 6 votes |
/** * Constructs new restore request * * @param cause cause for restoring the snapshot * @param repository repository name * @param name snapshot name * @param indices list of indices to restore * @param indicesOptions indices options * @param renamePattern pattern to rename indices * @param renameReplacement replacement for renamed indices * @param settings repository specific restore settings * @param masterNodeTimeout master node timeout * @param includeGlobalState include global state into restore * @param partial allow partial restore * @param indexSettings index settings that should be changed on restore * @param ignoreIndexSettings index settings that shouldn't be restored */ public RestoreRequest(String cause, String repository, String name, String[] indices, IndicesOptions indicesOptions, String renamePattern, String renameReplacement, Settings settings, TimeValue masterNodeTimeout, boolean includeGlobalState, boolean partial, boolean includeAliases, Settings indexSettings, String[] ignoreIndexSettings ) { this.cause = cause; this.name = name; this.repository = repository; this.indices = indices; this.renamePattern = renamePattern; this.renameReplacement = renameReplacement; this.indicesOptions = indicesOptions; this.settings = settings; this.masterNodeTimeout = masterNodeTimeout; this.includeGlobalState = includeGlobalState; this.partial = partial; this.includeAliases = includeAliases; this.indexSettings = indexSettings; this.ignoreIndexSettings = ignoreIndexSettings; }
Example #5
Source File: ClusterInfoRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); indices = in.readStringArray(); types = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); }
Example #6
Source File: RestDeleteIndexAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(Strings.splitStringByCommaToArray(request.param("index"))); deleteIndexRequest.timeout(request.paramAsTime("timeout", deleteIndexRequest.timeout())); deleteIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteIndexRequest.masterNodeTimeout())); deleteIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, deleteIndexRequest.indicesOptions())); client.admin().indices().delete(deleteIndexRequest, new AcknowledgedRestListener<DeleteIndexResponse>(channel)); }
Example #7
Source File: PutMappingRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); type = in.readOptionalString(); source = in.readString(); updateAllTypes = in.readBoolean(); reindex = in.readBoolean(); readTimeout(in); }
Example #8
Source File: ClusterSearchShardsRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); indices = new String[in.readVInt()]; for (int i = 0; i < indices.length; i++) { indices[i] = in.readString(); } routing = in.readOptionalString(); preference = in.readOptionalString(); types = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); }
Example #9
Source File: RestGetFieldMappingAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final String[] types = request.paramAsStringArrayOrEmptyIfAll("type"); final String[] fields = Strings.splitStringByCommaToArray(request.param("fields")); GetFieldMappingsRequest getMappingsRequest = new GetFieldMappingsRequest(); getMappingsRequest.indices(indices).types(types).fields(fields).includeDefaults(request.paramAsBoolean("include_defaults", false)); getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions())); getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local())); client.admin().indices().getFieldMappings(getMappingsRequest, new RestBuilderListener<GetFieldMappingsResponse>(channel) { @SuppressWarnings("unchecked") @Override public RestResponse buildResponse(GetFieldMappingsResponse response, XContentBuilder builder) throws Exception { ImmutableMap<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> mappingsByIndex = response.mappings(); boolean isPossibleSingleFieldRequest = indices.length == 1 && types.length == 1 && fields.length == 1; if (isPossibleSingleFieldRequest && isFieldMappingMissingField(mappingsByIndex)) { return new BytesRestResponse(OK, builder.startObject().endObject()); } RestStatus status = OK; if (mappingsByIndex.isEmpty() && fields.length > 0) { status = NOT_FOUND; } builder.startObject(); response.toXContent(builder, request); builder.endObject(); return new BytesRestResponse(status, builder); } }); }
Example #10
Source File: ClusterStateRequest.java From crate with Apache License 2.0 | 5 votes |
public ClusterStateRequest(StreamInput in) throws IOException { super(in); routingTable = in.readBoolean(); nodes = in.readBoolean(); metaData = in.readBoolean(); blocks = in.readBoolean(); customs = in.readBoolean(); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); }
Example #11
Source File: DropTableTask.java From Elasticsearch with Apache License 2.0 | 5 votes |
private void deleteESIndex(String indexOrAlias) { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexOrAlias); deleteIndexRequest.putHeader(LoginUserContext.USER_INFO_KEY, this.getParamContext().getLoginUserContext()); if (tableInfo.isPartitioned()) { deleteIndexRequest.indicesOptions(IndicesOptions.lenientExpandOpen()); } deleteIndexAction.execute(deleteIndexRequest, new ActionListener<DeleteIndexResponse>() { @Override public void onResponse(DeleteIndexResponse response) { if (!response.isAcknowledged()) { warnNotAcknowledged(String.format(Locale.ENGLISH, "dropping table '%s'", tableInfo.ident().fqn())); } result.set(SUCCESS_RESULT); } @Override public void onFailure(Throwable e) { if (tableInfo.isPartitioned()) { logger.warn("Could not (fully) delete all partitions of {}. " + "Some orphaned partitions might still exist, " + "but are not accessible.", e, tableInfo.ident().fqn()); } if (ifExists && e instanceof IndexNotFoundException) { result.set(TaskResult.ZERO); } else { result.setException(e); } } }); }
Example #12
Source File: RestCountAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { CountRequest countRequest = new CountRequest(Strings.splitStringByCommaToArray(request.param("index"))); countRequest.indicesOptions(IndicesOptions.fromRequest(request, countRequest.indicesOptions())); if (RestActions.hasBodyContent(request)) { countRequest.source(RestActions.getRestContent(request)); } else { QuerySourceBuilder querySourceBuilder = RestActions.parseQuerySource(request); if (querySourceBuilder != null) { countRequest.source(querySourceBuilder); } } countRequest.routing(request.param("routing")); countRequest.minScore(request.paramAsFloat("min_score", DEFAULT_MIN_SCORE)); countRequest.types(Strings.splitStringByCommaToArray(request.param("type"))); countRequest.preference(request.param("preference")); final int terminateAfter = request.paramAsInt("terminate_after", DEFAULT_TERMINATE_AFTER); if (terminateAfter < 0) { throw new IllegalArgumentException("terminateAfter must be > 0"); } else if (terminateAfter > 0) { countRequest.terminateAfter(terminateAfter); } client.search(countRequest.toSearchRequest(), new RestBuilderListener<SearchResponse>(channel) { @Override public RestResponse buildResponse(SearchResponse response, XContentBuilder builder) throws Exception { builder.startObject(); if (terminateAfter != DEFAULT_TERMINATE_AFTER) { builder.field("terminated_early", response.isTerminatedEarly()); } builder.field("count", response.getHits().totalHits()); buildBroadcastShardsHeader(builder, request, response.getTotalShards(), response.getSuccessfulShards(), response.getFailedShards(), response.getShardFailures()); builder.endObject(); return new BytesRestResponse(response.status(), builder); } }); }
Example #13
Source File: AbstractOpenCloseTableClusterStateTaskExecutor.java From crate with Apache License 2.0 | 5 votes |
protected Context prepare(ClusterState currentState, OpenCloseTableOrPartitionRequest request) { RelationName relationName = request.tableIdent(); String partitionIndexName = request.partitionIndexName(); MetaData metaData = currentState.metaData(); String indexToResolve = partitionIndexName != null ? partitionIndexName : relationName.indexNameOrAlias(); PartitionName partitionName = partitionIndexName != null ? PartitionName.fromIndexOrTemplate(partitionIndexName) : null; String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames( currentState, IndicesOptions.lenientExpandOpen(), indexToResolve); Set<IndexMetaData> indicesMetaData = DDLClusterStateHelpers.indexMetaDataSetFromIndexNames(metaData, concreteIndices, indexState()); IndexTemplateMetaData indexTemplateMetaData = null; if (partitionIndexName == null) { indexTemplateMetaData = DDLClusterStateHelpers.templateMetaData(metaData, relationName); } return new Context(indicesMetaData, indexTemplateMetaData, partitionName); }
Example #14
Source File: ClusterStateRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); routingTable = in.readBoolean(); nodes = in.readBoolean(); metaData = in.readBoolean(); blocks = in.readBoolean(); customs = in.readBoolean(); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); }
Example #15
Source File: Elasticsearch5Client.java From presto-connectors with Apache License 2.0 | 5 votes |
private static GetIndexRequest createGetIndexRequest(String index) { return new GetIndexRequest() .local(true) .indices(index) .features(GetIndexRequest.Feature.MAPPINGS) //lenient because we throw our own errors looking at the response e.g. if something was not resolved //also because this way security doesn't throw authorization exceptions but rather honours ignore_unavailable .indicesOptions(IndicesOptions.lenientExpandOpen()); }
Example #16
Source File: TransportSwapRelationsAction.java From crate with Apache License 2.0 | 5 votes |
@Override protected ClusterBlockException checkBlock(SwapRelationsRequest request, ClusterState state) { Set<String> affectedIndices = new HashSet<>(); for (RelationNameSwap swapAction : request.swapActions()) { affectedIndices.addAll(Arrays.asList(indexNameExpressionResolver.concreteIndexNames( state, IndicesOptions.LENIENT_EXPAND_OPEN, swapAction.source().indexNameOrAlias()))); affectedIndices.addAll(Arrays.asList(indexNameExpressionResolver.concreteIndexNames( state, IndicesOptions.LENIENT_EXPAND_OPEN, swapAction.target().indexNameOrAlias()))); } for (RelationName dropRelation : request.dropRelations()) { affectedIndices.addAll(Arrays.asList(indexNameExpressionResolver.concreteIndexNames( state, IndicesOptions.LENIENT_EXPAND_OPEN, dropRelation.indexNameOrAlias()))); } return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, affectedIndices.toArray(new String[0])); }
Example #17
Source File: RestExistsAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { final ExistsRequest existsRequest = new ExistsRequest(Strings.splitStringByCommaToArray(request.param("index"))); existsRequest.indicesOptions(IndicesOptions.fromRequest(request, existsRequest.indicesOptions())); if (RestActions.hasBodyContent(request)) { existsRequest.source(RestActions.getRestContent(request)); } else { QuerySourceBuilder querySourceBuilder = RestActions.parseQuerySource(request); if (querySourceBuilder != null) { existsRequest.source(querySourceBuilder); } } existsRequest.routing(request.param("routing")); existsRequest.minScore(request.paramAsFloat("min_score", DEFAULT_MIN_SCORE)); existsRequest.types(Strings.splitStringByCommaToArray(request.param("type"))); existsRequest.preference(request.param("preference")); client.exists(existsRequest, new RestBuilderListener<ExistsResponse>(channel) { @Override public RestResponse buildResponse(ExistsResponse response, XContentBuilder builder) throws Exception { RestStatus status = response.exists() ? OK : NOT_FOUND; builder.startObject(); builder.field("exists", response.exists()); builder.endObject(); return new BytesRestResponse(status, builder); } }); }
Example #18
Source File: IndicesShardStoresRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); indices = in.readStringArray(); int nStatus = in.readVInt(); statuses = EnumSet.noneOf(ClusterHealthStatus.class); for (int i = 0; i < nStatus; i++) { statuses.add(ClusterHealthStatus.fromValue(in.readByte())); } indicesOptions = IndicesOptions.readIndicesOptions(in); }
Example #19
Source File: RestSyncedFlushAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { IndicesOptions indicesOptions = IndicesOptions.fromRequest(request, IndicesOptions.lenientExpandOpen()); SyncedFlushRequest syncedFlushRequest = new SyncedFlushRequest(Strings.splitStringByCommaToArray(request.param("index"))); syncedFlushRequest.indicesOptions(indicesOptions); client.admin().indices().syncedFlush(syncedFlushRequest, new RestBuilderListener<SyncedFlushResponse>(channel) { @Override public RestResponse buildResponse(SyncedFlushResponse results, XContentBuilder builder) throws Exception { builder.startObject(); results.toXContent(builder, request); builder.endObject(); return new BytesRestResponse(results.restStatus(), builder); } }); }
Example #20
Source File: RestGetWarmerAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final String[] types = Strings.splitStringByCommaToArray(request.param("type")); final String[] names = request.paramAsStringArray("name", Strings.EMPTY_ARRAY); GetWarmersRequest getWarmersRequest = new GetWarmersRequest(); getWarmersRequest.indices(indices).types(types).warmers(names); getWarmersRequest.local(request.paramAsBoolean("local", getWarmersRequest.local())); getWarmersRequest.indicesOptions(IndicesOptions.fromRequest(request, getWarmersRequest.indicesOptions())); client.admin().indices().getWarmers(getWarmersRequest, new RestBuilderListener<GetWarmersResponse>(channel) { @Override public RestResponse buildResponse(GetWarmersResponse response, XContentBuilder builder) throws Exception { if (indices.length > 0 && response.warmers().isEmpty()) { return new BytesRestResponse(OK, builder.startObject().endObject()); } builder.startObject(); for (ObjectObjectCursor<String, List<IndexWarmersMetaData.Entry>> entry : response.warmers()) { builder.startObject(entry.key, XContentBuilder.FieldCaseConversion.NONE); builder.startObject(IndexWarmersMetaData.TYPE, XContentBuilder.FieldCaseConversion.NONE); for (IndexWarmersMetaData.Entry warmerEntry : entry.value) { IndexWarmersMetaData.toXContent(warmerEntry, builder, request); } builder.endObject(); builder.endObject(); } builder.endObject(); return new BytesRestResponse(OK, builder); } }); }
Example #21
Source File: RestDeleteWarmerAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { DeleteWarmerRequest deleteWarmerRequest = new DeleteWarmerRequest(Strings.splitStringByCommaToArray(request.param("name"))) .indices(Strings.splitStringByCommaToArray(request.param("index"))); deleteWarmerRequest.timeout(request.paramAsTime("timeout", deleteWarmerRequest.timeout())); deleteWarmerRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteWarmerRequest.masterNodeTimeout())); deleteWarmerRequest.indicesOptions(IndicesOptions.fromRequest(request, deleteWarmerRequest.indicesOptions())); client.admin().indices().deleteWarmer(deleteWarmerRequest, new AcknowledgedRestListener<DeleteWarmerResponse>(channel)); }
Example #22
Source File: RestPutWarmerAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { PutWarmerRequest putWarmerRequest = new PutWarmerRequest(request.param("name")); SearchRequest searchRequest = new SearchRequest(Strings.splitStringByCommaToArray(request.param("index"))) .types(Strings.splitStringByCommaToArray(request.param("type"))) .requestCache(request.paramAsBoolean("request_cache", null)) .source(request.content()); searchRequest.indicesOptions(IndicesOptions.fromRequest(request, searchRequest.indicesOptions())); putWarmerRequest.searchRequest(searchRequest); putWarmerRequest.timeout(request.paramAsTime("timeout", putWarmerRequest.timeout())); putWarmerRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putWarmerRequest.masterNodeTimeout())); client.admin().indices().putWarmer(putWarmerRequest, new AcknowledgedRestListener<PutWarmerResponse>(channel)); }
Example #23
Source File: CreateSnapshotRequest.java From crate with Apache License 2.0 | 5 votes |
public CreateSnapshotRequest(StreamInput in) throws IOException { super(in); snapshot = in.readString(); repository = in.readString(); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); settings = readSettingsFromStream(in); includeGlobalState = in.readBoolean(); waitForCompletion = in.readBoolean(); partial = in.readBoolean(); }
Example #24
Source File: RestFieldStatsAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { if (RestActions.hasBodyContent(request) && request.hasParam("fields")) { throw new IllegalArgumentException("can't specify a request body and [fields] request parameter, either specify a request body or the [fields] request parameter"); } final FieldStatsRequest fieldStatsRequest = new FieldStatsRequest(); fieldStatsRequest.indices(Strings.splitStringByCommaToArray(request.param("index"))); fieldStatsRequest.indicesOptions(IndicesOptions.fromRequest(request, fieldStatsRequest.indicesOptions())); fieldStatsRequest.level(request.param("level", FieldStatsRequest.DEFAULT_LEVEL)); if (RestActions.hasBodyContent(request)) { fieldStatsRequest.source(RestActions.getRestContent(request)); } else { fieldStatsRequest.setFields(Strings.splitStringByCommaToArray(request.param("fields"))); } client.fieldStats(fieldStatsRequest, new RestBuilderListener<FieldStatsResponse>(channel) { @Override public RestResponse buildResponse(FieldStatsResponse response, XContentBuilder builder) throws Exception { builder.startObject(); buildBroadcastShardsHeader(builder, request, response); builder.startObject("indices"); for (Map.Entry<String, Map<String, FieldStats>> entry1 : response.getIndicesMergedFieldStats().entrySet()) { builder.startObject(entry1.getKey()); builder.startObject("fields"); for (Map.Entry<String, FieldStats> entry2 : entry1.getValue().entrySet()) { builder.field(entry2.getKey()); entry2.getValue().toXContent(builder, request); } builder.endObject(); builder.endObject(); } builder.endObject(); return new BytesRestResponse(RestStatus.OK, builder); } }); }
Example #25
Source File: RestClusterSearchShardsAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final ClusterSearchShardsRequest clusterSearchShardsRequest = Requests.clusterSearchShardsRequest(indices); clusterSearchShardsRequest.local(request.paramAsBoolean("local", clusterSearchShardsRequest.local())); clusterSearchShardsRequest.types(Strings.splitStringByCommaToArray(request.param("type"))); clusterSearchShardsRequest.routing(request.param("routing")); clusterSearchShardsRequest.preference(request.param("preference")); clusterSearchShardsRequest.indicesOptions(IndicesOptions.fromRequest(request, clusterSearchShardsRequest.indicesOptions())); client.admin().cluster().searchShards(clusterSearchShardsRequest, new RestToXContentListener<ClusterSearchShardsResponse>(channel)); }
Example #26
Source File: GetSettingsRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); names = in.readStringArray(); humanReadable = in.readBoolean(); }
Example #27
Source File: RestOpenIndexAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { OpenIndexRequest openIndexRequest = new OpenIndexRequest(Strings.splitStringByCommaToArray(request.param("index"))); openIndexRequest.timeout(request.paramAsTime("timeout", openIndexRequest.timeout())); openIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", openIndexRequest.masterNodeTimeout())); openIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, openIndexRequest.indicesOptions())); client.admin().indices().open(openIndexRequest, new AcknowledgedRestListener<OpenIndexResponse>(channel)); }
Example #28
Source File: RestGetSettingsAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { final String[] names = request.paramAsStringArrayOrEmptyIfAll("name"); GetSettingsRequest getSettingsRequest = new GetSettingsRequest() .indices(Strings.splitStringByCommaToArray(request.param("index"))) .indicesOptions(IndicesOptions.fromRequest(request, IndicesOptions.strictExpandOpen())) .humanReadable(request.hasParam("human")) .names(names); getSettingsRequest.local(request.paramAsBoolean("local", getSettingsRequest.local())); client.admin().indices().getSettings(getSettingsRequest, new RestBuilderListener<GetSettingsResponse>(channel) { @Override public RestResponse buildResponse(GetSettingsResponse getSettingsResponse, XContentBuilder builder) throws Exception { builder.startObject(); for (ObjectObjectCursor<String, Settings> cursor : getSettingsResponse.getIndexToSettings()) { // no settings, jump over it to shorten the response data if (cursor.value.getAsMap().isEmpty()) { continue; } builder.startObject(cursor.key, XContentBuilder.FieldCaseConversion.NONE); builder.startObject(Fields.SETTINGS); cursor.value.toXContent(builder, request); builder.endObject(); builder.endObject(); } builder.endObject(); return new BytesRestResponse(OK, builder); } }); }
Example #29
Source File: UpdateSettingsRequest.java From crate with Apache License 2.0 | 5 votes |
public UpdateSettingsRequest(StreamInput in) throws IOException { super(in); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); settings = readSettingsFromStream(in); preserveExisting = in.readBoolean(); }
Example #30
Source File: RestClusterStateAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { final ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest(); clusterStateRequest.indicesOptions(IndicesOptions.fromRequest(request, clusterStateRequest.indicesOptions())); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout())); final String[] indices = Strings.splitStringByCommaToArray(request.param("indices", "_all")); boolean isAllIndicesOnly = indices.length == 1 && "_all".equals(indices[0]); if (!isAllIndicesOnly) { clusterStateRequest.indices(indices); } if (request.hasParam("metric")) { EnumSet<ClusterState.Metric> metrics = ClusterState.Metric.parseString(request.param("metric"), true); // do not ask for what we do not need. clusterStateRequest.nodes(metrics.contains(ClusterState.Metric.NODES) || metrics.contains(ClusterState.Metric.MASTER_NODE)); //there is no distinction in Java api between routing_table and routing_nodes, it's the same info set over the wire, one single flag to ask for it clusterStateRequest.routingTable(metrics.contains(ClusterState.Metric.ROUTING_TABLE) || metrics.contains(ClusterState.Metric.ROUTING_NODES)); clusterStateRequest.metaData(metrics.contains(ClusterState.Metric.METADATA)); clusterStateRequest.blocks(metrics.contains(ClusterState.Metric.BLOCKS)); clusterStateRequest.customs(metrics.contains(ClusterState.Metric.CUSTOMS)); } settingsFilter.addFilterSettingParams(request); client.admin().cluster().state(clusterStateRequest, new RestBuilderListener<ClusterStateResponse>(channel) { @Override public RestResponse buildResponse(ClusterStateResponse response, XContentBuilder builder) throws Exception { builder.startObject(); builder.field(Fields.CLUSTER_NAME, response.getClusterName().value()); response.getState().toXContent(builder, request); builder.endObject(); return new BytesRestResponse(RestStatus.OK, builder); } }); }