本文整理汇总了Java中org.onosproject.net.flow.FlowRuleBatchRequest类的典型用法代码示例。如果您正苦于以下问题:Java FlowRuleBatchRequest类的具体用法?Java FlowRuleBatchRequest怎么用?Java FlowRuleBatchRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FlowRuleBatchRequest类属于org.onosproject.net.flow包,在下文中一共展示了FlowRuleBatchRequest类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: storeBatchInternal
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的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()));
}
示例2: storeBatchInternal
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的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()));
}
示例3: batchOperationComplete
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的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);
}
}
示例4: batchOperationCompleted
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的package包/类
@Override
public void batchOperationCompleted(long batchId, CompletedBatchOperation operation) {
store.batchOperationComplete(FlowRuleBatchEvent.completed(
new FlowRuleBatchRequest(batchId, Collections.emptySet()),
operation
));
}
示例5: setupKryoPool
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的package包/类
@Override
protected void setupKryoPool() {
serializerPool = KryoNamespace.newBuilder()
.register(DistributedStoreSerializers.STORE_COMMON)
.nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN)
.register(FlowExtCompletedOperation.class)
.register(FlowRuleBatchRequest.class)
.register(DownStreamFlowEntry.class)
.register(DefaultFlowRuleExt.class)
.build();
}
示例6: activate
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的package包/类
@Activate
public void activate() {
messageHandlingExecutor = Executors.newFixedThreadPool(
MESSAGE_HANDLER_THREAD_POOL_SIZE,
groupedThreads("onos/flow", "message-handlers"));
clusterCommunicator.addSubscriber(APPLY_EXTEND_FLOWS,
new ClusterMessageHandler() {
@Override
public void handle(ClusterMessage message) {
// decode the extended flow entry and store them in memory.
FlowRuleBatchRequest operation = SERIALIZER.decode(message.payload());
log.info("received batch request {}", operation);
final ListenableFuture<FlowExtCompletedOperation> f = applyBatchInternal(operation);
f.addListener(new Runnable() {
@Override
public void run() {
FlowExtCompletedOperation result = Futures.getUnchecked(f);
try {
message.respond(SERIALIZER.encode(result));
} catch (IOException e) {
log.error("Failed to respond back", e);
}
}
}, futureListeners);
}
}, messageHandlingExecutor);
replicaInfoManager.addListener(replicaInfoEventListener);
log.info("Started");
}
示例7: applySubBatch
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的package包/类
/**
* apply the sub batch of flow extension rules.
*
* @param batchOperation batch of flow rules.
* A batch can contain flow rules for a single device only.
* @return Future response indicating success/failure of the batch operation
* all the way down to the device.
*/
@Override
public Future<FlowExtCompletedOperation> applySubBatch(FlowRuleBatchRequest batchOperation) {
// TODO Auto-generated method stub
if (batchOperation.ops().isEmpty()) {
return Futures.immediateFuture(new FlowExtCompletedOperation(
batchOperation.batchId(), true, Collections.emptySet()));
}
// get the deviceId all the collection belongs to
DeviceId deviceId = getBatchDeviceId(batchOperation.ops());
if (deviceId == null) {
log.error("This Batch exists more than two deviceId");
return null;
}
ReplicaInfo replicaInfo = replicaInfoManager
.getReplicaInfoFor(deviceId);
if (replicaInfo.master().get()
.equals(clusterService.getLocalNode().id())) {
return applyBatchInternal(batchOperation);
}
log.trace("Forwarding storeBatch to {}, which is the primary (master) for device {}",
replicaInfo.master().orNull(), deviceId);
ClusterMessage message = new ClusterMessage(clusterService
.getLocalNode().id(), APPLY_EXTEND_FLOWS, SERIALIZER.encode(batchOperation));
try {
ListenableFuture<byte[]> responseFuture = clusterCommunicator
.sendAndReceive(message, replicaInfo.master().get());
// here should add another decode process
return Futures.transform(responseFuture,
new DecodeTo<FlowExtCompletedOperation>(SERIALIZER));
} catch (IOException e) {
return Futures.immediateFailedFuture(e);
}
}
示例8: notify
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的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));
}
}
示例9: notify
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的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;
}
}
示例10: storeBatch
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的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()));
}
示例11: notify
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的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;
}
}
示例12: applyBatchInternal
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的package包/类
/**
* apply the batch in local node.
* It means this instance is master of the device the flow entry belongs to.
*
* @param batchOperation a collection of flow entry, all they should send down to one device
* @return Future response indicating success/failure of the batch operation
* all the way down to the device.
*/
private ListenableFuture<FlowExtCompletedOperation> applyBatchInternal(FlowRuleBatchRequest batchOperation) {
SettableFuture<FlowExtCompletedOperation> r = SettableFuture.create();
pendingExtendFutures.put(batchOperation.batchId(), r);
// here should notify manager to complete
notify(batchOperation);
return r;
}
示例13: applyBatch
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的package包/类
/**
* Applies a batch operation of FlowRules.
* this batch can be divided into many sub-batch by deviceId, and application
* gives a batchId, it means once one flowRule apply failed, all flow rules should
* withdraw.
*
* @param batch batch operation to apply
* @return future indicating the state of the batch operation
*/
Future<FlowExtCompletedOperation> applyBatch(FlowRuleBatchRequest batch);
示例14: applySubBatch
import org.onosproject.net.flow.FlowRuleBatchRequest; //导入依赖的package包/类
/**
* apply the sub batch of flow extension rules.
*
* @param batchOperation batch of flow rules.
* A batch can contain flow rules for a single device only.
* @return Future response indicating success/failure of the batch operation
* all the way down to the device.
*/
Future<FlowExtCompletedOperation> applySubBatch(FlowRuleBatchRequest batchOperation);