Update for OOM integration

Issue-ID: DMAAP-107
Change-Id: Iff9f93040f7b3120cffb5755adc693e24de991a7
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@ericsson.com>
diff --git a/datarouter-prov/src/main/resources/docker-compose/database/sql_init_01.sql b/datarouter-prov/src/main/resources/docker-compose/database/sql_init_01.sql
new file mode 100644
index 0000000..e01ce3b
--- /dev/null
+++ b/datarouter-prov/src/main/resources/docker-compose/database/sql_init_01.sql
@@ -0,0 +1,145 @@
+use datarouter;
+
+CREATE TABLE FEEDS (
+    FEEDID         INT UNSIGNED NOT NULL PRIMARY KEY,
+    GROUPID        INT(10) UNSIGNED NOT NULL DEFAULT 0,
+    NAME           VARCHAR(255) NOT NULL,
+    VERSION        VARCHAR(20) NOT NULL,
+    DESCRIPTION    VARCHAR(1000),
+    BUSINESS_DESCRIPTION VARCHAR(1000) DEFAULT NULL,
+    AUTH_CLASS     VARCHAR(32) NOT NULL,
+    PUBLISHER      VARCHAR(8) NOT NULL,
+    SELF_LINK      VARCHAR(256),
+    PUBLISH_LINK   VARCHAR(256),
+    SUBSCRIBE_LINK VARCHAR(256),
+    LOG_LINK       VARCHAR(256),
+    DELETED        BOOLEAN DEFAULT FALSE,
+    LAST_MOD       TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+    SUSPENDED      BOOLEAN DEFAULT FALSE,
+    CREATED_DATE   TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE TABLE FEED_ENDPOINT_IDS (
+    FEEDID        INT UNSIGNED NOT NULL,
+    USERID        VARCHAR(20) NOT NULL,
+    PASSWORD      VARCHAR(32) NOT NULL
+);
+
+CREATE TABLE FEED_ENDPOINT_ADDRS (
+    FEEDID        INT UNSIGNED NOT NULL,
+    ADDR          VARCHAR(44) NOT NULL
+);
+
+CREATE TABLE SUBSCRIPTIONS (
+    SUBID              INT UNSIGNED NOT NULL PRIMARY KEY,
+    FEEDID             INT UNSIGNED NOT NULL,
+    GROUPID            INT(10) UNSIGNED NOT NULL DEFAULT 0,
+    DELIVERY_URL       VARCHAR(256),
+    DELIVERY_USER      VARCHAR(20),
+    DELIVERY_PASSWORD  VARCHAR(32),
+    DELIVERY_USE100    BOOLEAN DEFAULT FALSE,
+    METADATA_ONLY      BOOLEAN DEFAULT FALSE,
+    SUBSCRIBER         VARCHAR(8) NOT NULL,
+    SELF_LINK          VARCHAR(256),
+    LOG_LINK           VARCHAR(256),
+    LAST_MOD           TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+    SUSPENDED          BOOLEAN DEFAULT FALSE,
+    CREATED_DATE       TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+
+);
+
+CREATE TABLE PARAMETERS (
+    KEYNAME        VARCHAR(32) NOT NULL PRIMARY KEY,
+    VALUE          VARCHAR(4096) NOT NULL
+);
+
+CREATE TABLE LOG_RECORDS (
+    TYPE           ENUM('pub', 'del', 'exp', 'pbf', 'dlx') NOT NULL,
+    EVENT_TIME     BIGINT NOT NULL,           /* time of the publish request */
+    PUBLISH_ID     VARCHAR(64) NOT NULL,      /* unique ID assigned to this publish attempt */
+    FEEDID         INT UNSIGNED NOT NULL,     /* pointer to feed in FEEDS */
+    REQURI         VARCHAR(256) NOT NULL,     /* request URI */
+    METHOD         ENUM('DELETE', 'GET', 'HEAD', 'OPTIONS', 'PUT', 'POST', 'TRACE') NOT NULL, /* HTTP method */
+    CONTENT_TYPE   VARCHAR(256) NOT NULL,     /* content type of published file */
+    CONTENT_LENGTH BIGINT NOT NULL,  /* content length of published file */
+
+    FEED_FILEID    VARCHAR(256),        /* file ID of published file */
+    REMOTE_ADDR    VARCHAR(40),         /* IP address of publishing endpoint */
+    USER           VARCHAR(50),         /* user name of publishing endpoint */
+    STATUS         SMALLINT,            /* status code returned to delivering agent */
+
+    DELIVERY_SUBID INT UNSIGNED,        /* pointer to subscription in SUBSCRIPTIONS */
+    DELIVERY_FILEID  VARCHAR(256),      /* file ID of file being delivered */
+    RESULT         SMALLINT,            /* result received from subscribing agent */
+
+    ATTEMPTS       INT,             /* deliveries attempted */
+    REASON         ENUM('notRetryable', 'retriesExhausted', 'diskFull', 'other'),
+
+    RECORD_ID      BIGINT UNSIGNED NOT NULL PRIMARY KEY, /* unique ID for this record */
+    CONTENT_LENGTH_2 BIGINT,
+
+    INDEX (FEEDID) USING BTREE,
+    INDEX (DELIVERY_SUBID) USING BTREE,
+    INDEX (RECORD_ID) USING BTREE
+) ENGINE = MyISAM;
+
+CREATE TABLE INGRESS_ROUTES (
+    SEQUENCE  INT UNSIGNED NOT NULL,
+    FEEDID    INT UNSIGNED NOT NULL,
+    USERID    VARCHAR(20),
+    SUBNET    VARCHAR(44),
+    NODESET   INT UNSIGNED NOT NULL
+);
+
+CREATE TABLE EGRESS_ROUTES (
+    SUBID    INT UNSIGNED NOT NULL PRIMARY KEY,
+    NODEID   INT UNSIGNED NOT NULL
+);
+
+CREATE TABLE NETWORK_ROUTES (
+    FROMNODE INT UNSIGNED NOT NULL,
+    TONODE   INT UNSIGNED NOT NULL,
+    VIANODE  INT UNSIGNED NOT NULL
+);
+
+CREATE TABLE NODESETS (
+    SETID   INT UNSIGNED NOT NULL,
+    NODEID  INT UNSIGNED NOT NULL
+);
+
+CREATE TABLE NODES (
+    NODEID  INT UNSIGNED NOT NULL PRIMARY KEY,
+    NAME    VARCHAR(255) NOT NULL,
+    ACTIVE  BOOLEAN DEFAULT TRUE
+);
+
+CREATE TABLE GROUPS (
+    GROUPID        INT UNSIGNED NOT NULL PRIMARY KEY,
+    AUTHID         VARCHAR(100) NOT NULL,
+    NAME           VARCHAR(50) NOT NULL,
+    DESCRIPTION    VARCHAR(255),
+    CLASSIFICATION VARCHAR(20) NOT NULL,
+    MEMBERS        TINYTEXT,
+    LAST_MOD       TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+
+INSERT INTO PARAMETERS VALUES
+    ('ACTIVE_POD',  'prov.datarouternew.com'),
+    ('PROV_ACTIVE_NAME',  'prov.datarouternew.com'),
+    ('STANDBY_POD', ''),
+    ('PROV_NAME',   'prov.datarouternew.com'),
+    ('NODES',       '172.100.0.1|node.datarouternew.com'),
+    ('PROV_DOMAIN', 'datarouternew.com'),
+    ('DELIVERY_INIT_RETRY_INTERVAL', '10'),
+    ('DELIVERY_MAX_AGE', '86400'),
+    ('DELIVERY_MAX_RETRY_INTERVAL', '3600'),
+    ('DELIVERY_RETRY_RATIO', '2'),
+    ('LOGROLL_INTERVAL', '300'),
+    ('PROV_AUTH_ADDRESSES', '172.100.0.1|prov.datarouternew.com|node.datarouternew.com'),
+    ('PROV_AUTH_SUBJECTS', ''),
+    ('PROV_MAXFEED_COUNT',  '10000'),
+    ('PROV_MAXSUB_COUNT',   '100000'),
+    ('PROV_REQUIRE_CERT', 'false'),
+    ('PROV_REQUIRE_SECURE', 'false'),
+    ('_INT_VALUES', 'LOGROLL_INTERVAL|PROV_MAXFEED_COUNT|PROV_MAXSUB_COUNT|DELIVERY_INIT_RETRY_INTERVAL|DELIVERY_MAX_RETRY_INTERVAL|DELIVERY_RETRY_RATIO|DELIVERY_MAX_AGE')
+    ;
diff --git a/datarouter-prov/src/main/resources/docker-compose/docker-compose.yml b/datarouter-prov/src/main/resources/docker-compose/docker-compose.yml
index eece155..6aee4db 100644
--- a/datarouter-prov/src/main/resources/docker-compose/docker-compose.yml
+++ b/datarouter-prov/src/main/resources/docker-compose/docker-compose.yml
@@ -30,11 +30,9 @@
      - "8443:8443"

      - "8080:8080"  

     volumes:

-     - ./prov_data/proserver.properties:/opt/app/datartr/etc/proserver.properties

-#     - ./prov_data/datarouter-prov-jar-with-dependencies.jar:/opt/app/datartr/lib/datarouter-prov-jar-with-dependencies.jar

+     - ./prov_data/provserver.properties:/opt/app/datartr/etc/provserver.properties

      - ./prov_data/addSubscriber.txt:/opt/app/datartr/addSubscriber.txt

      - ./prov_data/addFeed3.txt:/opt/app/datartr/addFeed3.txt

-    entrypoint: ["bash", "-c", "./startup.sh"]

     depends_on:

       mariadb_container:

         condition: service_healthy

@@ -58,7 +56,6 @@
      - "9090:8080"

     volumes:

      - ./node_data/node.properties:/opt/app/datartr/etc/node.properties

-    entrypoint: ["bash", "-c", "./startup.sh"]

     depends_on:

       datarouter-prov:

         condition: service_healthy

@@ -73,15 +70,17 @@
     container_name: mariadb

     ports:

       - "3306:3306"

+#    volumes:

+#     - ./database/sql_init_01.sql:/docker-entrypoint-initdb.d/sql_init_01.sql

     environment:

       MYSQL_ROOT_PASSWORD: datarouter

       MYSQL_DATABASE: datarouter

       MYSQL_USER: datarouter

       MYSQL_PASSWORD: datarouter

     healthcheck:

-      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]

+      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "--silent"]

       interval: 10s

