@Inject public DiscoveryNodeManager( @ServiceType("presto") ServiceSelector serviceSelector, NodeInfo nodeInfo, FailureDetector failureDetector, NodeVersion expectedNodeVersion, @ForNodeManager HttpClient httpClient, InternalCommunicationConfig internalCommunicationConfig) { this.serviceSelector = requireNonNull(serviceSelector, "serviceSelector is null"); this.failureDetector = requireNonNull(failureDetector, "failureDetector is null"); this.expectedNodeVersion = requireNonNull(expectedNodeVersion, "expectedNodeVersion is null"); this.httpClient = requireNonNull(httpClient, "httpClient is null"); this.nodeStateUpdateExecutor = newSingleThreadScheduledExecutor(threadsNamed("node-state-poller-%s")); this.nodeStateEventExecutor = newCachedThreadPool(threadsNamed("node-state-events-%s")); this.httpsRequired = internalCommunicationConfig.isHttpsRequired(); this.currentNode = findCurrentNode( serviceSelector.selectAllServices(), requireNonNull(nodeInfo, "nodeInfo is null").getNodeId(), expectedNodeVersion, httpsRequired); refreshNodesInternal(); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof ServiceType)) { return false; } ServiceType that = (ServiceType) o; if (!value.equals(that.value())) { return false; } return true; }
@Test public void testAnnotationType() { assertEquals(ServiceTypes.serviceType("apple").annotationType(), ServiceType.class); assertEquals(ServiceTypes.serviceType("apple").annotationType(), appleServiceType.annotationType()); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof ServiceType)) { return false; } ServiceType that = (ServiceType) o; if (!value.equals(that.value())) { return false; } return true; }
@Test public void testAnnotationType() { assertEquals(ServiceTypes.serviceType("apple").annotationType(), ServiceType.class); assertEquals(ServiceTypes.serviceType("apple").annotationType(), appleServiceType.annotationType()); }
@Inject public HeartbeatFailureDetector( @ServiceType("presto") ServiceSelector selector, @ForFailureDetector HttpClient httpClient, FailureDetectorConfig failureDetectorConfig, NodeInfo nodeInfo, InternalCommunicationConfig internalCommunicationConfig) { requireNonNull(selector, "selector is null"); requireNonNull(httpClient, "httpClient is null"); requireNonNull(nodeInfo, "nodeInfo is null"); requireNonNull(failureDetectorConfig, "config is null"); checkArgument(failureDetectorConfig.getHeartbeatInterval().toMillis() >= 1, "heartbeat interval must be >= 1ms"); this.selector = selector; this.httpClient = httpClient; this.nodeInfo = nodeInfo; this.failureRatioThreshold = failureDetectorConfig.getFailureRatioThreshold(); this.heartbeat = failureDetectorConfig.getHeartbeatInterval(); this.warmupInterval = failureDetectorConfig.getWarmupInterval(); this.gcGraceInterval = failureDetectorConfig.getExpirationGraceInterval(); this.isEnabled = failureDetectorConfig.isEnabled(); this.httpsRequired = internalCommunicationConfig.isHttpsRequired(); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof ServiceType)) { return false; } ServiceType that = (ServiceType) o; if (!value.equals(that.value())) { return false; } return true; }
@Test public void testAnnotationType() { Assert.assertEquals(ServiceTypes.serviceType("apple").annotationType(), ServiceType.class); Assert.assertEquals(ServiceTypes.serviceType("apple").annotationType(), appleServiceType.annotationType()); }
@Inject public HttpEventClient( @ServiceType("collector") HttpServiceSelector serviceSelector, JsonEventWriter eventWriter, NodeInfo nodeInfo, @ForEventClient AsyncHttpClient httpClient) { this.serviceSelector = checkNotNull(serviceSelector, "serviceSelector is null"); this.eventWriter = checkNotNull(eventWriter, "eventWriter is null"); this.nodeInfo = checkNotNull(nodeInfo, "nodeInfo is null"); this.httpClient = checkNotNull(httpClient, "httpClient is null"); }
public void bindSelector(ServiceType serviceType) { requireNonNull(serviceType, "serviceType is null"); configBinder(binder).bindConfig(ServiceSelectorConfig.class, serviceType, "discovery." + serviceType.value()); Key<ServiceSelector> key = Key.get(ServiceSelector.class, serviceType); binder.bind(key).toProvider(new ServiceSelectorProvider(serviceType.value())).in(Scopes.SINGLETON); serviceSelectorBinder.addBinding().to(key).in(Scopes.SINGLETON); }
@Inject public HttpEventClient( @ServiceType("collector") HttpServiceSelector serviceSelector, JsonEventWriter eventWriter, NodeInfo nodeInfo, @ForEventClient HttpClient httpClient) { this.serviceSelector = requireNonNull(serviceSelector, "serviceSelector is null"); this.eventWriter = requireNonNull(eventWriter, "eventWriter is null"); this.nodeInfo = requireNonNull(nodeInfo, "nodeInfo is null"); this.httpClient = requireNonNull(httpClient, "httpClient is null"); }
public void bindSelector(ServiceType serviceType) { Preconditions.checkNotNull(serviceType, "serviceType is null"); configBinder(binder).bindConfig(ServiceSelectorConfig.class, serviceType, "discovery." + serviceType.value()); Key<ServiceSelector> key = Key.get(ServiceSelector.class, serviceType); binder.bind(key).toProvider(new ServiceSelectorProvider(serviceType.value())).in(Scopes.SINGLETON); serviceSelectorBinder.addBinding().to(key).in(Scopes.SINGLETON); }
@Inject public HttpEventClient( @ServiceType("collector") HttpServiceSelector serviceSelector, JsonEventWriter eventWriter, NodeInfo nodeInfo, @ForEventClient HttpClient httpClient) { this.serviceSelector = requireNonNull(serviceSelector, "serviceSelector is null"); this.eventWriter = requireNonNull(eventWriter, "eventWriter is null"); this.nodeInfo = requireNonNull(nodeInfo, "nodeInfo is null"); this.httpClient = requireNonNull(httpClient, "httpClient is null"); }
public void bindHttpSelector(ServiceType serviceType) { requireNonNull(serviceType, "serviceType is null"); bindSelector(serviceType); binder.bind(HttpServiceSelector.class).annotatedWith(serviceType).toProvider(new HttpServiceSelectorProvider(serviceType.value())).in(Scopes.SINGLETON); }
@Inject public HttpEventClient( @ServiceType("collector") HttpServiceSelector serviceSelector, JsonEventWriter eventWriter, NodeInfo nodeInfo, @ForEventClient HttpClient httpClient) { this.serviceSelector = checkNotNull(serviceSelector, "serviceSelector is null"); this.eventWriter = checkNotNull(eventWriter, "eventWriter is null"); this.nodeInfo = checkNotNull(nodeInfo, "nodeInfo is null"); this.httpClient = checkNotNull(httpClient, "httpClient is null"); }
public void bindHttpSelector(ServiceType serviceType) { Preconditions.checkNotNull(serviceType, "serviceType is null"); bindSelector(serviceType); binder.bind(HttpServiceSelector.class).annotatedWith(serviceType).toProvider(new HttpServiceSelectorProvider(serviceType.value())).in(Scopes.SINGLETON); }
@Inject public DiscoveryNodeManager( @ServiceType("presto") ServiceSelector serviceSelector, NodeInfo nodeInfo, FailureDetector failureDetector, NodeVersion expectedNodeVersion, @ForGracefulShutdown HttpClient httpClient) { this.serviceSelector = requireNonNull(serviceSelector, "serviceSelector is null"); this.nodeInfo = requireNonNull(nodeInfo, "nodeInfo is null"); this.failureDetector = requireNonNull(failureDetector, "failureDetector is null"); this.expectedNodeVersion = requireNonNull(expectedNodeVersion, "expectedNodeVersion is null"); this.httpClient = requireNonNull(httpClient, "httpClient is null"); this.nodeStateUpdateExecutor = newSingleThreadScheduledExecutor(threadsNamed("node-state-poller-%s")); this.currentNode = refreshNodesInternal(); }
public void bindHttpSelector(ServiceType serviceType) { Preconditions.checkNotNull(serviceType, "serviceType is null"); bindSelector(serviceType); binder.bind(HttpServiceSelector.class).annotatedWith(serviceType).toProvider(new HttpServiceSelectorProvider(serviceType.value())).in(Scopes.SINGLETON); }
public class TestServiceTypes @ServiceType("apple") private final ServiceType appleServiceType; @ServiceType("banana") private final ServiceType bananaServiceType;
public void bindSelector(ServiceType serviceType) { Preconditions.checkNotNull(serviceType, "serviceType is null"); bindConfig(binder).annotatedWith(serviceType).prefixedWith("discovery." + serviceType.value()).to(ServiceSelectorConfig.class); binder.bind(ServiceSelector.class).annotatedWith(serviceType).toProvider(new ServiceSelectorProvider(serviceType.value())).in(Scopes.SINGLETON); }