use of org.onosproject.incubator.net.virtual.provider.VirtualMeterProviderService in project onos by opennetworkinglab.
the class DefaultVirtualMeterProvider method activate.
@Activate
public void activate() {
providerRegistryService.registerProvider(this);
internalMeterListener = new InternalMeterListener();
idGenerator = getIdGenerator();
pendingOperations = CacheBuilder.newBuilder().expireAfterWrite(TIMEOUT, TimeUnit.SECONDS).removalListener((RemovalNotification<Long, VirtualMeterOperation> notification) -> {
if (notification.getCause() == RemovalCause.EXPIRED) {
NetworkId networkId = notification.getValue().networkId();
MeterOperation op = notification.getValue().operation();
VirtualMeterProviderService providerService = (VirtualMeterProviderService) providerRegistryService.getProviderService(networkId, VirtualMeterProvider.class);
providerService.meterOperationFailed(op, MeterFailReason.TIMEOUT);
}
}).build();
meterService.addListener(internalMeterListener);
log.info("Started");
}
use of org.onosproject.incubator.net.virtual.provider.VirtualMeterProviderService in project onos by opennetworkinglab.
the class DefaultVirtualMeterProvider method performOperation.
private void performOperation(NetworkId networkId, DeviceId deviceId, MeterOperation op) {
VirtualMeterOperation vOp = new VirtualMeterOperation(networkId, op);
pendingOperations.put(idGenerator.getNewId(), vOp);
switch(op.type()) {
case ADD:
// TODO: devirtualize + submit
break;
case REMOVE:
// TODO: devirtualize + withdraw
break;
case MODIFY:
// TODO: devitualize + withdraw and submit
break;
default:
log.warn("Unknown Meter command {}; not sending anything", op.type());
VirtualMeterProviderService providerService = (VirtualMeterProviderService) providerRegistryService.getProviderService(networkId, VirtualMeterProvider.class);
providerService.meterOperationFailed(op, MeterFailReason.UNKNOWN_COMMAND);
}
}
Aggregations