Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* 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.dsl.Reaper;
import io.alauda.kubernetes.client.dsl.ScalableResource;
import io.alauda.kubernetes.client.dsl.base.HasMetadataOperation;
import io.alauda.kubernetes.client.utils.Utils;
import okhttp3.OkHttpClient;
import io.alauda.kubernetes.api.model.extensions.Deployment;
import io.alauda.kubernetes.api.model.extensions.DeploymentList;
import io.alauda.kubernetes.api.model.extensions.DoneableDeployment;
import io.alauda.kubernetes.api.model.LabelSelector;
import io.alauda.kubernetes.client.Config;
import io.alauda.kubernetes.client.KubernetesClientException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
public class DeploymentOperationsImpl extends HasMetadataOperation>
implements ScalableResource {
static final transient Logger LOG = LoggerFactory.getLogger(DeploymentOperationsImpl.class);
public DeploymentOperationsImpl(OkHttpClient client, Config config, String namespace) {
this(client, config, "v1beta1", namespace, null, true, null, null, false, -1, new TreeMap(), new TreeMap(), new TreeMap(), new TreeMap(), new TreeMap());
}
public DeploymentOperationsImpl(OkHttpClient client, Config config, String apiVersion, String namespace, String name, Boolean cascading, Deployment item, String resourceVersion, Boolean reloadingFromServer, long gracePeriodSeconds, Map labels, Map labelsNot, Map labelsIn, Map labelsNotIn, Map fields) {
super(client, config, "extensions", apiVersion, "deployments", namespace, name, cascading, item, resourceVersion, reloadingFromServer, gracePeriodSeconds, labels, labelsNot, labelsIn, labelsNotIn, fields);
reaper = new DeploymentReaper(this);
}
@Override
public Deployment scale(int count) {
return scale(count, false);
}
@Override
public Deployment scale(int count, boolean wait) {
Deployment res = cascading(false).edit().editSpec().withReplicas(count).endSpec().done();
if (wait) {
waitUntilDeploymentIsScaled(count);
res = getMandatory();
}
return res;
}
@Override
public DoneableDeployment edit() {
if (isCascading()) {
return cascading(false).edit();
}
return super.edit();
}
@Override
public Deployment replace(Deployment item) {
if (isCascading()) {
return cascading(false).replace(item);
}
return super.replace(item);
}
@Override
public Deployment patch(Deployment item) {
if (isCascading()) {
return cascading(false).patch(item);
}
return super.patch(item);
}
/**
* Lets wait until there are enough Ready pods of the given Deployment
*/
private void waitUntilDeploymentIsScaled(final int count) {
final BlockingQueue