summaryrefslogtreecommitdiffstats
path: root/dataChange/provider/src/main
diff options
context:
space:
mode:
authorRyan Goulding <ryandgoulding@gmail.com>2017-09-07 15:21:05 -0400
committerRyan Goulding <ryandgoulding@gmail.com>2017-09-12 09:17:38 -0400
commit3f9970cb513e632ea5c1613c3b7ff577ac9fd4d1 (patch)
tree3d4803613e384000483aa85dfe7bb99d83d5f526 /dataChange/provider/src/main
parent43348099556e047d28a1cdbf85fedf9e7e8a6d47 (diff)
Fix SDNC service registration
Move the northbound to utilize Aries Blueprint instead of ODL's configuration subsystem Change-Id: I7388391d40912136176bb28b817157676f71557d Issue-Id: SDNC-54 Signed-off-by: Ryan Goulding <ryandgoulding@gmail.com>
Diffstat (limited to 'dataChange/provider/src/main')
-rw-r--r--dataChange/provider/src/main/java/org/onap/ccsdk/sli/northbound/DataChangeClient.java30
-rw-r--r--dataChange/provider/src/main/java/org/onap/ccsdk/sli/northbound/DataChangeProvider.java79
-rw-r--r--dataChange/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/northbound/datachange/provider/impl/rev140523/DataChangeProviderModule.java55
-rw-r--r--dataChange/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/northbound/datachange/provider/impl/rev140523/DataChangeProviderModuleFactory.java34
-rw-r--r--dataChange/provider/src/main/resources/initial/dataChange-provider.xml70
-rw-r--r--dataChange/provider/src/main/resources/org/opendaylight/blueprint/datachange-blueprint.xml32
6 files changed, 68 insertions, 232 deletions
diff --git a/dataChange/provider/src/main/java/org/onap/ccsdk/sli/northbound/DataChangeClient.java b/dataChange/provider/src/main/java/org/onap/ccsdk/sli/northbound/DataChangeClient.java
index 75cc0a02e..4bf857797 100644
--- a/dataChange/provider/src/main/java/org/onap/ccsdk/sli/northbound/DataChangeClient.java
+++ b/dataChange/provider/src/main/java/org/onap/ccsdk/sli/northbound/DataChangeClient.java
@@ -27,40 +27,22 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.rev150519.DataChangeNotificationOutputBuilder;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DataChangeClient {
- private static final Logger LOG = LoggerFactory
- .getLogger(DataChangeClient.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DataChangeClient.class);
- private SvcLogicService svcLogic = null;
+ private SvcLogicService svcLogicService = null;
- public DataChangeClient()
- {
- BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext();
-
- // Get SvcLogicService reference
- ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME);
- if (sref != null)
- {
- svcLogic = (SvcLogicService) bctx.getService(sref);
-
- }
- else
- {
- LOG.warn("Cannot find service reference for "+SvcLogicService.NAME);
-
- }
+ public DataChangeClient(final SvcLogicService svcLogicService) {
+ this.svcLogicService = svcLogicService;
}
public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
{
- return(svcLogic.hasGraph(module, rpc, version, mode));
+ return(svcLogicService.hasGraph(module, rpc, version, mode));
}
public Properties execute(String module, String rpc, String version, String mode, DataChangeNotificationOutputBuilder serviceData)
@@ -89,7 +71,7 @@ public class DataChangeClient {
}
}
- Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, parms);
if (LOG.isDebugEnabled())
{
diff --git a/dataChange/provider/src/main/java/org/onap/ccsdk/sli/northbound/DataChangeProvider.java b/dataChange/provider/src/main/java/org/onap/ccsdk/sli/northbound/DataChangeProvider.java
index dcfbf6ee2..d47bcd1b3 100644
--- a/dataChange/provider/src/main/java/org/onap/ccsdk/sli/northbound/DataChangeProvider.java
+++ b/dataChange/provider/src/main/java/org/onap/ccsdk/sli/northbound/DataChangeProvider.java
@@ -49,33 +49,39 @@ import com.google.common.util.concurrent.Futures;
* base class provides some basic logging and initialization / clean up methods.
*
*/
-public class DataChangeProvider implements AutoCloseable, DataChangeService{
+public class DataChangeProvider implements AutoCloseable, DataChangeService {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DataChangeProvider.class);
+
+ private static final String APPLICATION_NAME = "DataChange";
- private final Logger log = LoggerFactory.getLogger( DataChangeProvider.class );
- private final String appName = "DataChange";
private final ExecutorService executor;
protected DataBroker dataBroker;
protected NotificationProviderService notificationService;
protected RpcProviderRegistry rpcRegistry;
protected BindingAwareBroker.RpcRegistration<DataChangeService> rpcRegistration;
+ private final DataChangeClient dataChangeClient;
+
+ public DataChangeProvider(final DataBroker dataBroker,
+ final NotificationProviderService notificationProviderService,
+ final RpcProviderRegistry rpcProviderRegistry,
+ final DataChangeClient dataChangeClient) {
- public DataChangeProvider(DataBroker dataBroker2,
- NotificationProviderService notificationProviderService,
- RpcProviderRegistry rpcProviderRegistry) {
- this.log.info( "Creating provider for " + appName );
+ this.LOG.info( "Creating provider for {}", APPLICATION_NAME);
executor = Executors.newFixedThreadPool(1);
- dataBroker = dataBroker2;
- notificationService = notificationProviderService;
- rpcRegistry = rpcProviderRegistry;
+ this.dataBroker = dataBroker;
+ this.notificationService = notificationProviderService;
+ this.rpcRegistry = rpcProviderRegistry;
+ this.dataChangeClient = dataChangeClient;
initialize();
}
public void initialize(){
- log.info( "Initializing provider for " + appName );
+ LOG.info( "Initializing provider for {}", APPLICATION_NAME);
rpcRegistration = rpcRegistry.addRpcImplementation(DataChangeService.class, this);
- log.info( "Initialization complete for " + appName );
+ LOG.info( "Initialization complete for {}", APPLICATION_NAME);
}
protected void initializeChild() {
@@ -84,32 +90,10 @@ public class DataChangeProvider implements AutoCloseable, DataChangeService{
@Override
public void close() throws Exception {
- log.info( "Closing provider for " + appName );
+ LOG.info( "Closing provider for {}", APPLICATION_NAME);
executor.shutdown();
rpcRegistration.close();
- log.info( "Successfully closed provider for " + appName );
- }
-
- public void setDataBroker(DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- if( log.isDebugEnabled() ){
- log.debug( "DataBroker set to " + (dataBroker==null?"null":"non-null") + "." );
- }
- }
-
- public void setNotificationService(
- NotificationProviderService notificationService) {
- this.notificationService = notificationService;
- if( log.isDebugEnabled() ){
- log.debug( "Notification Service set to " + (notificationService==null?"null":"non-null") + "." );
- }
- }
-
- public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
- this.rpcRegistry = rpcRegistry;
- if( log.isDebugEnabled() ){
- log.debug( "RpcRegistry set to " + (rpcRegistry==null?"null":"non-null") + "." );
- }
+ LOG.info( "Successfully closed provider for {}", APPLICATION_NAME);
}
@Override
@@ -120,10 +104,10 @@ public class DataChangeProvider implements AutoCloseable, DataChangeService{
Properties parms = new Properties();
DataChangeNotificationOutputBuilder serviceDataBuilder = new DataChangeNotificationOutputBuilder();
- log.info( SVC_OPERATION +" called." );
+ LOG.info( SVC_OPERATION +" called." );
if(input == null || input.getAaiEventId() == null) {
- log.debug("exiting " +SVC_OPERATION+ " because of invalid input");
+ LOG.debug("exiting " +SVC_OPERATION+ " because of invalid input");
serviceDataBuilder.setDataChangeResponseCode("403");
RpcResult<DataChangeNotificationOutput> rpcResult =
RpcResultBuilder.<DataChangeNotificationOutput> status(true).withResult(serviceDataBuilder.build()).build();
@@ -131,46 +115,43 @@ public class DataChangeProvider implements AutoCloseable, DataChangeService{
}
// add input to parms
- log.info("Adding INPUT data for "+SVC_OPERATION+" input: " + input);
+ LOG.info("Adding INPUT data for "+SVC_OPERATION+" input: " + input);
DataChangeNotificationInputBuilder inputBuilder = new DataChangeNotificationInputBuilder(input);
MdsalHelper.toProperties(parms, inputBuilder.build());
// Call SLI sync method
- // Get SvcLogicService reference
-
- DataChangeClient svcLogicClient = new DataChangeClient();
Properties respProps = null;
try
{
- if (svcLogicClient.hasGraph("DataChange", SVC_OPERATION , null, "sync"))
+ if (dataChangeClient.hasGraph("DataChange", SVC_OPERATION , null, "sync"))
{
try
{
- respProps = svcLogicClient.execute("DataChange", SVC_OPERATION, null, "sync", serviceDataBuilder, parms);
+ respProps = dataChangeClient.execute("DataChange", SVC_OPERATION, null, "sync", serviceDataBuilder, parms);
}
catch (Exception e)
{
- log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+ LOG.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
serviceDataBuilder.setDataChangeResponseCode("500");
}
} else {
- log.error("No service logic active for DataChange: '" + SVC_OPERATION + "'");
+ LOG.error("No service logic active for DataChange: '" + SVC_OPERATION + "'");
serviceDataBuilder.setDataChangeResponseCode("503");
}
}
catch (Exception e)
{
- log.error("Caught exception looking for service logic", e);
+ LOG.error("Caught exception looking for service logic", e);
serviceDataBuilder.setDataChangeResponseCode("500");
}
String errorCode = serviceDataBuilder.getDataChangeResponseCode();
if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) {
- log.error("Returned FAILED for "+SVC_OPERATION+" error code: '" + errorCode + "'");
+ LOG.error("Returned FAILED for "+SVC_OPERATION+" error code: '" + errorCode + "'");
} else {
- log.info("Returned SUCCESS for "+SVC_OPERATION+" ");
+ LOG.info("Returned SUCCESS for "+SVC_OPERATION+" ");
}
RpcResult<DataChangeNotificationOutput> rpcResult =
diff --git a/dataChange/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/northbound/datachange/provider/impl/rev140523/DataChangeProviderModule.java b/dataChange/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/northbound/datachange/provider/impl/rev140523/DataChangeProviderModule.java
deleted file mode 100644
index e210613b5..000000000
--- a/dataChange/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/northbound/datachange/provider/impl/rev140523/DataChangeProviderModule.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.provider.impl.rev140523;
-
-import org.onap.ccsdk.sli.northbound.DataChangeProvider;
-
-public class DataChangeProviderModule extends org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.provider.impl.rev140523.AbstractDataChangeProviderModule {
- public DataChangeProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public DataChangeProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.provider.impl.rev140523.DataChangeProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
- super(identifier, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public void customValidation() {
- // add custom validation form module attributes here.
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- final DataChangeProvider provider = new DataChangeProvider(getDataBrokerDependency()
- , getNotificationServiceDependency()
- , getRpcRegistryDependency());
-
- return new AutoCloseable() {
-
- @Override
- public void close() throws Exception {
- provider.close();
- }
- };
- }
-
-}
diff --git a/dataChange/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/northbound/datachange/provider/impl/rev140523/DataChangeProviderModuleFactory.java b/dataChange/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/northbound/datachange/provider/impl/rev140523/DataChangeProviderModuleFactory.java
deleted file mode 100644
index 468989998..000000000
--- a/dataChange/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/northbound/datachange/provider/impl/rev140523/DataChangeProviderModuleFactory.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: DataChange-provider-impl yang module local name: DataChange-provider-impl
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Tue Aug 15 09:41:53 EDT 2017
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.provider.impl.rev140523;
-public class DataChangeProviderModuleFactory extends org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.datachange.provider.impl.rev140523.AbstractDataChangeProviderModuleFactory {
-
-}
diff --git a/dataChange/provider/src/main/resources/initial/dataChange-provider.xml b/dataChange/provider/src/main/resources/initial/dataChange-provider.xml
deleted file mode 100644
index 2da0546aa..000000000
--- a/dataChange/provider/src/main/resources/initial/dataChange-provider.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- openECOMP : SDN-C
- ================================================================================
- Copyright (C) 2017 AT&T Intellectual Property. All rights
- reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
- -->
-
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<snapshot>
- <configuration>
- <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <module>
-
- <!-- This xmlns:prefix should match the namespace in the *-provider-impl.yang file
- The prefix: inside type should match the prefix of the yang file. -->
- <type xmlns:prefix="org:onap:ccsdk:sli:northbound:datachange:provider:impl">
- prefix:DataChange-provider-impl
- </type>
- <name>DataChange-provider-impl</name>
-
- <!-- The following sections contain bindings to services defined in the
- *-provider-impl yang file. For example the rpc-registry is required
- because we have a dependency (or augmentation) named "rpc-registry"
- and which binds to the md-sa-binding-registry. If you remove those
- dependencies from the yang file then you can remove them from here. -->
- <rpc-registry>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
- <name>binding-rpc-broker</name>
- </rpc-registry>
-
- <data-broker>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
- <name>binding-data-broker</name>
- </data-broker>
-
- <notification-service>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
- binding:binding-notification-service
- </type>
- <name>binding-notification-broker</name>
- </notification-service>
- </module>
-
- </modules>
- </data>
-
- </configuration>
-
- <!-- Required capabilities are basically a listing of all modules that need to be imported before
- our service can be resolved. Capabilities for dependencies defined above are implied which is
- why we do not have define a required capability for the data broker, for example. -->
- <required-capabilities>
- <capability>org:onap:ccsdk:sli:northbound:datachange:provider:impl?module=DataChange-provider-impl&amp;revision=2014-05-23</capability>
- </required-capabilities>
-
-</snapshot>
diff --git a/dataChange/provider/src/main/resources/org/opendaylight/blueprint/datachange-blueprint.xml b/dataChange/provider/src/main/resources/org/opendaylight/blueprint/datachange-blueprint.xml
new file mode 100644
index 000000000..b826b0113
--- /dev/null
+++ b/dataChange/provider/src/main/resources/org/opendaylight/blueprint/datachange-blueprint.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <reference id="svcLogicService"
+ interface="org.onap.ccsdk.sli.core.sli.provider.SvcLogicService" />
+
+ <bean id="client" class="org.onap.ccsdk.sli.northbound.DataChangeClient">
+ <argument ref="svcLogicService" />
+ </bean>
+
+ <reference id="dataBroker"
+ interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+ odl:type="default" />
+
+ <reference id="notificationService"
+ interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"
+ odl:type="default" />
+
+ <reference id="rpcRegistry"
+ interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"
+ odl:type="default" />
+
+ <bean id="provider" class="org.onap.ccsdk.sli.northbound.DataChangeProvider">
+ <argument ref="dataBroker" />
+ <argument ref="notificationService" />
+ <argument ref="rpcRegistry" />
+ <argument ref="client" />
+ </bean>
+
+</blueprint> \ No newline at end of file