*/
package org.opendaylight.openflowplugin.impl.services;
-import java.util.Collection;
-import java.util.concurrent.Future;
-
-import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Collection;
+import java.util.concurrent.Future;
+import javax.annotation.Nullable;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
-import org.opendaylight.openflowplugin.impl.registry.flow.FlowDescriptorFactory;
+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.FlowId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.annotation.Nullable;
-
public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource {
private static final Logger LOG = LoggerFactory.getLogger(SalGroupServiceImpl.class);
private final GroupService<AddGroupInput, AddGroupOutput> addGroup;
private final DeviceContext deviceContext;
private ItemLifecycleListener itemLifecycleListener;
- public SalGroupServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ public SalGroupServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
this.deviceContext = deviceContext;
- addGroup = new GroupService<>(requestContextStack, deviceContext, AddGroupOutput.class);
- updateGroup = new GroupService<>(requestContextStack, deviceContext, UpdateGroupOutput.class);
- removeGroup = new GroupService<>(requestContextStack, deviceContext, RemoveGroupOutput.class);
+ addGroup = new GroupService<>(requestContextStack, deviceContext, AddGroupOutput.class, convertorExecutor);
+ updateGroup = new GroupService<>(requestContextStack, deviceContext, UpdateGroupOutput.class, convertorExecutor);
+ removeGroup = new GroupService<>(requestContextStack, deviceContext, RemoveGroupOutput.class, convertorExecutor);
}
@Override
@Override
public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
- addGroup.getDeviceContext().getDeviceGroupRegistry().store(input.getGroupId());
final ListenableFuture<RpcResult<AddGroupOutput>> resultFuture = addGroup.handleServiceCall(input);
Futures.addCallback(resultFuture, new FutureCallback<RpcResult<AddGroupOutput>>() {
@Override
if(LOG.isDebugEnabled()) {
LOG.debug("group add with id={} finished without error", input.getGroupId().getValue());
}
+ deviceContext.getDeviceGroupRegistry().store(input.getGroupId());
addIfNecessaryToDS(input.getGroupId(), input);
} else {
- LOG.error("group add with id={} failed, errors={}", input.getGroupId().getValue(),
- errorsToString(result.getErrors()));
- }
+ LOG.error("group add with id={} failed, errors={}", input.getGroupId().getValue(),
+ errorsToString(result.getErrors()));
+ }
}
@Override
public void onFailure(Throwable t) {
- LOG.error("Service call for group add failed for id={}. Exception: {}",
- input.getGroupId().getValue(), t);
+ LOG.error("Service call for group add failed for id={}. Exception: {}", input.getGroupId().getValue(), t);
}
});
@Override
public Future<RpcResult<RemoveGroupOutput>> removeGroup(final RemoveGroupInput input) {
- removeGroup.getDeviceContext().getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
final ListenableFuture<RpcResult<RemoveGroupOutput>> resultFuture = removeGroup.handleServiceCall(input);
Futures.addCallback(resultFuture, new FutureCallback<RpcResult<RemoveGroupOutput>>() {
@Override
if(LOG.isDebugEnabled()) {
LOG.debug("Group remove for id {} succeded", input.getGroupId().getValue());
}
+ removeGroup.getDeviceRegistry().getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
removeIfNecessaryFromDS(input.getGroupId());
}else{
LOG.error("group remove failed with id={}, errors={}", input.getGroupId().getValue(),
if (itemLifecycleListener != null) {
KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group, GroupKey> groupPath
= createGroupPath(groupId,
- deviceContext.getDeviceState().getNodeInstanceIdentifier());
+ deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
itemLifecycleListener.onRemoved(groupPath);
}
}
if (itemLifecycleListener != null) {
KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group, GroupKey> groupPath
= createGroupPath(groupId,
- deviceContext.getDeviceState().getNodeInstanceIdentifier());
+ deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
itemLifecycleListener.onAdded(groupPath, new GroupBuilder(data).build());
}
}
}
return errors.toString();
}
-}
+}
\ No newline at end of file