[Minor]Add metadata-related logs and missing UT for kill tasks. (#10956)

* logs more info when delete segments && add deleteSegments-related UT

* revert msic.xml

* code review

* use log.debugSegments

Co-authored-by: yuezhang <yuezhang@freewheel.tv>
This commit is contained in:
zhangyue19921010 2021-03-12 10:00:52 +08:00 committed by GitHub
parent b0432be07a
commit 3277479ff7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View File

@ -1278,9 +1278,14 @@ public class IndexerSQLMetadataStorageCoordinator implements IndexerMetadataStor
@Override
public Void inTransaction(Handle handle, TransactionStatus transactionStatus)
{
int segmentSize = segments.size();
String dataSource = "";
for (final DataSegment segment : segments) {
dataSource = segment.getDataSource();
deleteSegment(handle, segment);
}
log.debugSegments(segments, "Delete the metadata of segments");
log.info("Removed [%d] segments from metadata storage for dataSource [%s]!", segmentSize, dataSource);
return null;
}

View File

@ -848,6 +848,39 @@ public class IndexerSQLMetadataStorageCoordinatorTest
Assert.assertNull("getDataSourceMetadataNullAfterDelete", coordinator.retrieveDataSourceMetadata("fooDataSource"));
}
@Test
public void testDeleteSegmentsInMetaDataStorage() throws IOException
{
// Published segments to MetaDataStorage
coordinator.announceHistoricalSegments(SEGMENTS);
// check segments Published
Assert.assertEquals(
SEGMENTS,
ImmutableSet.copyOf(
coordinator.retrieveUsedSegmentsForInterval(
defaultSegment.getDataSource(),
defaultSegment.getInterval(),
Segments.ONLY_VISIBLE
)
)
);
// remove segments in MetaDataStorage
coordinator.deleteSegments(SEGMENTS);
// check segments removed
Assert.assertEquals(
0,
ImmutableSet.copyOf(
coordinator.retrieveUsedSegmentsForInterval(
defaultSegment.getDataSource(),
defaultSegment.getInterval(),
Segments.ONLY_VISIBLE
)
).size()
);
}
@Test
public void testSingleAdditionalNumberedShardWithNoCorePartitions() throws IOException
{