
io.alauda.kubernetes.client.dsl.internal.LogWatchCallback Maven / Gradle / Ivy
/**
* Copyright (C) 2018 Alauda
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.alauda.kubernetes.client.dsl.internal;
import io.alauda.kubernetes.client.Config;
import io.alauda.kubernetes.client.KubernetesClientException;
import io.alauda.kubernetes.client.dsl.LogWatch;
import io.alauda.kubernetes.client.utils.BlockingInputStreamPumper;
import io.alauda.kubernetes.client.utils.InputStreamPumper;
import io.alauda.kubernetes.client.utils.Utils;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static io.alauda.kubernetes.client.utils.Utils.closeQuietly;
import static io.alauda.kubernetes.client.utils.Utils.shutdownExecutorService;
public class LogWatchCallback implements LogWatch, Callback, AutoCloseable {
private static final Logger LOGGER = LoggerFactory.getLogger(LogWatchCallback.class);
private final Config config;
private final OutputStream out;
private final PipedInputStream output;
private final Set toClose = new LinkedHashSet<>();
private final AtomicBoolean started = new AtomicBoolean(false);
private final ArrayBlockingQueue
© 2015 - 2025 Weber Informatics LLC | Privacy Policy