-      timeout: 10s

+      timeout: 30s

       retries: 5

 

     networks:

diff --git a/datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties b/datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties
index d733cc2..10bb5eb 100644
--- a/datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties
+++ b/datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties
@@ -24,22 +24,24 @@
 #Jetty Server properties
 org.onap.dmaap.datarouter.provserver.http.port           = 8080
 org.onap.dmaap.datarouter.provserver.https.port          = 8443
-org.onap.dmaap.datarouter.provserver.https.relaxation       = false
-org.onap.dmaap.datarouter.provserver.keymanager.password = changeit
+org.onap.dmaap.datarouter.provserver.https.relaxation    = false
+
 org.onap.dmaap.datarouter.provserver.keystore.type       = jks
+org.onap.dmaap.datarouter.provserver.keymanager.password = changeit
 org.onap.dmaap.datarouter.provserver.keystore.path       = /opt/app/datartr/self_signed/keystore.jks
-
 org.onap.dmaap.datarouter.provserver.keystore.password   = changeit
-#org.onap.dmaap.datarouter.provserver.truststore.path     = /home/eby/dr2/misc/cacerts+1
-#org.onap.dmaap.datarouter.provserver.truststore.path     = /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts
 org.onap.dmaap.datarouter.provserver.truststore.path     = /opt/app/datartr/self_signed/cacerts.jks
