/** * Subscribe for the specified service link and provide a notification handler to be callback * when there is an update or delete of the specified services. * The Consumer<String> callback will contain either the subscription ID or null in case * something went wrong. */ public void start(Consumer<SubscriptionNotification<T>> notificationHandler, Consumer<String> callback) { start(notificationHandler, false, callback); }
private void subscribeForSslTrustCertNotifications() { this.subscriptionManager.start((n) -> { loadSslTrustCertServices(); }, null); }
private void subscribeForSslTrustCertNotifications() { this.subscriptionManager.start((n) -> { loadSslTrustCertServices(); }, null); }
containerHostRemovalTaskState, ContainerHostRemovalTaskState.class); subscriptionManager.start(notification -> { ContainerHostRemovalTaskState eats = notification.getResult(); EnumSet<TaskStage> terminalStages = of(TaskStage.FINISHED,
containerHostRemovalTaskState, ContainerHostRemovalTaskState.class); sm.start(notification -> { ContainerHostRemovalTaskState eats = notification.getResult(); EnumSet<TaskStage> terminalStages = of(TaskStage.FINISHED,
private SubscriptionManager<ExampleServiceState> subscribe(ServiceHost h, ExampleServiceState serviceState, Consumer<SubscriptionNotification<ExampleServiceState>> notificationConsumer) { SubscriptionManager<ExampleServiceState> subscriptionManager = new SubscriptionManager<>( h, h.getId(), serviceState.documentSelfLink, ExampleServiceState.class); TestContext ctx = new TestContext(1, Duration.ofSeconds(SUBSCRIPTION_START_TIMEOUT_SECONDS)); String subscriptionServiceLink; // This single element array is used to extract the result from lambda. final String[] subscriptionServiceLinkResult = new String[1]; subscriptionManager.start(notificationConsumer, (subscriptionLink) -> { subscriptionServiceLinkResult[0] = subscriptionLink; ctx.completeIteration(); }); ctx.await(); subscriptionServiceLink = subscriptionServiceLinkResult[0]; cluster.log(Level.INFO, "Waiting for subscription for %s on host %s", serviceState.documentSelfLink, cluster.getId()); TestContext testCtx = new TestContext(1, Duration.ofSeconds(SUBSCRIPTION_START_TIMEOUT_SECONDS)); h.registerForServiceAvailability((o, e) -> { if (e != null) { testCtx.fail(e); } else { testCtx.complete(); } }, subscriptionServiceLink); testCtx.await(); return subscriptionManager; }
private String subscribe() throws Throwable { TestContext ctx = testCreate(2); subscriptionManager.setCompletionHandler((e) -> { if (e != null) { ctx.failIteration(e); return; } ctx.completeIteration(); }); final String[] subscriptionId = new String[1]; subscriptionManager.start(handler(), (id) -> { subscriptionId[0] = id; ctx.completeIteration(); }); testWait(ctx); // reset completion handler subscriptionManager.setCompletionHandler(null); return subscriptionId[0]; }