use of org.openkilda.pce.cache.ResourceCache 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);
}
}
}
}
Aggregations