org.opensearch.tasks.TaskThreadContextStatePropagator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opensearch Show documentation
Show all versions of opensearch Show documentation
OpenSearch subproject :server
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
package org.opensearch.tasks;
import org.opensearch.common.util.concurrent.ThreadContextStatePropagator;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import static org.opensearch.tasks.TaskResourceTrackingService.TASK_ID;
/**
* Propagates TASK_ID across thread contexts
*/
public class TaskThreadContextStatePropagator implements ThreadContextStatePropagator {
@Override
public Map transients(Map source) {
final Map transients = new HashMap<>();
if (source.containsKey(TASK_ID)) {
transients.put(TASK_ID, source.get(TASK_ID));
}
return transients;
}
@Override
public Map headers(Map source) {
return Collections.emptyMap();
}
}