@Override
    public void doRun() {
        // Point deflector to a new index if required.
        if (cluster.isConnected()) {
            indexSetRegistry.forEach((indexSet) -> {
                try {
                    if (indexSet.getConfig().isWritable()) {
                        checkAndRepair(indexSet);
                        checkForRotation(indexSet);
                    } else {
                        LOG.debug("Skipping non-writable index set <{}> ({})", indexSet.getConfig().id(), indexSet.getConfig().title());
                    }
                } catch (Exception e) {
                    LOG.error("Couldn't point deflector to a new index", e);
                }
            });
        } else {
            LOG.warn("Elasticsearch cluster isn't healthy. Skipping index rotation.");
        }
    }
@Test
    public void testDoNotPerformRotationIfClusterIsDown() throws NoTargetIndexException {
        final Provider<RotationStrategy> provider = spy(new RotationStrategyProvider());
        when(cluster.isConnected()).thenReturn(false);

        final IndexRotationThread rotationThread = new IndexRotationThread(
                notificationService,
                indices,
                indexSetRegistry,
                cluster,
                new NullActivityWriter(),
                nodeId,
                ImmutableMap.<String, Provider<RotationStrategy>>builder().put("strategy", provider).build(),
                dataTieringOrchestrator);
        rotationThread.doRun();

        verify(indexSet, never()).cycle();
        verify(provider, never()).get();
    }