Search in sources :

Example 1 with TaskStatus

use of org.apache.druid.client.indexing.TaskStatus in project druid by druid-io.

the class LocalIntermediaryDataManager method deleteExpiredSuprevisorTaskPartitionsIfNotRunning.

/**
 * Check supervisorTask status if its partitions have not been accessed in timeout and
 * delete all partitions for the supervisorTask if it is already finished.
 *
 * Note that the overlord sends a cleanup request when a supervisorTask is finished. The below check is to trigger
 * the self-cleanup for when the cleanup request is missing.
 */
private void deleteExpiredSuprevisorTaskPartitionsIfNotRunning() throws InterruptedException {
    final DateTime now = DateTimes.nowUtc();
    final Set<String> expiredSupervisorTasks = new HashSet<>();
    for (Entry<String, DateTime> entry : supervisorTaskCheckTimes.entrySet()) {
        final String supervisorTaskId = entry.getKey();
        final DateTime checkTime = entry.getValue();
        if (checkTime.isAfter(now)) {
            expiredSupervisorTasks.add(supervisorTaskId);
        }
    }
    if (!expiredSupervisorTasks.isEmpty()) {
        LOG.info("Found [%s] expired supervisor tasks", expiredSupervisorTasks.size());
    }
    if (!expiredSupervisorTasks.isEmpty()) {
        final Map<String, TaskStatus> taskStatuses = indexingServiceClient.getTaskStatuses(expiredSupervisorTasks);
        for (Entry<String, TaskStatus> entry : taskStatuses.entrySet()) {
            final String supervisorTaskId = entry.getKey();
            final TaskStatus status = entry.getValue();
            if (status.getStatusCode().isComplete()) {
                // If it's finished, clean up all partitions for the supervisor task.
                try {
                    deletePartitions(supervisorTaskId);
                } catch (IOException e) {
                    LOG.warn(e, "Failed to delete partitions for task[%s]", supervisorTaskId);
                }
            } else {
                // If it's still running, update last access time.
                supervisorTaskCheckTimes.put(supervisorTaskId, getExpiryTimeFromNow());
            }
        }
    }
}
Also used : IOException(java.io.IOException) TaskStatus(org.apache.druid.client.indexing.TaskStatus) DateTime(org.joda.time.DateTime) HashSet(java.util.HashSet)

Example 2 with TaskStatus

use of org.apache.druid.client.indexing.TaskStatus in project druid by druid-io.

the class LocalIntermediaryDataManagerAutoCleanupTest method setup.

@Before
public void setup() throws IOException {
    final WorkerConfig workerConfig = new WorkerConfig() {

        @Override
        public long getIntermediaryPartitionDiscoveryPeriodSec() {
            return 1;
        }

        @Override
        public long getIntermediaryPartitionCleanupPeriodSec() {
            return 2;
        }

        @Override
        public Period getIntermediaryPartitionTimeout() {
            return new Period("PT2S");
        }
    };
    final TaskConfig taskConfig = new TaskConfig(null, null, null, null, null, false, null, null, ImmutableList.of(new StorageLocationConfig(tempDir.newFolder(), null, null)), false, false, TaskConfig.BATCH_PROCESSING_MODE_DEFAULT.name());
    final IndexingServiceClient indexingServiceClient = new NoopIndexingServiceClient() {

        @Override
        public Map<String, TaskStatus> getTaskStatuses(Set<String> taskIds) {
            final Map<String, TaskStatus> result = new HashMap<>();
            for (String taskId : taskIds) {
                result.put(taskId, new TaskStatus(taskId, TaskState.SUCCESS, 10));
            }
            return result;
        }
    };
    intermediaryDataManager = new LocalIntermediaryDataManager(workerConfig, taskConfig, indexingServiceClient);
    intermediaryDataManager.start();
}
Also used : IndexingServiceClient(org.apache.druid.client.indexing.IndexingServiceClient) NoopIndexingServiceClient(org.apache.druid.client.indexing.NoopIndexingServiceClient) StorageLocationConfig(org.apache.druid.segment.loading.StorageLocationConfig) Set(java.util.Set) NoopIndexingServiceClient(org.apache.druid.client.indexing.NoopIndexingServiceClient) HashMap(java.util.HashMap) WorkerConfig(org.apache.druid.indexing.worker.config.WorkerConfig) Period(org.joda.time.Period) TaskConfig(org.apache.druid.indexing.common.config.TaskConfig) TaskStatus(org.apache.druid.client.indexing.TaskStatus) Before(org.junit.Before)

