@Test public void getPartitionsTest() throws JSONException { String specialPartitionClass = "specialPartitionClass"; TestHardwareLayout hardwareLayout = new TestHardwareLayout("Alpha"); String dc = hardwareLayout.getRandomDatacenter().getName(); TestPartitionLayout testPartitionLayout = new TestPartitionLayout(hardwareLayout, dc); assertTrue("There should be more than 1 replica per partition in each DC for this test to work", testPartitionLayout.replicaCountPerDc > 1); PartitionRangeCheckParams defaultRw = new PartitionRangeCheckParams(0, testPartitionLayout.partitionCount, DEFAULT_PARTITION_CLASS, PartitionState.READ_WRITE); PartitionRangeCheckParams specialRw = new PartitionRangeCheckParams(defaultRw.rangeEnd + 1, 15, specialPartitionClass, PartitionState.READ_WRITE); testPartitionLayout.addNewPartitions(specialRw.count, specialPartitionClass, PartitionState.READ_WRITE, dc); PartitionRangeCheckParams defaultRo = new PartitionRangeCheckParams(specialRw.rangeEnd + 1, 10, DEFAULT_PARTITION_CLASS, PartitionState.READ_ONLY); testPartitionLayout.addNewPartitions(defaultRo.count, DEFAULT_PARTITION_CLASS, PartitionState.READ_ONLY, dc); PartitionRangeCheckParams specialRo = new PartitionRangeCheckParams(defaultRo.rangeEnd + 1, 5, specialPartitionClass, PartitionState.READ_ONLY); testPartitionLayout.addNewPartitions(specialRo.count, specialPartitionClass, PartitionState.READ_ONLY, dc); PartitionLayout partitionLayout = testPartitionLayout.getPartitionLayout(); List<PartitionId> returnedPartitions = partitionLayout.getPartitions(null); checkReturnedPartitions(returnedPartitions, Arrays.asList(defaultRw, defaultRo, specialRw, specialRo)); returnedPartitions = partitionLayout.getWritablePartitions(null); checkReturnedPartitions(returnedPartitions, Arrays.asList(defaultRw, specialRw)); returnedPartitions = partitionLayout.getPartitions(DEFAULT_PARTITION_CLASS); checkReturnedPartitions(returnedPartitions, Arrays.asList(defaultRw, defaultRo)); returnedPartitions = partitionLayout.getWritablePartitions(DEFAULT_PARTITION_CLASS); checkReturnedPartitions(returnedPartitions, Collections.singletonList(defaultRw)); returnedPartitions = partitionLayout.getPartitions(specialPartitionClass); checkReturnedPartitions(returnedPartitions, Arrays.asList(specialRw, specialRo)); returnedPartitions = partitionLayout.getWritablePartitions(specialPartitionClass); checkReturnedPartitions(returnedPartitions, Collections.singletonList(specialRw)); DataNode dataNode = hardwareLayout.getRandomDataNodeFromDc(dc); Partition partition = partitionLayout.addNewPartition(dataNode.getDisks().subList(0, 1), testPartitionLayout.replicaCapacityInBytes, specialPartitionClass); PartitionRangeCheckParams extraPartCheckParams = new PartitionRangeCheckParams(specialRo.rangeEnd + 1, 1, specialPartitionClass, PartitionState.READ_WRITE); returnedPartitions = partitionLayout.getPartitions(specialPartitionClass); assertTrue("Added partition should exist in returned partitions", returnedPartitions.contains(partition)); checkReturnedPartitions(returnedPartitions, Arrays.asList(specialRw, specialRo, extraPartCheckParams)); returnedPartitions = partitionLayout.getWritablePartitions(specialPartitionClass); assertFalse("Added partition should not exist in returned partitions", returnedPartitions.contains(partition)); checkReturnedPartitions(returnedPartitions, Collections.singletonList(specialRw)); }
public List<PartitionId> getPartitions(String partitionClass) { return partitionSelectionHelper.getPartitions(partitionClass); }
PartitionLayout { public List<PartitionId> getPartitions(String partitionClass) { return partitionSelectionHelper.getPartitions(partitionClass); } }
PartitionLayout { public List<PartitionId> getPartitions(String partitionClass) { return partitionSelectionHelper.getPartitions(partitionClass); } PartitionLayout(HardwareLayout hardwareLayout, JSONObject jsonObject, ClusterMapConfig clusterMapConfig);  PartitionLayout(HardwareLayout hardwareLayout, ClusterMapConfig clusterMapConfig); }
PartitionLayout { public List<PartitionId> getPartitions(String partitionClass) { return partitionSelectionHelper.getPartitions(partitionClass); } PartitionLayout(HardwareLayout hardwareLayout, JSONObject jsonObject, ClusterMapConfig clusterMapConfig);  PartitionLayout(HardwareLayout hardwareLayout, ClusterMapConfig clusterMapConfig); HardwareLayout getHardwareLayout(); String getClusterName(); long getVersion(); long getPartitionCount(); long getPartitionInStateCount(PartitionState partitionState); List<PartitionId> getPartitions(String partitionClass); List<PartitionId> getWritablePartitions(String partitionClass); PartitionId getRandomWritablePartition(String partitionClass, List<PartitionId> toExclude); long getAllocatedRawCapacityInBytes(); long getAllocatedUsableCapacityInBytes(); Partition addNewPartition(List<Disk> disks, long replicaCapacityInBytes, String partitionClass); void addNewReplicas(Partition partition, List<Disk> disks); Partition getPartition(InputStream stream); JSONObject toJSONObject(); List<String> getAllPartitionNames(); @Override String toString(); @Override boolean equals(Object o); }
PartitionLayout { public List<PartitionId> getPartitions(String partitionClass) { return partitionSelectionHelper.getPartitions(partitionClass); } PartitionLayout(HardwareLayout hardwareLayout, JSONObject jsonObject, ClusterMapConfig clusterMapConfig);  PartitionLayout(HardwareLayout hardwareLayout, ClusterMapConfig clusterMapConfig); HardwareLayout getHardwareLayout(); String getClusterName(); long getVersion(); long getPartitionCount(); long getPartitionInStateCount(PartitionState partitionState); List<PartitionId> getPartitions(String partitionClass); List<PartitionId> getWritablePartitions(String partitionClass); PartitionId getRandomWritablePartition(String partitionClass, List<PartitionId> toExclude); long getAllocatedRawCapacityInBytes(); long getAllocatedUsableCapacityInBytes(); Partition addNewPartition(List<Disk> disks, long replicaCapacityInBytes, String partitionClass); void addNewReplicas(Partition partition, List<Disk> disks); Partition getPartition(InputStream stream); JSONObject toJSONObject(); List<String> getAllPartitionNames(); @Override String toString(); @Override boolean equals(Object o);  }