use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class JavaScriptTieredBrokerSelectorStrategyTest method testDisabled.
@Test
public void testDisabled() throws Exception {
ObjectMapper mapper = new DefaultObjectMapper();
mapper.setInjectableValues(new InjectableValues.Std().addValue(JavaScriptConfig.class, new JavaScriptConfig(false)));
final String strategyString = mapper.writeValueAsString(STRATEGY);
expectedException.expect(JsonMappingException.class);
expectedException.expectCause(CoreMatchers.instanceOf(IllegalStateException.class));
expectedException.expectMessage("JavaScript is disabled");
mapper.readValue(strategyString, JavaScriptTieredBrokerSelectorStrategy.class);
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class JavaScriptTieredBrokerSelectorStrategyTest method testSerde.
@Test
public void testSerde() throws Exception {
ObjectMapper mapper = new DefaultObjectMapper();
mapper.setInjectableValues(new InjectableValues.Std().addValue(JavaScriptConfig.class, JavaScriptConfig.getEnabledInstance()));
Assert.assertEquals(STRATEGY, mapper.readValue(mapper.writeValueAsString(STRATEGY), JavaScriptTieredBrokerSelectorStrategy.class));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class ManualTieredBrokerSelectorStrategyTest method testSerde.
@Test
public void testSerde() throws Exception {
final ObjectMapper mapper = new DefaultObjectMapper();
String json = "{\"type\":\"manual\"}";
TieredBrokerSelectorStrategy strategy = mapper.readValue(json, TieredBrokerSelectorStrategy.class);
assertTrue(strategy instanceof ManualTieredBrokerSelectorStrategy);
ManualTieredBrokerSelectorStrategy queryContextStrategy = (ManualTieredBrokerSelectorStrategy) strategy;
assertNull(queryContextStrategy.getDefaultManualBrokerService());
json = "{\"type\":\"manual\",\"defaultManualBrokerService\":\"hotBroker\"}";
queryContextStrategy = mapper.readValue(json, ManualTieredBrokerSelectorStrategy.class);
assertEquals(queryContextStrategy.getDefaultManualBrokerService(), "hotBroker");
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class CuratorDruidNodeAnnouncerAndDiscoveryTest method testAnnouncementAndDiscovery.
@Test(timeout = 60_000L)
public void testAnnouncementAndDiscovery() throws Exception {
ObjectMapper objectMapper = new DefaultObjectMapper();
// additional setup to serde DruidNode
objectMapper.setInjectableValues(new InjectableValues.Std().addValue(ServerConfig.class, new ServerConfig()).addValue("java.lang.String", "dummy").addValue("java.lang.Integer", 1234).addValue(ObjectMapper.class, objectMapper));
curator.start();
curator.blockUntilConnected();
Announcer announcer = new Announcer(curator, Execs.directExecutor());
announcer.start();
CuratorDruidNodeAnnouncer druidNodeAnnouncer = new CuratorDruidNodeAnnouncer(announcer, new ZkPathsConfig(), objectMapper);
DiscoveryDruidNode coordinatorNode1 = new DiscoveryDruidNode(new DruidNode("s1", "h1", false, 8080, null, true, false), NodeRole.COORDINATOR, ImmutableMap.of());
DiscoveryDruidNode coordinatorNode2 = new DiscoveryDruidNode(new DruidNode("s2", "h2", false, 8080, null, true, false), NodeRole.COORDINATOR, ImmutableMap.of());
DiscoveryDruidNode overlordNode1 = new DiscoveryDruidNode(new DruidNode("s3", "h3", false, 8080, null, true, false), NodeRole.OVERLORD, ImmutableMap.of());
DiscoveryDruidNode overlordNode2 = new DiscoveryDruidNode(new DruidNode("s4", "h4", false, 8080, null, true, false), NodeRole.OVERLORD, ImmutableMap.of());
druidNodeAnnouncer.announce(coordinatorNode1);
druidNodeAnnouncer.announce(overlordNode1);
CuratorDruidNodeDiscoveryProvider druidNodeDiscoveryProvider = new CuratorDruidNodeDiscoveryProvider(curator, new ZkPathsConfig(), objectMapper);
druidNodeDiscoveryProvider.start();
DruidNodeDiscovery coordDiscovery = druidNodeDiscoveryProvider.getForNodeRole(NodeRole.COORDINATOR);
BooleanSupplier coord1NodeDiscovery = druidNodeDiscoveryProvider.getForNode(coordinatorNode1.getDruidNode(), NodeRole.COORDINATOR);
DruidNodeDiscovery overlordDiscovery = druidNodeDiscoveryProvider.getForNodeRole(NodeRole.OVERLORD);
BooleanSupplier overlord1NodeDiscovery = druidNodeDiscoveryProvider.getForNode(overlordNode1.getDruidNode(), NodeRole.OVERLORD);
while (!checkNodes(ImmutableSet.of(coordinatorNode1), coordDiscovery.getAllNodes()) && !coord1NodeDiscovery.getAsBoolean()) {
Thread.sleep(100);
}
while (!checkNodes(ImmutableSet.of(overlordNode1), overlordDiscovery.getAllNodes()) && !overlord1NodeDiscovery.getAsBoolean()) {
Thread.sleep(100);
}
HashSet<DiscoveryDruidNode> coordNodes = new HashSet<>();
coordDiscovery.registerListener(createSetAggregatingListener(coordNodes));
HashSet<DiscoveryDruidNode> overlordNodes = new HashSet<>();
overlordDiscovery.registerListener(createSetAggregatingListener(overlordNodes));
while (!checkNodes(ImmutableSet.of(coordinatorNode1), coordNodes)) {
Thread.sleep(100);
}
while (!checkNodes(ImmutableSet.of(overlordNode1), overlordNodes)) {
Thread.sleep(100);
}
druidNodeAnnouncer.announce(coordinatorNode2);
druidNodeAnnouncer.announce(overlordNode2);
while (!checkNodes(ImmutableSet.of(coordinatorNode1, coordinatorNode2), coordDiscovery.getAllNodes())) {
Thread.sleep(100);
}
while (!checkNodes(ImmutableSet.of(overlordNode1, overlordNode2), overlordDiscovery.getAllNodes())) {
Thread.sleep(100);
}
while (!checkNodes(ImmutableSet.of(coordinatorNode1, coordinatorNode2), coordNodes)) {
Thread.sleep(100);
}
while (!checkNodes(ImmutableSet.of(overlordNode1, overlordNode2), overlordNodes)) {
Thread.sleep(100);
}
druidNodeAnnouncer.unannounce(coordinatorNode1);
druidNodeAnnouncer.unannounce(coordinatorNode2);
druidNodeAnnouncer.unannounce(overlordNode1);
druidNodeAnnouncer.unannounce(overlordNode2);
while (!checkNodes(ImmutableSet.of(), coordDiscovery.getAllNodes())) {
Thread.sleep(100);
}
while (!checkNodes(ImmutableSet.of(), overlordDiscovery.getAllNodes())) {
Thread.sleep(100);
}
while (!coordNodes.isEmpty()) {
Thread.sleep(100);
}
while (!overlordNodes.isEmpty()) {
Thread.sleep(100);
}
druidNodeDiscoveryProvider.stop();
announcer.stop();
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class SupervisorStatusTest method testSerde.
@Test
public void testSerde() throws IOException {
final ObjectMapper mapper = new DefaultObjectMapper();
final SupervisorStatus.Builder builder = new SupervisorStatus.Builder();
final SupervisorStatus supervisorStatus = builder.withId("wikipedia").withState("RUNNING").withDetailedState("RUNNING").withHealthy(true).withType("kafka").withSource("wikipedia").withSuspended(false).build();
final String serialized = mapper.writeValueAsString(supervisorStatus);
final SupervisorStatus deserialized = mapper.readValue(serialized, SupervisorStatus.class);
Assert.assertEquals(supervisorStatus, deserialized);
}
Aggregations