summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/data-provider')
-rw-r--r--sdnr/wt/data-provider/provider/pom.xml5
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java59
-rw-r--r--sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml5
3 files changed, 60 insertions, 9 deletions
diff --git a/sdnr/wt/data-provider/provider/pom.xml b/sdnr/wt/data-provider/provider/pom.xml
index 2a7b68632..85b8f308d 100644
--- a/sdnr/wt/data-provider/provider/pom.xml
+++ b/sdnr/wt/data-provider/provider/pom.xml
@@ -58,6 +58,10 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.karaf.bundle</groupId>
+ <artifactId>org.apache.karaf.bundle.core</artifactId>
+ </dependency>
+ <dependency>
<groupId>${project.groupId}</groupId>
<artifactId>sdnr-wt-data-provider-setup</artifactId>
<version>${project.version}</version>
@@ -82,6 +86,7 @@
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.core</artifactId>
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
index cb74911ff..284365021 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
@@ -26,6 +26,9 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.karaf.bundle.core.BundleInfo;
+import org.apache.karaf.bundle.core.BundleService;
+import org.apache.karaf.bundle.core.BundleState;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about.MarkdownTable;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -42,10 +45,16 @@ public class ReadyHttpServlet extends HttpServlet {
private static final Logger LOG = LoggerFactory.getLogger(ReadyHttpServlet.class);
private static boolean status;
+
+ private BundleService bundleService = null;
+
+ public void setBundleService(BundleService bundleService) {
+ this.bundleService = bundleService;
+ }
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- if (isReady() && this.getBundleStatesNotActiveCount()==0) {
+ if (isReady() && this.getBundleStatesReady()) {
resp.setStatus(HttpServletResponse.SC_OK);
} else {
@@ -66,30 +75,66 @@ public class ReadyHttpServlet extends HttpServlet {
LOG.info("status is set to ready: {}", status);
}
- private int getBundleStatesNotActiveCount() {
+ private boolean getBundleStatesReady() {
Bundle thisbundle = FrameworkUtil.getBundle(this.getClass());
BundleContext context = thisbundle ==null?null:thisbundle.getBundleContext();
if (context == null) {
LOG.debug("no bundle context available");
- return 0;
+ return true;
}
Bundle[] bundles = context.getBundles();
if (bundles == null || bundles.length <= 0) {
LOG.debug("no bundles found");
- return 0;
+ return true;
}
LOG.debug("found {} bundles", bundles.length);
MarkdownTable table = new MarkdownTable();
table.setHeader(new String[] {"Bundle-Id","Version","Symbolic-Name","Status"});
int cntNotActive=0;
+
for (Bundle bundle : bundles) {
+ if(this.bundleService!=null) {
+ BundleInfo info = this.bundleService.getInfo(bundle);
+ if(info.getState()==BundleState.Active ) {
+ continue;
+ }
+ if(info.getState()==BundleState.Resolved ) {
+ if(!this.isBundleImportant(bundle.getSymbolicName())) {
+ LOG.trace("ignore not important bundle {} with state {}",bundle.getSymbolicName(),info.getState());
+ continue;
+ }
+ }
- if(bundle.getState()!=Bundle.ACTIVE) {
- cntNotActive++;
+ LOG.trace("bundle {} is in state {}",bundle.getSymbolicName(),info.getState());
}
+ else {
+ LOG.warn("bundle service is null");
+ }
+ cntNotActive++;
+ }
+ return cntNotActive==0;
+ }
+
+ private boolean isBundleImportant(String symbolicName) {
+ symbolicName = symbolicName.toLowerCase();
+ if(symbolicName.contains("mdsal")) {
+ return true;
+ }
+ if(symbolicName.contains("netconf")) {
+ return true;
+ }
+ if(symbolicName.contains("ccsdk")) {
+ return true;
}
- return cntNotActive;
+ if(symbolicName.contains("devicemanager")) {
+ return true;
+ }
+ if(symbolicName.contains("restconf")) {
+ return true;
+ }
+
+ return false;
}
}
diff --git a/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
index ad9661f66..1be114612 100644
--- a/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
+++ b/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
@@ -29,11 +29,12 @@
<reference id="rpcProviderService"
interface="org.opendaylight.mdsal.binding.api.RpcProviderService"
odl:type="default"/>
-
-<!-- <reference id="bundleService" interface="org.apache.karaf.bundle.core.BundleService" odl:type="default"/> -->
+ <reference id="bundleService"
+ interface="org.apache.karaf.bundle.core.BundleService" />
<bean id="readyServlet"
class="org.onap.ccsdk.features.sdnr.wt.dataprovider.http.ReadyHttpServlet">
+ <property name="bundleService" ref="bundleService"/>
</bean>
<service interface="javax.servlet.http.HttpServlet"
ref="readyServlet">