HDDS-170. Fix TestBlockDeletingService#testBlockDeletionTimeout. Contributed by Lokesh Jain.

This commit is contained in:
Xiaoyu Yao 2018-06-27 13:56:45 -07:00
parent e9ec3d78f5
commit 1e30547642
5 changed files with 15 additions and 12 deletions

View File

@ -126,7 +126,7 @@ public synchronized void run() {
try {
// Collect task results
BackgroundTaskResult result = serviceTimeout > 0
? taskResultFuture.get(serviceTimeout, TimeUnit.MILLISECONDS)
? taskResultFuture.get(serviceTimeout, unit)
: taskResultFuture.get();
if (LOG.isDebugEnabled()) {
LOG.debug("task execution result size {}", result.getSize());

View File

@ -83,10 +83,10 @@ public class BlockDeletingService extends BackgroundService{
private final static int BLOCK_DELETING_SERVICE_CORE_POOL_SIZE = 10;
public BlockDeletingService(ContainerManager containerManager,
long serviceInterval, long serviceTimeout, Configuration conf) {
super("BlockDeletingService", serviceInterval,
TimeUnit.MILLISECONDS, BLOCK_DELETING_SERVICE_CORE_POOL_SIZE,
serviceTimeout);
long serviceInterval, long serviceTimeout, TimeUnit unit,
Configuration conf) {
super("BlockDeletingService", serviceInterval, unit,
BLOCK_DELETING_SERVICE_CORE_POOL_SIZE, serviceTimeout);
this.containerManager = containerManager;
this.conf = conf;
this.blockLimitPerTask = conf.getInt(

View File

@ -122,7 +122,7 @@ public OzoneContainer(
OZONE_BLOCK_DELETING_SERVICE_TIMEOUT,
OZONE_BLOCK_DELETING_SERVICE_TIMEOUT_DEFAULT, TimeUnit.MILLISECONDS);
this.blockDeletingService = new BlockDeletingService(manager,
svcInterval, serviceTimeout, ozoneConfig);
svcInterval, serviceTimeout, TimeUnit.MILLISECONDS, ozoneConfig);
this.dispatcher = new Dispatcher(manager, this.ozoneConfig);

View File

@ -44,8 +44,8 @@ public class BlockDeletingServiceTestImpl
public BlockDeletingServiceTestImpl(ContainerManager containerManager,
int serviceInterval, Configuration conf) {
super(containerManager, serviceInterval,
SERVICE_TIMEOUT_IN_MILLISECONDS, conf);
super(containerManager, serviceInterval, SERVICE_TIMEOUT_IN_MILLISECONDS,
TimeUnit.MILLISECONDS, conf);
}
@VisibleForTesting

View File

@ -280,10 +280,11 @@ public void testBlockDeletionTimeout() throws Exception {
ContainerManager containerManager = createContainerManager(conf);
createToDeleteBlocks(containerManager, conf, 1, 3, 1, chunksDir);
// set timeout value as 1ms to trigger timeout behavior
// set timeout value as 1ns to trigger timeout behavior
long timeout = 1;
BlockDeletingService svc =
new BlockDeletingService(containerManager, 1000, timeout, conf);
BlockDeletingService svc = new BlockDeletingService(containerManager,
TimeUnit.MILLISECONDS.toNanos(1000), timeout, TimeUnit.NANOSECONDS,
conf);
svc.start();
LogCapturer log = LogCapturer.captureLogs(BackgroundService.LOG);
@ -303,7 +304,9 @@ public void testBlockDeletionTimeout() throws Exception {
// test for normal case that doesn't have timeout limitation
timeout = 0;
createToDeleteBlocks(containerManager, conf, 1, 3, 1, chunksDir);
svc = new BlockDeletingService(containerManager, 1000, timeout, conf);
svc = new BlockDeletingService(containerManager,
TimeUnit.MILLISECONDS.toNanos(1000), timeout, TimeUnit.NANOSECONDS,
conf);
svc.start();
// get container meta data