X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=itm%2Fitm-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Fitm%2Fimpl%2FItmProvider.java;h=2c2126e95cc6f428f9e1117d07cdc387cb32882f;hb=64b73ec2d82a489b159a41513df93b3cc59c321e;hp=441979ea2a2123a12aa813a9a2a47283529b5f13;hpb=e2253650acc6343c84883216d5d7f1bd6abf177f;p=vpnservice.git diff --git a/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java index 441979ea..2c2126e9 100644 --- a/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java +++ b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java @@ -9,29 +9,34 @@ package org.opendaylight.vpnservice.itm.impl; import java.math.BigInteger; import java.util.List; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.binding.api.NotificationService; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager; import org.opendaylight.vpnservice.itm.api.IITMProvider; +import org.opendaylight.vpnservice.itm.globals.ITMConstants; import org.opendaylight.vpnservice.itm.listeners.TransportZoneListener; import org.opendaylight.vpnservice.itm.rpc.ItmManagerRpcService; import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.GetTunnelIdInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.GetTunnelIdOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.ItmStateService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.TunnelsState; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.rev150701.transport.zones.transport.zone.*;; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.OdlInterfaceRpcService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.ItmRpcService; + import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMProvider,ItmStateService { +public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMProvider /*,ItmStateService */{ private static final Logger LOG = LoggerFactory.getLogger(ItmProvider.class); private IInterfaceManager interfaceManager; @@ -40,24 +45,38 @@ public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMPro private DataBroker dataBroker; private NotificationPublishService notificationPublishService; private ItmManagerRpcService itmRpcService ; + private IdManagerService idManager; private NotificationService notificationService; private TransportZoneListener tzChangeListener; + private RpcProviderRegistry rpcProviderRegistry; + + public void setRpcProviderRegistry(RpcProviderRegistry rpcProviderRegistry) { + this.rpcProviderRegistry = rpcProviderRegistry; + } + + public RpcProviderRegistry getRpcProviderRegistry() { + return this.rpcProviderRegistry; + } @Override public void onSessionInitiated(ProviderContext session) { LOG.info("ItmProvider Session Initiated"); try { dataBroker = session.getSALService(DataBroker.class); + idManager = getRpcProviderRegistry().getRpcService(IdManagerService.class); itmManager = new ITMManager(dataBroker); - tzChangeListener = new TransportZoneListener(dataBroker) ; - itmRpcService = new ItmManagerRpcService(dataBroker); - + tzChangeListener = new TransportZoneListener(dataBroker, idManager) ; + itmRpcService = new ItmManagerRpcService(dataBroker, idManager); + final BindingAwareBroker.RpcRegistration rpcRegistration = getRpcProviderRegistry().addRpcImplementation(ItmRpcService.class, itmRpcService); + itmRpcService.setMdsalManager(mdsalManager); itmManager.setMdsalManager(mdsalManager); itmManager.setNotificationPublishService(notificationPublishService); itmManager.setMdsalManager(mdsalManager); + tzChangeListener.setMdsalManager(mdsalManager); tzChangeListener.setItmManager(itmManager); tzChangeListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker); + createIdPool(); } catch (Exception e) { LOG.error("Error initializing services", e); } @@ -90,11 +109,19 @@ public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMPro LOG.info("ItmProvider Closed"); } - @Override - public Future> getTunnelId( - GetTunnelIdInput input) { - // TODO Auto-generated method stub - return null; + private void createIdPool() { + CreateIdPoolInput createPool = new CreateIdPoolInputBuilder() + .setPoolName(ITMConstants.ITM_IDPOOL_NAME) + .setLow(ITMConstants.ITM_IDPOOL_START) + .setHigh(new BigInteger(ITMConstants.ITM_IDPOOL_SIZE).longValue()) + .build(); + try { + Future> result = idManager.createIdPool(createPool); + if ((result != null) && (result.get().isSuccessful())) { + LOG.debug("Created IdPool for ITM Service"); + } + } catch (InterruptedException | ExecutionException e) { + LOG.error("Failed to create idPool for ITM Service",e); + } } - }