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 abstract class BackgroundService {
try { try {
// Collect task results // Collect task results
BackgroundTaskResult result = serviceTimeout > 0 BackgroundTaskResult result = serviceTimeout > 0
? taskResultFuture.get(serviceTimeout, TimeUnit.MILLISECONDS) ? taskResultFuture.get(serviceTimeout, unit)
: taskResultFuture.get(); : taskResultFuture.get();
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("task execution result size {}", result.getSize()); 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; private final static int BLOCK_DELETING_SERVICE_CORE_POOL_SIZE = 10;
public BlockDeletingService(ContainerManager containerManager, public BlockDeletingService(ContainerManager containerManager,
long serviceInterval, long serviceTimeout, Configuration conf) { long serviceInterval, long serviceTimeout, TimeUnit unit,
super("BlockDeletingService", serviceInterval, Configuration conf) {
TimeUnit.MILLISECONDS, BLOCK_DELETING_SERVICE_CORE_POOL_SIZE, super("BlockDeletingService", serviceInterval, unit,
serviceTimeout); BLOCK_DELETING_SERVICE_CORE_POOL_SIZE, serviceTimeout);
this.containerManager = containerManager; this.containerManager = containerManager;
this.conf = conf; this.conf = conf;
this.blockLimitPerTask = conf.getInt( this.blockLimitPerTask = conf.getInt(

View File

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

View File

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

View File

@ -280,10 +280,11 @@ public class TestBlockDeletingService {
ContainerManager containerManager = createContainerManager(conf); ContainerManager containerManager = createContainerManager(conf);
createToDeleteBlocks(containerManager, conf, 1, 3, 1, chunksDir); 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; long timeout = 1;
BlockDeletingService svc = BlockDeletingService svc = new BlockDeletingService(containerManager,
new BlockDeletingService(containerManager, 1000, timeout, conf); TimeUnit.MILLISECONDS.toNanos(1000), timeout, TimeUnit.NANOSECONDS,
conf);
svc.start(); svc.start();
LogCapturer log = LogCapturer.captureLogs(BackgroundService.LOG); LogCapturer log = LogCapturer.captureLogs(BackgroundService.LOG);
@ -303,7 +304,9 @@ public class TestBlockDeletingService {
// test for normal case that doesn't have timeout limitation // test for normal case that doesn't have timeout limitation
timeout = 0; timeout = 0;
createToDeleteBlocks(containerManager, conf, 1, 3, 1, chunksDir); 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(); svc.start();
// get container meta data // get container meta data