All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opensearch.tasks.TaskThreadContextStatePropagator Maven / Gradle / Ivy

There is a newer version: 2.18.0
Show newest version
/*
 * 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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy