mirror of https://github.com/apache/druid.git
fix unit test bug
This commit is contained in:
parent
0f4746450b
commit
efdff7b9f1
|
@ -264,6 +264,16 @@ public class RemoteTaskRunner implements TaskRunner
|
|||
return zkWorkers.size();
|
||||
}
|
||||
|
||||
public boolean isTaskRunning(String taskId)
|
||||
{
|
||||
for (WorkerWrapper workerWrapper : zkWorkers.values()) {
|
||||
if (workerWrapper.getRunningTasks().contains(taskId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Task task, TaskContext context, TaskCallback callback)
|
||||
{
|
||||
|
|
|
@ -196,8 +196,13 @@ public class RemoteTaskRunnerTest
|
|||
);
|
||||
|
||||
// Really don't like this way of waiting for the task to appear
|
||||
while (remoteTaskRunner.getNumWorkers() == 0) {
|
||||
int count = 0;
|
||||
while (!remoteTaskRunner.isTaskRunning("task1")) {
|
||||
Thread.sleep(500);
|
||||
if (count > 10) {
|
||||
throw new ISE("WTF?! Task still not announced in ZK?");
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
final MutableBoolean callbackCalled = new MutableBoolean(false);
|
||||
|
@ -364,8 +369,13 @@ public class RemoteTaskRunnerTest
|
|||
String.format("%s/worker1", announcementsPath),
|
||||
jsonMapper.writeValueAsBytes(worker1)
|
||||
);
|
||||
int count = 0;
|
||||
while (remoteTaskRunner.getNumWorkers() == 0) {
|
||||
Thread.sleep(500);
|
||||
if (count > 10) {
|
||||
throw new ISE("WTF?! Still can't find worker!");
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue