Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--features/org.eclipse.osee.x.server.external.feature/feature.xml11
-rw-r--r--features/org.eclipse.osee.x.server.feature/feature.xml7
-rw-r--r--features/org.eclipse.osee.x.server.feature/pom.xml49
-rw-r--r--plugins/org.eclipse.osee.framework.core.server/build.properties3
-rw-r--r--plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/console/ServerStatsCommand.java195
-rw-r--r--plugins/org.eclipse.osee.parent/tools/osee-application-server.xml3
-rw-r--r--plugins/org.eclipse.osee.support.config/launchConfig/osee.hsql.json53
-rw-r--r--plugins/org.eclipse.osee.x.parent/pom.xml1
-rw-r--r--plugins/org.eclipse.osee.x.server.application/.project5
-rw-r--r--plugins/org.eclipse.osee.x.server.application/META-INF/MANIFEST.MF17
-rw-r--r--plugins/org.eclipse.osee.x.server.application/OSGI-INF/osee.server.application.xml (renamed from plugins/org.eclipse.osee.framework.core.server/OSGI-INF/server.stats.console.command.xml)8
-rw-r--r--plugins/org.eclipse.osee.x.server.application/build.properties3
-rw-r--r--plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/ServerApplication.java52
-rw-r--r--plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/ServerHealthEndpointImpl.java166
-rw-r--r--plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/model/ServerStatus.java56
-rw-r--r--plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/model/StatusKey.java51
-rw-r--r--plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/operations/BuildServerStatusOperation.java60
-rw-r--r--plugins/org.eclipse.osee.x.server.p2/etc/osee.hsql.json53
-rw-r--r--plugins/org.eclipse.osee.x.server.parent/pom.xml1
19 files changed, 503 insertions, 291 deletions
diff --git a/features/org.eclipse.osee.x.server.external.feature/feature.xml b/features/org.eclipse.osee.x.server.external.feature/feature.xml
index 3497925d37f..f38b7e631bf 100644
--- a/features/org.eclipse.osee.x.server.external.feature/feature.xml
+++ b/features/org.eclipse.osee.x.server.external.feature/feature.xml
@@ -271,7 +271,7 @@
install-size="0"
version="0.0.0"
unpack="false"/>
-
+
<plugin
id="org.eclipse.equinox.console.ssh"
download-size="0"
@@ -320,7 +320,7 @@
install-size="0"
version="0.0.0"
unpack="false"/>
-
+
<plugin
id="com.lowagie.text"
download-size="0"
@@ -551,4 +551,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.eclipse.osee.x.server.application"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/features/org.eclipse.osee.x.server.feature/feature.xml b/features/org.eclipse.osee.x.server.feature/feature.xml
index 6e850ba3876..4876048c20f 100644
--- a/features/org.eclipse.osee.x.server.feature/feature.xml
+++ b/features/org.eclipse.osee.x.server.feature/feature.xml
@@ -74,4 +74,11 @@
install-size="0"
version="0.0.0"/>
+ <plugin
+ id="org.eclipse.osee.x.server.application"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/features/org.eclipse.osee.x.server.feature/pom.xml b/features/org.eclipse.osee.x.server.feature/pom.xml
index 3a446097969..c0168f36166 100644
--- a/features/org.eclipse.osee.x.server.feature/pom.xml
+++ b/features/org.eclipse.osee.x.server.feature/pom.xml
@@ -1,37 +1,40 @@
-<project
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
<modelVersion>4.0.0</modelVersion>
+
<parent>
<groupId>org.eclipse.osee</groupId>
<artifactId>org.eclipse.osee.x.server.parent</artifactId>
<version>0.25.4-SNAPSHOT</version>
<relativePath>../../plugins/org.eclipse.osee.x.server.parent</relativePath>
</parent>
+
<artifactId>org.eclipse.osee.x.server.feature</artifactId>
<packaging>eclipse-feature</packaging>
<name>OSEE X Server Feature - (Incubation)</name>
-
+
<build>
- <plugins>
- <plugin>
- <groupId>org.eclipse.tycho.extras</groupId>
- <artifactId>tycho-source-feature-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <id>source-feature</id>
- <goals>
- <goal>source-feature</goal>
- </goals>
- <configuration>
- <excludes>
- <plugin id="org.eclipse.osee.web.ui" />
- </excludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho.extras</groupId>
+ <artifactId>tycho-source-feature-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <id>source-feature</id>
+ <goals>
+ <goal>source-feature</goal>
+ </goals>
+ <configuration>
+ <excludes>
+ <plugin id="org.eclipse.osee.web.ui" />
+ </excludes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
-
+
</project> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.server/build.properties b/plugins/org.eclipse.osee.framework.core.server/build.properties
index 9b367b10cf6..4dba2c3edda 100644
--- a/plugins/org.eclipse.osee.framework.core.server/build.properties
+++ b/plugins/org.eclipse.osee.framework.core.server/build.properties
@@ -3,6 +3,5 @@ bin.includes = META-INF/,\
.,\
OSGI-INF/,\
OSGI-INF/application.server.manager.xml,\
- OSGI-INF/session.manager.xml,\
- OSGI-INF/server.stats.console.command.xml
+ OSGI-INF/session.manager.xml
source.. = src/
diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/console/ServerStatsCommand.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/console/ServerStatsCommand.java
deleted file mode 100644
index eac3dc8a013..00000000000
--- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/console/ServerStatsCommand.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.server.internal.console;
-
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.osee.console.admin.Console;
-import org.eclipse.osee.console.admin.ConsoleCommand;
-import org.eclipse.osee.console.admin.ConsoleParameters;
-import org.eclipse.osee.framework.core.server.IApplicationServerManager;
-import org.eclipse.osee.framework.core.server.IAuthenticationManager;
-import org.eclipse.osee.framework.core.server.OseeServerProperties;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.jdbc.JdbcClientConfig;
-import org.eclipse.osee.jdbc.JdbcServerConfig;
-import org.eclipse.osee.jdbc.JdbcService;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ServerStatsCommand implements ConsoleCommand {
-
- private final Map<String, JdbcService> jdbcServices = new ConcurrentHashMap<>();
- private IApplicationServerManager manager;
- private IAuthenticationManager authManager;
-
- public void setApplicationServerManager(IApplicationServerManager manager) {
- this.manager = manager;
- }
-
- public void setAuthenticationManager(IAuthenticationManager authManager) {
- this.authManager = authManager;
- }
-
- public void addJdbcService(JdbcService jdbcService) {
- jdbcServices.put(jdbcService.getId(), jdbcService);
- }
-
- public void removeJdbcService(JdbcService jdbcService) {
- jdbcServices.remove(jdbcService.getId());
- }
-
- @Override
- public String getName() {
- return "server_status";
- }
-
- @Override
- public String getDescription() {
- return "Displays server status information";
- }
-
- @Override
- public String getUsage() {
- return "";
- }
-
- @Override
- public Callable<?> createCallable(final Console console, final ConsoleParameters params) {
- return new Callable<Boolean>() {
-
- @Override
- public Boolean call() throws Exception {
- console.writeln("\n----------------------------------------------");
- console.writeln(" Server Stats");
- console.writeln("----------------------------------------------");
-
- console.writeln("Server:[%s]", manager.getServerUri());
- console.writeln("Id: [%s]", manager.getId());
- console.writeln("Running Since: [%s]\n",
- DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(manager.getDateStarted()));
-
- console.writeln("Code Base Location: [%s]", System.getProperty("user.dir"));
- console.writeln("Binary Data Path: [%s]", OseeServerProperties.getOseeApplicationServerData(null));
- JdbcService jdbcService = getJdbcService("orcs.jdbc.service");
- writeOrcsJdbcServiceInfo(jdbcService);
- console.writeln();
-
- console.writeln("Authentication Scheme: [%s]", authManager.getProtocol());
- console.writeln("Supported Authentication Schemes: %s", Arrays.deepToString(authManager.getProtocols()));
- console.writeln();
-
- console.writeln("Supported Versions: %s", Arrays.deepToString(manager.getVersions()));
- console.writeln(Lib.getMemoryInfo());
-
- logServlets(manager);
-
- console.writeln("\nServer State: [%s]", manager.isSystemIdle() ? "IDLE" : "BUSY");
- console.writeln("Active Threads: [%s]", manager.getNumberOfActiveThreads());
-
- IJobManager jobManager = Job.getJobManager();
- console.writeln("Job Manager: [%s]", jobManager.isIdle() ? "IDLE" : "BUSY");
-
- Job current = jobManager.currentJob();
-
- console.writeln("Current Job: [%s]", current != null ? current.getName() : "NONE");
-
- console.write("Current Tasks: ");
- List<String> entries = manager.getCurrentProcesses();
- if (entries.isEmpty()) {
- console.writeln("[NONE]");
- } else {
- console.writeln();
- for (int index = 0; index < entries.size(); index++) {
- console.writeln("\t[%s] - %s", index, entries.get(index));
- }
- }
- console.writeln();
- writeJdbcStats();
- console.writeln();
- return Boolean.TRUE;
- }
-
- private void logServlets(IApplicationServerManager manager) {
- console.writeln("Servlets:");
- List<String> contexts = new ArrayList<>(manager.getRegisteredServlets());
- Collections.sort(contexts);
- if (contexts.size() % 2 == 1) {
- contexts.add("");
- }
- int midPoint = contexts.size() / 2;
- for (int i = 0; i < midPoint; i++) {
- console.writeln("%-40.40s%s", contexts.get(i), contexts.get(i + midPoint));
- }
- }
-
- private void writeOrcsJdbcServiceInfo(JdbcService jdbcService) {
- if (jdbcService != null) {
- JdbcClientConfig config = jdbcService.getClient().getConfig();
- console.writeln("Datastore Uri: [%s]", config.getDbUri());
- if (jdbcService.hasServer()) {
- JdbcServerConfig serverConfig = jdbcService.getServerConfig();
- console.writeln("Datastore Db Path: [%s]", serverConfig.getDbPath());
- }
- } else {
- console.writeln("Datastore: [N/A]");
- }
- }
-
- private JdbcService getJdbcService(String binding) {
- JdbcService toReturn = null;
- for (JdbcService jdbcService : jdbcServices.values()) {
- if (jdbcService.getBindings().contains(binding)) {
- toReturn = jdbcService;
- break;
- }
- }
- return toReturn;
- }
-
- private void writeJdbcStats() {
- console.writeln("Jdbc Services:");
- boolean isFirst = true;
- for (JdbcService jdbcService : jdbcServices.values()) {
- try {
- if (!isFirst) {
- console.writeln("");
- }
- console.writeln("\tid: %s", jdbcService.getId());
- console.writeln("\tbindings: %s", jdbcService.getBindings());
- console.writeln("\turi: %s", jdbcService.getClient().getConfig().getDbUri());
- if (jdbcService.hasServer()) {
- console.writeln("\tdb.file: %s", jdbcService.getServerConfig().getDbPath());
- }
- Map<String, String> store = jdbcService.getClient().getStatistics();
- for (String key : store.keySet()) {
- String value = store.get(key);
- console.writeln("\t%s: %s", key, value);
- }
- isFirst = false;
- } catch (Exception ex) {
- console.write(ex);
- }
- }
- }
- };
- }
-
-}
diff --git a/plugins/org.eclipse.osee.parent/tools/osee-application-server.xml b/plugins/org.eclipse.osee.parent/tools/osee-application-server.xml
index 755ed80069b..462d34e6096 100644
--- a/plugins/org.eclipse.osee.parent/tools/osee-application-server.xml
+++ b/plugins/org.eclipse.osee.parent/tools/osee-application-server.xml
@@ -155,7 +155,8 @@
"orcs.jdbc.service",
"account.jdbc.service",
"oauth.jdbc.service",
- "app.server.jdbc.service"
+ "app.server.jdbc.service",
+ "server.jdbc.service"
]
}
]
diff --git a/plugins/org.eclipse.osee.support.config/launchConfig/osee.hsql.json b/plugins/org.eclipse.osee.support.config/launchConfig/osee.hsql.json
index a30d173f401..36f4e8fa29c 100644
--- a/plugins/org.eclipse.osee.support.config/launchConfig/osee.hsql.json
+++ b/plugins/org.eclipse.osee.support.config/launchConfig/osee.hsql.json
@@ -1,27 +1,30 @@
{
- "config": [
- {
- "service.pid": "org.eclipse.osee.jdbc.internal.osgi.JdbcComponentFactory",
- "jdbc.service": [
- {
- "service.id": "1001",
- "jdbc.server.host": "127.0.0.1",
- "jdbc.server.port": "8088",
- "jdbc.server.db.data.path": "file:~/hsql/osee.hsql.db",
- "jdbc.client.db.username": "public",
- "jdbc.client.connection.pool.enabled": "true",
- "jdbc.client.connection.pool.max.active.connections": "100",
- "jdbc.client.connection.pool.max.idle.connections": "100",
- "osgi.binding": [
- "client.jdbc.service",
- "activity.jdbc.service",
- "orcs.jdbc.service",
- "account.jdbc.service",
- "oauth.jdbc.service",
- "app.server.jdbc.service"
- ]
- }
- ]
- }
- ]
+ "config": [
+ {
+ "service.pid": "org.eclipse.osee.jdbc.internal.osgi.JdbcComponentFactory",
+ "jdbc.service": [
+ {
+ "service.id": "1001",
+ "jdbc.server.host": "127.0.0.1",
+ "jdbc.server.port": "8088",
+ "jdbc.server.db.data.path": "file:~/hsql/osee.hsql.db",
+ "jdbc.client.db.username": "public",
+ "jdbc.client.connection.pool.enabled": "true",
+ "jdbc.client.connection.pool.max.active.connections": "100",
+ "jdbc.client.connection.pool.max.idle.connections": "100",
+ "osgi.binding": [
+ "client.jdbc.service",
+ "activity.jdbc.service",
+ "orcs.jdbc.service",
+ "account.jdbc.service",
+ "oauth.jdbc.service",
+ "app.server.jdbc.service"
+ ],
+ "application.servers": [
+ "localhost:8089"
+ ]
+ }
+ ]
+ }
+ ]
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.x.parent/pom.xml b/plugins/org.eclipse.osee.x.parent/pom.xml
index 053fe9ce7cb..4bf7ac11e1f 100644
--- a/plugins/org.eclipse.osee.x.parent/pom.xml
+++ b/plugins/org.eclipse.osee.x.parent/pom.xml
@@ -22,5 +22,6 @@
<module>../../plugins/org.eclipse.osee.disposition.parent</module>
<module>../../plugins/org.eclipse.osee.x.ats.parent</module>
<module>../../plugins/org.eclipse.osee.x.server.parent</module>
+ <module>../../plugins/org.eclipse.osee.x.server.application</module>
</modules>
</project>
diff --git a/plugins/org.eclipse.osee.x.server.application/.project b/plugins/org.eclipse.osee.x.server.application/.project
index c2341d0e97c..10d2165ed75 100644
--- a/plugins/org.eclipse.osee.x.server.application/.project
+++ b/plugins/org.eclipse.osee.x.server.application/.project
@@ -20,6 +20,11 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
diff --git a/plugins/org.eclipse.osee.x.server.application/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.x.server.application/META-INF/MANIFEST.MF
index 3fafda2902b..7467c9610d3 100644
--- a/plugins/org.eclipse.osee.x.server.application/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.x.server.application/META-INF/MANIFEST.MF
@@ -4,5 +4,20 @@ Bundle-Name: OSEE X Server Application
Bundle-SymbolicName: org.eclipse.osee.x.server.application
Bundle-Version: 0.25.4.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
+Service-Component: OSGI-INF/*.xml
+Osee-Data: OSEE-INF/*
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Import-Package: org.eclipse.equinox.app
+Import-Package: javax.ws.rs,
+ javax.ws.rs.core,
+ javax.ws.rs.ext,
+ org.codehaus.jackson,
+ org.codehaus.jackson.annotate;version="1.9.13",
+ org.codehaus.jackson.map;version="1.9.13",
+ org.eclipse.core.runtime.jobs,
+ org.eclipse.equinox.app,
+ org.eclipse.osee.framework.core.server,
+ org.eclipse.osee.framework.core.util,
+ org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.jdbc,
+ org.eclipse.osee.logger,
+ org.eclipse.osee.orcs.data
diff --git a/plugins/org.eclipse.osee.framework.core.server/OSGI-INF/server.stats.console.command.xml b/plugins/org.eclipse.osee.x.server.application/OSGI-INF/osee.server.application.xml
index 201d7157774..4362dec2435 100644
--- a/plugins/org.eclipse.osee.framework.core.server/OSGI-INF/server.stats.console.command.xml
+++ b/plugins/org.eclipse.osee.x.server.application/OSGI-INF/osee.server.application.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
- <implementation class="org.eclipse.osee.framework.core.server.internal.console.ServerStatsCommand"/>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop">
+ <implementation class="org.eclipse.osee.x.server.application.ServerApplication"/>
<service>
- <provide interface="org.eclipse.osee.console.admin.ConsoleCommand"/>
+ <provide interface="javax.ws.rs.core.Application"/>
</service>
<reference bind="setApplicationServerManager" cardinality="1..1" interface="org.eclipse.osee.framework.core.server.IApplicationServerManager" name="IApplicationServerManager" policy="static"/>
- <reference bind="setAuthenticationManager" cardinality="1..1" interface="org.eclipse.osee.framework.core.server.IAuthenticationManager" name="IAuthenticationManager" policy="static"/>
<reference bind="addJdbcService" cardinality="0..n" interface="org.eclipse.osee.jdbc.JdbcService" name="JdbcService" policy="dynamic" unbind="removeJdbcService"/>
+ <reference bind="setAuthenticationManager" cardinality="1..1" interface="org.eclipse.osee.framework.core.server.IAuthenticationManager" name="IAuthenticationManager" policy="static"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.x.server.application/build.properties b/plugins/org.eclipse.osee.x.server.application/build.properties
index 34d2e4d2dad..c58ea2178c3 100644
--- a/plugins/org.eclipse.osee.x.server.application/build.properties
+++ b/plugins/org.eclipse.osee.x.server.application/build.properties
@@ -1,4 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ OSGI-INF/
diff --git a/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/ServerApplication.java b/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/ServerApplication.java
index 7994f811521..58774f6c20a 100644
--- a/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/ServerApplication.java
+++ b/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/ServerApplication.java
@@ -10,28 +10,56 @@
*******************************************************************************/
package org.eclipse.osee.x.server.application;
-import org.eclipse.equinox.app.IApplication;
-import org.eclipse.equinox.app.IApplicationContext;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import org.eclipse.osee.framework.core.server.IApplicationServerManager;
+import org.eclipse.osee.framework.core.server.IAuthenticationManager;
+import org.eclipse.osee.jdbc.JdbcService;
+import org.eclipse.osee.x.server.application.internal.ServerHealthEndpointImpl;
/**
* @author Roberto E. Escobar
+ * @author Donald G. Dunne
*/
-public class ServerApplication implements IApplication {
+@ApplicationPath("server")
+public class ServerApplication extends Application {
- private IApplicationContext context;
+ private final Set<Object> singletons = new HashSet<Object>();
+ private IApplicationServerManager applicationServerManager;
+ private final Map<String, JdbcService> jdbcServices = new ConcurrentHashMap<>();
+ private IAuthenticationManager authManager;
- @Override
- public Object start(IApplicationContext context) throws Exception {
- this.context = context;
- // context.applicationRunning();
- return IApplicationContext.EXIT_ASYNC_RESULT;
+ public void setAuthenticationManager(IAuthenticationManager authManager) {
+ this.authManager = authManager;
+ }
+
+ public void setApplicationServerManager(IApplicationServerManager applicationServerManager) {
+ this.applicationServerManager = applicationServerManager;
+ }
+
+ public void addJdbcService(JdbcService jdbcService) {
+ jdbcServices.put(jdbcService.getId(), jdbcService);
+ }
+
+ public void removeJdbcService(JdbcService jdbcService) {
+ jdbcServices.remove(jdbcService.getId());
}
@Override
+ public Set<Object> getSingletons() {
+ return singletons;
+ }
+
+ public void start(Map<String, Object> properties) {
+ singletons.add(new ServerHealthEndpointImpl(applicationServerManager, jdbcServices, authManager));
+ }
+
public void stop() {
- if (context != null) {
- context.setResult(IApplication.EXIT_OK, this);
- }
+ singletons.clear();
}
}
diff --git a/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/ServerHealthEndpointImpl.java b/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/ServerHealthEndpointImpl.java
new file mode 100644
index 00000000000..c228ff81c77
--- /dev/null
+++ b/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/ServerHealthEndpointImpl.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.x.server.application.internal;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.eclipse.osee.framework.core.server.IApplicationServerManager;
+import org.eclipse.osee.framework.core.server.IAuthenticationManager;
+import org.eclipse.osee.framework.core.util.HttpProcessor;
+import org.eclipse.osee.framework.core.util.HttpProcessor.AcquireResult;
+import org.eclipse.osee.framework.jdk.core.util.AHTML;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.jdbc.JdbcClientConfig;
+import org.eclipse.osee.jdbc.JdbcService;
+import org.eclipse.osee.x.server.application.internal.model.ServerStatus;
+import org.eclipse.osee.x.server.application.internal.model.StatusKey;
+import org.eclipse.osee.x.server.application.internal.operations.BuildServerStatusOperation;
+
+/**
+ * @author Donald G. Dunne
+ */
+@Path("/health")
+public final class ServerHealthEndpointImpl {
+ private final IApplicationServerManager applicationServerManager;
+ private final Map<String, JdbcService> jdbcServices;
+ private final IAuthenticationManager authManager;
+ private ObjectMapper mapper;
+
+ public ServerHealthEndpointImpl(IApplicationServerManager applicationServerManager, Map<String, JdbcService> jdbcServices, IAuthenticationManager authManager) {
+ this.applicationServerManager = applicationServerManager;
+ this.jdbcServices = jdbcServices;
+ this.authManager = authManager;
+ }
+
+ @Path("top")
+ @GET
+ @Produces(MediaType.TEXT_HTML)
+ public String getTop() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ if (Lib.isWindows()) {
+ sb.append("Top is not available for windows");
+ } else {
+ ProcessBuilder pb = new ProcessBuilder("top", "-l", "1");
+ pb.redirectError();
+ Process p = pb.start();
+ InputStream is = p.getInputStream();
+ int value = -1;
+ while ((value = is.read()) != -1) {
+ sb.append(((char) value));
+ }
+ int exitCode = p.waitFor();
+ sb.append("Top exited with " + exitCode);
+ }
+ return sb.toString();
+ }
+
+ @Path("status")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public ServerStatus serverStatus() {
+ return new BuildServerStatusOperation(applicationServerManager, authManager).get();
+ }
+
+ @Path("status/all")
+ @GET
+ @Produces(MediaType.TEXT_HTML)
+ public String serverStatusAsll() {
+ return serverStatusAsll(false);
+ }
+
+ @Path("status/all/detail")
+ @GET
+ @Produces(MediaType.TEXT_HTML)
+ public String serverStatusAsllDetails() {
+ return serverStatusAsll(true);
+ }
+
+ private String serverStatusAsll(boolean details) {
+
+ final JdbcClientConfig config = jdbcServices.values().iterator().next().getClient().getConfig();
+ Object serverObj = config.getDbProps().get("application.servers");
+ if (serverObj == null || !(serverObj instanceof String)) {
+ throw new IllegalStateException("No application.servers configured in osee.json file");
+ }
+ String serversStr = ((String) serverObj).replaceAll("[\\[\\]]", "");
+ serversStr = serversStr.replaceAll(" ", "");
+ String[] servers = serversStr.split(",");
+ if (servers.length == 0) {
+ throw new IllegalStateException("No application.servers configured in osee.json file");
+ }
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(AHTML.beginMultiColumnTable(95, 2));
+ List<String> headers = new LinkedList<>();
+ headers.add("Name");
+ headers.add("Alive");
+ for (StatusKey key : StatusKey.values()) {
+ if (details || !key.isDetails()) {
+ headers.add(key.name());
+ }
+ }
+ sb.append(AHTML.addHeaderRowMultiColumnTable(headers));
+ for (String server : (servers)) {
+ addServer(sb, server, details);
+ }
+ sb.append(AHTML.endMultiColumnTable());
+ return sb.toString();
+ }
+
+ private ObjectMapper getMapper() {
+ if (mapper == null) {
+ mapper = new ObjectMapper();
+ }
+ return mapper;
+ }
+
+ private void addServer(StringBuilder sb, String server, boolean details) {
+ List<String> values = new LinkedList<>();
+ String statusUrl = "http://" + server + "/server/health/status";
+ values.add(AHTML.getHyperlink(statusUrl, server));
+ try {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ URL url = new URL(String.format("http://%s%s", server, "/server/health/status"));
+ AcquireResult result = HttpProcessor.acquire(url, outputStream, 5000);
+ if (result.wasSuccessful()) {
+ values.add("Ok");
+ } else {
+ values.add("Not successful: " + result.getResult());
+ return;
+ }
+
+ String json = outputStream.toString(result.getEncoding());
+ ServerStatus stat = getMapper().readValue(json, ServerStatus.class);
+ for (StatusKey key : StatusKey.values()) {
+ if (details || !key.isDetails()) {
+ String value = stat.get(key);
+ if (value == null) {
+ value = "";
+ }
+ values.add(value);
+ }
+ }
+ } catch (Exception ex) {
+ values.add("Exception: " + ex.getMessage());
+ }
+ sb.append(AHTML.addRowMultiColumnTable(values.toArray(new String[values.size()])));
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/model/ServerStatus.java b/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/model/ServerStatus.java
new file mode 100644
index 00000000000..74c5c1a39a7
--- /dev/null
+++ b/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/model/ServerStatus.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.x.server.application.internal.model;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.codehaus.jackson.annotate.JsonIgnore;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class ServerStatus {
+
+ private final Map<String, String> data = new HashMap<String, String>();
+
+ public void set(StatusKey key, String value) {
+ data.put(key.name(), value);
+ }
+
+ @JsonIgnore
+ public String get(StatusKey key) {
+ return data.get(key.name());
+ }
+
+ public void add(String keyStr, String value) {
+ StatusKey key = StatusKey.Unknown;
+ try {
+ key = StatusKey.valueOf(keyStr);
+ } catch (Exception ex) {
+ // do nothing
+ }
+ if (key == StatusKey.Unknown) {
+ String newStr = data.get(StatusKey.Unknown);
+ if (newStr == null) {
+ newStr = String.format("[%s][%s]", key.name(), value);
+ } else {
+ newStr += String.format("%s - [%s][%s]", key.name(), value);
+ }
+ data.put(StatusKey.Unknown.name(), newStr);
+ }
+ data.put(keyStr, value);
+ }
+
+ public Map<String, String> getData() {
+ return data;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/model/StatusKey.java b/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/model/StatusKey.java
new file mode 100644
index 00000000000..2f19a8d5afa
--- /dev/null
+++ b/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/model/StatusKey.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.x.server.application.internal.model;
+
+/**
+ * @author Donald G. Dunne
+ */
+public enum StatusKey {
+ ServerUri("URI", false),
+ ServerState("State", false),
+ MemoryAllocated("Mem Alloc", false),
+ MemoryUsed("Mem-Used", false),
+ MemoryMax("Mem-Max", false),
+ ActiveThreads("Threads", false),
+ JobManager("Jobs", false),
+ CurrentJob("Curr Job", false),
+ CurrentTasks("Curr Tasks", true),
+ ServerId("ID", true),
+ StartTime("Start", true),
+ CodeLocation("Start", true),
+ BinaryDataPath("Binary", true),
+ AuthenticationScheme("Auth-Scheme", true),
+ AuthenticationSchemeSupported("Auth-Supported", true),
+ SupportedVersions("Versions", true),
+ Unknown("Unknown", true);
+
+ private final String shortName;
+ private final boolean details;
+
+ private StatusKey(String shortName, boolean details) {
+ this.shortName = shortName;
+ this.details = details;
+ }
+
+ public boolean isDetails() {
+ return details;
+ }
+
+ public String getShortName() {
+ return shortName;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/operations/BuildServerStatusOperation.java b/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/operations/BuildServerStatusOperation.java
new file mode 100644
index 00000000000..58d90cdfa82
--- /dev/null
+++ b/plugins/org.eclipse.osee.x.server.application/src/org/eclipse/osee/x/server/application/internal/operations/BuildServerStatusOperation.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.x.server.application.internal.operations;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryUsage;
+import java.text.DateFormat;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.osee.framework.core.server.IApplicationServerManager;
+import org.eclipse.osee.framework.core.server.IAuthenticationManager;
+import org.eclipse.osee.framework.core.server.OseeServerProperties;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.x.server.application.internal.model.ServerStatus;
+import org.eclipse.osee.x.server.application.internal.model.StatusKey;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class BuildServerStatusOperation {
+
+ private final IApplicationServerManager applicationServerManager;
+ private final IAuthenticationManager authManager;
+
+ public BuildServerStatusOperation(IApplicationServerManager applicationServerManager, IAuthenticationManager authManager) {
+ this.applicationServerManager = applicationServerManager;
+ this.authManager = authManager;
+ }
+
+ public ServerStatus get() {
+ ServerStatus stat = new ServerStatus();
+ stat.set(StatusKey.ServerUri, applicationServerManager.getServerUri().toString());
+ stat.set(StatusKey.ServerId, applicationServerManager.getId());
+ stat.set(StatusKey.StartTime, DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(
+ applicationServerManager.getDateStarted()));
+ stat.set(StatusKey.CodeLocation, System.getProperty("user.dir"));
+ stat.set(StatusKey.BinaryDataPath, OseeServerProperties.getOseeApplicationServerData(null));
+ stat.set(StatusKey.AuthenticationScheme, authManager.getProtocol());
+ stat.set(StatusKey.AuthenticationSchemeSupported, Arrays.deepToString(authManager.getProtocols()));
+ stat.set(StatusKey.SupportedVersions, Arrays.deepToString(applicationServerManager.getVersions()));
+ MemoryUsage heapMem = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
+ stat.set(StatusKey.MemoryUsed, Lib.toMBytes(heapMem.getUsed()));
+ stat.set(StatusKey.MemoryAllocated, Lib.toMBytes(heapMem.getCommitted()));
+ stat.set(StatusKey.MemoryMax, Lib.toMBytes(heapMem.getMax()));
+ stat.set(StatusKey.ServerState, applicationServerManager.isSystemIdle() ? "IDLE" : "BUSY");
+ stat.set(StatusKey.ActiveThreads, String.valueOf(applicationServerManager.getNumberOfActiveThreads()));
+ List<String> entries = applicationServerManager.getCurrentProcesses();
+ stat.set(StatusKey.CurrentTasks,
+ entries.isEmpty() ? "NONE" : org.eclipse.osee.framework.jdk.core.util.Collections.toString(", ", entries));
+ return stat;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.x.server.p2/etc/osee.hsql.json b/plugins/org.eclipse.osee.x.server.p2/etc/osee.hsql.json
index a30d173f401..36f4e8fa29c 100644
--- a/plugins/org.eclipse.osee.x.server.p2/etc/osee.hsql.json
+++ b/plugins/org.eclipse.osee.x.server.p2/etc/osee.hsql.json
@@ -1,27 +1,30 @@
{
- "config": [
- {
- "service.pid": "org.eclipse.osee.jdbc.internal.osgi.JdbcComponentFactory",
- "jdbc.service": [
- {
- "service.id": "1001",
- "jdbc.server.host": "127.0.0.1",
- "jdbc.server.port": "8088",
- "jdbc.server.db.data.path": "file:~/hsql/osee.hsql.db",
- "jdbc.client.db.username": "public",
- "jdbc.client.connection.pool.enabled": "true",
- "jdbc.client.connection.pool.max.active.connections": "100",
- "jdbc.client.connection.pool.max.idle.connections": "100",
- "osgi.binding": [
- "client.jdbc.service",
- "activity.jdbc.service",
- "orcs.jdbc.service",
- "account.jdbc.service",
- "oauth.jdbc.service",
- "app.server.jdbc.service"
- ]
- }
- ]
- }
- ]
+ "config": [
+ {
+ "service.pid": "org.eclipse.osee.jdbc.internal.osgi.JdbcComponentFactory",
+ "jdbc.service": [
+ {
+ "service.id": "1001",
+ "jdbc.server.host": "127.0.0.1",
+ "jdbc.server.port": "8088",
+ "jdbc.server.db.data.path": "file:~/hsql/osee.hsql.db",
+ "jdbc.client.db.username": "public",
+ "jdbc.client.connection.pool.enabled": "true",
+ "jdbc.client.connection.pool.max.active.connections": "100",
+ "jdbc.client.connection.pool.max.idle.connections": "100",
+ "osgi.binding": [
+ "client.jdbc.service",
+ "activity.jdbc.service",
+ "orcs.jdbc.service",
+ "account.jdbc.service",
+ "oauth.jdbc.service",
+ "app.server.jdbc.service"
+ ],
+ "application.servers": [
+ "localhost:8089"
+ ]
+ }
+ ]
+ }
+ ]
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.x.server.parent/pom.xml b/plugins/org.eclipse.osee.x.server.parent/pom.xml
index f601d262546..f0a992f2655 100644
--- a/plugins/org.eclipse.osee.x.server.parent/pom.xml
+++ b/plugins/org.eclipse.osee.x.server.parent/pom.xml
@@ -48,6 +48,7 @@
<module>../../features/org.eclipse.osee.x.server.external.feature</module>
<module>../../plugins/org.eclipse.osee.x.server.p2</module>
+ <module>../../plugins/org.eclipse.osee.x.server.application</module>
<!-- <module>../../plugins/org.eclipse.osee.x.server.integration.tests</module> -->
</modules>
</profile>

Back to the top