Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1324,47 +1324,65 @@ public IdealState apply(@Nullable IdealState idealState) {
}, RetryPolicies.exponentialBackoffRetryPolicy(5, 500L, 2.0f));
}

public void deleteOfflineTable(String tableName) {
String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(tableName);
public void deleteOfflineTable(String rawTableName) {
String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(rawTableName);
LOGGER.info("Deleting table {}: Start", offlineTableName);

// Remove the table from brokerResource
HelixHelper.removeResourceFromBrokerIdealState(_helixZkManager, offlineTableName);
LOGGER.info("Deleting table {}: Removed from broker resource", offlineTableName);

// Drop the table
if (_helixAdmin.getResourcesInCluster(_helixClusterName).contains(offlineTableName)) {
_helixAdmin.dropResource(_helixClusterName, offlineTableName);
LOGGER.info("Deleting table {}: Removed helix table resource", offlineTableName);
}

// Remove all segments for the table
// Remove all stored segments for the table
_segmentDeletionManager.removeSegmentsFromStore(offlineTableName, getSegmentsFor(offlineTableName));
LOGGER.info("Deleting table {}: Removed stored segments", offlineTableName);

// Remove segment metadata
ZKMetadataProvider.removeResourceSegmentsFromPropertyStore(_propertyStore, offlineTableName);
LOGGER.info("Deleting table {}: Removed segment metadata", offlineTableName);

// Remove table config
ZKMetadataProvider.removeResourceConfigFromPropertyStore(_propertyStore, offlineTableName);
LOGGER.info("Deleting table {}: Removed table config", offlineTableName);

// Remove replica group partition assignment
ZKMetadataProvider.removeInstancePartitionAssignmentFromPropertyStore(_propertyStore, offlineTableName);
LOGGER.info("Deleting table {}: Removed replica group partition assignment", offlineTableName);
LOGGER.info("Deleting table {}: Finish", offlineTableName);
}

public void deleteRealtimeTable(String tableName) {
String realtimeTableName = TableNameBuilder.REALTIME.tableNameWithType(tableName);
public void deleteRealtimeTable(String rawTableName) {
String realtimeTableName = TableNameBuilder.REALTIME.tableNameWithType(rawTableName);
LOGGER.info("Deleting table {}: Start", realtimeTableName);

// Remove the table from brokerResource
HelixHelper.removeResourceFromBrokerIdealState(_helixZkManager, realtimeTableName);
LOGGER.info("Deleting table {}: Removed from broker resource", realtimeTableName);

// Cache the state and drop the table
Set<String> instancesForTable = null;
if (_helixAdmin.getResourcesInCluster(_helixClusterName).contains(realtimeTableName)) {
instancesForTable = getAllInstancesForTable(realtimeTableName);
_helixAdmin.dropResource(_helixClusterName, realtimeTableName);
LOGGER.info("Deleting table {}: Removed helix table resource", realtimeTableName);
}

// Remove all segments for the table
// Remove all stored segments for the table
_segmentDeletionManager.removeSegmentsFromStore(realtimeTableName, getSegmentsFor(realtimeTableName));
LOGGER.info("Deleting table {}: Removed stored segments", realtimeTableName);

// Remove segment metadata
ZKMetadataProvider.removeResourceSegmentsFromPropertyStore(_propertyStore, realtimeTableName);
LOGGER.info("Deleting table {}: Removed segment metadata", realtimeTableName);

// Remove table config
ZKMetadataProvider.removeResourceConfigFromPropertyStore(_propertyStore, realtimeTableName);
LOGGER.info("Deleting table {}: Removed table config", realtimeTableName);

// Remove groupId/PartitionId mapping for HLC table
if (instancesForTable != null) {
Expand All @@ -1376,6 +1394,8 @@ public void deleteRealtimeTable(String tableName) {
}
}
}
LOGGER.info("Deleting table {}: Removed replica group partition assignment", realtimeTableName);
LOGGER.info("Deleting table {}: Finish", realtimeTableName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ public void testBalanceNumSegmentAssignmentStrategy()
@Test
public void testReplicaGroupPartitionAssignment()
throws Exception {
String tableNameWithType =
TableNameBuilder.OFFLINE.tableNameWithType(TABLE_NAME_REPLICA_GROUP_PARTITION_ASSIGNMENT);
String rawTableName = TABLE_NAME_REPLICA_GROUP_PARTITION_ASSIGNMENT;
String tableNameWithType = TableNameBuilder.OFFLINE.tableNameWithType(rawTableName);

// Adding a table without replica group
TableConfig tableConfig = new TableConfig.Builder(CommonConstants.Helix.TableType.OFFLINE)
Expand Down Expand Up @@ -236,7 +236,7 @@ public void testReplicaGroupPartitionAssignment()
Assert.assertTrue(partitionAssignment != null);

// After table deletion, check that the replica group partition assignment is deleted
_pinotHelixResourceManager.deleteOfflineTable(tableNameWithType);
_pinotHelixResourceManager.deleteOfflineTable(rawTableName);
partitionAssignment = _partitionAssignmentGenerator.getReplicaGroupPartitionAssignment(tableNameWithType);
Assert.assertTrue(partitionAssignment == null);

Expand All @@ -246,7 +246,7 @@ public void testReplicaGroupPartitionAssignment()
Assert.assertTrue(partitionAssignment != null);

// Check that the replica group partition assignment is deleted
_pinotHelixResourceManager.deleteOfflineTable(tableNameWithType);
_pinotHelixResourceManager.deleteOfflineTable(rawTableName);
partitionAssignment = _partitionAssignmentGenerator.getReplicaGroupPartitionAssignment(tableNameWithType);
Assert.assertTrue(partitionAssignment == null);
}
Expand Down