Java Code Examples for org.elasticsearch.common.settings.Settings#size()

The following examples show how to use org.elasticsearch.common.settings.Settings#size() . 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: TransportUpdateSettingsAction.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
protected ClusterBlockException checkBlock(UpdateSettingsRequest request, ClusterState state) {
    // allow for dedicated changes to the metadata blocks, so we don't block those to allow to "re-enable" it
    ClusterBlockException globalBlock = state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
    if (globalBlock != null) {
        return globalBlock;
    }

    // always allow removing of archived settings, so filter them out before doing further block checks
    Settings settings = request.settings().filter(k -> k.startsWith(ARCHIVED_SETTINGS_PREFIX + "*") == false);

    if (settings.size() == 1 &&  // we have to allow resetting these settings otherwise users can't unblock an index
        IndexMetaData.INDEX_BLOCKS_METADATA_SETTING.exists(settings)
        || IndexMetaData.INDEX_READ_ONLY_SETTING.exists(settings)
        || IndexMetaData.INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING.exists(settings)) {
        return null;
    }
    return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indexNameExpressionResolver.concreteIndexNames(state, request));
}
 
Example 2
Source File: AlterTablePlan.java    From crate with Apache License 2.0 5 votes vote down vote up
static void maybeRaiseBlockedException(TableInfo tableInfo, Settings tableSettings) {
    if (tableSettings.size() != 1 ||
        (tableSettings.get(IndexMetaData.SETTING_BLOCKS_METADATA) == null &&
         tableSettings.get(IndexMetaData.SETTING_READ_ONLY) == null)) {

        Operation.blockedRaiseException(tableInfo, Operation.ALTER);
    }
}
 
Example 3
Source File: AlterTableOperation.java    From crate with Apache License 2.0 5 votes vote down vote up
public CompletableFuture<Long> executeAlterTable(BoundAlterTable analysis) {
    final Settings settings = analysis.tableParameter().settings();
    final boolean includesNumberOfShardsSetting = settings.hasValue(SETTING_NUMBER_OF_SHARDS);
    final boolean isResizeOperationRequired = includesNumberOfShardsSetting &&
                                              (!analysis.isPartitioned() || analysis.partitionName().isPresent());

    if (isResizeOperationRequired) {
        if (settings.size() > 1) {
            throw new IllegalArgumentException("Setting [number_of_shards] cannot be combined with other settings");
        }
        return executeAlterTableChangeNumberOfShards(analysis);
    }
    return executeAlterTableSetOrReset(analysis);
}
 
Example 4
Source File: HostBasedAuthentication.java    From crate with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
SortedMap<String, Map<String, String>> convertHbaSettingsToHbaConf(Settings settings) {
    Settings hbaSettings = AuthSettings.AUTH_HOST_BASED_CONFIG_SETTING.setting().get(settings);
    ImmutableSortedMap.Builder<String, Map<String, String>> hostBasedConf = ImmutableSortedMap.naturalOrder();
    for (Map.Entry<String, Settings> entry : hbaSettings.getAsGroups().entrySet()) {
        Settings hbaEntry = entry.getValue();
        HashMap<String, String> map = new HashMap<>(hbaEntry.size());
        for (String name : hbaEntry.keySet()) {
            map.put(name, hbaEntry.get(name));
        }
        hostBasedConf.put(entry.getKey(), map);
    }
    return hostBasedConf.build();
}