Example 3 with TaskStatus

use of org.apache.druid.client.indexing.TaskStatus in project druid by druid-io.

the class ShuffleResourceTest method setup.

@Before
public void setup() throws IOException {
    final WorkerConfig workerConfig = new WorkerConfig() {

        @Override
        public long getIntermediaryPartitionDiscoveryPeriodSec() {
            return 1;
        }

        @Override
        public long getIntermediaryPartitionCleanupPeriodSec() {
            return 2;
        }

        @Override
        public Period getIntermediaryPartitionTimeout() {
            return new Period("PT2S");
        }
    };
    final TaskConfig taskConfig = new TaskConfig(null, null, null, null, null, false, null, null, ImmutableList.of(new StorageLocationConfig(tempDir.newFolder(), null, null)), false, false, TaskConfig.BATCH_PROCESSING_MODE_DEFAULT.name());
    final IndexingServiceClient indexingServiceClient = new NoopIndexingServiceClient() {

        @Override
        public Map<String, TaskStatus> getTaskStatuses(Set<String> taskIds) {
            final Map<String, TaskStatus> result = new HashMap<>();
            for (String taskId : taskIds) {
                result.put(taskId, new TaskStatus(taskId, TaskState.SUCCESS, 10));
            }
            return result;
        }
    };
    intermediaryDataManager = new LocalIntermediaryDataManager(workerConfig, taskConfig, indexingServiceClient);
    shuffleMetrics = new ShuffleMetrics();
    shuffleResource = new ShuffleResource(intermediaryDataManager, Optional.of(shuffleMetrics));
}
Also used : IndexingServiceClient(org.apache.druid.client.indexing.IndexingServiceClient) NoopIndexingServiceClient(org.apache.druid.client.indexing.NoopIndexingServiceClient) StorageLocationConfig(org.apache.druid.segment.loading.StorageLocationConfig) Set(java.util.Set) HashMap(java.util.HashMap) Period(org.joda.time.Period) TaskConfig(org.apache.druid.indexing.common.config.TaskConfig) TaskStatus(org.apache.druid.client.indexing.TaskStatus) NoopIndexingServiceClient(org.apache.druid.client.indexing.NoopIndexingServiceClient) PerDatasourceShuffleMetrics(org.apache.druid.indexing.worker.shuffle.ShuffleMetrics.PerDatasourceShuffleMetrics) WorkerConfig(org.apache.druid.indexing.worker.config.WorkerConfig) Before(org.junit.Before)

Aggregations

TaskStatus (org.apache.druid.client.indexing.TaskStatus)3 HashMap (java.util.HashMap)2 Set (java.util.Set)2 IndexingServiceClient (org.apache.druid.client.indexing.IndexingServiceClient)2 NoopIndexingServiceClient (org.apache.druid.client.indexing.NoopIndexingServiceClient)2 TaskConfig (org.apache.druid.indexing.common.config.TaskConfig)2 WorkerConfig (org.apache.druid.indexing.worker.config.WorkerConfig)2 StorageLocationConfig (org.apache.druid.segment.loading.StorageLocationConfig)2 Period (org.joda.time.Period)2 Before (org.junit.Before)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 PerDatasourceShuffleMetrics (org.apache.druid.indexing.worker.shuffle.ShuffleMetrics.PerDatasourceShuffleMetrics)1 DateTime (org.joda.time.DateTime)1