• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Watch类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.fabric8.kubernetes.client.Watch的典型用法代码示例。如果您正苦于以下问题:Java Watch类的具体用法?Java Watch怎么用?Java Watch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Watch类属于io.fabric8.kubernetes.client包,在下文中一共展示了Watch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getResource

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
@Override
public Resource<Pod> getResource(ObserverKey observerKey, KubernetesClient client) {
    return new Resource<Pod>() {
        @Override
        public Watch watchResources(Watcher watcher) {
            return client.pods().inNamespace(client.getNamespace()).withLabels(observerKey.getLabelFilter()).watch(watcher);
        }

        @Override
        public Set<Pod> listResources() {
            return client.pods().inNamespace(client.getNamespace()).withLabels(observerKey.getLabelFilter()).list().getItems().stream()
                    .filter(pod -> filterPod(observerKey, pod))
                    .map(Pod::new)
                    .collect(Collectors.toSet());
        }
    };
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:18,代码来源:PodSenseSubscriptionConfig.java


示例2: getResource

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
@Override
public Resource<TestResource> getResource(ObserverKey observerKey, KubernetesClient client) {
    return new Resource<TestResource>() {
        @Override
        public Watch watchResources(Watcher watcher) {
            return testWatch;
        }

        @Override
        public Set<TestResource> listResources() {
            try {
                return stream.take();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    };
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:19,代码来源:TestSubscriptionConfig.java


示例3: doDelete

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
private CompletableFuture<Void> doDelete(String name) throws InfrastructureException {
  try {
    final PodResource<Pod, DoneablePod> podResource =
        clientFactory.create().pods().inNamespace(namespace).withName(name);
    final CompletableFuture<Void> deleteFuture = new CompletableFuture<>();
    final Watch watch = podResource.watch(new DeleteWatcher(deleteFuture));

    podResource.delete();
    return deleteFuture.whenComplete(
        (v, e) -> {
          if (e != null) {
            LOG.warn("Failed to remove pod {} cause {}", name, e.getMessage());
          }
          watch.close();
        });
  } catch (KubernetesClientException ex) {
    throw new InfrastructureException(ex.getMessage(), ex);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:OpenShiftPods.java


示例4: findMatching

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
/**
 * Returns the {@link PodList} that match the specified {@link Deployment}.
 *
 * @param deployment The {@link Deployment}
 */
public static PodList findMatching(KubernetesClient client, Deployment deployment) {
    FilterWatchListDeletable<Pod, PodList, Boolean, Watch, Watcher<Pod>> podLister =
            client.pods().inNamespace(deployment.getMetadata().getNamespace());
    if (deployment.getSpec().getSelector().getMatchLabels() != null) {
        podLister.withLabels(deployment.getSpec().getSelector().getMatchLabels());
    }
    if (deployment.getSpec().getSelector().getMatchExpressions() != null) {
        for (LabelSelectorRequirement req : deployment.getSpec().getSelector().getMatchExpressions()) {
            switch (req.getOperator()) {
                case "In":
                    podLister.withLabelIn(req.getKey(), req.getValues().toArray(new String[]{}));
                    break;
                case "NotIn":
                    podLister.withLabelNotIn(req.getKey(), req.getValues().toArray(new String[]{}));
                    break;
                case "DoesNotExist":
                    podLister.withoutLabel(req.getKey());
                    break;
                case "Exists":
                    podLister.withLabel(req.getKey());
                    break;
            }
        }
    }
    return podLister.list();
}
 
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:32,代码来源:FeedbackUtils.java


示例5: stop

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
public synchronized void stop() {
    if (relister != null && !relister.isDone()) {
        relister.cancel(true);
        relister = null;
    }

    for (Map.Entry<String, Watch> entry : watches.entrySet()) {
        entry.getValue().close();
        watches.remove(entry.getKey());
    }
}
 
开发者ID:jenkinsci,项目名称:openshift-sync-plugin,代码行数:12,代码来源:BaseWatcher.java


示例6: unwatch

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
@PreDestroy
public void unwatch() {
    if (this.watches != null) {
        for (Map.Entry<String, Watch> entry : this.watches.entrySet()) {
            try {
                log.debug("Closing the watch {}", entry.getKey());
                entry.getValue().close();

            } catch (Exception e) {
                log.error("Error while closing the watch connection", e);
            }
        }
    }
}
 
开发者ID:fabric8io,项目名称:spring-cloud-kubernetes,代码行数:15,代码来源:EventBasedConfigurationChangeDetector.java


示例7: registerWatcher

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
private Watch registerWatcher() {
    return kubernetesClient.pods().watch(new Watcher<Pod>() {
        @Override
        public void eventReceived(Action eventAction, Pod eventPod) {
            boolean continueBlocking = continueBlocking(eventAction, eventPod);
            if (!continueBlocking)
                block[0] = false;
        }

        @Override
        public void onClose(KubernetesClientException e) {
        }
    });
}
 
开发者ID:qaware,项目名称:gradle-cloud-deployer,代码行数:15,代码来源:BasePodDeletionBlocker.java


示例8: getServicesByLabel

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
private static ServiceList getServicesByLabel(Map<String, String> labels, KubernetesClient client)
    throws KubernetesClientException {
  Objects.requireNonNull(client, "no client available");
  final MixedOperation<Service, ServiceList, DoneableService, Resource<Service, DoneableService>>
      services = client.services();
  final FilterWatchListDeletable<Service, ServiceList, Boolean, Watch, Watcher<Service>>
      listable = createLabelFilterQuery(labels, services);
  return listable.list();
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:10,代码来源:KubeDiscovery.java


示例9: createLabelFilterQuery

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
private static FilterWatchListDeletable<Service, ServiceList, Boolean, Watch, Watcher<Service>>
    createLabelFilterQuery(
        Map<String, String> labels,
        MixedOperation<Service, ServiceList, DoneableService, Resource<Service, DoneableService>>
            services) {
  FilterWatchListDeletable<Service, ServiceList, Boolean, Watch, Watcher<Service>> listable =
      null;
  for (Entry<String, String> entry : labels.entrySet()) {
    listable =
        listable == null
            ? services.withLabel(entry.getKey(), entry.getValue())
            : listable.withLabel(entry.getKey(), entry.getValue());
  }
  return listable;
}
 
开发者ID:amoAHCP,项目名称:vxms,代码行数:16,代码来源:KubeDiscovery.java


示例10: BaseWatcher

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
@SuppressFBWarnings("EI_EXPOSE_REP2")
public BaseWatcher(String[] namespaces) {
    this.namespaces = namespaces;
    watches = new HashMap<String, Watch>();
}
 
开发者ID:jenkinsci,项目名称:openshift-sync-plugin,代码行数:6,代码来源:BaseWatcher.java


示例11: watchPods

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
public Watch watchPods(String namespace, Watcher<Pod> podWatcher) {
    return client.pods().inNamespace(namespace).watch(podWatcher);
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:4,代码来源:Kubernetes.java


示例12: watchResources

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
@Override
public Watch watchResources(Watcher watcher) {
    return () -> {};
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:5,代码来源:ResourceControllerTest.java


示例13: watchResources

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
@Override
public Watch watchResources(io.fabric8.kubernetes.client.Watcher watcher) {
    return client.pods().withLabels(labelFilter).watch(watcher);
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:5,代码来源:DiscoveryClient.java


示例14: addClient

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
protected void addClient(Watch watch) {
    watches.add(watch);
}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:4,代码来源:KubernetesHubotNotifier.java


示例15: print

import io.fabric8.kubernetes.client.Watch; //导入依赖的package包/类
private static List<String> print(FilterWatchListDeletable<Pod, PodList, Boolean, Watch, Watcher<Pod>> pods) {
    return pods.list().getItems().stream()
            .map(pod -> String.format("%s (%s)", pod.getMetadata().getName(), pod.getStatus().getPhase()))
            .collect(Collectors.toList());
}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:6,代码来源:KubernetesTestUtil.java



注:本文中的io.fabric8.kubernetes.client.Watch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PermissionsEx类代码示例发布时间:2022-05-21
下一篇:
Java WindowsBorders类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap