Search in sources :

Example 26 with ClusterStateUpdateTask

use of org.elasticsearch.cluster.ClusterStateUpdateTask in project elasticsearch by elastic.

the class RareClusterStateIT method testAssignmentWithJustAddedNodes.

public void testAssignmentWithJustAddedNodes() throws Exception {
    internalCluster().startNode();
    final String index = "index";
    prepareCreate(index).setSettings(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1, IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0).get();
    ensureGreen(index);
    // close to have some unassigned started shards shards..
    client().admin().indices().prepareClose(index).get();
    final String masterName = internalCluster().getMasterName();
    final ClusterService clusterService = internalCluster().clusterService(masterName);
    final AllocationService allocationService = internalCluster().getInstance(AllocationService.class, masterName);
    clusterService.submitStateUpdateTask("test-inject-node-and-reroute", new ClusterStateUpdateTask() {

        @Override
        public ClusterState execute(ClusterState currentState) throws Exception {
            // inject a node
            ClusterState.Builder builder = ClusterState.builder(currentState);
            builder.nodes(DiscoveryNodes.builder(currentState.nodes()).add(new DiscoveryNode("_non_existent", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT)));
            // open index
            final IndexMetaData indexMetaData = IndexMetaData.builder(currentState.metaData().index(index)).state(IndexMetaData.State.OPEN).build();
            builder.metaData(MetaData.builder(currentState.metaData()).put(indexMetaData, true));
            builder.blocks(ClusterBlocks.builder().blocks(currentState.blocks()).removeIndexBlocks(index));
            ClusterState updatedState = builder.build();
            RoutingTable.Builder routingTable = RoutingTable.builder(updatedState.routingTable());
            routingTable.addAsRecovery(updatedState.metaData().index(index));
            updatedState = ClusterState.builder(updatedState).routingTable(routingTable.build()).build();
            return allocationService.reroute(updatedState, "reroute");
        }

        @Override
        public void onFailure(String source, Exception e) {
        }
    });
    ensureGreen(index);
    // remove the extra node
    clusterService.submitStateUpdateTask("test-remove-injected-node", new ClusterStateUpdateTask() {

        @Override
        public ClusterState execute(ClusterState currentState) throws Exception {
            ClusterState.Builder builder = ClusterState.builder(currentState);
            builder.nodes(DiscoveryNodes.builder(currentState.nodes()).remove("_non_existent"));
            currentState = builder.build();
            return allocationService.deassociateDeadNodes(currentState, true, "reroute");
        }

        @Override
        public void onFailure(String source, Exception e) {
        }
    });
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) ClusterService(org.elasticsearch.cluster.service.ClusterService) ClusterStateUpdateTask(org.elasticsearch.cluster.ClusterStateUpdateTask) AllocationService(org.elasticsearch.cluster.routing.allocation.AllocationService) IOException(java.io.IOException) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData)

Example 27 with ClusterStateUpdateTask

use of org.elasticsearch.cluster.ClusterStateUpdateTask in project elasticsearch by elastic.

the class ClusterServiceTests method testLongClusterStateUpdateLogging.

