use of com.fasterxml.jackson.core.JsonProcessingException in project open-kilda by telstra.
the class CacheBolt method emitRerouteCommands.
private void emitRerouteCommands(Set<ImmutablePair<Flow, Flow>> flows, Tuple tuple, String correlationId, FlowOperation operation) {
for (ImmutablePair<Flow, Flow> flow : flows) {
try {
flow.getLeft().setState(FlowState.DOWN);
flow.getRight().setState(FlowState.DOWN);
FlowRerouteRequest request = new FlowRerouteRequest(flow.getLeft(), operation);
Values values = new Values(Utils.MAPPER.writeValueAsString(new CommandMessage(request, System.currentTimeMillis(), correlationId, Destination.WFM)));
outputCollector.emit(StreamType.WFM_DUMP.toString(), tuple, values);
logger.debug("Flow {} reroute command message sent with correlationId {}", flow.getLeft().getFlowId(), correlationId);
} catch (JsonProcessingException exception) {
logger.error("Could not format flow reroute request by flow={}", flow, exception);
}
}
}
use of com.fasterxml.jackson.core.JsonProcessingException in project open-kilda by telstra.
the class CacheBolt method emitRestoreCommands.
private void emitRestoreCommands(Set<ImmutablePair<Flow, Flow>> flows, Tuple tuple) {
if (flows != null) {
ResourceCache resourceCache = new ResourceCache();
for (ImmutablePair<Flow, Flow> flow : flows) {
resourceCache.allocateFlow(flow);
}
for (ImmutablePair<Flow, Flow> flow : flows) {
try {
FlowRestoreRequest request = new FlowRestoreRequest(flowCache.buildFlow(flow.getLeft(), new ImmutablePair<>(null, null), resourceCache));
resourceCache.deallocateFlow(flow);
Values values = new Values(Utils.MAPPER.writeValueAsString(new CommandMessage(request, System.currentTimeMillis(), UUID.randomUUID().toString(), Destination.WFM)));
outputCollector.emit(StreamType.WFM_DUMP.toString(), tuple, values);
logger.info("Flow {} restore command message sent", flow.getLeft().getFlowId());
} catch (JsonProcessingException exception) {
logger.error("Could not format flow restore request by flow={}", flow, exception);
}
}
}
}
use of com.fasterxml.jackson.core.JsonProcessingException in project open-kilda by telstra.
the class OFELinkBolt method sendNetworkRequest.
/**
* Send network dump request to FL
*/
private void sendNetworkRequest(Tuple tuple) {
try {
logger.debug("Send network dump request");
CommandMessage command = new CommandMessage(new NetworkCommandData(), System.currentTimeMillis(), Utils.SYSTEM_CORRELATION_ID, Destination.CONTROLLER);
String json = Utils.MAPPER.writeValueAsString(command);
collector.emit(islDiscoveryTopic, tuple, new Values(PAYLOAD, json));
} catch (JsonProcessingException exception) {
logger.error("Could not serialize network cache request", exception);
}
}
use of com.fasterxml.jackson.core.JsonProcessingException in project open-kilda by telstra.
the class NorthboundReplyBolt method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(Tuple tuple) {
ComponentType componentId = ComponentType.valueOf(tuple.getSourceComponent());
StreamType streamId = StreamType.valueOf(tuple.getSourceStreamId());
Message message = (Message) tuple.getValueByField(AbstractTopology.MESSAGE_FIELD);
Values values = null;
try {
logger.debug("Request tuple={}", tuple);
switch(componentId) {
case TOPOLOGY_ENGINE_BOLT:
case CRUD_BOLT:
case ERROR_BOLT:
logger.debug("Flow response: {}={}, component={}, stream={}, message={}", Utils.CORRELATION_ID, message.getCorrelationId(), componentId, streamId, message);
message.setDestination(Destination.NORTHBOUND);
values = new Values(MAPPER.writeValueAsString(message));
outputCollector.emit(StreamType.RESPONSE.toString(), tuple, values);
break;
default:
logger.debug("Flow unknown response: {}={}, component={}, stream={}, message={}", Utils.CORRELATION_ID, message.getCorrelationId(), componentId, streamId, message);
break;
}
} catch (JsonProcessingException exception) {
logger.error("Could not serialize message: component={}, stream={}, message={}", componentId, streamId, message);
} finally {
logger.debug("Northbound-Reply message ack: component={}, stream={}, tuple={}, values={}", tuple.getSourceComponent(), tuple.getSourceStreamId(), tuple, values);
outputCollector.ack(tuple);
}
}
use of com.fasterxml.jackson.core.JsonProcessingException in project open-kilda by telstra.
the class ControllerUtils method addStaticFlow.
public void addStaticFlow(StaticFlowEntry flow) throws JsonProcessingException, FloodlightQueryException {
Response response;
String json = Utils.MAPPER.writeValueAsString(flow);
try {
response = restClient.target(DefaultParameters.FLOODLIGHT_ENDPOINT).path("/wm/staticentrypusher/json").request().accept(MediaType.APPLICATION_JSON).post(Entity.json(json));
} catch (ProcessingException e) {
throw new FloodlightQueryException(e);
}
if (response.getStatus() != 200) {
throw new FloodlightQueryException(201, response.getStatus());
}
}
Aggregations