From 6f5370663c5079b52b87f15777fa3aee14c8c505 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Thu, 5 Mar 2020 17:16:13 +0100 Subject: [PATCH] made mapExpeditionMessageFieldIdToMetadata map static, saving initialization effort --- .../UDPExpeditionReceiver.java | 32 +++++++------- wiki/info/landscape/amazon-ec2.md | 42 +++++++++++++++---- 2 files changed, 52 insertions(+), 22 deletions(-) diff --git a/java/com.sap.sailing.expeditionconnector/src/com/sap/sailing/expeditionconnector/UDPExpeditionReceiver.java b/java/com.sap.sailing.expeditionconnector/src/com/sap/sailing/expeditionconnector/UDPExpeditionReceiver.java index 1b6be99d92a..bcefe657526 100755 --- a/java/com.sap.sailing.expeditionconnector/src/com/sap/sailing/expeditionconnector/UDPExpeditionReceiver.java +++ b/java/com.sap.sailing.expeditionconnector/src/com/sap/sailing/expeditionconnector/UDPExpeditionReceiver.java @@ -38,6 +38,23 @@ public class UDPExpeditionReceiver extends UDPReceiver mapExpeditionMessageFieldIdToMetadata; + + static { + mapExpeditionMessageFieldIdToMetadata = new HashMap<>(); + mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_ROLL, ExpeditionExtendedSensorDataMetadata.HEEL); + mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_PITCH, ExpeditionExtendedSensorDataMetadata.TRIM); + mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_RUDDER, ExpeditionExtendedSensorDataMetadata.RUDDER); + mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_TACK_ANGLE, ExpeditionExtendedSensorDataMetadata.TACK_ANGLE); + mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_RAKE_DEG, ExpeditionExtendedSensorDataMetadata.RAKE_DEG); + mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_DFLCTR_PP, ExpeditionExtendedSensorDataMetadata.DEFLECTOR_PERCENTAGE); + mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_TG_HEEL, ExpeditionExtendedSensorDataMetadata.TARGET_HEEL); + mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_FORESTAY_LOAD, ExpeditionExtendedSensorDataMetadata.FORESTAY_LOAD); + mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_FORESTAY_PRES, ExpeditionExtendedSensorDataMetadata.FORESTAY_PRESSURE); + mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_DFLECTR_MM, ExpeditionExtendedSensorDataMetadata.DEFLECTOR_MILLIMETERS); + mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_TARG_BSP_P, ExpeditionExtendedSensorDataMetadata.TARGET_BOATSPEED_P); + } /** * Launches a listener and dumps messages received to the console @@ -100,19 +117,6 @@ public class UDPExpeditionReceiver extends UDPReceiver mapExpeditionMessageFieldIdToMetadata = new HashMap<>(); - mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_ROLL, ExpeditionExtendedSensorDataMetadata.HEEL); - mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_PITCH, ExpeditionExtendedSensorDataMetadata.TRIM); - mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_RUDDER, ExpeditionExtendedSensorDataMetadata.RUDDER); - mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_TACK_ANGLE, ExpeditionExtendedSensorDataMetadata.TACK_ANGLE); - mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_RAKE_DEG, ExpeditionExtendedSensorDataMetadata.RAKE_DEG); - mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_DFLCTR_PP, ExpeditionExtendedSensorDataMetadata.DEFLECTOR_PERCENTAGE); - mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_TG_HEEL, ExpeditionExtendedSensorDataMetadata.TARGET_HEEL); - mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_FORESTAY_LOAD, ExpeditionExtendedSensorDataMetadata.FORESTAY_LOAD); - mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_FORESTAY_PRES, ExpeditionExtendedSensorDataMetadata.FORESTAY_PRESSURE); - mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_DFLECTR_MM, ExpeditionExtendedSensorDataMetadata.DEFLECTOR_MILLIMETERS); - mapExpeditionMessageFieldIdToMetadata.put(ExpeditionMessage.ID_TARG_BSP_P, ExpeditionExtendedSensorDataMetadata.TARGET_BOATSPEED_P); - int maxColumnIndex = -1; final Map valuesPerDoubleVectorFixColumnIndices = new HashMap<>(); for (final Entry mapEntry : mapExpeditionMessageFieldIdToMetadata.entrySet()) { @@ -126,7 +130,7 @@ public class UDPExpeditionReceiver extends UDPReceiver + + ``` INSTALL_FROM_RELEASE=`name-of-release` USE_ENVIRONMENT=live-server MONGODB_URI="mongodb://mongo0.internal.sapsailing.com,mongo1.internal.sapsailing.com/myspecificevent?replicaSet=live&retryWrites=true" @@ -29,7 +30,15 @@ You may need to select "All generations" instead of "Current generation" to see BUILD_COMPLETE_NOTIFY=your@email.here SERVER_STARTUP_NOTIFY=your@email.here ADDITIONAL_JAVA_ARGS="$ADDITIONAL_JAVA_ARGS -Dcom.sap.sailing.domain.tracking.MailInvitationType=SailInsight2" - + # Provide authentication credentials for a user on security-service.sapsailing.com permitted to replicate, either by username/password... + #REPLICATE_MASTER_USERNAME=(user for replicator login on security-service.sapsailing.com server having SERVER:REPLICATE:<server-name> permission) + #REPLICATE_MASTER_PASSWORD=(password of the user for replication login on security-service.sapsailing.com) + # Or by bearer token, obtained, e.g., through + # curl -d "username=myuser&password=mysecretpassword" "https://security-service.sapsailing.com/security/api/restsecurity/access_token" | jq .access_token + # or by logging in to the security-service.sapsailing.com server using your web browser and then navigating to + # https://security-service.sapsailing.com/security/api/restsecurity/access_token + #REPLICATE_MASTER_BEARER_TOKEN= +``` The *MailInvitationType* property controls which version of the SAP Sail Insight app will be targeted by tracking invitations sent out by e-mail. Two different Branch.io URL schemes exist for the Sail Insight app: sailinsight-app.sapsailing.com and sailinsight20-app.sapsailing.com. @@ -40,7 +49,8 @@ iOS app has hit the store. If not provided, it will default to *SailInsight2*. Note that when you select to install an environment using the `USE_ENVIRONMENT` variable, any other variable that you specify in the user data, such as the `MONGODB_URI` or `REPLICATION_CHANNEL` properties in the example above, these additional user data properties will override whatever comes from the environment specified by the `USE_ENVIRONMENT` parameter. - To build from git, install and start, set the following in the instance's user data, adjusting the branch name (`BUILD_FROM`), the `myspecificevent` naming and memory settings according to your needs: -
+
+```
   BUILD_BEFORE_START=True
   BUILD_FROM=master
   RUN_TESTS=False
@@ -52,7 +62,15 @@ Note that when you select to install an environment using the `USE_ENVIRONMENT`
   REPLICATION_HOST=rabbit.internal.sapsailing.com
   REPLICATION_CHANNEL=myspecificevent
   MONGODB_URI="mongodb://mongo0.internal.sapsailing.com,mongo1.internal.sapsailing.com/myspecificevent?replicaSet=live&retryWrites=true"
-  
+ # Provide authentication credentials for a user on security-service.sapsailing.com permitted to replicate, either by username/password... + #REPLICATE_MASTER_USERNAME=(user for replicator login on security-service.sapsailing.com server having SERVER:REPLICATE:<server-name> permission) + #REPLICATE_MASTER_PASSWORD=(password of the user for replication login on security-service.sapsailing.com) + # Or by bearer token, obtained, e.g., through + # curl -d "username=myuser&password=mysecretpassword" "https://security-service.sapsailing.com/security/api/restsecurity/access_token" | jq .access_token + # or by logging in to the security-service.sapsailing.com server using your web browser and then navigating to + # https://security-service.sapsailing.com/security/api/restsecurity/access_token + #REPLICATE_MASTER_BEARER_TOKEN= +``` #### Setting up a new image (AMI) from scratch (more or less) @@ -66,20 +84,28 @@ See [here](/wiki/creating-ec2-image-from-scratch) - Fire up a master with the following configuration. There is a preconfigured master environment at http://releases.sapsailing.com/environments/live-master-server that you should use. -
+```
 INSTALL_FROM_RELEASE=(name-of-release)
 USE_ENVIRONMENT=live-master-server
 SERVER_NAME=MYSPECIFICEVENT
 REPLICATION_CHANNEL=myspecificevent
 MONGODB_URI="mongodb://mongo0.internal.sapsailing.com,mongo1.internal.sapsailing.com/myspecificevent?replicaSet=live&retryWrites=true"
 SERVER_STARTUP_NOTIFY=you@email.com
-
+# Provide authentication credentials for a user on security-service.sapsailing.com permitted to replicate, either by username/password... +#REPLICATE_MASTER_USERNAME=(user for replicator login on security-service.sapsailing.com server having SERVER:REPLICATE:<server-name> permission) +#REPLICATE_MASTER_PASSWORD=(password of the user for replication login on security-service.sapsailing.com) +# Or by bearer token, obtained, e.g., through +# curl -d "username=myuser&password=mysecretpassword" "https://security-service.sapsailing.com/security/api/restsecurity/access_token" | jq .access_token +# or by logging in to the security-service.sapsailing.com server using your web browser and then navigating to +# https://security-service.sapsailing.com/security/api/restsecurity/access_token +#REPLICATE_MASTER_BEARER_TOKEN= +``` - After your master server is ready, note the internal IP and configure your replica instances. Set up a user account there that has the following permission: ``SERVER:REPLICATE:{SERVERNAME}``. You will need this user's credentials to authenticate your replicas for replication. - Make sure to use the preconfigured environment from http://releases.sapsailing.com/environments/live-replica-server. Then absolutely make sure to add the line "REPLICATE_MASTER_SERVLET_HOST" to the user-data and adjust the `myspecificevent` master exchange name to the `REPLICATION_CHANNEL` setting you used for the master configuration. -
+```
 INSTALL_FROM_RELEASE=(name-of-release)
 USE_ENVIRONMENT=live-replica-server
 REPLICATE_MASTER_SERVLET_HOST=(IP of your master server)
@@ -96,7 +122,7 @@ SERVER_NAME=MYSPECIFICEVENT
 MONGODB_URI="mongodb://mongo0.internal.sapsailing.com,mongo1.internal.sapsailing.com/myspecificevent-replica?replicaSet=live&retryWrites=true"
 EVENT_ID=<some-uuid-of-an-event-you-want-to-feature>
 SERVER_STARTUP_NOTIFY=you@email.com
-
+``` #### Setting up a Multi Instance To set up a multi instance for a server with name "SSV", subdomain "ssv.sapsailing.com" and description "Schwartauer Segler-Verein, [www.ssv-net.de](http://www.ssv-net.de), Alexander Probst, [webmaster@alexprobst.de](mailto:webmaster@alexprobst.de)" perform the following steps: