mirror of
https://gitee.com/juicedata/JuiceFS.git
synced 2025-12-06 17:49:22 +08:00
Hadoop: fix BgTaskUtilTest (#5735)
This commit is contained in:
@@ -15,13 +15,14 @@
|
||||
*/
|
||||
package io.juicefs.utils;
|
||||
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -33,6 +34,12 @@ public class BgTaskUtil {
|
||||
private static final Map<String, Object> tasks = new HashMap<>(); // volName|taskName -> running
|
||||
private static final Map<String, Set<Long>> runningInstance = new HashMap<>();
|
||||
|
||||
public static void reset() {
|
||||
bgThreadForName.clear();
|
||||
tasks.clear();
|
||||
runningInstance.clear();
|
||||
}
|
||||
|
||||
public static Map<String, ScheduledExecutorService> getBgThreadForName() {
|
||||
return bgThreadForName;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ public class BgTaskUtilTest extends TestCase {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BgTaskUtilTest.class);
|
||||
|
||||
public void testBgTask() throws Exception {
|
||||
BgTaskUtil.reset();
|
||||
|
||||
String[] volNames = new String[]{"fs1", "fs2", "fs3"};
|
||||
String[] taskNames = new String[]{"task1", "task2", "task3"};
|
||||
int threads = 20;
|
||||
|
||||
Reference in New Issue
Block a user