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

org.elasticsearch.indices.IndicesLifecycle Maven / Gradle / Ivy

There is a newer version: 8.13.4
Show newest version
/*
 * Licensed to Elastic Search and Shay Banon under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Elastic Search 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.indices;

import org.elasticsearch.index.Index;
import org.elasticsearch.index.service.IndexService;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.shard.service.IndexShard;

/**
 * A global component allowing to register for lifecycle of an index (create/closed) and
 * an index shard (created/closed).
 *
 * @author kimchy (shay.banon)
 */
public interface IndicesLifecycle {

    /**
     * Add a listener.
     */
    void addListener(Listener listener);

    /**
     * Remove a listener.
     */
    void removeListener(Listener listener);

    /**
     * A listener for index and index shard lifecycle events (create/closed).
     */
    public abstract static class Listener {

        /**
         * Called before the index gets created.
         */
        public void beforeIndexCreated(Index index) {

        }

        /**
         * Called after the index has been created.
         */
        public void afterIndexCreated(IndexService indexService) {

        }

        /**
         * Called before the index shard gets created.
         */
        public void beforeIndexShardCreated(ShardId shardId) {

        }

        /**
         * Called after the index shard has been created.
         */
        public void afterIndexShardCreated(IndexShard indexShard) {

        }

        /**
         * Called before the index get closed.
         *
         * @param indexService The index service
         * @param delete       Does the index gets closed because of a delete command, or because the node is shutting down
         */
        public void beforeIndexClosed(IndexService indexService, boolean delete) {

        }

        /**
         * Called after the index has been closed.
         *
         * @param index  The index
         * @param delete Does the index gets closed because of a delete command, or because the node is shutting down
         */
        public void afterIndexClosed(Index index, boolean delete) {

        }

        /**
         * Called before the index shard gets closed.
         *
         * @param indexShard The index shard
         * @param delete     Does the index shard gets closed because of a delete command, or because the node is shutting down
         */
        public void beforeIndexShardClosed(IndexShard indexShard, boolean delete) {

        }

        /**
         * Called after the index shard has been closed.
         *
         * @param shardId The shard id
         * @param delete  Does the index shard gets closed because of a delete command, or because the node is shutting down
         */
        public void afterIndexShardClosed(ShardId shardId, boolean delete) {

        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy