Skip to content

Commit

Permalink
remove unnecessary extra interface, add license, fix constructor call…
Browse files Browse the repository at this point in the history
…s after merge
  • Loading branch information
bbeaudreault committed May 19, 2020
1 parent 3342279 commit e1cee61
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
import java.util.Collection;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;

/**
* Class for Default Kubernetes Client implementing KubernetesClient interface.
Expand Down Expand Up @@ -158,7 +157,7 @@ public ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable<HasM

@Override
public NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable<HasMetadata, Boolean> resourceList(KubernetesResourceList item) {
return new NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl(httpClient, getConfiguration(), getNamespace(), null, false, false, new ArrayList<Visitor>(), item, null, null, -1, DeletionPropagation.BACKGROUND, true) {
return new NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl(httpClient, getConfiguration(), getNamespace(), null, false, false, new ArrayList<>(), item, null, DeletionPropagation.BACKGROUND, true) {
};
}

Expand All @@ -174,20 +173,20 @@ public NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable<HasMetadata,

@Override
public ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable<HasMetadata, Boolean> resourceList(String s) {
return new NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl(httpClient, getConfiguration(), getNamespace(), null, false, false, new ArrayList<Visitor>(), s, null, null, -1, DeletionPropagation.BACKGROUND, true) {
return new NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl(httpClient, getConfiguration(), getNamespace(), null, false, false, new ArrayList<>(), s, null, DeletionPropagation.BACKGROUND, true) {
};
}


@Override
public NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable<HasMetadata, Boolean> resource(HasMetadata item) {
return new NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl(httpClient, getConfiguration(), getNamespace(), null, false, false, new ArrayList<Visitor>(), item, -1, DeletionPropagation.BACKGROUND, true, 5, 2) {
return new NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl(httpClient, getConfiguration(), getNamespace(), null, false, false, new ArrayList<Visitor>(), item, -1, DeletionPropagation.BACKGROUND, true, Waitable.DEFAULT_INITIAL_BACKOFF_MILLIS, Waitable.DEFAULT_BACKOFF_MULTIPLIER) {
};
}

@Override
public NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable<HasMetadata, Boolean> resource(String s) {
return new NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl(httpClient, getConfiguration(), getNamespace(), null, false, false, new ArrayList<Visitor>(), s, -1, DeletionPropagation.BACKGROUND, true, 5, 2) {
return new NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl(httpClient, getConfiguration(), getNamespace(), null, false, false, new ArrayList<Visitor>(), s, -1, DeletionPropagation.BACKGROUND, true, Waitable.DEFAULT_INITIAL_BACKOFF_MILLIS, Waitable.DEFAULT_BACKOFF_MULTIPLIER) {
};
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
public interface Resource<T, D> extends CreateOrReplaceable<T, T, D>, CreateFromServerGettable<T, T, D>,
CascadingEditReplacePatchDeletable<T, T, D, Boolean>,
VersionWatchable<Watch, Watcher<T>>,
WatchingWaitableWithBackoff<T, T>, Requirable<T>, Readiable {
Waitable<T, T>, Requirable<T>, Readiable {
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface VisitFromServerGetWatchDeleteRecreateWaitApplicable<T, B> exten
FromServerGettable<T>, RecreateApplicable<T, T>,
CascadingDeletable<B>,
Watchable<Watch, Watcher<T>>,
WatchingWaitableWithBackoff<T, T>,
Waitable<T, T>,
GracePeriodConfigurable<CascadingDeletable<B>>,
PropagationPolicyConfigurable<CascadingDeletable<B>> {
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* <p>
* 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
Expand All @@ -20,7 +20,19 @@

public interface Waitable<T, P> {

T waitUntilReady(long amount, TimeUnit timeUnit) throws InterruptedException;
long DEFAULT_INITIAL_BACKOFF_MILLIS = 5;
double DEFAULT_BACKOFF_MULTIPLIER = 2;

T waitUntilCondition(Predicate<P> condition, long amount, TimeUnit timeUnit) throws InterruptedException;
T waitUntilReady(long amount, TimeUnit timeUnit) throws InterruptedException;

T waitUntilCondition(Predicate<P> condition, long amount, TimeUnit timeUnit) throws InterruptedException;

/**
* Configure the backoff strategy to use when waiting for conditions, in case the watcher encounters a retryable error.
* @param initialBackoff the value for the initial backoff on first error
* @param backoffUnit the TimeUnit for the initial backoff value
* @param backoffMultiplier what to multiply the backoff by on each subsequent error
* @return
*/
Waitable<T, P> withWaitRetryBackoff(long initialBackoff, TimeUnit backoffUnit, double backoffMultiplier);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.dsl.Waitable;
import io.fabric8.kubernetes.client.utils.ApiVersionUtil;
import io.fabric8.kubernetes.client.utils.Utils;
import okhttp3.OkHttpClient;
Expand All @@ -44,8 +45,8 @@ public class OperationContext {
protected long gracePeriodSeconds = -1L;
protected DeletionPropagation propagationPolicy;

protected long watchRetryInitialBackoffMillis = 5;
protected double watchRetryBackoffMultiplier = 2;
protected long watchRetryInitialBackoffMillis = Waitable.DEFAULT_INITIAL_BACKOFF_MILLIS;
protected double watchRetryBackoffMultiplier = Waitable.DEFAULT_BACKOFF_MULTIPLIER;

protected Map<String, String> labels;
protected Map<String, String[]> labelsNot;
Expand Down Expand Up @@ -270,6 +271,8 @@ public OperationContext withOperationContext(OperationContext operationContext)
boolean cascadingCloned = getCascading();
boolean reloadingFromServerCloned = getReloadingFromServer();
long gracePeriodSecondsCloned = getGracePeriodSeconds();
long watchRetryInitialBackoffMillis = getWatchRetryInitialBackoffMillis();
double watchRetryBackoffMultiplier = getWatchRetryBackoffMultiplier();
DeletionPropagation propagationPolicyCloned = getPropagationPolicy();
Map<String, String> labelsCloned = getLabels();
Map<String, String[]> labelsNotCloned = getLabelsNot();
Expand Down Expand Up @@ -354,6 +357,6 @@ public OperationContext withOperationContext(OperationContext operationContext)
propagationPolicyCloned = operationContext.getPropagationPolicy();
}

