@Test public void isDiskAvailableTest() throws Exception { MockDataNodeId dataNode = clusterMap.getDataNodes().get(0); List<ReplicaId> replicas = clusterMap.getReplicaIds(dataNode); Map<DiskId, List<ReplicaId>> diskToReplicas = new HashMap<>(); StorageManager storageManager = createStorageManager(dataNode, metricRegistry, null); storageManager.start(); assertEquals("There should be no unexpected partitions reported", 0, getNumUnrecognizedPartitionsReported()); for (ReplicaId replica : replicas) { diskToReplicas.computeIfAbsent(replica.getDiskId(), disk -> new ArrayList<>()).add(replica); } for (List<ReplicaId> replicasOnDisk : diskToReplicas.values()) { for (int i = 0; i < replicasOnDisk.size() - 1; ++i) { storageManager.getStore(replicasOnDisk.get(i).getPartitionId(), false).shutdown(); } } for (List<ReplicaId> replicasOnDisk : diskToReplicas.values()) { assertTrue("Disk should be available", storageManager.isDiskAvailable(replicasOnDisk.get(0).getDiskId())); assertEquals("Disk state be available", HardwareState.AVAILABLE, replicasOnDisk.get(0).getDiskId().getState()); } for (List<ReplicaId> replicasOnDisk : diskToReplicas.values()) { storageManager.getStore(replicasOnDisk.get(replicasOnDisk.size() - 1).getPartitionId(), false).shutdown(); } for (List<ReplicaId> replicasOnDisk : diskToReplicas.values()) { assertFalse("Disk should be unavailable", storageManager.isDiskAvailable(replicasOnDisk.get(0).getDiskId())); } for (List<ReplicaId> replicasOnDisk : diskToReplicas.values()) { storageManager.startBlobStore(replicasOnDisk.get(0).getPartitionId()); } for (List<ReplicaId> replicasOnDisk : diskToReplicas.values()) { assertTrue("Disk should be available", storageManager.isDiskAvailable(replicasOnDisk.get(0).getDiskId())); assertEquals("Disk state be available", HardwareState.AVAILABLE, replicasOnDisk.get(0).getDiskId().getState()); } shutdownAndAssertStoresInaccessible(storageManager, replicas); }
boolean isDiskAvailable(DiskId disk) { DiskManager diskManager = diskToDiskManager.get(disk); return diskManager != null && !diskManager.areAllStoresDown(); }
StorageManager implements StoreManager { boolean isDiskAvailable(DiskId disk) { DiskManager diskManager = diskToDiskManager.get(disk); return diskManager != null && !diskManager.areAllStoresDown(); } }
StorageManager implements StoreManager { boolean isDiskAvailable(DiskId disk) { DiskManager diskManager = diskToDiskManager.get(disk); return diskManager != null && !diskManager.areAllStoresDown(); } StorageManager(StoreConfig storeConfig, DiskManagerConfig diskManagerConfig,
      ScheduledExecutorService scheduler, MetricRegistry registry, StoreKeyFactory keyFactory, ClusterMap clusterMap,
      DataNodeId dataNodeId, MessageStoreHardDelete hardDelete, List<ClusterParticipant> clusterParticipants, Time time,
      MessageStoreRecovery recovery, AccountService accountService); }
StorageManager implements StoreManager { boolean isDiskAvailable(DiskId disk) { DiskManager diskManager = diskToDiskManager.get(disk); return diskManager != null && !diskManager.areAllStoresDown(); } StorageManager(StoreConfig storeConfig, DiskManagerConfig diskManagerConfig,
      ScheduledExecutorService scheduler, MetricRegistry registry, StoreKeyFactory keyFactory, ClusterMap clusterMap,
      DataNodeId dataNodeId, MessageStoreHardDelete hardDelete, List<ClusterParticipant> clusterParticipants, Time time,
      MessageStoreRecovery recovery, AccountService accountService); void start(); @Override Store getStore(PartitionId id); Store getStore(PartitionId id, boolean skipStateCheck); @Override ReplicaId getReplica(String partitionName); @Override Collection<PartitionId> getLocalPartitions(); @Override ServerErrorCode checkLocalPartitionStatus(PartitionId partition, ReplicaId localReplica); @Override boolean scheduleNextForCompaction(PartitionId id); @Override boolean controlCompactionForBlobStore(PartitionId id, boolean enabled); void shutdown(); @Override boolean addBlobStore(ReplicaId replica); @Override boolean startBlobStore(PartitionId id); @Override boolean shutdownBlobStore(PartitionId id); @Override boolean removeBlobStore(PartitionId id); @Override List<PartitionId> setBlobStoreStoppedState(List<PartitionId> partitionIds, boolean markStop); }
StorageManager implements StoreManager { boolean isDiskAvailable(DiskId disk) { DiskManager diskManager = diskToDiskManager.get(disk); return diskManager != null && !diskManager.areAllStoresDown(); } StorageManager(StoreConfig storeConfig, DiskManagerConfig diskManagerConfig,
      ScheduledExecutorService scheduler, MetricRegistry registry, StoreKeyFactory keyFactory, ClusterMap clusterMap,
      DataNodeId dataNodeId, MessageStoreHardDelete hardDelete, List<ClusterParticipant> clusterParticipants, Time time,
      MessageStoreRecovery recovery, AccountService accountService); void start(); @Override Store getStore(PartitionId id); Store getStore(PartitionId id, boolean skipStateCheck); @Override ReplicaId getReplica(String partitionName); @Override Collection<PartitionId> getLocalPartitions(); @Override ServerErrorCode checkLocalPartitionStatus(PartitionId partition, ReplicaId localReplica); @Override boolean scheduleNextForCompaction(PartitionId id); @Override boolean controlCompactionForBlobStore(PartitionId id, boolean enabled); void shutdown(); @Override boolean addBlobStore(ReplicaId replica); @Override boolean startBlobStore(PartitionId id); @Override boolean shutdownBlobStore(PartitionId id); @Override boolean removeBlobStore(PartitionId id); @Override List<PartitionId> setBlobStoreStoppedState(List<PartitionId> partitionIds, boolean markStop);  }