// To ensure that we log cluster state events on WARN level
@TestLogging("org.elasticsearch.cluster.service:WARN")
public void testLongClusterStateUpdateLogging() throws Exception {
    MockLogAppender mockAppender = new MockLogAppender();
    mockAppender.start();
    mockAppender.addExpectation(new MockLogAppender.UnseenEventExpectation("test1 shouldn't see because setting is too low", "org.elasticsearch.cluster.service.ClusterServiceTests$TimedClusterService", Level.WARN, "*cluster state update task [test1] took [*] above the warn threshold of *"));
    mockAppender.addExpectation(new MockLogAppender.SeenEventExpectation("test2", "org.elasticsearch.cluster.service.ClusterServiceTests$TimedClusterService", Level.WARN, "*cluster state update task [test2] took [32s] above the warn threshold of *"));
    mockAppender.addExpectation(new MockLogAppender.SeenEventExpectation("test3", "org.elasticsearch.cluster.service.ClusterServiceTests$TimedClusterService", Level.WARN, "*cluster state update task [test3] took [33s] above the warn threshold of *"));
    mockAppender.addExpectation(new MockLogAppender.SeenEventExpectation("test4", "org.elasticsearch.cluster.service.ClusterServiceTests$TimedClusterService", Level.WARN, "*cluster state update task [test4] took [34s] above the warn threshold of *"));
    Logger clusterLogger = Loggers.getLogger("org.elasticsearch.cluster.service");
    Loggers.addAppender(clusterLogger, mockAppender);
    try {
        final CountDownLatch latch = new CountDownLatch(5);
        final CountDownLatch processedFirstTask = new CountDownLatch(1);
        clusterService.currentTimeOverride = System.nanoTime();
        clusterService.submitStateUpdateTask("test1", new ClusterStateUpdateTask() {

            @Override
            public ClusterState execute(ClusterState currentState) throws Exception {
                clusterService.currentTimeOverride += TimeValue.timeValueSeconds(1).nanos();
                return currentState;
            }

            @Override
            public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
                latch.countDown();
                processedFirstTask.countDown();
            }

            @Override
            public void onFailure(String source, Exception e) {
                fail();
            }
        });
        processedFirstTask.await();
        clusterService.submitStateUpdateTask("test2", new ClusterStateUpdateTask() {

            @Override
            public ClusterState execute(ClusterState currentState) throws Exception {
                clusterService.currentTimeOverride += TimeValue.timeValueSeconds(32).nanos();
                throw new IllegalArgumentException("Testing handling of exceptions in the cluster state task");
            }

            @Override
            public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
                fail();
            }

            @Override
            public void onFailure(String source, Exception e) {
                latch.countDown();
            }
        });
        clusterService.submitStateUpdateTask("test3", new ClusterStateUpdateTask() {

            @Override
            public ClusterState execute(ClusterState currentState) throws Exception {
                clusterService.currentTimeOverride += TimeValue.timeValueSeconds(33).nanos();
                return ClusterState.builder(currentState).incrementVersion().build();
            }

            @Override
            public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
                latch.countDown();
            }

            @Override
            public void onFailure(String source, Exception e) {
                fail();
            }
        });
        clusterService.submitStateUpdateTask("test4", new ClusterStateUpdateTask() {

            @Override
            public ClusterState execute(ClusterState currentState) throws Exception {
                clusterService.currentTimeOverride += TimeValue.timeValueSeconds(34).nanos();
                return currentState;
            }

            @Override
            public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
                latch.countDown();
            }

            @Override
            public void onFailure(String source, Exception e) {
                fail();
            }
        });
        // Additional update task to make sure all previous logging made it to the loggerName
        // We don't check logging for this on since there is no guarantee that it will occur before our check
        clusterService.submitStateUpdateTask("test5", new ClusterStateUpdateTask() {

            @Override
            public ClusterState execute(ClusterState currentState) {
                return currentState;
            }

            @Override
            public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
                latch.countDown();
            }

            @Override
            public void onFailure(String source, Exception e) {
                fail();
            }
        });
        latch.await();
    } finally {
        Loggers.removeAppender(clusterLogger, mockAppender);
        mockAppender.stop();
    }
    mockAppender.assertAllExpectationsMatched();
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) MockLogAppender(org.elasticsearch.test.MockLogAppender) ClusterStateUpdateTask(org.elasticsearch.cluster.ClusterStateUpdateTask) Matchers.hasToString(org.hamcrest.Matchers.hasToString) Matchers.containsString(org.hamcrest.Matchers.containsString) Logger(org.apache.logging.log4j.Logger) CountDownLatch(java.util.concurrent.CountDownLatch) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) TestLogging(org.elasticsearch.test.junit.annotations.TestLogging)

Example 28 with ClusterStateUpdateTask

use of org.elasticsearch.cluster.ClusterStateUpdateTask in project elasticsearch by elastic.

the class ClusterServiceTests method testDisconnectFromNewlyAddedNodesIfClusterStatePublishingFails.

public void testDisconnectFromNewlyAddedNodesIfClusterStatePublishingFails() throws InterruptedException {
    TimedClusterService timedClusterService = new TimedClusterService(Settings.builder().put("cluster.name", "ClusterServiceTests").build(), new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), threadPool, () -> new DiscoveryNode("node1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
    Set<DiscoveryNode> currentNodes = new HashSet<>();
    timedClusterService.setNodeConnectionsService(new NodeConnectionsService(Settings.EMPTY, null, null) {

        @Override
        public void connectToNodes(DiscoveryNodes discoveryNodes) {
            discoveryNodes.forEach(currentNodes::add);
        }

        @Override
        public void disconnectFromNodesExcept(DiscoveryNodes nodesToKeep) {
            Set<DiscoveryNode> nodeSet = new HashSet<>();
            nodesToKeep.iterator().forEachRemaining(nodeSet::add);
            currentNodes.removeIf(node -> nodeSet.contains(node) == false);
        }
    });
    AtomicBoolean failToCommit = new AtomicBoolean();
    timedClusterService.setClusterStatePublisher((event, ackListener) -> {
        if (failToCommit.get()) {
            throw new Discovery.FailedToCommitClusterStateException("just to test this");
        }
    });
    timedClusterService.setDiscoverySettings(new DiscoverySettings(Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
    timedClusterService.start();
    ClusterState state = timedClusterService.state();
    final DiscoveryNodes nodes = state.nodes();
    final DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(nodes).masterNodeId(nodes.getLocalNodeId());
    state = ClusterState.builder(state).blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK).nodes(nodesBuilder).build();
    setState(timedClusterService, state);
    assertThat(currentNodes, equalTo(Sets.newHashSet(timedClusterService.state().getNodes())));
    final CountDownLatch latch = new CountDownLatch(1);
    // try to add node when cluster state publishing fails
    failToCommit.set(true);
    timedClusterService.submitStateUpdateTask("test", new ClusterStateUpdateTask() {

        @Override
        public ClusterState execute(ClusterState currentState) throws Exception {
            DiscoveryNode newNode = new DiscoveryNode("node2", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
            return ClusterState.builder(currentState).nodes(DiscoveryNodes.builder(currentState.nodes()).add(newNode)).build();
        }

        @Override
        public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
            latch.countDown();
        }

        @Override
        public void onFailure(String source, Exception e) {
            latch.countDown();
        }
    });
    latch.await();
    assertThat(currentNodes, equalTo(Sets.newHashSet(timedClusterService.state().getNodes())));
    timedClusterService.close();
}
Also used : Matchers.hasToString(org.hamcrest.Matchers.hasToString) Arrays(java.util.Arrays) Level(org.apache.logging.log4j.Level) ClusterBlocks(org.elasticsearch.cluster.block.ClusterBlocks) Matchers.hasKey(org.hamcrest.Matchers.hasKey) ClusterState(org.elasticsearch.cluster.ClusterState) ClusterStateUpdateTask(org.elasticsearch.cluster.ClusterStateUpdateTask) Settings(org.elasticsearch.common.settings.Settings) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) After(org.junit.After) Map(java.util.Map) ThreadPool(org.elasticsearch.threadpool.ThreadPool) MockLogAppender(org.elasticsearch.test.MockLogAppender) ClusterStateObserver(org.elasticsearch.cluster.ClusterStateObserver) Releasable(org.elasticsearch.common.lease.Releasable) AfterClass(org.junit.AfterClass) CyclicBarrier(java.util.concurrent.CyclicBarrier) Priority(org.elasticsearch.common.Priority) TestLogging(org.elasticsearch.test.junit.annotations.TestLogging) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) ClusterChangedEvent(org.elasticsearch.cluster.ClusterChangedEvent) Collectors(java.util.stream.Collectors) Sets(org.elasticsearch.common.util.set.Sets) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Version(org.elasticsearch.Version) Supplier(org.apache.logging.log4j.util.Supplier) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Matchers.is(org.hamcrest.Matchers.is) Matchers.anyOf(org.hamcrest.Matchers.anyOf) Matchers.containsString(org.hamcrest.Matchers.containsString) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) BeforeClass(org.junit.BeforeClass) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) BaseFuture(org.elasticsearch.common.util.concurrent.BaseFuture) HashSet(java.util.HashSet) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) ClusterStateTaskListener(org.elasticsearch.cluster.ClusterStateTaskListener) TimeValue(org.elasticsearch.common.unit.TimeValue) ESTestCase(org.elasticsearch.test.ESTestCase) Before(org.junit.Before) Loggers(org.elasticsearch.common.logging.Loggers) Collections.emptyMap(java.util.Collections.emptyMap) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) Matchers.empty(org.hamcrest.Matchers.empty) Collections.emptySet(java.util.Collections.emptySet) Discovery(org.elasticsearch.discovery.Discovery) Semaphore(java.util.concurrent.Semaphore) DiscoverySettings(org.elasticsearch.discovery.DiscoverySettings) ClusterStateTaskConfig(org.elasticsearch.cluster.ClusterStateTaskConfig) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) ClusterStateTaskExecutor(org.elasticsearch.cluster.ClusterStateTaskExecutor) TimeUnit(java.util.concurrent.TimeUnit) ExceptionsHelper(org.elasticsearch.ExceptionsHelper) LocalNodeMasterListener(org.elasticsearch.cluster.LocalNodeMasterListener) NodeConnectionsService(org.elasticsearch.cluster.NodeConnectionsService) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) LocalClusterUpdateTask(org.elasticsearch.cluster.LocalClusterUpdateTask) Tuple(org.elasticsearch.common.collect.Tuple) Collections(java.util.Collections) ClusterServiceUtils.setState(org.elasticsearch.test.ClusterServiceUtils.setState) ClusterState(org.elasticsearch.cluster.ClusterState) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) Set(java.util.Set) HashSet(java.util.HashSet) Collections.emptySet(java.util.Collections.emptySet) NodeConnectionsService(org.elasticsearch.cluster.NodeConnectionsService) ClusterStateUpdateTask(org.elasticsearch.cluster.ClusterStateUpdateTask) Matchers.hasToString(org.hamcrest.Matchers.hasToString) Matchers.containsString(org.hamcrest.Matchers.containsString) DiscoverySettings(org.elasticsearch.discovery.DiscoverySettings) CountDownLatch(java.util.concurrent.CountDownLatch) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) HashSet(java.util.HashSet)

