*/
package org.opendaylight.lispflowmapping.southbound;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.nio.ByteBuffer;
import org.opendaylight.lispflowmapping.lisp.serializer.MapRequestSerializer;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MessageType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.GetStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.GetStatsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.GetStatsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.GetStatsOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.OdlLispSbService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ResetStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ResetStatsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ResetStatsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ResetStatsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapNotify;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapNotifyInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapNotifyOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapNotifyOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRegister;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRegisterInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRegisterOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRegisterOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReplyInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReplyOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReplyOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRequest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRequestInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRequestOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRequestOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.get.stats.output.ControlMessageStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.get.stats.output.MapRegisterCacheStatsBuilder;
import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.Rpc;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
*/
@Singleton
@Component(service = { })
-public class LispSouthboundRPC implements OdlLispSbService {
+public class LispSouthboundRPC {
protected static final Logger LOG = LoggerFactory.getLogger(LispSouthboundRPC.class);
private final LispSouthboundPlugin lispSbPlugin;
public LispSouthboundRPC(final @Reference LispSouthboundPlugin lispSbPlugin,
final @Reference RpcProviderService rpcProviderService) {
this.lispSbPlugin = lispSbPlugin;
- rpcRegistration = rpcProviderService.registerRpcImplementation(OdlLispSbService.class, this);
+ rpcRegistration = rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
+ .put(SendMapRequest.class, this::sendMapRequest)
+ .put(SendMapReply.class, this::sendMapReply)
+ .put(SendMapRegister.class, this::sendMapRegister)
+ .put(SendMapNotify.class, this::sendMapNotify)
+ .put(GetStats.class, this::getStats)
+ .put(ResetStats.class, this::resetStats)
+ .build());
}
@Deactivate
rpcRegistration.close();
}
- @Override
public ListenableFuture<RpcResult<SendMapNotifyOutput>> sendMapNotify(final SendMapNotifyInput mapNotifyInput) {
LOG.trace("sendMapNotify called!!");
if (mapNotifyInput != null) {
new SendMapNotifyOutputBuilder().build()).build());
}
- @Override
public ListenableFuture<RpcResult<SendMapReplyOutput>> sendMapReply(final SendMapReplyInput mapReplyInput) {
LOG.trace("sendMapReply called!!");
if (mapReplyInput != null) {
new SendMapReplyOutputBuilder().build()).build());
}
- @Override
public ListenableFuture<RpcResult<SendMapRequestOutput>> sendMapRequest(final SendMapRequestInput mapRequestInput) {
LOG.trace("sendMapRequest called!!");
if (mapRequestInput != null) {
new SendMapRequestOutputBuilder().build()).build());
}
- @Override
- public ListenableFuture<RpcResult<SendMapRegisterOutput>> sendMapRegister(
+ @VisibleForTesting
+ ListenableFuture<RpcResult<SendMapRegisterOutput>> sendMapRegister(
final SendMapRegisterInput mapRegisterInput) {
LOG.trace("sendMapRegister called!!");
if (mapRegisterInput != null) {
new SendMapRegisterOutputBuilder().build()).build());
}
- @Override
- public ListenableFuture<RpcResult<GetStatsOutput>> getStats(final GetStatsInput input) {
+ ListenableFuture<RpcResult<GetStatsOutput>> getStats(final GetStatsInput input) {
LOG.trace("getStats called!!");
RpcResultBuilder<GetStatsOutput> rpcResultBuilder;
return Futures.immediateFuture(rpcResultBuilder.build());
}
- @Override
- public ListenableFuture<RpcResult<ResetStatsOutput>> resetStats(final ResetStatsInput input) {
+ ListenableFuture<RpcResult<ResetStatsOutput>> resetStats(final ResetStatsInput input) {
LOG.trace("resetStats called!!");
ConcurrentLispSouthboundStats stats = lispSbPlugin.getStats();
List<ControlMessage> messages = new ArrayList<>();
for (int i = 0; i <= ConcurrentLispSouthboundStats.MAX_LISP_TYPES; i++) {
- if (MessageType.forValue(i) == null) {
- continue;
+ final var type = MessageType.forValue(i);
+ if (type != null) {
+ messages.add(new ControlMessageBuilder()
+ .setMsgType(type)
+ .setRxCount(rxStats[i])
+ .setTxCount(txStats[i])
+ .build());
}
- ControlMessageBuilder cmb = new ControlMessageBuilder();
- cmb.setMsgType(MessageType.forValue(i));
- cmb.setRxCount(rxStats[i]);
- cmb.setTxCount(txStats[i]);
- messages.add(cmb.build());
}
cmsb.setControlMessage(messages);