Package org.elasticsearch.cluster.metadata

Examples of org.elasticsearch.cluster.metadata.IndexMetaData


            if (clusterExcludeFilters.match(node.node())) {
                return allocation.decision(Decision.NO, NAME, "node matches global exclude filters [%s]", clusterExcludeFilters);
            }
        }

        IndexMetaData indexMd = allocation.routingNodes().metaData().index(shardRouting.index());
        if (indexMd.requireFilters() != null) {
            if (!indexMd.requireFilters().match(node.node())) {
                return allocation.decision(Decision.NO, NAME, "node does not match index required filters [%s]", indexMd.requireFilters());
            }
        }
        if (indexMd.includeFilters() != null) {
            if (!indexMd.includeFilters().match(node.node())) {
                return allocation.decision(Decision.NO, NAME, "node does not match index include filters [%s]", indexMd.includeFilters());
            }
        }
        if (indexMd.excludeFilters() != null) {
            if (indexMd.excludeFilters().match(node.node())) {
                return allocation.decision(Decision.NO, NAME, "node matches index exclude filters [%s]", indexMd.excludeFilters());
            }
        }

        return allocation.decision(Decision.YES, NAME, "node passes include/exclude/require filters");
    }
View Full Code Here


                    RoutingTable.Builder routingTable = RoutingTable.builder(currentState.routingTable());
                    // go over existing indices, and see if they need to be removed
                    for (IndexMetaData index : currentState.metaData()) {
                        String markedTribeName = index.settings().get(TRIBE_NAME);
                        if (markedTribeName != null && markedTribeName.equals(tribeName)) {
                            IndexMetaData tribeIndex = tribeState.metaData().index(index.index());
                            if (tribeIndex == null) {
                                logger.info("[{}] removing index [{}]", tribeName, index.index());
                                removeIndex(blocks, metaData, routingTable, index);
                            } else {
                                // always make sure to update the metadata and routing table, in case
                                // there are changes in them (new mapping, shards moving from initializing to started)
                                routingTable.add(tribeState.routingTable().index(index.index()));
                                Settings tribeSettings = ImmutableSettings.builder().put(tribeIndex.settings()).put(TRIBE_NAME, tribeName).build();
                                metaData.put(IndexMetaData.builder(tribeIndex).settings(tribeSettings));
                            }
                        }
                    }
                    // go over tribe one, and see if they need to be added
                    for (IndexMetaData tribeIndex : tribeState.metaData()) {
                        // if there is no routing table yet, do nothing with it...
                        IndexRoutingTable table = tribeState.routingTable().index(tribeIndex.index());
                        if (table == null) {
                            continue;
                        }
                        final IndexMetaData indexMetaData = currentState.metaData().index(tribeIndex.index());
                        if (indexMetaData == null) {
                            if (!droppedIndices.contains(tribeIndex.index())) {
                                // a new index, add it, and add the tribe name as a setting
                                logger.info("[{}] adding index [{}]", tribeName, tribeIndex.index());
                                addNewIndex(tribeState, blocks, metaData, routingTable, tribeIndex);
                            }
                        } else {
                            String existingFromTribe = indexMetaData.getSettings().get(TRIBE_NAME);
                            if (!tribeName.equals(existingFromTribe)) {
                                // we have a potential conflict on index names, decide what to do...
                                if (ON_CONFLICT_ANY.equals(onConflict)) {
                                    // we chose any tribe, carry on
                                } else if (ON_CONFLICT_DROP.equals(onConflict)) {
View Full Code Here

                List<ShardRouting> shardRoutingsToBeApplied = new ArrayList<>(shardRoutingEntries.size());
                for (int i = 0; i < shardRoutingEntries.size(); i++) {
                    ShardRoutingEntry shardRoutingEntry = shardRoutingEntries.get(i);
                    shardRoutingEntry.processed = true;
                    ShardRouting shardRouting = shardRoutingEntry.shardRouting;
                    IndexMetaData indexMetaData = metaData.index(shardRouting.index());
                    // if there is no metadata or the current index is not of the right uuid, the index has been deleted while it was being allocated
                    // which is fine, we should just ignore this
                    if (indexMetaData == null) {
                        continue;
                    }
                    if (!indexMetaData.isSameUUID(shardRoutingEntry.indexUUID)) {
                        logger.debug("{} ignoring shard failed, different index uuid, current {}, got {}", shardRouting.shardId(), indexMetaData.getUUID(), shardRoutingEntry);
                        continue;
                    }

                    logger.debug("{} will apply shard failed {}", shardRouting.shardId(), shardRoutingEntry);
                    shardRoutingsToBeApplied.add(shardRouting);
View Full Code Here

                        for (int i = 0; i < shardRoutingEntries.size(); i++) {
                            ShardRoutingEntry shardRoutingEntry = shardRoutingEntries.get(i);
                            shardRoutingEntry.processed = true;
                            ShardRouting shardRouting = shardRoutingEntry.shardRouting;
                            try {
                                IndexMetaData indexMetaData = metaData.index(shardRouting.index());
                                IndexRoutingTable indexRoutingTable = routingTable.index(shardRouting.index());
                                // if there is no metadata, no routing table or the current index is not of the right uuid, the index has been deleted while it was being allocated
                                // which is fine, we should just ignore this
                                if (indexMetaData == null) {
                                    continue;
                                }
                                if (indexRoutingTable == null) {
                                    continue;
                                }

                                if (!indexMetaData.isSameUUID(shardRoutingEntry.indexUUID)) {
                                    logger.debug("{} ignoring shard started, different index uuid, current {}, got {}", shardRouting.shardId(), indexMetaData.getUUID(), shardRoutingEntry);
                                    continue;
                                }

                                // find the one that maps to us, if its already started, no need to do anything...
                                // the shard might already be started since the nodes that is starting the shards might get cluster events
View Full Code Here

    public void validate(RoutingTableValidation validation, MetaData metaData) {
        if (!metaData.hasIndex(index())) {
            validation.addIndexFailure(index(), "Exists in routing does not exists in metadata");
            return;
        }
        IndexMetaData indexMetaData = metaData.index(index());
        for (String failure : validate(indexMetaData)) {
            validation.addIndexFailure(index, failure);
        }

    }
View Full Code Here

    public int requiredAverageNumberOfShardsPerNode() {
        int totalNumberOfShards = 0;
        // we need to recompute to take closed shards into account
        for (ObjectCursor<IndexMetaData> cursor : metaData.indices().values()) {
            IndexMetaData indexMetaData = cursor.value;
            if (indexMetaData.state() == IndexMetaData.State.OPEN) {
                totalNumberOfShards += indexMetaData.totalNumberOfShards();
            }
        }
        return totalNumberOfShards / nodesToShards.size();
    }
View Full Code Here

        MetaData.Builder metaDataBuilder = MetaData.builder(clusterState.getMetaData());
        RoutingTable.Builder routingTableBuilder = RoutingTable.builder(clusterState.routingTable());

        IndexMetaData.Builder index = IndexMetaData.builder("test" + indexOrdinal).settings(settings(Version.CURRENT)).numberOfShards(numberOfShards).numberOfReplicas(
                numberOfReplicas);
        IndexMetaData imd = index.build();
        metaDataBuilder = metaDataBuilder.put(imd, true);
        routingTableBuilder.addAsNew(imd);

        MetaData metaData = metaDataBuilder.build();
        RoutingTable routingTable = routingTableBuilder.build();
View Full Code Here

    public boolean indexMetaDataChanged(IndexMetaData current) {
        MetaData previousMetaData = previousState.metaData();
        if (previousMetaData == null) {
            return true;
        }
        IndexMetaData previousIndexMetaData = previousMetaData.index(current.index());
        // no need to check on version, since disco modules will make sure to use the
        // same instance if its a version match
        if (previousIndexMetaData == current) {
            return false;
        }
View Full Code Here

        ensureGreen();

        assertAcked(client().admin().indices().prepareClose("test"));

        for (Client client : clients()) {
            IndexMetaData indexMetaData = getLocalClusterState(client).metaData().indices().get("test");
            assertThat(indexMetaData.getState(), equalTo(State.CLOSE));
        }
    }
View Full Code Here

        assertAcked(client().admin().indices().prepareClose("test"));

        assertAcked(client().admin().indices().prepareOpen("test"));

        for (Client client : clients()) {
            IndexMetaData indexMetaData = getLocalClusterState(client).metaData().indices().get("test");
            assertThat(indexMetaData.getState(), equalTo(State.OPEN));
        }
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.cluster.metadata.IndexMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.