Example 29 with ClusterStateUpdateTask

use of org.elasticsearch.cluster.ClusterStateUpdateTask in project elasticsearch by elastic.

the class ClusterServiceTests method testMasterAwareExecution.

public void testMasterAwareExecution() throws Exception {
    ClusterService nonMaster = createTimedClusterService(false);
    final boolean[] taskFailed = { false };
    final CountDownLatch latch1 = new CountDownLatch(1);
    nonMaster.submitStateUpdateTask("test", new ClusterStateUpdateTask() {

        @Override
        public ClusterState execute(ClusterState currentState) throws Exception {
            latch1.countDown();
            return currentState;
        }

        @Override
        public void onFailure(String source, Exception e) {
            taskFailed[0] = true;
            latch1.countDown();
        }
    });
    latch1.await();
    assertTrue("cluster state update task was executed on a non-master", taskFailed[0]);
    taskFailed[0] = true;
    final CountDownLatch latch2 = new CountDownLatch(1);
    nonMaster.submitStateUpdateTask("test", new LocalClusterUpdateTask() {

        @Override
        public ClusterTasksResult<LocalClusterUpdateTask> execute(ClusterState currentState) throws Exception {
            taskFailed[0] = false;
            latch2.countDown();
            return unchanged();
        }

        @Override
        public void onFailure(String source, Exception e) {
            taskFailed[0] = true;
            latch2.countDown();
        }
    });
    latch2.await();
    assertFalse("non-master cluster state update task was not executed", taskFailed[0]);
    nonMaster.close();
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) LocalClusterUpdateTask(org.elasticsearch.cluster.LocalClusterUpdateTask) ClusterStateUpdateTask(org.elasticsearch.cluster.ClusterStateUpdateTask) Matchers.hasToString(org.hamcrest.Matchers.hasToString) Matchers.containsString(org.hamcrest.Matchers.containsString) CountDownLatch(java.util.concurrent.CountDownLatch) BrokenBarrierException(java.util.concurrent.BrokenBarrierException)

