Skip to content

Commit

Permalink
feat: adds getHealth function in TaskManagerMemory #1638
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanzalu committed Jan 27, 2025
1 parent ac39de1 commit ef5a295
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ public void clear() {
tasks.clear();
}

@Override
public boolean getHealth() {
return !executor.isShutdown();
}

@Override
public void addEventListener(Consumer<Event> callback) {
// no need for this we use task runner reference for stopping tasks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package org.icij.datashare.asynctasks;

import org.icij.datashare.PropertiesProvider;
import org.icij.datashare.tasks.RoutingStrategy;
import org.icij.datashare.test.LogbackCapturingRule;
import org.icij.datashare.user.User;
import org.icij.extract.redis.RedissonClientFactory;
import org.icij.task.Options;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.redisson.api.RedissonClient;
import org.slf4j.event.Level;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -126,6 +131,18 @@ public void test_wait_task_to_be_done() throws Exception {
assertThat(tasks).hasSize(1);
}

@Test
public void test_health_ok() {
assertThat(taskManager.getHealth()).isTrue();
}

@Test
public void test_health_ko() throws IOException {
taskManager.shutdown();

assertThat(taskManager.getHealth()).isFalse();
}

@After
public void tearDown() throws Exception {
taskManager.close();
Expand Down

0 comments on commit ef5a295

Please sign in to comment.