Skip to content

Commit 979e84a

Browse files
authored
Merge pull request #220 from NASA-AMMOS/develop
Merge: develop --> main
2 parents 654e79b + b17d422 commit 979e84a

File tree

36 files changed

+782
-349
lines changed

36 files changed

+782
-349
lines changed

CHANGELOG.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [X.Y.Z](https://github.com/NASA-AMMOS/<repo_name>/releases/tag/X.Y.Z) - 2023-MM-DD
99

10-
### Added
11-
12-
-
10+
### Added
11+
- IDS-10140
12+
- Configure Elasticsearch Index name with Prefix setting: `elasticsearch_index_prefix`
1313

14+
### Changed
15+
### Deprecated
16+
### Removed
17+
### Fixed
18+
### Security

ci/ci.sh

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ DB_PASS=${8}
1212

1313
ES_PROTOCOL=${9}
1414
ES_HOST=${10}
15-
ES_PORT=${11}
16-
ES_USE_AUTH=${12}
17-
ES_USERNAME=${13}
18-
ES_PASSWORD=${14}
15+
ES_INDEX_PREFIX=${11}
16+
ES_PORT=${12}
17+
ES_USE_AUTH=${13}
18+
ES_USERNAME=${14}
19+
ES_PASSWORD=${15}
1920

20-
CLOUD=${15}
21-
SECURITY=${16}
22-
HOSTNAME=${17}
23-
EMAIL_LIST=${18}
24-
ADMIN_FIRST=${19}
25-
ADMIN_LAST=${20}
26-
ADMIN_EMAIL=${21}
27-
NUM_WORKERS=${22}
28-
WORKER_ABANDONED_DAYS=${23}
21+
CLOUD=${16}
22+
SECURITY=${17}
23+
HOSTNAME=${18}
24+
EMAIL_LIST=${19}
25+
ADMIN_FIRST=${20}
26+
ADMIN_LAST=${21}
27+
ADMIN_EMAIL=${22}
28+
NUM_WORKERS=${23}
29+
WORKER_ABANDONED_DAYS=${24}
2930

3031

3132
source ${ROOT}/../utils.sh
@@ -105,6 +106,7 @@ project_webapp_root=proj
105106
cws_enable_cloud_autoscaling=n
106107
elasticsearch_protocol=${ES_PROTOCOL}
107108
elasticsearch_host=${ES_HOST}
109+
elasticsearch_index_prefix=${ES_INDEX_PREFIX}
108110
elasticsearch_use_auth=${ES_USE_AUTH}
109111
elasticsearch_port=${ES_PORT}
110112
elasticsearch_username=${ES_USERNAME}
@@ -115,6 +117,7 @@ default_cws_ldap_url=ldap://localhost:389
115117
cws_ldap_url=ldap://localhost:389
116118
default_elasticsearch_use_auth=n
117119
aws_cloudwatch_endpoint=monitoring.us-west-1.amazonaws.com
120+
default_elasticsearch_index_prefix=cws-index
118121
default_elasticsearch_port=9200
119122
default_aws_cloudwatch_endpoint=monitoring.us-west-1.amazonaws.com
120123
aws_sqs_dispatcher_msgFetchLimit=1
@@ -167,11 +170,13 @@ email_subject=[CWS] You have been assigned a task (CWS_TASK_NAME)
167170
email_body=fn:CWS_USER_FIRSTNAME<br/>ln:CWS_USER_LASTNAME,<br/>tn:(CWS_TASK_NAME), em:CWS_USER_EMAIL
168171
elasticsearch_protocol=${ES_PROTOCOL}
169172
elasticsearch_host=${ES_HOST}
173+
elasticsearch_index_prefix=${ES_INDEX_PREFIX}
170174
elasticsearch_use_auth=${ES_USE_AUTH}
171175
elasticsearch_port=${ES_PORT}
172176
elasticsearch_username=${ES_USERNAME}
173177
elasticsearch_password=${ES_PASSWORD}
174178
smtp_hostname=smtp.localhost
179+
default_elasticsearch_index_prefix=cws-index
175180
default_smtp_hostname=smtp.localhost
176181
default_cws_ldap_url=ldap://localhost:389
177182
cws_ldap_url=ldap://localhost:389

ci/run_ci.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ ADMIN_EMAIL="/"
3131

3232
ES_PROTOCOL="HTTP"
3333
ES_HOST="http://localhost"
34+
ES_INDEX_PREFIX="cws-index"
3435
ES_PORT=9200
3536
ES_USE_AUTH=n
3637
ES_USERNAME="na"
@@ -44,4 +45,4 @@ NUM_WORKERS=${2} # parameter is passed as an env through workflow file
4445
WORKER_ABANDONED_DAYS=1
4546

4647
# Run the ci script
47-
./ci.sh `pwd` ${USER} ${DB_TYPE} ${DB_HOST} ${DB_PORT} ${DB_NAME} ${DB_USER} ${DB_PASS} ${ES_PROTOCOL} ${ES_HOST} ${ES_PORT} ${ES_USE_AUTH} ${ES_USERNAME} ${ES_PASSWORD} ${CLOUD} ${SECURITY} ${HOSTNAME} ${EMAIL_LIST} ${ADMIN_FIRST} ${ADMIN_LAST} ${ADMIN_EMAIL} ${NUM_WORKERS} ${WORKER_ABANDONED_DAYS}
48+
./ci.sh `pwd` ${USER} ${DB_TYPE} ${DB_HOST} ${DB_PORT} ${DB_NAME} ${DB_USER} ${DB_PASS} ${ES_PROTOCOL} ${ES_HOST} ${ES_INDEX_PREFIX} ${ES_PORT} ${ES_USE_AUTH} ${ES_USERNAME} ${ES_PASSWORD} ${CLOUD} ${SECURITY} ${HOSTNAME} ${EMAIL_LIST} ${ADMIN_FIRST} ${ADMIN_LAST} ${ADMIN_EMAIL} ${NUM_WORKERS} ${WORKER_ABANDONED_DAYS}

cws-adaptation/src/main/java/jpl/cws/controller/custom/MyRestService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.springframework.stereotype.Controller;
1111
import org.springframework.web.bind.annotation.RequestMapping;
1212
import org.springframework.web.bind.annotation.ResponseBody;
13+
import springfox.documentation.annotations.ApiIgnore;
1314

1415
@Controller
1516
@RequestMapping("/api")
@@ -27,6 +28,7 @@ public MyRestService() {
2728
* Example POST service
2829
*
2930
*/
31+
@ApiIgnore
3032
@RequestMapping(value = "/example", method = POST)
3133
public @ResponseBody String example(
3234
final HttpSession session) {

cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ public int getCountForClaimedProcInstPerKey(String procDefKey, List<String> clai
400400

401401
public List<Map<String, Object>> getProcDefKeyLatestCompleteInst(String procDefKey) {
402402
return jdbcTemplate.queryForList(
403-
"SELECT proc_inst_id, start_time, end_time FROM cws_proc_inst_status WHERE proc_def_key=? AND status='complete' ORDER BY start_time DESC LIMIT 1",
404-
new Object[]{procDefKey}
403+
"SELECT proc_inst_id, start_time, end_time FROM cws_proc_inst_status WHERE proc_def_key=? AND status='complete' ORDER BY start_time DESC LIMIT 1",
404+
new Object[]{procDefKey}
405405
);
406406
}
407407

@@ -604,8 +604,8 @@ public int getNumUpWorkers() {
604604
*/
605605
public List<Map<String, Object>> getWorkerNumRunningProcs() {
606606
return jdbcTemplate.queryForList(
607-
"SELECT cws_worker.id, active_count as cnt " +
608-
"FROM cws_worker");
607+
"SELECT cws_worker.id, COUNT(*) AS cnt FROM cws_proc_inst_status,cws_worker "
608+
+ "WHERE cws_proc_inst_status.status NOT LIKE '%complete%' GROUP BY cws_worker.id");
609609
}
610610

611611

cws-installer/src/main/java/jpl/cws/task/CwsInstaller.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public class CwsInstaller {
222222
private static String elasticsearch_protocol_init;
223223
private static String elasticsearch_host;
224224
private static String elasticsearch_host_init;
225+
private static String elasticsearch_index_prefix;
225226
private static String elasticsearch_port;
226227
private static String elasticsearch_use_auth;
227228
private static String elasticsearch_username;
@@ -1368,6 +1369,21 @@ private static void setupElasticsearch() {
13681369

13691370
log.debug("elasticsearch_port: " + elasticsearch_port);
13701371

1372+
// PROMPT USER FOR ELASTICSEARCH INDEX
1373+
elasticsearch_index_prefix = getPreset("elasticsearch_index_prefix");
1374+
1375+
if (elasticsearch_index_prefix == null) {
1376+
elasticsearch_index_prefix = getPreset("default_elasticsearch_index_prefix");
1377+
}
1378+
1379+
if (cws_installer_mode.equals("interactive")) {
1380+
elasticsearch_index_prefix = readLine("Enter the Elasticsearch Index. " +
1381+
"Default is " + elasticsearch_index_prefix + ": ", elasticsearch_index_prefix);
1382+
}
1383+
1384+
log.debug("elasticsearch_index_prefix: " + elasticsearch_index_prefix);
1385+
1386+
13711387
// PROMPT USER ELASTICSEARCH AUTH
13721388
elasticsearch_use_auth = getPreset("elasticsearch_use_auth");
13731389

@@ -1783,7 +1799,8 @@ private static void showInstallationInfo() {
17831799
print("....................................................................................");
17841800
print("Elasticsearch Protocol = " + elasticsearch_protocol);
17851801
print("Elasticsearch Host = " + elasticsearch_host);
1786-
print("Elasticsearch Port = " + elasticsearch_port);
1802+
print("Elasticsearch Index Prefix = " + elasticsearch_index_prefix);
1803+
print("Elasticsearch Port = " + elasticsearch_port);
17871804
if (elasticsearch_use_auth.equalsIgnoreCase("Y")) {
17881805
print("Elasticsearch User = " + elasticsearch_username);
17891806
print("Elasticsearch Password = ****** (hidden) ");
@@ -2442,6 +2459,7 @@ private static int validateElasticsearch() {
24422459
print(" [ELASTICSEARCH]: Configuration Details");
24432460
print(" elasticsearch_protocol=" + elasticsearch_protocol_init + " ");
24442461
print(" elasticsearch_host=" + elasticsearch_host_init + " ");
2462+
print(" elasticsearch_index_prefix=" + elasticsearch_index_prefix + " ");
24452463
print(" elasticsearch_port=" + elasticsearch_port + " ");
24462464
print(" .........................................................................................");
24472465
print("");
@@ -2964,6 +2982,7 @@ private static void updateCwsUiProperties() throws IOException {
29642982
content = content.replace("__CWS_CONSOLE_SSL_PORT__", cws_console_ssl_port);
29652983
content = content.replace("__CWS_ES_PROTOCOL__", elasticsearch_protocol);
29662984
content = content.replace("__CWS_ES_HOST__", elasticsearch_host);
2985+
content = content.replace("__CWS_ES_INDEX_PREFIX__", elasticsearch_index_prefix);
29672986
content = content.replace("__CWS_ES_PORT__", elasticsearch_port);
29682987
content = content.replace("__CWS_ES_USE_AUTH__", elasticsearch_use_auth);
29692988
content = content.replace("__CWS_ENABLE_CLOUD_AUTOSCALING__", cws_enable_cloud_autoscaling);
@@ -3086,8 +3105,9 @@ private static void updateCwsUiConfig() throws IOException {
30863105
content = getFileContents(path);
30873106
content = content.replace("__ES_PROTOCOL__", elasticsearch_protocol);
30883107
content = content.replace("__ES_HOST__", elasticsearch_host);
3108+
content = content.replace("__ES_INDEX_PREFIX__", elasticsearch_index_prefix);
30893109
content = content.replace("__ES_PORT__", elasticsearch_port);
3090-
content = content.replace("__ES_USE_AUTH__", elasticsearch_use_auth);
3110+
content = content.replace("__ES_USE_AUTH__", elasticsearch_use_auth);
30913111
if (elasticsearch_use_auth.equalsIgnoreCase("Y")) {
30923112
content = content.replace("__ES_USERNAME__", elasticsearch_username);
30933113
content = content.replace("__ES_PASSWORD__", elasticsearch_password);
@@ -3330,6 +3350,7 @@ private static void installLogstash() throws IOException {
33303350

33313351
logstashContent = logstashContent.replace("__CWS_ES_PROTOCOL__", elasticsearch_protocol);
33323352
logstashContent = logstashContent.replace("__CWS_ES_HOST__", elasticsearch_host);
3353+
logstashContent = logstashContent.replace("__CWS_ES_INDEX_PREFIX__", elasticsearch_index_prefix);
33333354
logstashContent = logstashContent.replace("__CWS_ES_PORT__", elasticsearch_port);
33343355
if (elasticsearch_use_auth.equalsIgnoreCase(("Y"))) {
33353356
// Construct the auth config for logstash
@@ -3415,6 +3436,7 @@ private static void writeOutConfigurationFile() throws IOException {
34153436
setPreset("cws_token_expiration_hours", cws_token_expiration_hours);
34163437
setPreset("elasticsearch_protocol", elasticsearch_protocol);
34173438
setPreset("elasticsearch_host", elasticsearch_host);
3439+
setPreset("elasticsearch_index_prefix", elasticsearch_index_prefix);
34183440
setPreset("elasticsearch_port", elasticsearch_port);
34193441
setPreset("elasticsearch_use_auth", elasticsearch_use_auth);
34203442
setPreset("elasticsearch_username", elasticsearch_username);

cws-service/pom.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
<artifactId>spring-test</artifactId>
3030
</dependency>
3131

32-
33-
3432
<!-- AWS JAVA API -->
3533
<dependency>
3634
<groupId>software.amazon.awssdk</groupId>
@@ -255,6 +253,15 @@
255253
<groupId>org.xmlunit</groupId>
256254
<artifactId>xmlunit-core</artifactId>
257255
</dependency>
256+
257+
<dependency>
258+
<groupId>org.webjars</groupId>
259+
<artifactId>bootstrap</artifactId>
260+
</dependency>
261+
<dependency>
262+
<groupId>io.springfox</groupId>
263+
<artifactId>springfox-swagger2</artifactId>
264+
</dependency>
258265
</dependencies>
259266
</profile>
260267
</profiles>

0 commit comments

Comments
 (0)