use of org.codehaus.jackson.map.SerializationConfig in project camunda-bpm-platform by camunda.
the class JsonUtil method getMapper.
public static ObjectMapper getMapper() {
if (mapper == null) {
mapper = new ObjectMapper();
SerializationConfig config = mapper.getSerializationConfig().withSerializationInclusion(Inclusion.NON_EMPTY).without(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
mapper.setSerializationConfig(config);
}
return mapper;
}
use of org.codehaus.jackson.map.SerializationConfig in project helix by apache.
the class TestHelixAdminScenariosRest method ObjectToJson.
public static String ObjectToJson(Object object) throws JsonGenerationException, JsonMappingException, IOException {
ObjectMapper mapper = new ObjectMapper();
SerializationConfig serializationConfig = mapper.getSerializationConfig();
serializationConfig.set(SerializationConfig.Feature.INDENT_OUTPUT, true);
StringWriter sw = new StringWriter();
mapper.writeValue(sw, object);
return sw.toString();
}
use of org.codehaus.jackson.map.SerializationConfig in project helix by apache.
the class ClusterRepresentationUtil method ObjectToJson.
public static String ObjectToJson(Object object) throws JsonGenerationException, JsonMappingException, IOException {
ObjectMapper mapper = new ObjectMapper();
SerializationConfig serializationConfig = mapper.getSerializationConfig();
serializationConfig.set(SerializationConfig.Feature.INDENT_OUTPUT, true);
StringWriter sw = new StringWriter();
mapper.writeValue(sw, object);
return sw.toString();
}
use of org.codehaus.jackson.map.SerializationConfig in project helix by apache.
the class ResourceUtil method objectToJson.
private static String objectToJson(Object object) {
ObjectMapper mapper = new ObjectMapper();
SerializationConfig serializationConfig = mapper.getSerializationConfig();
serializationConfig.set(SerializationConfig.Feature.INDENT_OUTPUT, true);
StringWriter sw = new StringWriter();
try {
mapper.writeValue(sw, object);
} catch (JsonGenerationException e) {
// Should not be here
} catch (JsonMappingException e) {
// Should not be here
} catch (IOException e) {
// Should not be here
}
return sw.toString();
}
use of org.codehaus.jackson.map.SerializationConfig in project helix by apache.
the class TestSchedulerMessage method testSchedulerZeroMsg.
@Test
public void testSchedulerZeroMsg() throws Exception {
_factory._results.clear();
HelixManager manager = null;
for (int i = 0; i < NODE_NR; i++) {
_participants[i].getMessagingService().registerMessageHandlerFactory(_factory.getMessageTypes(), _factory);
// _startCMResultMap.get(hostDest)._manager;
manager = _participants[i];
}
Message schedulerMessage = new Message(MessageType.SCHEDULER_MSG + "", UUID.randomUUID().toString());
schedulerMessage.setTgtSessionId("*");
schedulerMessage.setTgtName("CONTROLLER");
// TODO: change it to "ADMIN" ?
schedulerMessage.setSrcName("CONTROLLER");
// Template for the individual message sent to each participant
Message msg = new Message(_factory.getMessageTypes().get(0), "Template");
msg.setTgtSessionId("*");
msg.setMsgState(MessageState.NEW);
// Criteria to send individual messages
Criteria cr = new Criteria();
cr.setInstanceName("localhost_DOESNOTEXIST");
cr.setRecipientInstanceType(InstanceType.PARTICIPANT);
cr.setSessionSpecific(false);
cr.setResource("%");
cr.setPartition("%");
ObjectMapper mapper = new ObjectMapper();
SerializationConfig serializationConfig = mapper.getSerializationConfig();
serializationConfig.set(SerializationConfig.Feature.INDENT_OUTPUT, true);
StringWriter sw = new StringWriter();
mapper.writeValue(sw, cr);
String crString = sw.toString();
schedulerMessage.getRecord().setSimpleField("Criteria", crString);
schedulerMessage.getRecord().setMapField("MessageTemplate", msg.getRecord().getSimpleFields());
schedulerMessage.getRecord().setSimpleField("TIMEOUT", "-1");
HelixDataAccessor helixDataAccessor = manager.getHelixDataAccessor();
Builder keyBuilder = helixDataAccessor.keyBuilder();
PropertyKey controllerMessageKey = keyBuilder.controllerMessage(schedulerMessage.getMsgId());
helixDataAccessor.setProperty(controllerMessageKey, schedulerMessage);
Thread.sleep(3000);
Assert.assertEquals(0, _factory._results.size());
PropertyKey controllerTaskStatus = keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.name(), schedulerMessage.getMsgId());
for (int i = 0; i < 10; i++) {
StatusUpdate update = helixDataAccessor.getProperty(controllerTaskStatus);
if (update == null || update.getRecord().getMapField("SentMessageCount") == null) {
Thread.sleep(1000);
}
}
ZNRecord statusUpdate = helixDataAccessor.getProperty(controllerTaskStatus).getRecord();
Assert.assertTrue(statusUpdate.getMapField("SentMessageCount").get("MessageCount").equals("0"));
int count = 0;
for (Set<String> val : _factory._results.values()) {
count += val.size();
}
Assert.assertEquals(count, 0);
}
Aggregations