summaryrefslogtreecommitdiffstats
path: root/auth/auth-core/src
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2019-03-29 15:42:37 -0500
committerInstrumental <jonathan.gathman@att.com>2019-03-29 16:53:00 -0500
commitaae5c072bcb4608ae87c70fd1edf7ac5b1794ccf (patch)
tree3607e74c88a9c8f054c5535b25f1781513b3acac /auth/auth-core/src
parent1ee8f051ba40bf4f3578952ae499dd15549a86a9 (diff)
Refine Container Startup
Issue-ID: AAF-773 Change-Id: Ia198a11eceb9bfacafde26cde97d15949a3fe78c Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/auth-core/src')
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java1
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java38
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java5
3 files changed, 37 insertions, 7 deletions
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java
index e2317a52..02d93512 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java
@@ -187,5 +187,4 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
}
return def;
}
-
}
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java
index fe610e57..ee92540b 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java
@@ -19,7 +19,10 @@
*
*/
package org.onap.aaf.auth.server;
+import java.io.File;
import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.UnknownHostException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -29,6 +32,7 @@ import org.onap.aaf.auth.org.OrganizationFactory;
import org.onap.aaf.auth.rserv.RServlet;
import org.onap.aaf.cadi.Access;
import org.onap.aaf.cadi.Access.Level;
+import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.cadi.register.Registrant;
import org.onap.aaf.cadi.register.Registrar;
import org.onap.aaf.misc.env.Trans;
@@ -38,6 +42,7 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
private Registrar<ENV> registrar;
private boolean do_register;
protected AbsService<ENV,TRANS> service;
+ protected String hostname;
public AbsServiceStarter(final AbsService<ENV,TRANS> service) {
@@ -52,6 +57,14 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
// for Debugging purposes without fear that real clients will start to call your debug instance
do_register = !"TRUE".equalsIgnoreCase(access().getProperty("aaf_locate_no_register",null));
_propertyAdjustment();
+ hostname = access().getProperty(Config.HOSTNAME, null);
+ if (hostname==null) {
+ try {
+ hostname = Inet4Address.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ hostname= "cannotBeDetermined";
+ }
+ }
}
public abstract void _start(RServlet<TRANS> rserv) throws Exception;
@@ -70,6 +83,8 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
ExecutorService es = Executors.newSingleThreadExecutor();
Future<?> app = es.submit(this);
final AbsServiceStarter<?,?> absSS = this;
+ // Docker/K8 may separately create startup Status in this dir for startup
+ // sequencing. If so, delete ON EXIT
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
@@ -120,7 +135,28 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
registrar=null;
}
if (service!=null) {
- service.destroy();
+ File status = new File("/opt/app/aaf/status/");
+ boolean deleted = false;
+ if(status.exists()) {
+ int lastdot = service.app_name.lastIndexOf("aaf.");
+ String fname;
+ if(lastdot<0) {
+ fname = service.app_name + '-' + hostname;
+ } else {
+ fname = service.app_name.substring(lastdot).replace('.', '-')
+ + '-' + hostname;
+ }
+ status = new File(status, fname);
+ if(status.exists()) {
+ status.delete();
+ }
+ }
+ if(deleted) {
+ service.access.log(Level.INIT, "Deleted Status",status.getAbsolutePath());
+ } else {
+ service.access.log(Level.INIT, "Status not deleted: ",status.getAbsolutePath());
+ }
+ service.destroy();
}
}
}
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java
index 1256c601..182956cf 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java
@@ -21,7 +21,6 @@
package org.onap.aaf.auth.server;
import java.io.IOException;
-import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.Properties;
@@ -93,10 +92,6 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
@Override
public void _start(RServlet<TRANS> rserv) throws Exception {
- String hostname = access().getProperty(Config.HOSTNAME, null);
- if (hostname==null) {
- hostname = Inet4Address.getLocalHost().getHostName();
- }
final int port = Integer.parseInt(access().getProperty("port","0"));
final String keystore = access().getProperty(Config.CADI_KEYSTORE, null);
final int IDLE_TIMEOUT = Integer.parseInt(access().getProperty(Config.AAF_CONN_IDLE_TIMEOUT, Config.AAF_CONN_IDLE_TIMEOUT_DEF));