use of io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper in project mantis by Netflix.
the class JobsRouteTest method validateJobsListResponse.
private void validateJobsListResponse(String resp, int expectedJobsCount, boolean isCompact) {
try {
assert !Strings.isNullOrEmpty(resp);
ObjectMapper mapper = new ObjectMapper();
JsonNode responseObj = mapper.readTree(resp).get("list");
assert responseObj.size() == expectedJobsCount;
for (int i = 0; i < expectedJobsCount; i++) {
validateJobsListItem(responseObj.get(i), isCompact);
}
} catch (IOException ex) {
logger.error("Failed to validate job response: " + ex.getMessage());
assert false;
}
}
use of io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper in project mantis by Netflix.
the class JobsRouteTest method validateJobDetails.
private void validateJobDetails(String resp) {
try {
assert !Strings.isNullOrEmpty(resp);
ObjectMapper mapper = new ObjectMapper();
JsonNode responseObj = mapper.readTree(resp);
validateJobsListItem(responseObj, false);
} catch (IOException ex) {
logger.error("Failed to validate job details response: " + ex.getMessage());
assert false;
}
}
use of io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper in project mantis by Netflix.
the class AppJobClustersMapTest method testDeSerFromString.
@Test
public void testDeSerFromString() throws IOException {
final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
final String mapping = "{\"version\":\"1\",\"timestamp\":2,\"mappings\":{\"testApp\":{\"__default__\":\"SharedMrePublishEventSource\"}}}";
AppJobClustersMap appJobClustersMap = mapper.readValue(mapping, AppJobClustersMap.class);
assertEquals(2, appJobClustersMap.getTimestamp());
assertEquals("testApp", appJobClustersMap.getStreamJobClusterMap("testApp").getAppName());
assertEquals("SharedMrePublishEventSource", appJobClustersMap.getStreamJobClusterMap("testApp").getJobCluster("testStream"));
}
use of io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper in project mantis by Netflix.
the class AppJobClustersMapTest method testSerDe.
@Test
public void testSerDe() throws IOException {
Map<String, Object> mappings = new HashMap<>();
Map<String, Object> defaultAppMappings = new HashMap<>();
defaultAppMappings.put(StreamJobClusterMap.DEFAULT_STREAM_KEY, "SharedPushEventSource");
defaultAppMappings.put("testEventStream", "TestPushEventSource");
mappings.put(AppJobClustersMap.DEFAULT_APP_KEY, defaultAppMappings);
Map<String, Object> customAppMappings = new HashMap<>();
customAppMappings.put("customEventStream", "CustomPushEventSource");
customAppMappings.put(StreamJobClusterMap.DEFAULT_STREAM_KEY, "CustomDefaultPushEventSource");
mappings.put("custom", customAppMappings);
AppJobClustersMap mapV1 = new AppJobClustersMap(AppJobClustersMap.VERSION_1, System.currentTimeMillis(), mappings);
assertEquals("SharedPushEventSource", mapV1.getStreamJobClusterMap(AppJobClustersMap.DEFAULT_APP_KEY).getJobCluster(StreamJobClusterMap.DEFAULT_STREAM_KEY));
assertEquals("SharedPushEventSource", mapV1.getStreamJobClusterMap(AppJobClustersMap.DEFAULT_APP_KEY).getJobCluster("AnyRandomStream"));
assertEquals("TestPushEventSource", mapV1.getStreamJobClusterMap(AppJobClustersMap.DEFAULT_APP_KEY).getJobCluster("testEventStream"));
StreamJobClusterMap customStreamJCMap = mapV1.getStreamJobClusterMap("custom");
System.out.println("custom app mapping: " + customStreamJCMap);
assertTrue(customStreamJCMap.getStreamJobClusterMap().size() == 2);
assertTrue(customStreamJCMap.getStreamJobClusterMap().containsKey(StreamJobClusterMap.DEFAULT_STREAM_KEY));
assertFalse(customStreamJCMap.getStreamJobClusterMap().containsKey("testEventStream"));
assertTrue(customStreamJCMap.getStreamJobClusterMap().containsKey("customEventStream"));
assertEquals("CustomDefaultPushEventSource", customStreamJCMap.getJobCluster(StreamJobClusterMap.DEFAULT_STREAM_KEY));
assertEquals("CustomDefaultPushEventSource", customStreamJCMap.getJobCluster("AnyRandomStreamName"));
assertEquals("CustomDefaultPushEventSource", customStreamJCMap.getJobCluster("testEventStream"));
assertEquals("CustomPushEventSource", customStreamJCMap.getJobCluster("customEventStream"));
ObjectMapper mapper = new ObjectMapper();
String mappingStr = mapper.writeValueAsString(mapV1);
System.out.println("input mappings " + mappingStr);
AppJobClustersMap appJobClustersMap = mapper.readValue(mappingStr, AppJobClustersMap.class);
System.out.println("parsed mappings " + appJobClustersMap);
assertEquals(mapV1, appJobClustersMap);
}
use of io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper in project mantis by Netflix.
the class AdaptiveAutoscalerConfig method main.
public static void main(String[] args) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
String cfg = "{\"metric\": \"KafkaProcessed\", \"setPoint\": 1, \"invert\": true, \"rope\": 0, \"kp\": 0.1, \"ki\": 0.00, \"kd\": 0.00, \"minScale\": 1, \"maxScale\": 5}\n";
AdaptiveAutoscalerConfig config = objectMapper.readValue(cfg, new TypeReference<AdaptiveAutoscalerConfig>() {
});
System.out.println(config.toString());
}
Aggregations