use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project open-kilda by telstra.
the class TopologyTest method verifyEmittedValues.
@Test
public void verifyEmittedValues() {
MkClusterParam clusterParam = new MkClusterParam();
clusterParam.setSupervisors(1);
withSimulatedTimeLocalCluster(clusterParam, new TestJob() {
@Override
public void run(ILocalCluster cluster) throws JsonProcessingException {
MockedSources mockedSources = new MockedSources();
mockedSources.addMockData(builder.getSpoutId(), new Values(SWITCH_ID));
Config config = new Config();
config.setDebug(true);
CompleteTopologyParam topologyParam = new CompleteTopologyParam();
topologyParam.setMockedSources(mockedSources);
topologyParam.setStormConf(config);
Map<?, ?> result = completeTopology(cluster, builder.build(), topologyParam);
assertTrue(multiseteq(new Values(new Values(SWITCH_ID)), readTuples(result, builder.getSpoutId())));
assertTrue(multiseteq(new Values(new Values(SWITCH_ID)), readTuples(result, builder.getConfirmationBoltId())));
}
});
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project open-kilda by telstra.
the class KafkaMessageProducer method send.
/**
* Sends messages to WorkFlowManager.
*
* @param topic kafka topic
* @param object object to serialize and send
*/
public void send(final String topic, final Object object) {
String message;
try {
message = MAPPER.writeValueAsString(object);
} catch (JsonProcessingException exception) {
logger.error("Unable to serialize object: object={}", object, exception);
throw new MessageException(DATA_INVALID, System.currentTimeMillis());
}
kafkaTemplate.send(topic, message).addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
@Override
public void onSuccess(SendResult<String, String> result) {
logger.debug("Message sent: topic={}, message={}", topic, message);
}
@Override
public void onFailure(Throwable exception) {
logger.error("Unable to send message: topic={}, message={}", topic, message, exception);
}
});
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project airlift by airlift.
the class SmileMapper method readFrom.
@Override
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream inputStream) throws IOException {
Object object;
try {
JsonParser jsonParser = new SmileFactory().createParser(inputStream);
// Important: we are NOT to close the underlying stream after
// mapping, so we need to instruct parser:
jsonParser.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);
object = objectMapper.readValue(jsonParser, objectMapper.getTypeFactory().constructType(genericType));
} catch (Exception e) {
// we want to return a 400 for bad JSON but not for a real IO exception
if (e instanceof IOException && !(e instanceof JsonProcessingException) && !(e instanceof EOFException)) {
throw (IOException) e;
}
// log the exception at debug so it can be viewed during development
// Note: we are not logging at a higher level because this could cause a denial of service
log.debug(e, "Invalid json for Java type %s", type);
// Invalid json request. Throwing exception so the response code can be overridden using a mapper.
throw new JsonMapperParsingException(type, e);
}
return object;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project connect-utils by jcustenborder.
the class RstTemplateHelper method jsonExample.
public String jsonExample(ConnectorTemplate template) {
StringWriter writer = new StringWriter();
final ObjectNode outputNode = createJsonNode(template);
final String json;
try {
json = this.objectMapper.writeValueAsString(outputNode);
} catch (JsonProcessingException e) {
throw new IllegalStateException(e);
}
writer.write(".. code-block:: json");
writer.write('\n');
writer.write(" :name: connector.json");
writer.write('\n');
List<Integer> emphasizeLines = emphasizeLines(json);
if (!emphasizeLines.isEmpty()) {
writer.write(" :emphasize-lines: ");
writer.write(Joiner.on(',').join(emphasizeLines));
writer.write('\n');
}
writer.write('\n');
writer.write(indent(json));
writer.write('\n');
return writer.toString();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project indy by Commonjava.
the class AutoProxCalculatorResource method eval.
@ApiOperation(value = "Calculate the effects of referencing a store with the given type and name to determine what AutoProx will auto-create", response = AutoProxCalculation.class)
@ApiResponse(code = 200, message = "Result of calculation")
@Path("/{packageType}/{type: (hosted|group|remote)}/{name}")
@GET
@Produces(ApplicationContent.application_json)
public Response eval(@PathParam("packageType") final String packageType, @PathParam("type") final String type, @PathParam("name") final String remoteName) {
Response response = checkEnabled();
if (response != null) {
return response;
}
try {
StoreKey key = new StoreKey(packageType, StoreType.get(type), remoteName);
final AutoProxCalculation calc = controller.eval(key);
response = formatOkResponseWithJsonEntity(serializer.writeValueAsString(calc == null ? Collections.singletonMap("error", "Nothing was created") : calc));
} catch (final IndyWorkflowException e) {
logger.error(String.format("Failed to create demo RemoteRepository for: '%s'. Reason: %s", remoteName, e.getMessage()), e);
response = formatResponse(e);
} catch (final JsonProcessingException e) {
logger.error(String.format("Failed to create demo RemoteRepository for: '%s'. Reason: %s", remoteName, e.getMessage()), e);
response = formatResponse(e);
}
return response;
}
Aggregations