Java Code Examples for io.fabric8.kubernetes.client.utils.Utils#waitUntilReady()
The following examples show how to use
io.fabric8.kubernetes.client.utils.Utils#waitUntilReady() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogWatchCallback.java From kubernetes-client with Apache License 2.0 | 5 votes |
public void waitUntilReady() { if (!Utils.waitUntilReady(queue, config.getRequestTimeout(), TimeUnit.MILLISECONDS)) { if (LOGGER.isDebugEnabled()) { LOGGER.warn("Log watch request has not been opened within: " + config.getRequestTimeout() + " millis."); } } }
Example 2
Source File: ExecWebSocketListener.java From kubernetes-client with Apache License 2.0 | 4 votes |
public void waitUntilReady() { Utils.waitUntilReady(queue, config.getWebsocketTimeout(), TimeUnit.MILLISECONDS); }
Example 3
Source File: RawWatchConnectionManager.java From kubernetes-client with Apache License 2.0 | 4 votes |
public void waitUntilReady() { Utils.waitUntilReady(queue, 10, TimeUnit.SECONDS); }
Example 4
Source File: WatchConnectionManager.java From kubernetes-client with Apache License 2.0 | 4 votes |
public void waitUntilReady() { Utils.waitUntilReady(queue, 10, TimeUnit.SECONDS); }
Example 5
Source File: DeploymentOperationsImpl.java From kubernetes-client with Apache License 2.0 | 4 votes |
/** * Lets wait until there are enough Ready pods of the given Deployment */ private void waitUntilDeploymentIsScaled(final int count) { final BlockingQueue<Object> queue = new ArrayBlockingQueue<>(1); final AtomicReference<Integer> replicasRef = new AtomicReference<>(0); final String name = checkName(getItem()); final String namespace = checkNamespace(getItem()); final Runnable deploymentPoller = () -> { try { Deployment deployment = get(); //If the deployment is gone, we shouldn't wait. if (deployment == null) { if (count == 0) { queue.put(true); return; } else { queue.put(new IllegalStateException("Can't wait for Deployment: " + checkName(getItem()) + " in namespace: " + checkName(getItem()) + " to scale. Resource is no longer available.")); return; } } replicasRef.set(deployment.getStatus().getReplicas()); int currentReplicas = deployment.getStatus().getReplicas() != null ? deployment.getStatus().getReplicas() : 0; long generation = deployment.getMetadata().getGeneration() != null ? deployment.getMetadata().getGeneration() : 0; long observedGeneration = deployment.getStatus() != null && deployment.getStatus().getObservedGeneration() != null ? deployment.getStatus().getObservedGeneration() : -1; if (observedGeneration >= generation && Objects.equals(deployment.getSpec().getReplicas(), currentReplicas)) { queue.put(true); } else { LOG.debug("Only {}/{} pods scheduled for Deployment: {} in namespace: {} seconds so waiting...", deployment.getStatus().getReplicas(), deployment.getSpec().getReplicas(), deployment.getMetadata().getName(), namespace); } } catch (Throwable t) { LOG.error("Error while waiting for Deployment to be scaled.", t); } }; ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); ScheduledFuture poller = executor.scheduleWithFixedDelay(deploymentPoller, 0, POLL_INTERVAL_MS, TimeUnit.MILLISECONDS); try { if (Utils.waitUntilReady(queue, getConfig().getScaleTimeout(), TimeUnit.MILLISECONDS)) { LOG.debug("{}/{} pod(s) ready for Deployment: {} in namespace: {}.", replicasRef.get(), count, name, namespace); } else { LOG.error("{}/{} pod(s) ready for Deployment: {} in namespace: {} after waiting for {} seconds so giving up", replicasRef.get(), count, name, namespace, TimeUnit.MILLISECONDS.toSeconds(getConfig().getScaleTimeout())); } } finally { poller.cancel(true); executor.shutdown(); } }
Example 6
Source File: DeploymentConfigOperationsImpl.java From kubernetes-client with Apache License 2.0 | 4 votes |
/** * Lets wait until there are enough Ready pods of the given Deployment */ private void waitUntilDeploymentConfigIsScaled(final int count) { final BlockingQueue<Object> queue = new ArrayBlockingQueue<Object>(1); final AtomicReference<Integer> replicasRef = new AtomicReference<>(0); final String name = checkName(getItem()); final String namespace = checkNamespace(getItem()); final Runnable deploymentPoller = () -> { try { DeploymentConfig deploymentConfig = get(); //If the rs is gone, we shouldn't wait. if (deploymentConfig == null) { if (count == 0) { queue.put(true); return; } else { queue.put(new IllegalStateException("Can't wait for DeploymentConfig: " + checkName(getItem()) + " in namespace: " + checkName(getItem()) + " to scale. Resource is no longer available.")); return; } } replicasRef.set(deploymentConfig.getStatus().getReplicas()); int currentReplicas = deploymentConfig.getStatus().getReplicas() != null ? deploymentConfig.getStatus().getReplicas() : 0; if (deploymentConfig.getStatus().getObservedGeneration() >= deploymentConfig.getMetadata().getGeneration() && Objects.equals(deploymentConfig.getSpec().getReplicas(), currentReplicas)) { queue.put(true); } else { LOG.debug("Only {}/{} pods scheduled for DeploymentConfig: {} in namespace: {} seconds so waiting...", deploymentConfig.getStatus().getReplicas(), deploymentConfig.getSpec().getReplicas(), deploymentConfig.getMetadata().getName(), namespace); } } catch (Throwable t) { LOG.error("Error while waiting for Deployment to be scaled.", t); } }; ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); ScheduledFuture poller = executor.scheduleWithFixedDelay(deploymentPoller, 0, POLL_INTERVAL_MS, TimeUnit.MILLISECONDS); try { if (Utils.waitUntilReady(queue, getConfig().getScaleTimeout(), TimeUnit.MILLISECONDS)) { LOG.debug("{}/{} pod(s) ready for DeploymentConfig: {} in namespace: {}.", replicasRef.get(), count, name, namespace); } else { LOG.error("{}/{} pod(s) ready for DeploymentConfig: {} in namespace: {} after waiting for {} seconds so giving up", replicasRef.get(), count, name, namespace, TimeUnit.MILLISECONDS.toSeconds(getConfig().getScaleTimeout())); } } finally { poller.cancel(true); executor.shutdown(); } }