if(deployDate != -1 && (deployDate != partition.getValue().getDeploymentDate())) {
throw new TablespaceVersionInfoException(
"Inconsistent partition metadata within same node, deploy date was " + deployDate
+ " versus " + partition.getValue().getDeploymentDate());
}
PartitionMetadata metadata = partition.getValue();
Integer shard = partition.getKey();
// Create a PartitionEntry according to this PartitionMetadata
PartitionEntry myEntry = new PartitionEntry();
myEntry.setMax(metadata.getMaxKey());
myEntry.setMin(metadata.getMinKey());
myEntry.setShard(shard);
PartitionEntry existingPartitionEntry = null;
// Look for an existing PartitionEntry for the same shard in the PartitionMap
if(!partitionMap.contains(myEntry)) {
if(!event.equals(DNodeEvent.LEAVE)) {
// In this case all conditions are met for adding a new entry to the PartitionMap
partitionMap.add(myEntry);
// Note that now the PartitionMap is not necessarily sorted! let's sort it now
Collections.sort(partitionMap);
}
} else {
// Check consistency of this Partition Metadata
existingPartitionEntry = partitionMap.get(partitionMap.indexOf(myEntry));
if(existingPartitionEntry.getMax() == null || myEntry.getMax() == null) {
if(!(existingPartitionEntry.getMax() == null && myEntry.getMax() == null)) {
throw new TablespaceVersionInfoException(
"Inconsistent partition metadata between nodes: " + existingPartitionEntry
+ " versus " + myEntry);
}
} else {
if(!existingPartitionEntry.getMax().equals(myEntry.getMax())) {
throw new TablespaceVersionInfoException(
"Inconsistent partition metadata between nodes: " + existingPartitionEntry
+ " versus " + myEntry);
}
}
if(existingPartitionEntry.getMin() == null || myEntry.getMin() == null) {
if(!(existingPartitionEntry.getMin() == null && myEntry.getMin() == null)) {
throw new TablespaceVersionInfoException(
"Inconsistent partition metadata between nodes: " + existingPartitionEntry
+ " versus " + myEntry);
}
} else {
if(!existingPartitionEntry.getMin().equals(myEntry.getMin())) {
throw new TablespaceVersionInfoException(
"Inconsistent partition metadata between nodes: " + existingPartitionEntry
+ " versus " + myEntry);
}
}
}
// Create a ReplicationEntry according to this PartitionMetadata
// Will only contain this DNode as we don't know about the others yet
ReplicationEntry reEntry = new ReplicationEntry();
reEntry.setShard(shard);
reEntry.setExpectedReplicationFactor(metadata.getNReplicas());
reEntry.setNodes(new ArrayList<String>());
// Look for an existing ReplicationEntry for the same shard in the ReplicationMap
if(replicationMap.contains(reEntry)) {
ReplicationEntry existingEntry = replicationMap.get(replicationMap.indexOf(reEntry));
if(event.equals(DNodeEvent.LEAVE)) {