use of org.apache.druid.discovery.NodeRole in project druid by druid-io.
the class InitializationTest method testCreateInjectorWithNodeRoleFilter_moduleNotLoaded.
@Test
public void testCreateInjectorWithNodeRoleFilter_moduleNotLoaded() {
final DruidNode expected = new DruidNode("test-inject", null, false, null, null, true, false);
Injector startupInjector = GuiceInjectors.makeStartupInjector();
Injector injector = Initialization.makeInjectorWithModules(ImmutableSet.of(new NodeRole("role1"), new NodeRole("role2")), startupInjector, ImmutableList.of((com.google.inject.Module) binder -> JsonConfigProvider.bindInstance(binder, Key.get(DruidNode.class, Self.class), expected), new LoadOnAnnotationTestModule()));
Assert.assertNotNull(injector);
Assert.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
Assert.assertThrows("Guice configuration errors", ConfigurationException.class, () -> injector.getInstance(Key.get(String.class, Names.named("emperor"))));
}
use of org.apache.druid.discovery.NodeRole in project druid by druid-io.
the class ITHighAvailabilityTest method testCustomDiscovery.
@Test
public void testCustomDiscovery() {
ITRetryUtil.retryUntil(() -> {
try {
DruidNodeDiscovery customDisco = druidNodeDiscovery.getForNodeRole(new NodeRole(CliCustomNodeRole.SERVICE_NAME));
int count = testSelfDiscovery(customDisco.getAllNodes());
return count > 0;
} catch (Throwable t) {
return false;
}
}, true, RETRY_DELAY, NUM_RETRIES, "Custom service discovered");
}
use of org.apache.druid.discovery.NodeRole in project druid by druid-io.
the class CommonCacheNotifier method sendUpdate.
private List<ListenableFuture<StatusResponseHolder>> sendUpdate(String updatedAuthenticatorPrefix, byte[] serializedEntity) {
List<ListenableFuture<StatusResponseHolder>> futures = new ArrayList<>();
for (NodeRole nodeRole : NODE_TYPES) {
DruidNodeDiscovery nodeDiscovery = discoveryProvider.getForNodeRole(nodeRole);
Collection<DiscoveryDruidNode> nodes = nodeDiscovery.getAllNodes();
for (DiscoveryDruidNode node : nodes) {
URL listenerURL = getListenerURL(node.getDruidNode(), StringUtils.format(baseUrl, StringUtils.urlEncode(updatedAuthenticatorPrefix)));
// best effort, if this fails, remote node will poll and pick up the update eventually
Request req = new Request(HttpMethod.POST, listenerURL);
req.setContent(MediaType.APPLICATION_JSON, serializedEntity);
BasicAuthDBConfig itemConfig = itemConfigMap.get(updatedAuthenticatorPrefix);
ListenableFuture<StatusResponseHolder> future = httpClient.go(req, new ResponseHandler(), Duration.millis(itemConfig.getCacheNotificationTimeout()));
futures.add(future);
}
}
return futures;
}
use of org.apache.druid.discovery.NodeRole in project druid by druid-io.
the class InitializationTest method testCreateInjectorWithNodeRoles.
@Test
public void testCreateInjectorWithNodeRoles() {
final DruidNode expected = new DruidNode("test-inject", null, false, null, null, true, false);
Injector startupInjector = GuiceInjectors.makeStartupInjector();
Injector injector = Initialization.makeInjectorWithModules(ImmutableSet.of(new NodeRole("role1"), new NodeRole("role2")), startupInjector, ImmutableList.of(binder -> JsonConfigProvider.bindInstance(binder, Key.get(DruidNode.class, Self.class), expected)));
Assert.assertNotNull(injector);
Assert.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
}
use of org.apache.druid.discovery.NodeRole in project druid by druid-io.
the class InitializationTest method testCreateInjectorWithNodeRoleFilterUsingInject_moduleLoaded.
@Test
public void testCreateInjectorWithNodeRoleFilterUsingInject_moduleLoaded() {
final Set<NodeRole> nodeRoles = ImmutableSet.of(new NodeRole("role1"), new NodeRole("druid"));
final DruidNode expected = new DruidNode("test-inject", null, false, null, null, true, false);
Injector startupInjector = GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(binder -> {
Multibinder<NodeRole> selfBinder = Multibinder.newSetBinder(binder, NodeRole.class, Self.class);
nodeRoles.forEach(nodeRole -> selfBinder.addBinding().toInstance(nodeRole));
}));
Injector injector = Initialization.makeInjectorWithModules(nodeRoles, startupInjector, ImmutableList.of((com.google.inject.Module) binder -> JsonConfigProvider.bindInstance(binder, Key.get(DruidNode.class, Self.class), expected), new NodeRolesInjectTestModule()));
Assert.assertNotNull(injector);
Assert.assertEquals(expected, injector.getInstance(Key.get(DruidNode.class, Self.class)));
Assert.assertEquals("I am Druid", injector.getInstance(Key.get(String.class, Names.named("emperor"))));
}
Aggregations