Source:
<code>public void storeStartFailureTest() throws Exception { MockDataNodeId dataNode = clusterMap.getDataNodes().get(0); List<ReplicaId> replicas = clusterMap.getReplicaIds(dataNode); Set<Integer> badReplicaIndexes = new HashSet<>(Arrays.asList(2, 7)); for (Integer badReplicaIndex : badReplicaIndexes) { new File(replicas.get(badReplicaIndex).getReplicaPath()).setReadable(false); } StorageManager storageManager = createAndStartStoreManager(replicas, metricRegistry); Map<String, Counter> counters = metricRegistry.getCounters(); <START> assertEquals(2, getCounterValue(counters, DiskManager.class.getName(), "TotalStoreStartFailures")); <END> assertEquals(0, getCounterValue(counters, DiskManager.class.getName(), "DiskMountPathFailures")); for (int i = 0; i < replicas.size(); i++) { ReplicaId replica = replicas.get(i); PartitionId id = replica.getPartitionId(); if (badReplicaIndexes.contains(i)) { assertNull("This store should not be accessible.", storageManager.getStore(id)); assertFalse("Compaction should not be scheduled", storageManager.scheduleNextForCompaction(id)); } else { Store store = storageManager.getStore(id); assertTrue("Store should be started", ((BlobStore) store).isStarted()); assertTrue("Compaction should be scheduled", storageManager.scheduleNextForCompaction(id)); } } assertEquals("Compaction thread count is incorrect", dataNode.getMountPaths().size(), TestUtils.numThreadsByThisName(CompactionManager.THREAD_NAME_PREFIX)); verifyCompactionThreadCount(storageManager, dataNode.getMountPaths().size()); shutdownAndAssertStoresInaccessible(storageManager, replicas); assertEquals("Compaction thread count is incorrect", 0, storageManager.getCompactionThreadCount()); assertEquals(2, getCounterValue(counters, DiskManager.class.getName(), "TotalStoreShutdownFailures")); }</code><technical_language>Minor: badReplicaIndexes.size() instead of 2 here? in case change setup of test</technical_language>

Target:
public void storeStartFailureTest() throws Exception { MockDataNodeId dataNode = clusterMap.getDataNodes().get(0); List<ReplicaId> replicas = clusterMap.getReplicaIds(dataNode); Set<Integer> badReplicaIndexes = new HashSet<>(Arrays.asList(2, 7)); for (Integer badReplicaIndex : badReplicaIndexes) { new File(replicas.get(badReplicaIndex).getReplicaPath()).setReadable(false); } StorageManager storageManager = createAndStartStoreManager(replicas, metricRegistry); Map<String, Counter> counters = metricRegistry.getCounters(); assertEquals(badReplicaIndexes.size(), getCounterValue(counters, DiskManager.class.getName(), "TotalStoreStartFailures")); assertEquals(0, getCounterValue(counters, DiskManager.class.getName(), "DiskMountPathFailures")); for (int i = 0; i < replicas.size(); i++) { ReplicaId replica = replicas.get(i); PartitionId id = replica.getPartitionId(); if (badReplicaIndexes.contains(i)) { assertNull("This store should not be accessible.", storageManager.getStore(id)); assertFalse("Compaction should not be scheduled", storageManager.scheduleNextForCompaction(id)); } else { Store store = storageManager.getStore(id); assertTrue("Store should be started", ((BlobStore) store).isStarted()); assertTrue("Compaction should be scheduled", storageManager.scheduleNextForCompaction(id)); } } assertEquals("Compaction thread count is incorrect", dataNode.getMountPaths().size(), TestUtils.numThreadsByThisName(CompactionManager.THREAD_NAME_PREFIX)); verifyCompactionThreadCount(storageManager, dataNode.getMountPaths().size()); shutdownAndAssertStoresInaccessible(storageManager, replicas); assertEquals("Compaction thread count is incorrect", 0, storageManager.getCompactionThreadCount()); assertEquals(badReplicaIndexes.size(), getCounterValue(counters, DiskManager.class.getName(), "TotalStoreShutdownFailures")); }