use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.
the class ActionModule method initRestHandlers.
public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster) {
List<AbstractCatAction> catActions = new ArrayList<>();
Consumer<RestHandler> registerHandler = a -> {
if (a instanceof AbstractCatAction) {
catActions.add((AbstractCatAction) a);
}
};
registerHandler.accept(new RestMainAction(settings, restController));
registerHandler.accept(new RestNodesInfoAction(settings, restController, settingsFilter));
registerHandler.accept(new RestNodesStatsAction(settings, restController));
registerHandler.accept(new RestNodesHotThreadsAction(settings, restController));
registerHandler.accept(new RestClusterAllocationExplainAction(settings, restController));
registerHandler.accept(new RestClusterStatsAction(settings, restController));
registerHandler.accept(new RestClusterStateAction(settings, restController, settingsFilter));
registerHandler.accept(new RestClusterHealthAction(settings, restController));
registerHandler.accept(new RestClusterUpdateSettingsAction(settings, restController));
registerHandler.accept(new RestClusterGetSettingsAction(settings, restController, clusterSettings, settingsFilter));
registerHandler.accept(new RestClusterRerouteAction(settings, restController, settingsFilter));
registerHandler.accept(new RestClusterSearchShardsAction(settings, restController));
registerHandler.accept(new RestPendingClusterTasksAction(settings, restController));
registerHandler.accept(new RestPutRepositoryAction(settings, restController));
registerHandler.accept(new RestGetRepositoriesAction(settings, restController, settingsFilter));
registerHandler.accept(new RestDeleteRepositoryAction(settings, restController));
registerHandler.accept(new RestVerifyRepositoryAction(settings, restController));
registerHandler.accept(new RestGetSnapshotsAction(settings, restController));
registerHandler.accept(new RestCreateSnapshotAction(settings, restController));
registerHandler.accept(new RestRestoreSnapshotAction(settings, restController));
registerHandler.accept(new RestDeleteSnapshotAction(settings, restController));
registerHandler.accept(new RestSnapshotsStatusAction(settings, restController));
registerHandler.accept(new RestTypesExistsAction(settings, restController));
registerHandler.accept(new RestGetIndicesAction(settings, restController, indexScopedSettings, settingsFilter));
registerHandler.accept(new RestIndicesStatsAction(settings, restController));
registerHandler.accept(new RestIndicesSegmentsAction(settings, restController));
registerHandler.accept(new RestIndicesShardStoresAction(settings, restController));
registerHandler.accept(new RestGetAliasesAction(settings, restController));
registerHandler.accept(new RestIndexDeleteAliasesAction(settings, restController));
registerHandler.accept(new RestIndexPutAliasAction(settings, restController));
registerHandler.accept(new RestIndicesAliasesAction(settings, restController));
registerHandler.accept(new RestCreateIndexAction(settings, restController));
registerHandler.accept(new RestShrinkIndexAction(settings, restController));
registerHandler.accept(new RestRolloverIndexAction(settings, restController));
registerHandler.accept(new RestDeleteIndexAction(settings, restController));
registerHandler.accept(new RestCloseIndexAction(settings, restController));
registerHandler.accept(new RestOpenIndexAction(settings, restController));
registerHandler.accept(new RestUpdateSettingsAction(settings, restController));
registerHandler.accept(new RestGetSettingsAction(settings, restController, indexScopedSettings, settingsFilter));
registerHandler.accept(new RestAnalyzeAction(settings, restController));
registerHandler.accept(new RestGetIndexTemplateAction(settings, restController));
registerHandler.accept(new RestPutIndexTemplateAction(settings, restController));
registerHandler.accept(new RestDeleteIndexTemplateAction(settings, restController));
registerHandler.accept(new RestPutMappingAction(settings, restController));
registerHandler.accept(new RestGetMappingAction(settings, restController));
registerHandler.accept(new RestGetFieldMappingAction(settings, restController));
registerHandler.accept(new RestRefreshAction(settings, restController));
registerHandler.accept(new RestFlushAction(settings, restController));
registerHandler.accept(new RestSyncedFlushAction(settings, restController));
registerHandler.accept(new RestForceMergeAction(settings, restController));
registerHandler.accept(new RestUpgradeAction(settings, restController));
registerHandler.accept(new RestClearIndicesCacheAction(settings, restController));
registerHandler.accept(new RestIndexAction(settings, restController));
registerHandler.accept(new RestGetAction(settings, restController));
registerHandler.accept(new RestGetSourceAction(settings, restController));
registerHandler.accept(new RestMultiGetAction(settings, restController));
registerHandler.accept(new RestDeleteAction(settings, restController));
registerHandler.accept(new org.elasticsearch.rest.action.document.RestCountAction(settings, restController));
registerHandler.accept(new RestTermVectorsAction(settings, restController));
registerHandler.accept(new RestMultiTermVectorsAction(settings, restController));
registerHandler.accept(new RestBulkAction(settings, restController));
registerHandler.accept(new RestUpdateAction(settings, restController));
registerHandler.accept(new RestSearchAction(settings, restController));
registerHandler.accept(new RestSearchScrollAction(settings, restController));
registerHandler.accept(new RestClearScrollAction(settings, restController));
registerHandler.accept(new RestMultiSearchAction(settings, restController));
registerHandler.accept(new RestValidateQueryAction(settings, restController));
registerHandler.accept(new RestExplainAction(settings, restController));
registerHandler.accept(new RestRecoveryAction(settings, restController));
// Scripts API
registerHandler.accept(new RestGetStoredScriptAction(settings, restController));
registerHandler.accept(new RestPutStoredScriptAction(settings, restController));
registerHandler.accept(new RestDeleteStoredScriptAction(settings, restController));
registerHandler.accept(new RestFieldStatsAction(settings, restController));
// Tasks API
registerHandler.accept(new RestListTasksAction(settings, restController, nodesInCluster));
registerHandler.accept(new RestGetTaskAction(settings, restController));
registerHandler.accept(new RestCancelTasksAction(settings, restController, nodesInCluster));
// Ingest API
registerHandler.accept(new RestPutPipelineAction(settings, restController));
registerHandler.accept(new RestGetPipelineAction(settings, restController));
registerHandler.accept(new RestDeletePipelineAction(settings, restController));
registerHandler.accept(new RestSimulatePipelineAction(settings, restController));
// CAT API
registerHandler.accept(new RestAllocationAction(settings, restController));
registerHandler.accept(new RestShardsAction(settings, restController));
registerHandler.accept(new RestMasterAction(settings, restController));
registerHandler.accept(new RestNodesAction(settings, restController));
registerHandler.accept(new RestTasksAction(settings, restController, nodesInCluster));
registerHandler.accept(new RestIndicesAction(settings, restController, indexNameExpressionResolver));
registerHandler.accept(new RestSegmentsAction(settings, restController));
// Fully qualified to prevent interference with rest.action.count.RestCountAction
registerHandler.accept(new org.elasticsearch.rest.action.cat.RestCountAction(settings, restController));
// Fully qualified to prevent interference with rest.action.indices.RestRecoveryAction
registerHandler.accept(new org.elasticsearch.rest.action.cat.RestRecoveryAction(settings, restController));
registerHandler.accept(new RestHealthAction(settings, restController));
registerHandler.accept(new org.elasticsearch.rest.action.cat.RestPendingClusterTasksAction(settings, restController));
registerHandler.accept(new RestAliasAction(settings, restController));
registerHandler.accept(new RestThreadPoolAction(settings, restController));
registerHandler.accept(new RestPluginsAction(settings, restController));
registerHandler.accept(new RestFielddataAction(settings, restController));
registerHandler.accept(new RestNodeAttrsAction(settings, restController));
registerHandler.accept(new RestRepositoriesAction(settings, restController));
registerHandler.accept(new RestSnapshotAction(settings, restController));
registerHandler.accept(new RestTemplatesAction(settings, restController));
for (ActionPlugin plugin : actionPlugins) {
for (RestHandler handler : plugin.getRestHandlers(settings, restController, clusterSettings, indexScopedSettings, settingsFilter, indexNameExpressionResolver, nodesInCluster)) {
registerHandler.accept(handler);
}
}
registerHandler.accept(new RestCatAction(settings, restController, catActions));
}
use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.
the class TransportAnalyzeAction method getCharFilterFactories.
private static CharFilterFactory[] getCharFilterFactories(AnalyzeRequest request, IndexSettings indexSettings, AnalysisRegistry analysisRegistry, Environment environment, CharFilterFactory[] charFilterFactories) throws IOException {
if (request.charFilters() != null && request.charFilters().size() > 0) {
charFilterFactories = new CharFilterFactory[request.charFilters().size()];
for (int i = 0; i < request.charFilters().size(); i++) {
final AnalyzeRequest.NameOrDefinition charFilter = request.charFilters().get(i);
// parse anonymous settings
if (charFilter.definition != null) {
Settings settings = getAnonymousSettings(charFilter.definition);
String charFilterTypeName = settings.get("type");
if (charFilterTypeName == null) {
throw new IllegalArgumentException("Missing [type] setting for anonymous char filter: " + charFilter.definition);
}
AnalysisModule.AnalysisProvider<CharFilterFactory> charFilterFactoryFactory = analysisRegistry.getCharFilterProvider(charFilterTypeName);
if (charFilterFactoryFactory == null) {
throw new IllegalArgumentException("failed to find global char filter under [" + charFilterTypeName + "]");
}
// Need to set anonymous "name" of char_filter
charFilterFactories[i] = charFilterFactoryFactory.get(getNaIndexSettings(settings), environment, "_anonymous_charfilter_[" + i + "]", settings);
} else {
AnalysisModule.AnalysisProvider<CharFilterFactory> charFilterFactoryFactory;
if (indexSettings == null) {
charFilterFactoryFactory = analysisRegistry.getCharFilterProvider(charFilter.name);
if (charFilterFactoryFactory == null) {
throw new IllegalArgumentException("failed to find global char filter under [" + charFilter.name + "]");
}
charFilterFactories[i] = charFilterFactoryFactory.get(environment, charFilter.name);
} else {
charFilterFactoryFactory = analysisRegistry.getCharFilterProvider(charFilter.name, indexSettings);
if (charFilterFactoryFactory == null) {
throw new IllegalArgumentException("failed to find char filter under [" + charFilter.name + "]");
}
charFilterFactories[i] = charFilterFactoryFactory.get(indexSettings, environment, charFilter.name, AnalysisRegistry.getSettingsFromIndexSettings(indexSettings, AnalysisRegistry.INDEX_ANALYSIS_CHAR_FILTER + "." + charFilter.name));
}
}
if (charFilterFactories[i] == null) {
throw new IllegalArgumentException("failed to find char filter under [" + charFilter.name + "]");
}
}
}
return charFilterFactories;
}
use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.
the class GetIndexResponse method writeTo.
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeStringArray(indices);
out.writeVInt(mappings.size());
for (ObjectObjectCursor<String, ImmutableOpenMap<String, MappingMetaData>> indexEntry : mappings) {
out.writeString(indexEntry.key);
out.writeVInt(indexEntry.value.size());
for (ObjectObjectCursor<String, MappingMetaData> mappingEntry : indexEntry.value) {
out.writeString(mappingEntry.key);
mappingEntry.value.writeTo(out);
}
}
out.writeVInt(aliases.size());
for (ObjectObjectCursor<String, List<AliasMetaData>> indexEntry : aliases) {
out.writeString(indexEntry.key);
out.writeVInt(indexEntry.value.size());
for (AliasMetaData aliasEntry : indexEntry.value) {
aliasEntry.writeTo(out);
}
}
out.writeVInt(settings.size());
for (ObjectObjectCursor<String, Settings> indexEntry : settings) {
out.writeString(indexEntry.key);
Settings.writeSettingsToStream(indexEntry.value, out);
}
}
use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.
the class GetIndexResponse method readFrom.
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
this.indices = in.readStringArray();
int mappingsSize = in.readVInt();
ImmutableOpenMap.Builder<String, ImmutableOpenMap<String, MappingMetaData>> mappingsMapBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < mappingsSize; i++) {
String key = in.readString();
int valueSize = in.readVInt();
ImmutableOpenMap.Builder<String, MappingMetaData> mappingEntryBuilder = ImmutableOpenMap.builder();
for (int j = 0; j < valueSize; j++) {
mappingEntryBuilder.put(in.readString(), new MappingMetaData(in));
}
mappingsMapBuilder.put(key, mappingEntryBuilder.build());
}
mappings = mappingsMapBuilder.build();
int aliasesSize = in.readVInt();
ImmutableOpenMap.Builder<String, List<AliasMetaData>> aliasesMapBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < aliasesSize; i++) {
String key = in.readString();
int valueSize = in.readVInt();
List<AliasMetaData> aliasEntryBuilder = new ArrayList<>();
for (int j = 0; j < valueSize; j++) {
aliasEntryBuilder.add(new AliasMetaData(in));
}
aliasesMapBuilder.put(key, Collections.unmodifiableList(aliasEntryBuilder));
}
aliases = aliasesMapBuilder.build();
int settingsSize = in.readVInt();
ImmutableOpenMap.Builder<String, Settings> settingsMapBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < settingsSize; i++) {
String key = in.readString();
settingsMapBuilder.put(key, Settings.readSettingsFromStream(in));
}
settings = settingsMapBuilder.build();
}
use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.
the class TransportGetIndexAction method doMasterOperation.
@Override
protected void doMasterOperation(final GetIndexRequest request, String[] concreteIndices, final ClusterState state, final ActionListener<GetIndexResponse> listener) {
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappingsResult = ImmutableOpenMap.of();
ImmutableOpenMap<String, List<AliasMetaData>> aliasesResult = ImmutableOpenMap.of();
ImmutableOpenMap<String, Settings> settings = ImmutableOpenMap.of();
Feature[] features = request.features();
boolean doneAliases = false;
boolean doneMappings = false;
boolean doneSettings = false;
for (Feature feature : features) {
switch(feature) {
case MAPPINGS:
if (!doneMappings) {
mappingsResult = state.metaData().findMappings(concreteIndices, request.types());
doneMappings = true;
}
break;
case ALIASES:
if (!doneAliases) {
aliasesResult = state.metaData().findAliases(Strings.EMPTY_ARRAY, concreteIndices);
doneAliases = true;
}
break;
case SETTINGS:
if (!doneSettings) {
ImmutableOpenMap.Builder<String, Settings> settingsMapBuilder = ImmutableOpenMap.builder();
for (String index : concreteIndices) {
Settings indexSettings = state.metaData().index(index).getSettings();
if (request.humanReadable()) {
indexSettings = IndexMetaData.addHumanReadableSettings(indexSettings);
}
settingsMapBuilder.put(index, indexSettings);
}
settings = settingsMapBuilder.build();
doneSettings = true;
}
break;
default:
throw new IllegalStateException("feature [" + feature + "] is not valid");
}
}
listener.onResponse(new GetIndexResponse(concreteIndices, mappingsResult, aliasesResult, settings));
}
Aggregations