X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=olm%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Folm%2FOlmPowerServiceRpcImpl.java;h=e3c07e20169a8e6048dd0647a4a0bef9dc22970f;hb=b1b3bafd549bb501937cea5c976d5344608b6ed3;hp=78c165b2be31c5738699d21220f6cfd6201ca17b;hpb=d9ffad0ed3e046a5ad890c65bb0e8c0a1e611002;p=transportpce.git diff --git a/olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImpl.java b/olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImpl.java index 78c165b2b..e3c07e201 100644 --- a/olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImpl.java +++ b/olm/src/main/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImpl.java @@ -8,26 +8,26 @@ package org.opendaylight.transportpce.olm; -import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.collect.ImmutableClassToInstanceMap; +import org.opendaylight.mdsal.binding.api.RpcProviderService; +import org.opendaylight.transportpce.olm.rpc.impl.CalculateSpanlossBaseImpl; +import org.opendaylight.transportpce.olm.rpc.impl.CalculateSpanlossCurrentImpl; +import org.opendaylight.transportpce.olm.rpc.impl.GetPmImpl; +import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerResetImpl; +import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerSetupImpl; +import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerTurndownImpl; import org.opendaylight.transportpce.olm.service.OlmPowerService; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBaseInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBaseOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrentInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrentOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerResetInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerResetOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.TransportpceOlmService; -import org.opendaylight.yangtools.yang.common.ErrorType; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBase; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrent; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPm; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerReset; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetup; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndown; +import org.opendaylight.yangtools.concepts.Registration; +import org.opendaylight.yangtools.yang.binding.Rpc; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,131 +36,32 @@ import org.slf4j.LoggerFactory; * The Class OlmPowerServiceRpcImpl. */ @Component -public class OlmPowerServiceRpcImpl implements TransportpceOlmService { +public class OlmPowerServiceRpcImpl { private static final Logger LOG = LoggerFactory.getLogger(OlmPowerServiceRpcImpl.class); - private final OlmPowerService olmPowerService; + private Registration rpcRegistration; @Activate - public OlmPowerServiceRpcImpl(@Reference OlmPowerService olmPowerService) { - this.olmPowerService = olmPowerService; + public OlmPowerServiceRpcImpl(@Reference OlmPowerService olmPowerService, + @Reference RpcProviderService rpcProviderService) { + this.rpcRegistration = rpcProviderService.registerRpcImplementations( + ImmutableClassToInstanceMap.>builder() + .put(GetPm.class, new GetPmImpl(olmPowerService)) + .put(ServicePowerSetup.class, new ServicePowerSetupImpl(olmPowerService)) + .put(ServicePowerTurndown.class, new ServicePowerTurndownImpl(olmPowerService)) + .put(CalculateSpanlossBase.class, new CalculateSpanlossBaseImpl(olmPowerService)) + .put(CalculateSpanlossCurrent.class, new CalculateSpanlossCurrentImpl(olmPowerService)) + .put(ServicePowerReset.class, new ServicePowerResetImpl(olmPowerService)) + .build()); + LOG.info("OlmPowerServiceRpcImpl instantiated"); } - /** - * This method is the implementation of the 'get-pm' RESTCONF service, which - * is one of the external APIs into the olm application. - * - *

- * 1. get-pm This operation traverse through current PM list and gets PM for - * given NodeId and Resource name - * - *

- * The signature for this method was generated by yang tools from the - * olm API model. - * - * @param input - * Input parameter from the olm yang model - * - * @return Result of the request - */ - @Override - public ListenableFuture> getPm(GetPmInput input) { - if (this.olmPowerService.getPm(input).getNodeId() == null) { - LOG.error("getPm: Error with input parameters"); - return RpcResultBuilder.failed() - .withError(ErrorType.RPC, "Error with input parameters") - .buildFuture(); - } - return RpcResultBuilder.success(this.olmPowerService.getPm(input)).buildFuture(); + @Deactivate + public void close() { + this.rpcRegistration.close(); + LOG.info("OlmPowerServiceRpcImpl Closed"); } - /** - * This method is the implementation of the 'service-power-setup' RESTCONF service, which - * is one of the external APIs into the olm application. - * - *

- * 1. service-power-setup: This operation performs following steps: - * Step1: Calculate Spanloss on all links which are part of service. - * TODO Step2: Calculate power levels for each Tp-Id - * TODO Step3: Post power values on roadm connections - * - *

- * The signature for this method was generated by yang tools from the - * olm API model. - * - * @param input - * Input parameter from the olm yang model - * Input will contain nodeId and termination point - * - * @return Result of the request - */ - @Override - public ListenableFuture> servicePowerSetup( - ServicePowerSetupInput input) { - return RpcResultBuilder.success(this.olmPowerService.servicePowerSetup(input)).buildFuture(); - } - - /** - * This method is the implementation of the 'service-power-trundown' RESTCONF service, which - * is one of the external APIs into the olm application. - * - *

- * 1. service-power-turndown: This operation performs following steps: - * Step1: For each TP within Node sets interface outofservice . - * Step2: For each roam-connection sets power to -60dbm - * Step3: Turns power mode off - * - *

- * The signature for this method was generated by yang tools from the - * olm API model. - * - * @param input - * Input parameter from the olm yang model - * Input will contain nodeId and termination point - * - * @return Result of the request - */ - @Override - public ListenableFuture> - servicePowerTurndown(ServicePowerTurndownInput input) { - return RpcResultBuilder.success(this.olmPowerService.servicePowerTurndown(input)).buildFuture(); - } - - /** - * This method calculates Spanloss for all Roadm to Roadm links, - * part of active inventory in Network Model or for newly added links - * based on input src-type. - * - *

- * 1. Calculate-Spanloss-Base: This operation performs following steps: - * Step1: Read all Roadm-to-Roadm links from network model or get data for given linkID. - * Step2: Retrieve PMs for each end point for OTS interface - * Step3: Calculates Spanloss - * Step4: Posts calculated spanloss in Device and in network model - * - *

- * The signature for this method was generated by yang tools from the - * renderer API model. - * - * @param input - * Input parameter from the olm yang model - * Input will contain SourceType and linkId if srcType is Link - * - * @return Result of the request - */ - @Override - public ListenableFuture> - calculateSpanlossBase(CalculateSpanlossBaseInput input) { - return RpcResultBuilder.success(this.olmPowerService.calculateSpanlossBase(input)).buildFuture(); - } - - @Override - public ListenableFuture> calculateSpanlossCurrent( - CalculateSpanlossCurrentInput input) { - return RpcResultBuilder.success(this.olmPowerService.calculateSpanlossCurrent(input)).buildFuture(); - } - - @Override - public ListenableFuture> servicePowerReset(ServicePowerResetInput input) { - return RpcResultBuilder.success(this.olmPowerService.servicePowerReset(input)).buildFuture(); + public Registration getRegisteredRpc() { + return rpcRegistration; } }