return new OperationContext(clientCloned, configCloned, pluralCloned, namespaceCloned, nameCloned, apiGroupNameCloned, apiGroupVersionCloned, cascadingCloned, itemCloned, labelsCloned, labelsNotCloned, labelsInCloned, labelsNotInCloned, fieldsCloned, fieldsNotCloned, resourceVersionCloned, reloadingFromServerCloned, gracePeriodSecondsCloned, propagationPolicyCloned);
return new OperationContext(clientCloned, configCloned, pluralCloned, namespaceCloned, nameCloned, apiGroupNameCloned, apiGroupVersionCloned, cascadingCloned, itemCloned, labelsCloned, labelsNotCloned, labelsInCloned, labelsNotInCloned, fieldsCloned, fieldsNotCloned, resourceVersionCloned, reloadingFromServerCloned, gracePeriodSecondsCloned, propagationPolicyCloned, watchRetryInitialBackoffMillis, watchRetryBackoffMultiplier);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* 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.fabric8.kubernetes.client.dsl.base;

import java.net.HttpURLConnection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package io.fabric8.kubernetes.client.dsl.internal;

import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.client.dsl.WatchingWaitableWithBackoff;
import io.fabric8.kubernetes.client.utils.Utils;
import java.util.function.Predicate;

Expand Down Expand Up @@ -59,7 +58,7 @@
import okhttp3.OkHttpClient;

public class NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl extends OperationSupport implements NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable<HasMetadata, Boolean>,
WatchingWaitableWithBackoff<HasMetadata, HasMetadata>,
Waitable<HasMetadata, HasMetadata>,
Readiable {

private static final Logger LOGGER = LoggerFactory.getLogger(NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl.class);
Expand Down Expand Up @@ -227,7 +226,7 @@ public Deletable<Boolean> cascading(boolean cascading) {
}

@Override
public WatchingWaitableWithBackoff<HasMetadata, HasMetadata> withWaitRetryBackoff(long initialBackoff, TimeUnit backoffUnit, double backoffMultiplier) {
public Waitable<HasMetadata, HasMetadata> withWaitRetryBackoff(long initialBackoff, TimeUnit backoffUnit, double backoffMultiplier) {
long watchRetryInitialBackoffMillis = backoffUnit.toMillis(initialBackoff);
return new NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl(client, config, fallbackNamespace, explicitNamespace, fromServer, true, visitors, item, gracePeriodSeconds, propagationPolicy, cascading, watchRetryInitialBackoffMillis, backoffMultiplier);
}
Expand Down
Loading

0 comments on commit e1cee61

Please sign in to comment.