X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=mappingservice%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Flispflowmapping%2Fimplementation%2FMappingService.java;fp=mappingservice%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Flispflowmapping%2Fimplementation%2FMappingService.java;h=adb1ea5401cdf90d7f951ec70c45e93e058aea51;hb=e770a89370591510fdc3e3d25748352b0e3e2f10;hp=25f6f13014e9a638d9cc996bd74c656b8ca1ebf2;hpb=9775872996471009f3b24956d42384c57b764df9;p=lispflowmapping.git diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingService.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingService.java index 25f6f1301..adb1ea540 100644 --- a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingService.java +++ b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingService.java @@ -9,6 +9,8 @@ package org.opendaylight.lispflowmapping.implementation; import static java.util.Objects.requireNonNull; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.ImmutableClassToInstanceMap; import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; import java.util.List; @@ -37,63 +39,85 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.lo import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.container.MappingRecord; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.container.MappingRecordBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeys; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeysInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeysOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMapping; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappings; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingsOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetAllKeys; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetAllKeysInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetAllKeysOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetAllMappings; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetAllMappingsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetAllMappingsOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeys; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeysInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeysOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMapping; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingWithXtrId; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingWithXtrIdInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingWithXtrIdOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingWithXtrIdOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappings; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingsOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin; -import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveAllKeys; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveAllKeysInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveAllKeysOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveAllMappings; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveAllMappingsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveAllMappingsOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveAllOperationalContent; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveAllOperationalContentInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveAllOperationalContentOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveAllOperationalContentOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveKeyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveKeyOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveKeyOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveKeys; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveKeysInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveKeysOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMapping; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMappingInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMappingOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMappingOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMappings; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMappingsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.RemoveMappingsOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateKeyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateKeyOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateKeyOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateKeys; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateKeysInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateKeysOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMapping; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMappingInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMappingOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMappingOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMappings; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMappingsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMappingsOutput; 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; @@ -118,7 +142,7 @@ import org.slf4j.LoggerFactory; */ @Component(service = IMappingService.class, immediate = true, property = "type=default") @Singleton -public class MappingService implements OdlMappingserviceService, IMappingService, AutoCloseable { +public class MappingService implements IMappingService, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(MappingService.class); private MappingSystem mappingSystem; @@ -160,7 +184,32 @@ public class MappingService implements OdlMappingserviceService, IMappingService LOG.info("Mapping Service initializing..."); dsbe = new DataStoreBackEnd(dataBroker); - rpcRegistration = rpcProviderService.registerRpcImplementation(OdlMappingserviceService.class, this); + rpcRegistration = rpcProviderService.registerRpcImplementations( + ImmutableClassToInstanceMap.>builder() + .put(AddKey.class, this::addKey) + .put(GetKey.class, this::getKey) + .put(UpdateKey.class, this::updateKey) + .put(RemoveKey.class, this::removeKey) + .put(AddMapping.class, this::addMapping) + .put(GetMapping.class, this::getMapping) + .put(GetMappingWithXtrId.class, this::getMappingWithXtrId) + .put(UpdateMapping.class, this::updateMapping) + .put(RemoveMapping.class, this::removeMapping) + .put(AddKeys.class, this::addKeys) + .put(GetKeys.class, this::getKeys) + .put(UpdateKeys.class, this::updateKeys) + .put(RemoveKeys.class, this::removeKeys) + .put(AddMappings.class, this::addMappings) + .put(GetMappings.class, this::getMappings) + .put(UpdateMappings.class, this::updateMappings) + .put(RemoveMappings.class, this::removeMappings) + .put(GetAllKeys.class, this::getAllKeys) + .put(GetAllMappings.class, this::getAllMappings) + .put(RemoveAllKeys.class, this::removeAllKeys) + .put(RemoveAllMappings.class, this::removeAllMappings) + .put(RemoveAllOperationalContent.class, this::removeAllOperationalContent) + .build() + ); mappingSystem = new MappingSystem(dao, iterateMask, notificationPublishService, mappingMergePolicy); mappingSystem.setDataStoreBackEnd(dsbe); @@ -171,8 +220,8 @@ public class MappingService implements OdlMappingserviceService, IMappingService LOG.info("Mapping Service loaded."); } - @Override - public ListenableFuture> addKey(AddKeyInput input) { + @VisibleForTesting + ListenableFuture> addKey(AddKeyInput input) { requireNonNull(input, "add-key RPC input must be not null!"); LOG.trace("RPC received to add the following key: {}", input); @@ -193,8 +242,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService return rpcResultBuilder.buildFuture(); } - @Override - public ListenableFuture> addMapping(AddMappingInput input) { + ListenableFuture> addMapping(AddMappingInput input) { requireNonNull(input, "add-mapping RPC input must be not null!"); LOG.trace("RPC received to add the following mapping: {}", input); @@ -233,8 +281,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService mappingSystem.refreshMappingRegistration(key, xtrId, timestamp); } - @Override - public ListenableFuture> getKey(GetKeyInput input) { + ListenableFuture> getKey(GetKeyInput input) { requireNonNull(input, "get-key RPC input must be not null!"); LOG.trace("RPC received to get the following key: {}", input); @@ -253,8 +300,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService return rpcResultBuilder.buildFuture(); } - @Override - public ListenableFuture> getMapping(GetMappingInput input) { + ListenableFuture> getMapping(GetMappingInput input) { requireNonNull(input, "get-mapping RPC input must be not null!"); LOG.trace("RPC received to get the following mapping: {}", input); @@ -300,8 +346,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService return mappingSystem.getSubscribers(eid); } - @Override - public ListenableFuture> getMappingWithXtrId(GetMappingWithXtrIdInput input) { + private ListenableFuture> getMappingWithXtrId(GetMappingWithXtrIdInput input) { requireNonNull(input, "get-mapping RPC input must be not null!"); LOG.trace("RPC received to get the following mapping: {}", input); @@ -323,8 +368,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService return rpcResultBuilder.buildFuture(); } - @Override - public ListenableFuture> removeKey(RemoveKeyInput input) { + ListenableFuture> removeKey(RemoveKeyInput input) { requireNonNull(input, "remove-key RPC input must be not null!"); LOG.trace("RPC received to remove the following key: {}", input); @@ -337,8 +381,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService return rpcResultBuilder.buildFuture(); } - @Override - public ListenableFuture> removeMapping(RemoveMappingInput input) { + ListenableFuture> removeMapping(RemoveMappingInput input) { requireNonNull(input, "remove-mapping RPC input must be not null!"); LOG.trace("RPC received to remove the following mapping: {}", input); @@ -359,8 +402,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService dsbe.removeMapping(DSBEInputUtil.toMapping(origin, key)); } - @Override - public ListenableFuture> updateKey(UpdateKeyInput input) { + ListenableFuture> updateKey(UpdateKeyInput input) { requireNonNull(input, "update-key RPC input must be not null!"); LOG.trace("RPC received to update the following key: {}", input); @@ -381,8 +423,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService return rpcResultBuilder.buildFuture(); } - @Override - public ListenableFuture> updateMapping(UpdateMappingInput input) { + ListenableFuture> updateMapping(UpdateMappingInput input) { LOG.trace("RPC received to update the following mapping: {}", input); requireNonNull(input, "update-mapping RPC input must be not null!"); @@ -395,81 +436,68 @@ public class MappingService implements OdlMappingserviceService, IMappingService return rpcResultBuilder.buildFuture(); } - @Override - public ListenableFuture> removeKeys(RemoveKeysInput input) { + ListenableFuture> removeKeys(RemoveKeysInput input) { // TODO Auto-generated method stub return null; } - @Override - public ListenableFuture> removeMappings(RemoveMappingsInput input) { + ListenableFuture> removeMappings(RemoveMappingsInput input) { // TODO Auto-generated method stub return null; } - @Override - public ListenableFuture> getKeys(GetKeysInput input) { + ListenableFuture> getKeys(GetKeysInput input) { // TODO Auto-generated method stub return null; } - @Override - public ListenableFuture> addMappings(AddMappingsInput input) { + ListenableFuture> addMappings(AddMappingsInput input) { // TODO Auto-generated method stub return null; } - @Override - public ListenableFuture> updateKeys(UpdateKeysInput input) { + ListenableFuture> updateKeys(UpdateKeysInput input) { // TODO Auto-generated method stub return null; } - @Override - public ListenableFuture> removeAllMappings(RemoveAllMappingsInput input) { + ListenableFuture> removeAllMappings(RemoveAllMappingsInput input) { // TODO Auto-generated method stub return null; } - @Override - public ListenableFuture> removeAllKeys(RemoveAllKeysInput input) { + private ListenableFuture> removeAllKeys(RemoveAllKeysInput input) { // TODO Auto-generated method stub return null; } - @Override - public ListenableFuture> getAllKeys(GetAllKeysInput input) { + ListenableFuture> getAllKeys(GetAllKeysInput input) { // TODO Auto-generated method stub return null; } - @Override - public ListenableFuture> updateMappings(UpdateMappingsInput input) { + ListenableFuture> updateMappings(UpdateMappingsInput input) { // TODO Auto-generated method stub return null; } - @Override - public ListenableFuture> addKeys(AddKeysInput input) { + ListenableFuture> addKeys(AddKeysInput input) { // TODO Auto-generated method stub return null; } - @Override - public ListenableFuture> getAllMappings(GetAllMappingsInput input) { + ListenableFuture> getAllMappings(GetAllMappingsInput input) { // TODO Auto-generated method stub return null; } - @Override - public ListenableFuture> getMappings( + private ListenableFuture> getMappings( GetMappingsInput input) { // TODO Auto-generated method stub return null; } - @Override - public ListenableFuture> removeAllOperationalContent( + private ListenableFuture> removeAllOperationalContent( RemoveAllOperationalContentInput input) { RpcResultBuilder rpcResultBuilder;