use of org.onosproject.incubator.net.virtual.store.impl.primitives.VirtualFlowRuleBatchOperation in project onos by opennetworkinglab.
the class DistributedVirtualFlowRuleStore method storeBatch.
@Override
public void storeBatch(NetworkId networkId, FlowRuleBatchOperation operation) {
if (operation.getOperations().isEmpty()) {
notifyDelegate(networkId, FlowRuleBatchEvent.completed(new FlowRuleBatchRequest(operation.id(), Collections.emptySet()), new CompletedBatchOperation(true, Collections.emptySet(), operation.deviceId())));
return;
}
DeviceId deviceId = operation.deviceId();
MastershipService mastershipService = vnaService.get(networkId, MastershipService.class);
NodeId master = mastershipService.getMasterFor(deviceId);
if (master == null) {
log.warn("No master for {}, vnet {} : flows will be marked for removal", deviceId, networkId);
updateStoreInternal(networkId, operation);
notifyDelegate(networkId, FlowRuleBatchEvent.completed(new FlowRuleBatchRequest(operation.id(), Collections.emptySet()), new CompletedBatchOperation(true, Collections.emptySet(), operation.deviceId())));
return;
}
if (Objects.equals(local, master)) {
storeBatchInternal(networkId, operation);
return;
}
log.trace("Forwarding storeBatch to {}, which is the primary (master) for device {}, vent {}", master, deviceId, networkId);
clusterCommunicator.unicast(new VirtualFlowRuleBatchOperation(networkId, operation), APPLY_BATCH_FLOWS, serializer::encode, master).whenComplete((result, error) -> {
if (error != null) {
log.warn("Failed to storeBatch: {} to {}", operation, master, error);
Set<FlowRule> allFailures = operation.getOperations().stream().map(BatchOperationEntry::target).collect(Collectors.toSet());
notifyDelegate(networkId, FlowRuleBatchEvent.completed(new FlowRuleBatchRequest(operation.id(), Collections.emptySet()), new CompletedBatchOperation(false, allFailures, deviceId)));
}
});
}
Aggregations