-
 org.onap.dmaap.datarouter.provserver.truststore.password = changeit
+
 org.onap.dmaap.datarouter.provserver.accesslog.dir       = /opt/app/datartr/logs
 org.onap.dmaap.datarouter.provserver.spooldir            = /opt/app/datartr/spool
 org.onap.dmaap.datarouter.provserver.dbscripts           = /opt/app/datartr/etc/misc
 org.onap.dmaap.datarouter.provserver.logretention        = 30
 
+#DMAAP-597 (Tech Dept) REST request source IP auth
+# relaxation to accommodate OOM kubernetes deploy
+org.onap.dmaap.datarouter.provserver.isaddressauthenabled = true
+
 # Database access
 org.onap.dmaap.datarouter.db.driver   = org.mariadb.jdbc.Driver
 org.onap.dmaap.datarouter.db.url      = jdbc:mariadb://172.100.0.2:3306/datarouter
diff --git a/datarouter-prov/src/main/resources/docker/startup.sh b/datarouter-prov/src/main/resources/docker/startup.sh
index e964f66..ba0f735 100644
--- a/datarouter-prov/src/main/resources/docker/startup.sh
+++ b/datarouter-prov/src/main/resources/docker/startup.sh
@@ -13,5 +13,4 @@
 
 runner_file="$LIB/datarouter-prov-jar-with-dependencies.jar"
 echo "Starting using" $runner_file
