use of io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper in project mantis by Netflix.
the class LabelUtilsTest method testSerDe.
@Test
public void testSerDe() {
Label l = new Label("k1", "v1");
ObjectMapper mapper = new ObjectMapper();
try {
System.out.println(mapper.writeValueAsString(l));
} catch (JsonProcessingException e) {
fail();
}
}
use of io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper in project mantis by Netflix.
the class SchedulingInfo method main.
public static void main(String[] args) {
Map<StageScalingPolicy.ScalingReason, StageScalingPolicy.Strategy> smap = new HashMap<>();
smap.put(StageScalingPolicy.ScalingReason.Memory, new StageScalingPolicy.Strategy(StageScalingPolicy.ScalingReason.Memory, 0.1, 0.6, null));
Builder builder = new Builder().numberOfStages(2).multiWorkerScalableStageWithConstraints(2, new MachineDefinition(1, 1.24, 0.0, 1, 1), null, null, new StageScalingPolicy(1, 1, 3, 1, 1, 60, smap)).multiWorkerScalableStageWithConstraints(3, new MachineDefinition(1, 1.24, 0.0, 1, 1), null, null, new StageScalingPolicy(1, 1, 3, 1, 1, 60, smap));
ObjectMapper mapper = new ObjectMapper();
try {
System.out.println(mapper.writeValueAsString(builder.build()));
} catch (IOException e) {
e.printStackTrace();
}
}
use of io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper in project mantis by Netflix.
the class StageScalingPolicy method main.
public static void main(String[] args) {
Map<ScalingReason, Strategy> smap = new HashMap<>();
smap.put(ScalingReason.CPU, new Strategy(ScalingReason.CPU, 0.5, 0.75, null));
smap.put(ScalingReason.DataDrop, new Strategy(ScalingReason.DataDrop, 0.0, 2.0, null));
StageScalingPolicy policy = new StageScalingPolicy(1, 1, 2, 1, 1, 60, smap);
ObjectMapper mapper = new ObjectMapper();
try {
System.out.println(mapper.writeValueAsString(policy));
String json1 = "{\"stage\":1,\"min\":1,\"max\":2,\"increment\":1,\"decrement\":1,\"strategies\":{},\"enabled\":false}";
StageScalingPolicy sp = mapper.readValue(json1, StageScalingPolicy.class);
// System.out.println(mapper.writeValueAsString(sp));
String json2 = "{\"stage\":1,\"min\":1,\"max\":5,\"increment\":1,\"decrement\":1,\"coolDownSecs\":600,\"strategies\":{\"CPU\":{\"reason\":\"CPU\",\"scaleDownBelowPct\":50,\"scaleUpAbovePct\":75}},\"enabled\":true}";
sp = mapper.readValue(json2, StageScalingPolicy.class);
System.out.println(mapper.writeValueAsString(sp));
String json3 = "{\"stage\":1,\"min\":1,\"max\":3,\"increment\":1,\"decrement\":1,\"coolDownSecs\":0,\"strategies\":{\"Memory\":{\"reason\":\"Memory\",\"scaleDownBelowPct\":65,\"scaleUpAbovePct\":80,\"rollingCount\":{\"count\":6,\"of\":10}}},\"enabled\":true}";
sp = mapper.readValue(json3, StageScalingPolicy.class);
// System.out.println(mapper.writeValueAsString(sp));
} catch (IOException e) {
e.printStackTrace();
}
}
use of io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper in project mantis by Netflix.
the class JacksonTest method testDeser4.
@Test
public void testDeser4() throws IOException {
final ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
List<MantisJobMetadataView> jobIdInfos = Jackson.fromJSON(objectMapper, "[{\"jobMetadata\":{\"jobId\":\"sine-function-1\",\"name\":\"sine-function\"," + "\"user\":\"nmahilani\",\"submittedAt\":1527703650220,\"jarUrl\":\"https://mantis.staging.us-east-1.prod.netflix.net/mantis-artifacts/mantis-examples-sine-function-0.2.9.zip\"," + "\"numStages\":2,\"sla\":{\"runtimeLimitSecs\":0,\"minRuntimeSecs\":0,\"slaType\":\"Lossy\",\"durationType\":\"Perpetual\",\"userProvidedType\":\"\"}," + "\"state\":\"Accepted\",\"subscriptionTimeoutSecs\":0,\"parameters\":[{\"name\":\"useRandom\",\"value\":\"True\"}],\"nextWorkerNumberToUse\":11," + "\"migrationConfig\":{\"strategy\":\"PERCENTAGE\",\"configString\":\"{\\\"percentToMove\\\":25,\\\"intervalMs\\\":60000}\"}," + "\"labels\":[{\"name\":\"_mantis.user\",\"value\":\"nmahilani\"},{\"name\":\"_mantis.ownerEmail\",\"value\":\"nmahilani@netflix.com\"}," + "{\"name\":\"_mantis.jobType\",\"value\":\"other\"},{\"name\":\"_mantis.criticality\",\"value\":\"low\"},{\"name\":\"_mantis.artifact.version\",\"value\":\"0.2.9\"}]}," + "\"stageMetadataList\":[{\"jobId\":\"sine-function-1\",\"stageNum\":0,\"numStages\":2,\"machineDefinition\":{\"cpuCores\":1.0,\"memoryMB\":200.0,\"networkMbps\":128.0,\"diskMB\":1024.0,\"numPorts\":1}," + "\"numWorkers\":1,\"hardConstraints\":null,\"softConstraints\":null,\"scalingPolicy\":null,\"scalable\":false}," + "{\"jobId\":\"sine-function-1\",\"stageNum\":1,\"numStages\":2,\"machineDefinition\":{\"cpuCores\":1.0,\"memoryMB\":200.0,\"networkMbps\":128.0,\"diskMB\":1024.0,\"numPorts\":1},\"numWorkers\":1,\"hardConstraints\":[],\"softConstraints\":[\"M4Cluster\"]," + "\"scalingPolicy\":{\"stage\":1,\"min\":1,\"max\":10,\"increment\":2,\"decrement\":1,\"coolDownSecs\":600," + "\"strategies\":{\"CPU\":{\"reason\":\"CPU\",\"scaleDownBelowPct\":15.0,\"scaleUpAbovePct\":75.0,\"rollingCount\":{\"count\":12,\"of\":20}}},\"enabled\":true},\"scalable\":true}]," + "\"workerMetadataList\":[{\"workerIndex\":0,\"workerNumber\":2,\"jobId\":\"sine-function-1\",\"stageNum\":0,\"numberOfPorts\":4,\"metricsPort\":0,\"consolePort\":0," + "\"debugPort\":-1,\"ports\":[],\"state\":\"Accepted\",\"slave\":null,\"slaveID\":null,\"cluster\":{\"present\":false},\"acceptedAt\":1527703650231,\"launchedAt\":0,\"startingAt\":0,\"startedAt\":0," + "\"completedAt\":0,\"reason\":null,\"resubmitOf\":-1,\"totalResubmitCount\":0},{\"workerIndex\":0,\"workerNumber\":3,\"jobId\":\"sine-function-1\",\"stageNum\":1,\"numberOfPorts\":4,\"metricsPort\":0,\"consolePort\":0,\"debugPort\":-1,\"ports\":[],\"state\":\"Accepted\"," + "\"slave\":null,\"slaveID\":null,\"cluster\":{\"present\":false},\"acceptedAt\":1527703650232,\"launchedAt\":0,\"startingAt\":0,\"startedAt\":0,\"completedAt\":0," + "\"reason\":null,\"resubmitOf\":-1,\"totalResubmitCount\":0}]}]", new TypeReference<List<MantisJobMetadataView>>() {
});
System.out.println(jobIdInfos);
MantisWorkerMetadataWritable mwm = jobIdInfos.get(0).getWorkerMetadataList().get(0);
mwm.setCluster(Optional.ofNullable("test"));
System.out.println(objectMapper.writer(Jackson.DEFAULT_FILTER_PROVIDER).writeValueAsString(mwm));
}
use of io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper in project mantis by Netflix.
the class JobsRouteTest method validateJobResponse.
private void validateJobResponse(String resp) {
try {
assert !Strings.isNullOrEmpty(resp);
ObjectMapper mapper = new ObjectMapper();
JsonNode responseObj = mapper.readTree(resp);
assert responseObj.get("jobMetadata").get("name").asText().equals(TEST_CLUSTER);
assert responseObj.get("jobMetadata").get("jobId").asText().startsWith("sine-function-");
assert responseObj.get("jobMetadata").get("sla") != null;
assert responseObj.get("jobMetadata").get("labels") != null;
assert responseObj.get("stageMetadataList") != null;
assert responseObj.get("workerMetadataList") != null;
} catch (IOException ex) {
logger.error("Failed to validate job response: " + ex.getMessage());
assert false;
}
}
Aggregations