All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.elasticsearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest Maven / Gradle / Ivy

There is a newer version: 8.14.1
Show newest version
/*
 * Licensed to Elasticsearch under one or more contributor
 * license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright
 * ownership. Elasticsearch licenses this file to you under
 * the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.elasticsearch.action.admin.indices.create;

import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.support.ActiveShardCount;
import org.elasticsearch.cluster.ack.ClusterStateUpdateRequest;
import org.elasticsearch.cluster.block.ClusterBlock;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;
import org.elasticsearch.transport.TransportMessage;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * Cluster state update request that allows to create an index
 */
public class CreateIndexClusterStateUpdateRequest extends ClusterStateUpdateRequest {

    private final TransportMessage originalMessage;
    private final String cause;
    private final String index;
    private final String providedName;
    private final boolean updateAllTypes;
    private Index shrinkFrom;

    private IndexMetaData.State state = IndexMetaData.State.OPEN;

    private Settings settings = Settings.Builder.EMPTY_SETTINGS;

    private final Map mappings = new HashMap<>();

    private final Set aliases = new HashSet<>();

    private final Map customs = new HashMap<>();

    private final Set blocks = new HashSet<>();

    private ActiveShardCount waitForActiveShards = ActiveShardCount.DEFAULT;


    public CreateIndexClusterStateUpdateRequest(TransportMessage originalMessage, String cause, String index, String providedName,
                                                boolean updateAllTypes) {
        this.originalMessage = originalMessage;
        this.cause = cause;
        this.index = index;
        this.updateAllTypes = updateAllTypes;
        this.providedName = providedName;
    }

    public CreateIndexClusterStateUpdateRequest settings(Settings settings) {
        this.settings = settings;
        return this;
    }

    public CreateIndexClusterStateUpdateRequest mappings(Map mappings) {
        this.mappings.putAll(mappings);
        return this;
    }

    public CreateIndexClusterStateUpdateRequest aliases(Set aliases) {
        this.aliases.addAll(aliases);
        return this;
    }

    public CreateIndexClusterStateUpdateRequest customs(Map customs) {
        this.customs.putAll(customs);
        return this;
    }

    public CreateIndexClusterStateUpdateRequest blocks(Set blocks) {
        this.blocks.addAll(blocks);
        return this;
    }

    public CreateIndexClusterStateUpdateRequest state(IndexMetaData.State state) {
        this.state = state;
        return this;
    }

    public CreateIndexClusterStateUpdateRequest shrinkFrom(Index shrinkFrom) {
        this.shrinkFrom = shrinkFrom;
        return this;
    }

    public CreateIndexClusterStateUpdateRequest waitForActiveShards(ActiveShardCount waitForActiveShards) {
        this.waitForActiveShards = waitForActiveShards;
        return this;
    }

    public TransportMessage originalMessage() {
        return originalMessage;
    }

    public String cause() {
        return cause;
    }

    public String index() {
        return index;
    }

    public IndexMetaData.State state() {
        return state;
    }

    public Settings settings() {
        return settings;
    }

    public Map mappings() {
        return mappings;
    }

    public Set aliases() {
        return aliases;
    }

    public Map customs() {
        return customs;
    }

    public Set blocks() {
        return blocks;
    }

    public Index shrinkFrom() {
        return shrinkFrom;
    }

    /** True if all fields that span multiple types should be updated, false otherwise */
    public boolean updateAllTypes() {
        return updateAllTypes;
    }

    /**
     * The name that was provided by the user. This might contain a date math expression.
     * @see IndexMetaData#SETTING_INDEX_PROVIDED_NAME
     */
    public String getProvidedName() {
        return providedName;
    }

    public ActiveShardCount waitForActiveShards() {
        return waitForActiveShards;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy