import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
private ItemLifecycleListener itemLifecycleListener;
private final DeviceContext deviceContext;
- public SalMeterServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ public SalMeterServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
this.deviceContext = deviceContext;
- addMeter = new MeterService<>(requestContextStack, deviceContext, AddMeterOutput.class);
- updateMeter = new MeterService<>(requestContextStack, deviceContext, UpdateMeterOutput.class);
- removeMeter = new MeterService<>(requestContextStack, deviceContext, RemoveMeterOutput.class);
+ addMeter = new MeterService<>(requestContextStack, deviceContext, AddMeterOutput.class, convertorExecutor);
+ updateMeter = new MeterService<>(requestContextStack, deviceContext, UpdateMeterOutput.class, convertorExecutor);
+ removeMeter = new MeterService<>(requestContextStack, deviceContext, RemoveMeterOutput.class, convertorExecutor);
}
@Override
@Override
public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
- addMeter.getDeviceRegistry().getDeviceMeterRegistry().store(input.getMeterId());
final ListenableFuture<RpcResult<AddMeterOutput>> resultFuture = addMeter.handleServiceCall(input);
Futures.addCallback(resultFuture, new FutureCallback<RpcResult<AddMeterOutput>>() {
-
@Override
public void onSuccess(@Nullable RpcResult<AddMeterOutput> result) {
if (result.isSuccessful()) {
- if(LOG.isDebugEnabled()) {
+ if(LOG.isDebugEnabled()) {
LOG.debug("Meter add finished without error, id={}", input.getMeterId());
}
+ deviceContext.getDeviceMeterRegistry().store(input.getMeterId());
addIfNecessaryToDS(input.getMeterId(),input);
- }else{
+ } else {
LOG.error("Meter add with id {} failed with error {}", input.getMeterId(),
errorsToString(result.getErrors()));
}
@Override
public void onFailure(Throwable t) {
- LOG.error("Meter add failed for id={}. Exception {}", input.getMeterId(), t);
+ LOG.error("Meter add failed for id={}. Exception {}", input.getMeterId(), t);
}
});
@Override
public Future<RpcResult<UpdateMeterOutput>> updateMeter(final UpdateMeterInput input) {
final ListenableFuture<RpcResult<UpdateMeterOutput>> resultFuture = updateMeter.handleServiceCall(input.getUpdatedMeter());
-
Futures.addCallback(resultFuture, new FutureCallback<RpcResult<UpdateMeterOutput>>() {
@Override
}
return errors.toString();
}
-}
+}
\ No newline at end of file