-java -Dcom.att.eelf.logging.file==/opt/app/datartr/etc/logback.xml -Dcom.att.eelf.logging.path=/root -jar $runner_file
-
+java -Dorg.onap.dmaap.datarouter.provserver.properties=/opt/app/datartr/etc/provserver.properties -Dcom.att.eelf.logging.file=/opt/app/datartr/etc/logback.xml -Dcom.att.eelf.logging.path=/root -jar $runner_file
\ No newline at end of file
diff --git a/datarouter-prov/src/main/resources/misc/provcmd b/datarouter-prov/src/main/resources/misc/provcmd
index 75d0bff..e3654eb 100644
--- a/datarouter-prov/src/main/resources/misc/provcmd
+++ b/datarouter-prov/src/main/resources/misc/provcmd
@@ -19,6 +19,21 @@
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 
+urlencode() {
+    local data
+    if [[ $# != 1 ]]; then
+        echo "Usage: $0 string-to-urlencode"
+        return 1
+    fi
+    data="$(curl -s -o /dev/null -w %url_effective --get --data-urlencode "$1" "")"
+    if [[ $? != 3 ]]; then
+        echo "Unexpected error" 1>&2
+        return 2
+    fi
+    echo "${data##/?}"
+    return 0
+}
+export urlencode
 
 PATH=/opt/app/datartr/bin:/bin:/usr/bin:$PATH
 PROVCMD="$0"
diff --git a/datarouter-prov/src/main/resources/misc/sql_init_01.sql b/datarouter-prov/src/main/resources/misc/sql_init_01.sql
index e1dfd0c..e01ce3b 100644
--- a/datarouter-prov/src/main/resources/misc/sql_init_01.sql
+++ b/datarouter-prov/src/main/resources/misc/sql_init_01.sql
@@ -114,12 +114,12 @@
 );
 
 CREATE TABLE GROUPS (
-    GROUPID  INT UNSIGNED NOT NULL PRIMARY KEY,
-    AUTHID    VARCHAR(100) NOT NULL,
-    NAME    VARCHAR(50) NOT NULL,
+    GROUPID        INT UNSIGNED NOT NULL PRIMARY KEY,
+    AUTHID         VARCHAR(100) NOT NULL,
+    NAME           VARCHAR(50) NOT NULL,
     DESCRIPTION    VARCHAR(255),
-    CLASSIFICATION    VARCHAR(20) NOT NULL,
-    MEMBERS    TINYTEXT,
+    CLASSIFICATION VARCHAR(20) NOT NULL,
+    MEMBERS        TINYTEXT,
     LAST_MOD       TIMESTAMP DEFAULT CURRENT_TIMESTAMP
 );
 
@@ -143,6 +143,3 @@
     ('PROV_REQUIRE_SECURE', 'false'),
     ('_INT_VALUES', 'LOGROLL_INTERVAL|PROV_MAXFEED_COUNT|PROV_MAXSUB_COUNT|DELIVERY_INIT_RETRY_INTERVAL|DELIVERY_MAX_RETRY_INTERVAL|DELIVERY_RETRY_RATIO|DELIVERY_MAX_AGE')
     ;
-
-INSERT INTO FEED_ENDPOINT_ADDRS VALUES
-    (1,  '172.100.0.1');
\ No newline at end of file
diff --git a/datarouter-prov/src/main/resources/provserver.properties b/datarouter-prov/src/main/resources/provserver.properties
index 28ffb98..10bb5eb 100644
--- a/datarouter-prov/src/main/resources/provserver.properties
+++ b/datarouter-prov/src/main/resources/provserver.properties
@@ -24,22 +24,24 @@
 #Jetty Server properties
 org.onap.dmaap.datarouter.provserver.http.port           = 8080
 org.onap.dmaap.datarouter.provserver.https.port          = 8443
-org.onap.dmaap.datarouter.provserver.https.relaxation       = false
-org.onap.dmaap.datarouter.provserver.keymanager.password = changeit
+org.onap.dmaap.datarouter.provserver.https.relaxation    = false
+
 org.onap.dmaap.datarouter.provserver.keystore.type       = jks
+org.onap.dmaap.datarouter.provserver.keymanager.password = changeit
 org.onap.dmaap.datarouter.provserver.keystore.path       = /opt/app/datartr/self_signed/keystore.jks
-
 org.onap.dmaap.datarouter.provserver.keystore.password   = changeit
-#org.onap.dmaap.datarouter.provserver.truststore.path     = /home/eby/dr2/misc/cacerts+1
-#org.onap.dmaap.datarouter.provserver.truststore.path     = /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts
 org.onap.dmaap.datarouter.provserver.truststore.path     = /opt/app/datartr/self_signed/cacerts.jks
-
 org.onap.dmaap.datarouter.provserver.truststore.password = changeit
+
 org.onap.dmaap.datarouter.provserver.accesslog.dir       = /opt/app/datartr/logs
 org.onap.dmaap.datarouter.provserver.spooldir            = /opt/app/datartr/spool
-org.onap.dmaap.datarouter.provserver.dbscripts          = /opt/app/datartr/etc/misc
+org.onap.dmaap.datarouter.provserver.dbscripts           = /opt/app/datartr/etc/misc
 org.onap.dmaap.datarouter.provserver.logretention        = 30
 
+#DMAAP-597 (Tech Dept) REST request source IP auth
+# relaxation to accommodate OOM kubernetes deploy
+org.onap.dmaap.datarouter.provserver.isaddressauthenabled = true
+
 # Database access
 org.onap.dmaap.datarouter.db.driver   = org.mariadb.jdbc.Driver
 org.onap.dmaap.datarouter.db.url      = jdbc:mariadb://172.100.0.2:3306/datarouter