String newResourceVersion = list.getMetadata().getResourceVersion(); if (currentResourceVersion == null || currentResourceVersion.compareTo(newResourceVersion) < 0) { resourceVersion.compareAndSet(currentResourceVersion, newResourceVersion);
resourceVersion.set(list.getMetadata().getResourceVersion()); Watcher.Action action = Watcher.Action.valueOf(event.getType()); List<HasMetadata> items = list.getItems();
public WatchConnectionManager(final OkHttpClient client, final BaseOperation<T, L, ?, ?> baseOperation, final String version, final Watcher<T> watcher, final int reconnectInterval, final int reconnectLimit, long websocketTimeout) throws MalformedURLException { if (version == null) { L currentList = baseOperation.list(); this.resourceVersion = new AtomicReference<>(currentList.getMetadata().getResourceVersion()); } else { this.resourceVersion = new AtomicReference<>(version); } this.baseOperation = baseOperation; this.watcher = watcher; this.reconnectInterval = reconnectInterval; this.reconnectLimit = reconnectLimit; this.websocketTimeout = websocketTimeout; this.clonedClient = client.newBuilder().readTimeout(this.websocketTimeout, TimeUnit.MILLISECONDS).build(); // The URL is created, validated and saved once, so that reconnect attempts don't have to deal with // MalformedURLExceptions that would never occur requestUrl = baseOperation.getNamespacedUrl(); runWatch(); }
public ListMetaBuilder(ListMetaFluent<?> fluent,ListMeta instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withResourceVersion(instance.getResourceVersion()); fluent.withSelfLink(instance.getSelfLink()); this.validationEnabled = validationEnabled; } public ListMetaBuilder(ListMeta instance){
public ListMetaBuilder(ListMeta instance,Boolean validationEnabled){ this.fluent = this; this.withResourceVersion(instance.getResourceVersion()); this.withSelfLink(instance.getSelfLink()); this.validationEnabled = validationEnabled; }
public ListMetaBuilder( ListMetaFluent<?> fluent , ListMeta instance ){ this.fluent = fluent; fluent.withResourceVersion(instance.getResourceVersion()); fluent.withSelfLink(instance.getSelfLink()); } public ListMetaBuilder( ListMeta instance ){
public ListMetaFluentImpl(ListMeta instance){ this.withResourceVersion(instance.getResourceVersion()); this.withSelfLink(instance.getSelfLink()); }
public ListMetaBuilder( ListMetaFluent<?> fluent , ListMeta instance ){ this.fluent = fluent; fluent.withResourceVersion(instance.getResourceVersion()); fluent.withSelfLink(instance.getSelfLink()); } public ListMetaBuilder( ListMeta instance ){
public ListMetaBuilder( ListMeta instance ){ this.fluent = this; this.withResourceVersion(instance.getResourceVersion()); this.withSelfLink(instance.getSelfLink()); }
public ListMetaBuilder( ListMeta instance ){ this.fluent = this; this.withResourceVersion(instance.getResourceVersion()); this.withSelfLink(instance.getSelfLink()); }
this.resourceVersion = new AtomicReference<>(currentList.getMetadata().getResourceVersion()); } else { this.resourceVersion = new AtomicReference<>(version);
@VisibleForTesting synchronized void tryPollPods() { // Fetch pods _before_ fetching all active states final PodList list = client.pods().list(); final Map<WorkflowInstance, RunState> activeStates = stateManager.getActiveStates(); examineRunningWFISandAssociatedPods(activeStates, list); for (Pod pod : list.getItems()) { logEvent(Watcher.Action.MODIFIED, pod, list.getMetadata().getResourceVersion(), true); final Optional<WorkflowInstance> workflowInstance = readPodWorkflowInstance(pod); if (!workflowInstance.isPresent()) { continue; } final RunState runState = activeStates.get(workflowInstance.get()); if (runState != null && isPodRunState(pod, runState)) { emitPodEvents(pod, runState); cleanupWithRunState(workflowInstance.get(), pod, runState); } else { // The pod is stale as we fetched the active states _after_ listing all pods. cleanupWithoutRunState(workflowInstance.get(), pod); } } }
public void start() { final BuildList builds; if (namespace != null && !namespace.isEmpty()) { builds = getOpenShiftClient().builds().inNamespace(namespace).withField("status", BuildPhases.RUNNING).list(); buildsWatch = getOpenShiftClient().builds().inNamespace(namespace).withResourceVersion(builds.getMetadata().getResourceVersion()).watch(this); } else { builds = getOpenShiftClient().builds().withField("status", BuildPhases.RUNNING).list(); buildsWatch = getOpenShiftClient().builds().withResourceVersion(builds.getMetadata().getResourceVersion()).watch(this); } }
if (namespace != null && !namespace.isEmpty()) { buildConfigs = getOpenShiftClient().buildConfigs().inNamespace(namespace).list(); buildConfigWatch = getOpenShiftClient().buildConfigs().inNamespace(namespace).withResourceVersion(buildConfigs.getMetadata().getResourceVersion()).watch(this); } else { buildConfigs = getOpenShiftClient().buildConfigs().inAnyNamespace().list(); buildConfigWatch = getOpenShiftClient().buildConfigs().withResourceVersion(buildConfigs.getMetadata().getResourceVersion()).watch(this);
if (namespace != null && !namespace.isEmpty()) { builds = getOpenShiftClient().builds().inNamespace(namespace).withField("status", BuildPhases.NEW).list(); buildsWatch = getOpenShiftClient().builds().inNamespace(namespace).withResourceVersion(builds.getMetadata().getResourceVersion()).watch(this); } else { builds = getOpenShiftClient().builds().withField("status", BuildPhases.NEW).list(); buildsWatch = getOpenShiftClient().builds().withResourceVersion(builds.getMetadata().getResourceVersion()).watch(this);