本文整理汇总了Java中org.onosproject.net.flow.FlowRuleBatchEvent类的典型用法代码示例。如果您正苦于以下问题:Java FlowRuleBatchEvent类的具体用法?Java FlowRuleBatchEvent怎么用?Java FlowRuleBatchEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FlowRuleBatchEvent类属于org.onosproject.net.flow包,在下文中一共展示了FlowRuleBatchEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerMessageHandlers
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
private void registerMessageHandlers(ExecutorService executor) {
clusterCommunicator.addSubscriber(APPLY_BATCH_FLOWS, new OnStoreBatch(), executor);
clusterCommunicator.<FlowRuleBatchEvent>addSubscriber(
REMOTE_APPLY_COMPLETED, SERIALIZER::decode, this::notifyDelegate, executor);
clusterCommunicator.addSubscriber(
GET_FLOW_ENTRY, SERIALIZER::decode, flowTable::getFlowEntry, SERIALIZER::encode, executor);
clusterCommunicator.addSubscriber(
GET_DEVICE_FLOW_ENTRIES, SERIALIZER::decode, flowTable::getFlowEntries, SERIALIZER::encode, executor);
clusterCommunicator.addSubscriber(
REMOVE_FLOW_ENTRY, SERIALIZER::decode, this::removeFlowRuleInternal, SERIALIZER::encode, executor);
clusterCommunicator.addSubscriber(
REMOVE_FLOW_ENTRY, SERIALIZER::decode, this::removeFlowRuleInternal, SERIALIZER::encode, executor);
clusterCommunicator.addSubscriber(
FLOW_TABLE_BACKUP, SERIALIZER::decode, flowTable::onBackupReceipt, SERIALIZER::encode, executor);
}
示例2: storeBatchInternal
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
private void storeBatchInternal(FlowRuleBatchOperation operation) {
final DeviceId did = operation.deviceId();
//final Collection<FlowEntry> ft = flowTable.getFlowEntries(did);
Set<FlowRuleBatchEntry> currentOps = updateStoreInternal(operation);
if (currentOps.isEmpty()) {
batchOperationComplete(FlowRuleBatchEvent.completed(
new FlowRuleBatchRequest(operation.id(), Collections.emptySet()),
new CompletedBatchOperation(true, Collections.emptySet(), did)));
return;
}
notifyDelegate(FlowRuleBatchEvent.requested(new
FlowRuleBatchRequest(operation.id(),
currentOps), operation.deviceId()));
}
示例3: storeBatchInternal
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
private void storeBatchInternal(FlowRuleBatchOperation operation) {
final DeviceId did = operation.deviceId();
//final Collection<FlowEntry> ft = flowTable.getFlowEntries(did);
Set<FlowRuleBatchEntry> currentOps = updateStoreInternal(operation);
if (currentOps.isEmpty()) {
batchOperationComplete(FlowRuleBatchEvent.completed(
new FlowRuleBatchRequest(operation.id(), Collections.emptySet()),
new CompletedBatchOperation(true, Collections.emptySet(), did)));
return;
}
updateBackup(did, currentOps);
notifyDelegate(FlowRuleBatchEvent.requested(new
FlowRuleBatchRequest(operation.id(),
currentOps), operation.deviceId()));
}
示例4: batchOperationComplete
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
@Override
public void batchOperationComplete(FlowRuleBatchEvent event) {
//FIXME: need a per device pending response
NodeId nodeId = pendingResponses.remove(event.subject().batchId());
if (nodeId == null) {
notifyDelegate(event);
} else {
ClusterMessage message = new ClusterMessage(
clusterService.getLocalNode().id(),
REMOTE_APPLY_COMPLETED,
SERIALIZER.encode(event));
// TODO check unicast return value
clusterCommunicator.unicast(message, nodeId);
//error log: log.warn("Failed to respond to peer for batch operation result");
}
}
示例5: batchOperationComplete
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
/**
* Invoked on the completion of a storeBatch operation.
*
* @param event flow rule batch event
*/
@Override
public void batchOperationComplete(FlowRuleBatchEvent event) {
// TODO Auto-generated method stub
final Long batchId = event.subject().batchId();
SettableFuture<FlowExtCompletedOperation> future = pendingExtendFutures
.getIfPresent(batchId);
if (future != null) {
FlowRuleBatchRequest request = event.subject();
CompletedBatchOperation result = event.result();
FlowExtCompletedOperation completed =
new FlowExtCompletedOperation(request.batchId(), result.isSuccess(), result.failedItems());
future.set(completed);
pendingExtendFutures.invalidate(batchId);
}
}
示例6: batchOperationCompleted
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
@Override
public void batchOperationCompleted(long batchId, CompletedBatchOperation operation) {
store.batchOperationComplete(FlowRuleBatchEvent.completed(
new FlowRuleBatchRequest(batchId, Collections.emptySet()),
operation
));
}
示例7: batchOperationComplete
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
@Override
public void batchOperationComplete(FlowRuleBatchEvent event) {
final Long batchId = event.subject().batchId();
SettableFuture<CompletedBatchOperation> future
= pendingFutures.getIfPresent(batchId);
if (future != null) {
future.set(event.result());
pendingFutures.invalidate(batchId);
}
notifyDelegate(event);
}
示例8: batchOperationComplete
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
@Override
public void batchOperationComplete(FlowRuleBatchEvent event) {
//FIXME: need a per device pending response
NodeId nodeId = pendingResponses.remove(event.subject().batchId());
if (nodeId == null) {
notifyDelegate(event);
} else {
// TODO check unicast return value
clusterCommunicator.unicast(event, REMOTE_APPLY_COMPLETED, SERIALIZER::encode, nodeId);
//error log: log.warn("Failed to respond to peer for batch operation result");
}
}
示例9: notify
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
@Override
public void notify(FlowRuleBatchEvent event) {
// Request has been forwarded to MASTER Node
for (FlowRuleBatchEntry entry : event.subject().ops()) {
switch (entry.operator()) {
case ADD:
eventDispatcher
.post(new FlowRuleEvent(FlowRuleEvent.Type.RULE_ADD_REQUESTED,
entry.target()));
break;
// FALLTHROUGH
case REMOVE:
case MODIFY:
default:
// TODO not implemented
break;
}
}
// send it
FlowRuleProvider flowRuleProvider = getProvider(event.subject().ops()
.iterator().next().target().deviceId());
// TODO we may want to specify a deviceId
flowRuleProvider.executeBatch(event.subject().asBatchOperation(null));
// do not have transaction, assume it install success
// temporarily
FlowExtCompletedOperation result = new FlowExtCompletedOperation(
event.subject().batchId(), true, Collections.emptySet());
futureService.submit(() -> {
router.batchOperationComplete(FlowRuleBatchEvent
.completed(event.subject(), result));
});
}
示例10: notify
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
/**
* Notify the listener of Router to do some reaction.
*
* @param request the requested operation to do
*/
public void notify(FlowRuleBatchRequest request) {
for (FlowRuleExtRouterListener listener : routerListener) {
listener.notify(FlowRuleBatchEvent
// TODO fill in the deviceId
.requested(request, null));
}
}
示例11: notify
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
@Override
public void notify(FlowRuleBatchEvent event) {
final FlowRuleBatchRequest request = event.subject();
switch (event.type()) {
case BATCH_OPERATION_REQUESTED:
// Request has been forwarded to MASTER Node, and was
request.ops().stream().forEach(
op -> {
switch (op.operator()) {
case ADD:
post(new FlowRuleEvent(RULE_ADD_REQUESTED,
op.target()));
break;
case REMOVE:
post(new FlowRuleEvent(RULE_REMOVE_REQUESTED,
op.target()));
break;
case MODIFY:
//TODO: do something here when the time comes.
break;
default:
log.warn("Unknown flow operation operator: {}", op.operator());
}
}
);
DeviceId deviceId = event.deviceId();
FlowRuleBatchOperation batchOperation =
request.asBatchOperation(deviceId);
FlowRuleProvider flowRuleProvider = getProvider(deviceId);
if (flowRuleProvider != null) {
flowRuleProvider.executeBatch(batchOperation);
}
break;
case BATCH_OPERATION_COMPLETED:
FlowOperationsProcessor fops = pendingFlowOperations.remove(
event.subject().batchId());
if (event.result().isSuccess()) {
if (fops != null) {
fops.satisfy(event.deviceId());
}
} else {
fops.fail(event.deviceId(), event.result().failedItems());
}
break;
default:
break;
}
}
示例12: storeBatch
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
@Override
public void storeBatch(
FlowRuleBatchOperation operation) {
List<FlowRuleBatchEntry> toAdd = new ArrayList<>();
List<FlowRuleBatchEntry> toRemove = new ArrayList<>();
for (FlowRuleBatchEntry entry : operation.getOperations()) {
final FlowRule flowRule = entry.target();
if (entry.operator().equals(FlowRuleOperation.ADD)) {
if (!getFlowEntries(flowRule.deviceId(), flowRule.id()).contains(flowRule)) {
storeFlowRule(flowRule);
toAdd.add(entry);
}
} else if (entry.operator().equals(FlowRuleOperation.REMOVE)) {
if (getFlowEntries(flowRule.deviceId(), flowRule.id()).contains(flowRule)) {
deleteFlowRule(flowRule);
toRemove.add(entry);
}
} else {
throw new UnsupportedOperationException("Unsupported operation type");
}
}
if (toAdd.isEmpty() && toRemove.isEmpty()) {
notifyDelegate(FlowRuleBatchEvent.completed(
new FlowRuleBatchRequest(operation.id(), Collections.emptySet()),
new CompletedBatchOperation(true, Collections.emptySet(),
operation.deviceId())));
return;
}
SettableFuture<CompletedBatchOperation> r = SettableFuture.create();
final int batchId = localBatchIdGen.incrementAndGet();
pendingFutures.put(batchId, r);
toAdd.addAll(toRemove);
notifyDelegate(FlowRuleBatchEvent.requested(
new FlowRuleBatchRequest(batchId, Sets.newHashSet(toAdd)), operation.deviceId()));
}
示例13: notify
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
@Override
public void notify(FlowRuleBatchEvent event) {
final FlowRuleBatchRequest request = event.subject();
switch (event.type()) {
case BATCH_OPERATION_REQUESTED:
// Request has been forwarded to MASTER Node, and was
request.ops().stream().forEach(
op -> {
switch (op.operator()) {
case ADD:
eventDispatcher.post(
new FlowRuleEvent(
FlowRuleEvent.Type.RULE_ADD_REQUESTED,
op.target()));
break;
case REMOVE:
eventDispatcher.post(
new FlowRuleEvent(
FlowRuleEvent.Type.RULE_REMOVE_REQUESTED,
op.target()));
break;
case MODIFY:
//TODO: do something here when the time comes.
break;
default:
log.warn("Unknown flow operation operator: {}", op.operator());
}
}
);
DeviceId deviceId = event.deviceId();
FlowRuleBatchOperation batchOperation =
request.asBatchOperation(deviceId);
FlowRuleProvider flowRuleProvider =
getProvider(deviceId);
flowRuleProvider.executeBatch(batchOperation);
break;
case BATCH_OPERATION_COMPLETED:
FlowOperationsProcessor fops = pendingFlowOperations.remove(
event.subject().batchId());
if (event.result().isSuccess()) {
if (fops != null) {
fops.satisfy(event.deviceId());
}
} else {
fops.fail(event.deviceId(), event.result().failedItems());
}
break;
default:
break;
}
}
示例14: notify
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
/**
* Notify monitor the router has down its work.
*
* @param event the event to notify
*/
void notify(FlowRuleBatchEvent event);
示例15: batchOperationComplete
import org.onosproject.net.flow.FlowRuleBatchEvent; //导入依赖的package包/类
/**
* Invoked on the completion of a storeBatch operation.
*
* @param event flow rule batch event
*/
void batchOperationComplete(FlowRuleBatchEvent event);