public DockerDriverBase(ServiceHost serviceHost, DriverRegistry driverRegistry, ClosureDockerClientFactory dockerClientFactory) { this.serviceHost = serviceHost; this.driverRegistry = driverRegistry; this.dockerClientFactory = dockerClientFactory; this.trustCertificates = new AtomicReference<>(); this.subscriptionManager = new SubscriptionManager<>(serviceHost, serviceHost.getId() + getDockerImage(), SSL_TRUST_CONFIG_SUBSCRIBE_FOR_LINK, ConfigurationService.ConfigurationState.class, true); this.sslTrustQuery = new ServiceDocumentQuery<SslTrustCertificateState>(serviceHost, SslTrustCertificateState.class); queryHandler = new ClosureSslTrustQueryCompletionHandler(); subscribeForSslTrustCertNotifications(); loadSslTrustCertServices(); }
this.subscriptionManager = new SubscriptionManager<>(host, host.getId(), SSL_TRUST_CONFIG_SUBSCRIBE_FOR_LINK, ConfigurationState.class, true);
new SubscriptionManager<>( getHost(), UUID.randomUUID().toString(), containerHostRemovalTaskState,
@Before public void setUp() throws Throwable { waitForServiceAvailability(ContainerDescriptionService.FACTORY_LINK); waitForServiceAvailability(CompositeDescriptionFactoryService.SELF_LINK); waitForServiceAvailability(ContainerFactoryService.SELF_LINK); state = new ContainerState(); state.id = updatedTestId; state.image = updatedTestValue; state = doPost(state, ContainerFactoryService.SELF_LINK); results = Collections.synchronizedList(new ArrayList<>()); subscriptionManager = new SubscriptionManager<>( host, host.getId(), state.documentSelfLink, ContainerState.class); waitForServiceAvailability(ServiceUriPaths.CORE_QUERY_TASKS); waitForServiceAvailability(state.documentSelfLink); }
new SubscriptionManager<>( getHost(), UUID.randomUUID().toString(), containerHostRemovalTaskState,
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; }
subscriptionManager = new SubscriptionManager<>( host, host.getId(), state.documentSelfLink, ContainerState.class, true);