Example 30 with ClusterStateUpdateTask

use of org.elasticsearch.cluster.ClusterStateUpdateTask in project elasticsearch by elastic.

the class DelayedAllocationServiceTests method testDelayedUnassignedScheduleReroute.

public void testDelayedUnassignedScheduleReroute() throws Exception {
    TimeValue delaySetting = timeValueMillis(100);
    MetaData metaData = MetaData.builder().put(IndexMetaData.builder("test").settings(settings(Version.CURRENT).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delaySetting)).numberOfShards(1).numberOfReplicas(1)).build();
    ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2")).localNodeId("node1").masterNodeId("node1")).build();
    final long baseTimestampNanos = System.nanoTime();
    allocationService.setNanoTimeOverride(baseTimestampNanos);
    clusterState = allocationService.reroute(clusterState, "reroute");
    // starting primaries
    clusterState = allocationService.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING));
    // starting replicas
    clusterState = allocationService.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING));
    assertFalse("no shards should be unassigned", clusterState.getRoutingNodes().unassigned().size() > 0);
    String nodeId = null;
    final List<ShardRouting> allShards = clusterState.getRoutingTable().allShards("test");
    // we need to find the node with the replica otherwise we will not reroute
    for (ShardRouting shardRouting : allShards) {
        if (shardRouting.primary() == false) {
            nodeId = shardRouting.currentNodeId();
            break;
        }
    }
    assertNotNull(nodeId);
    // remove node that has replica and reroute
    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove(nodeId)).build();
    clusterState = allocationService.deassociateDeadNodes(clusterState, true, "reroute");
    ClusterState stateWithDelayedShard = clusterState;
    // make sure the replica is marked as delayed (i.e. not reallocated)
    assertEquals(1, UnassignedInfo.getNumberOfDelayedUnassigned(stateWithDelayedShard));
    ShardRouting delayedShard = stateWithDelayedShard.getRoutingNodes().unassigned().iterator().next();
    assertEquals(baseTimestampNanos, delayedShard.unassignedInfo().getUnassignedTimeInNanos());
    // mock ClusterService.submitStateUpdateTask() method
    CountDownLatch latch = new CountDownLatch(1);
    AtomicReference<ClusterStateUpdateTask> clusterStateUpdateTask = new AtomicReference<>();
    doAnswer(invocationOnMock -> {
        clusterStateUpdateTask.set((ClusterStateUpdateTask) invocationOnMock.getArguments()[1]);
        latch.countDown();
        return null;
    }).when(clusterService).submitStateUpdateTask(eq(CLUSTER_UPDATE_TASK_SOURCE), any(ClusterStateUpdateTask.class));
    assertNull(delayedAllocationService.delayedRerouteTask.get());
    long delayUntilClusterChangeEvent = TimeValue.timeValueNanos(randomInt((int) delaySetting.nanos() - 1)).nanos();
    long clusterChangeEventTimestampNanos = baseTimestampNanos + delayUntilClusterChangeEvent;
    delayedAllocationService.setNanoTimeOverride(clusterChangeEventTimestampNanos);
    delayedAllocationService.clusterChanged(new ClusterChangedEvent("fake node left", stateWithDelayedShard, clusterState));
    // check that delayed reroute task was created and registered with the proper settings
    DelayedAllocationService.DelayedRerouteTask delayedRerouteTask = delayedAllocationService.delayedRerouteTask.get();
    assertNotNull(delayedRerouteTask);
    assertFalse(delayedRerouteTask.cancelScheduling.get());
    assertThat(delayedRerouteTask.baseTimestampNanos, equalTo(clusterChangeEventTimestampNanos));
    assertThat(delayedRerouteTask.nextDelay.nanos(), equalTo(delaySetting.nanos() - (clusterChangeEventTimestampNanos - baseTimestampNanos)));
    // check that submitStateUpdateTask() was invoked on the cluster service mock
    assertTrue(latch.await(30, TimeUnit.SECONDS));
    verify(clusterService).submitStateUpdateTask(eq(CLUSTER_UPDATE_TASK_SOURCE), eq(clusterStateUpdateTask.get()));
    // advance the time on the allocation service to a timestamp that happened after the delayed scheduling
    long nanoTimeForReroute = clusterChangeEventTimestampNanos + delaySetting.nanos() + timeValueMillis(randomInt(200)).nanos();
    allocationService.setNanoTimeOverride(nanoTimeForReroute);
    // apply cluster state
    ClusterState stateWithRemovedDelay = clusterStateUpdateTask.get().execute(stateWithDelayedShard);
    // check that shard is not delayed anymore
    assertEquals(0, UnassignedInfo.getNumberOfDelayedUnassigned(stateWithRemovedDelay));
    // check that task is now removed
    assertNull(delayedAllocationService.delayedRerouteTask.get());
    // simulate calling listener (cluster change event)
    delayedAllocationService.setNanoTimeOverride(nanoTimeForReroute + timeValueMillis(randomInt(200)).nanos());
    delayedAllocationService.clusterChanged(new ClusterChangedEvent(CLUSTER_UPDATE_TASK_SOURCE, stateWithRemovedDelay, stateWithDelayedShard));
    // check that no new task is scheduled
    assertNull(delayedAllocationService.delayedRerouteTask.get());
    // check that no further cluster state update was submitted
    verifyNoMoreInteractions(clusterService);
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) ClusterStateUpdateTask(org.elasticsearch.cluster.ClusterStateUpdateTask) AtomicReference(java.util.concurrent.atomic.AtomicReference) ClusterChangedEvent(org.elasticsearch.cluster.ClusterChangedEvent) CountDownLatch(java.util.concurrent.CountDownLatch) MetaData(org.elasticsearch.cluster.metadata.MetaData) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData) TimeValue(org.elasticsearch.common.unit.TimeValue)

Aggregations

ClusterState (org.elasticsearch.cluster.ClusterState)45 ClusterStateUpdateTask (org.elasticsearch.cluster.ClusterStateUpdateTask)45 CountDownLatch (java.util.concurrent.CountDownLatch)21 Matchers.containsString (org.hamcrest.Matchers.containsString)15 ArrayList (java.util.ArrayList)13 ClusterService (org.elasticsearch.cluster.service.ClusterService)13 IOException (java.io.IOException)12 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)12 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)12 List (java.util.List)11 Logger (org.apache.logging.log4j.Logger)9 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)8 SnapshotDeletionsInProgress (org.elasticsearch.cluster.SnapshotDeletionsInProgress)8 SnapshotsInProgress (org.elasticsearch.cluster.SnapshotsInProgress)8 FailedToCommitClusterStateException (org.elasticsearch.cluster.coordination.FailedToCommitClusterStateException)8 Priority (org.elasticsearch.common.Priority)8 Settings (org.elasticsearch.common.settings.Settings)8 Set (java.util.Set)7 ImmutableOpenMap (org.elasticsearch.common.collect.ImmutableOpenMap)7 RepositoryMissingException (org.elasticsearch.repositories.RepositoryMissingException)7