// TODO: Right now we only dispatch events at individual flowEntry level.
// It may be more efficient for also dispatch events as a batch.
@Override
        public void notify(FlowTableBatchEvent event) {
            final FlowTableBatchRequest 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 FlowTableEvent(FlowTableEvent.Type.TABLE_ADD_REQUESTED,
                                                           op.target()));
                                    break;
                                case REMOVE:
                                    post(new FlowTableEvent(FlowTableEvent.Type.TABLE_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();
                FlowTableBatchOperation batchOperation =
                        request.asBatchOperation(deviceId);
                FlowTableProvider flowTableProvider = getProvider(deviceId);
                if (flowTableProvider != null) {
                    flowTableProvider.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;
            }
        }
@Override
public void notify(FlowTableBatchEvent event) {
final FlowTableBatchRequest 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 FlowTableEvent(FlowTableEvent.Type.TABLE_ADD_REQUESTED,
op.target()));
break;
case REMOVE:
post(new FlowTableEvent(FlowTableEvent.Type.TABLE_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();
FlowTableBatchOperation batchOperation =
request.asBatchOperation(deviceId);
FlowTableProvider flowTableProvider = getProvider(deviceId);
if (flowTableProvider != null) {
flowTableProvider.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;
}
}
@Override
public void notify(FlowTableBatchEvent event) {
final FlowTableBatchRequest 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 FlowTableEvent(FlowTableEvent.Type.TABLE_ADD_REQUESTED,
op.target()));
break;
case REMOVE:
post(new FlowTableEvent(FlowTableEvent.Type.TABLE_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();
FlowTableBatchOperation batchOperation =
request.asBatchOperation(deviceId);
FlowTableProvider flowTableProvider = getProvider(deviceId);
if (flowTableProvider != null) {
flowTableProvider.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;
}
}
@Override
public void notify(FlowTableBatchEvent event) {
final FlowTableBatchRequest 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 FlowTableEvent(FlowTableEvent.Type.TABLE_ADD_REQUESTED,
op.target()));
break;
case REMOVE:
post(new FlowTableEvent(FlowTableEvent.Type.TABLE_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();
FlowTableBatchOperation batchOperation =
request.asBatchOperation(deviceId);
FlowTableProvider flowTableProvider = getProvider(deviceId);
if (flowTableProvider != null) {
flowTableProvider.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;
}
}