@Test public void areAllReplicasForPartitionUpTest() { MockDataNodeId dn1 = getDataNodeId("dn1", "DC1"); MockDataNodeId dn2 = getDataNodeId("dn2", "DC2"); MockPartitionId partitionId = new MockPartitionId(1, "default", Arrays.asList(dn1, dn2), 0); MockReplicaId replicaId1 = (MockReplicaId) partitionId.getReplicaIds().get(0); MockReplicaId replicaId2 = (MockReplicaId) partitionId.getReplicaIds().get(1); assertTrue("All replicas should be up", ClusterMapUtils.areAllReplicasForPartitionUp(partitionId)); replicaId1.markReplicaDownStatus(true); assertFalse("Not all replicas should be up", ClusterMapUtils.areAllReplicasForPartitionUp(partitionId)); replicaId2.markReplicaDownStatus(true); assertFalse("Not all replicas should be up", ClusterMapUtils.areAllReplicasForPartitionUp(partitionId)); replicaId1.markReplicaDownStatus(false); assertFalse("Not all replicas should be up", ClusterMapUtils.areAllReplicasForPartitionUp(partitionId)); replicaId2.markReplicaDownStatus(false); assertTrue("All replicas should be up", ClusterMapUtils.areAllReplicasForPartitionUp(partitionId)); }
static boolean areAllReplicasForPartitionUp(PartitionId partition) { for (ReplicaId replica : partition.getReplicaIds()) { if (replica.isDown()) { logger.debug("Replica [{}] on {} {} is down", replica.getPartitionId().toPathString(), replica.getDataNodeId().getHostname(), replica.getMountPath()); return false; } } return true; }
ClusterMapUtils { static boolean areAllReplicasForPartitionUp(PartitionId partition) { for (ReplicaId replica : partition.getReplicaIds()) { if (replica.isDown()) { logger.debug("Replica [{}] on {} {} is down", replica.getPartitionId().toPathString(), replica.getDataNodeId().getHostname(), replica.getMountPath()); return false; } } return true; } }
ClusterMapUtils { static boolean areAllReplicasForPartitionUp(PartitionId partition) { for (ReplicaId replica : partition.getReplicaIds()) { if (replica.isDown()) { logger.debug("Replica [{}] on {} {} is down", replica.getPartitionId().toPathString(), replica.getDataNodeId().getHostname(), replica.getMountPath()); return false; } } return true; }  }
ClusterMapUtils { static boolean areAllReplicasForPartitionUp(PartitionId partition) { for (ReplicaId replica : partition.getReplicaIds()) { if (replica.isDown()) { logger.debug("Replica [{}] on {} {} is down", replica.getPartitionId().toPathString(), replica.getDataNodeId().getHostname(), replica.getMountPath()); return false; } } return true; }  static String getInstanceName(String host, Integer port); static Map<String, DcZkInfo> parseDcJsonAndPopulateDcInfo(String dcInfoJsonString); static List<String> getDisabledReplicas(InstanceConfig instanceConfig); static List<String> getDisabledReplicas(ZNRecord znRecord); static String getDcName(InstanceConfig instanceConfig); static String getDcName(ZNRecord znRecord); static Integer getSslPortStr(InstanceConfig instanceConfig); static Integer getHttp2PortStr(InstanceConfig instanceConfig); static String getFullyQualifiedDomainName(String unqualifiedHostname); static void validateHostName(Boolean clusterMapResolveHostnames, String hostName); static void validatePorts(Port plainTextPort, Port sslPort, Port http2Port, boolean sslRequired); }
ClusterMapUtils { static boolean areAllReplicasForPartitionUp(PartitionId partition) { for (ReplicaId replica : partition.getReplicaIds()) { if (replica.isDown()) { logger.debug("Replica [{}] on {} {} is down", replica.getPartitionId().toPathString(), replica.getDataNodeId().getHostname(), replica.getMountPath()); return false; } } return true; }  static String getInstanceName(String host, Integer port); static Map<String, DcZkInfo> parseDcJsonAndPopulateDcInfo(String dcInfoJsonString); static List<String> getDisabledReplicas(InstanceConfig instanceConfig); static List<String> getDisabledReplicas(ZNRecord znRecord); static String getDcName(InstanceConfig instanceConfig); static String getDcName(ZNRecord znRecord); static Integer getSslPortStr(InstanceConfig instanceConfig); static Integer getHttp2PortStr(InstanceConfig instanceConfig); static String getFullyQualifiedDomainName(String unqualifiedHostname); static void validateHostName(Boolean clusterMapResolveHostnames, String hostName); static void validatePorts(Port plainTextPort, Port sslPort, Port http2Port, boolean sslRequired); static final String PARTITION_OVERRIDE_STR; static final String REPLICA_ADDITION_STR; static final String PARTITION_DISABLED_STR; static final String PROPERTYSTORE_STR; static final String ADMIN_CONFIG_ZNODE_PATH; static final String PARTITION_OVERRIDE_ZNODE_PATH; static final String REPLICA_ADDITION_ZNODE_PATH; static final String PARTITION_DISABLED_ZNODE_PATH; }