ffea760069e8a78ec42893397503df40e37bb693
java/com.sap.sse.replication/src/com/sap/sse/replication/impl/ReplicationServiceImpl.java
| ... | ... | @@ -200,7 +200,12 @@ public class ReplicationServiceImpl implements ReplicationService { |
| 200 | 200 | private class LifeCycleListener implements ReplicableLifeCycleListener {
|
| 201 | 201 | @Override
|
| 202 | 202 | public void replicableAdded(Replicable<?, ?> replicable) {
|
| 203 | - addNewOperationExecutionListener(replicable);
|
|
| 203 | + // add a replication listener to the new replicable only if there are replicas currently registered
|
|
| 204 | + synchronized (replicationInstancesManager) {
|
|
| 205 | + if (replicationInstancesManager.hasReplicas()) {
|
|
| 206 | + addNewOperationExecutionListener(replicable);
|
|
| 207 | + }
|
|
| 208 | + }
|
|
| 204 | 209 | }
|
| 205 | 210 | |
| 206 | 211 | @Override
|
| ... | ... | @@ -285,15 +290,17 @@ public class ReplicationServiceImpl implements ReplicationService { |
| 285 | 290 | |
| 286 | 291 | @Override
|
| 287 | 292 | public void registerReplica(ReplicaDescriptor replica) throws IOException {
|
| 288 | - if (!replicationInstancesManager.hasReplicas()) {
|
|
| 289 | - addAsListenerToReplicables();
|
|
| 290 | - synchronized (this) {
|
|
| 291 | - if (masterChannel == null) {
|
|
| 292 | - masterChannel = createMasterChannelAndDeclareFanoutExchange();
|
|
| 293 | + synchronized (replicationInstancesManager) {
|
|
| 294 | + if (!replicationInstancesManager.hasReplicas()) {
|
|
| 295 | + addAsListenerToReplicables();
|
|
| 296 | + synchronized (this) {
|
|
| 297 | + if (masterChannel == null) {
|
|
| 298 | + masterChannel = createMasterChannelAndDeclareFanoutExchange();
|
|
| 299 | + }
|
|
| 293 | 300 | }
|
| 294 | 301 | }
|
| 302 | + replicationInstancesManager.registerReplica(replica);
|
|
| 295 | 303 | }
|
| 296 | - replicationInstancesManager.registerReplica(replica);
|
|
| 297 | 304 | logger.info("Registered replica " + replica);
|
| 298 | 305 | }
|
| 299 | 306 | |
| ... | ... | @@ -311,13 +318,15 @@ public class ReplicationServiceImpl implements ReplicationService { |
| 311 | 318 | @Override
|
| 312 | 319 | public void unregisterReplica(ReplicaDescriptor replica) throws IOException {
|
| 313 | 320 | logger.info("Unregistering replica " + replica);
|
| 314 | - replicationInstancesManager.unregisterReplica(replica);
|
|
| 315 | - if (!replicationInstancesManager.hasReplicas()) {
|
|
| 316 | - removeAsListenerFromReplicables();
|
|
| 317 | - synchronized (this) {
|
|
| 318 | - if (masterChannel != null) {
|
|
| 319 | - masterChannel.close();
|
|
| 320 | - masterChannel = null;
|
|
| 321 | + synchronized (replicationInstancesManager) {
|
|
| 322 | + replicationInstancesManager.unregisterReplica(replica);
|
|
| 323 | + if (!replicationInstancesManager.hasReplicas()) {
|
|
| 324 | + removeAsListenerFromReplicables();
|
|
| 325 | + synchronized (this) {
|
|
| 326 | + if (masterChannel != null) {
|
|
| 327 | + masterChannel.close();
|
|
| 328 | + masterChannel = null;
|
|
| 329 | + }
|
|
| 321 | 330 | }
|
| 322 | 331 | }
|
| 323 | 332 | }
|
java/target/env.sh
| ... | ... | @@ -27,10 +27,12 @@ MONGODB_PORT=27017 |
| 27 | 27 | MONGODB_NAME=winddb |
| 28 | 28 | EXPEDITION_PORT=2010 |
| 29 | 29 | |
| 30 | -# Start replication upon startup? If you activate this make sure to |
|
| 30 | +# To start replication upon startup provide the fully-qualified names of the Replicable service classes |
|
| 31 | +# for which to trigger replication. If you activate this make sure to |
|
| 31 | 32 | # set the REPLICATE_MASTER_EXCHANGE_NAME variable to the |
| 32 | 33 | # same channel the master is using in its REPLICATION_CHANNEL variable |
| 33 | -REPLICATE_ON_START=False |
|
| 34 | + |
|
| 35 | +# REPLICATE_ON_START=com.sap.sailing.server.impl.RacingEventServiceImpl |
|
| 34 | 36 | |
| 35 | 37 | # Host where the master Java instance is running |
| 36 | 38 | # Make sure firewall configurations allow access |
wiki/amazon-ec2-create-new-app-instance.md
| ... | ... | @@ -22,7 +22,7 @@ Leave Kernel and RAM disk to Default. Then put the configuration for this server |
| 22 | 22 | <pre> |
| 23 | 23 | INSTALL_FROM_RELEASE=name-of-release |
| 24 | 24 | USE_ENVIRONMENT=live-server |
| 25 | -MONGODB_PORT=10201 |
|
| 25 | +MONGODB_PORT=10202 |
|
| 26 | 26 | MONGODB_NAME=myspecificevent |
| 27 | 27 | REPLICATION_CHANNEL=myspecificevent |
| 28 | 28 | SERVER_NAME=MYSPECIFICEVENT |
wiki/amazon-ec2.md
| ... | ... | @@ -31,31 +31,21 @@ SERVER_STARTUP_NOTIFY=simon.marcel.pamies@sap.com |
| 31 | 31 | |
| 32 | 32 | 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_NAME` 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. |
| 33 | 33 | |
| 34 | -- To build from git, install and start, set the following in the instance's user data, adjusting the MONGODB_PORT and memory settings according to your needs: |
|
| 34 | +- 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: |
|
| 35 | 35 | <pre> |
| 36 | 36 | BUILD_BEFORE_START=True |
| 37 | 37 | BUILD_FROM=master |
| 38 | 38 | RUN_TESTS=False |
| 39 | 39 | COMPILE_GWT=True |
| 40 | -BUILD_COMPLETE_NOTIFY=simon.marcel.pamies@sap.com |
|
| 40 | +BUILD_COMPLETE_NOTIFY=you@email.com |
|
| 41 | 41 | SERVER_STARTUP_NOTIFY= |
| 42 | 42 | SERVER_NAME=MYSPECIFICEVENT |
| 43 | 43 | MEMORY=2048m |
| 44 | 44 | REPLICATION_HOST=172.31.25.253 |
| 45 | 45 | REPLICATION_CHANNEL=myspecificevent |
| 46 | -TELNET_PORT=14888 |
|
| 47 | -SERVER_PORT=8888 |
|
| 48 | 46 | MONGODB_HOST=172.31.25.253 |
| 49 | 47 | MONGODB_PORT=10202 |
| 50 | 48 | MONGODB_NAME=myspecificevent |
| 51 | -EXPEDITION_PORT=2010 |
|
| 52 | -REPLICATE_ON_START=False |
|
| 53 | -REPLICATE_MASTER_SERVLET_HOST= |
|
| 54 | -REPLICATE_MASTER_SERVLET_PORT= |
|
| 55 | -REPLICATE_MASTER_QUEUE_HOST= |
|
| 56 | -REPLICATE_MASTER_QUEUE_PORT= |
|
| 57 | -INSTALL_FROM_RELEASE= |
|
| 58 | -USE_ENVIRONMENT= |
|
| 59 | 49 | </pre> |
| 60 | 50 | |
| 61 | 51 | #### Receiving wind from Expedition |
| ... | ... | @@ -69,18 +59,23 @@ USE_ENVIRONMENT= |
| 69 | 59 | <pre> |
| 70 | 60 | INSTALL_FROM_RELEASE=(name-of-release) |
| 71 | 61 | USE_ENVIRONMENT=live-master-server |
| 72 | -BUILD_COMPLETE_NOTIFY=simon.marcel.pamies@sap.com |
|
| 73 | -SERVER_STARTUP_NOTIFY=simon.marcel.pamies@sap.com |
|
| 62 | +SERVER_NAME=MYSPECIFICEVENT |
|
| 63 | +REPLICATION_CHANNEL=myspecificevent |
|
| 64 | +MONGODB_NAME=myspecificevent |
|
| 65 | +SERVER_STARTUP_NOTIFY=you@email.com |
|
| 74 | 66 | </pre> |
| 75 | 67 | |
| 76 | -- After your master server is ready, note the internal IP and configure your replica instances. 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! |
|
| 68 | +- After your master server is ready, note the internal IP and configure your replica instances. 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. |
|
| 77 | 69 | |
| 78 | 70 | <pre> |
| 79 | 71 | INSTALL_FROM_RELEASE=(name-of-release) |
| 80 | 72 | USE_ENVIRONMENT=live-replica-server |
| 81 | 73 | REPLICATE_MASTER_SERVLET_HOST=(IP of your master server) |
| 82 | -SERVER_STARTUP_NOTIFY=simon.marcel.pamies@sap.com |
|
| 83 | -BUILD_COMPLETE_NOTIFY= |
|
| 74 | +REPLICATE_MASTER_EXCHANGE_NAME=myspecificevent |
|
| 75 | +SERVER_NAME=MYSPECIFICEVENT |
|
| 76 | +MONGODB_NAME=myspecificevent-replica |
|
| 77 | +EVENT_ID=<some-uuid-of-an-event-you-want-to-feature> |
|
| 78 | +SERVER_STARTUP_NOTIFY=you@email.com |
|
| 84 | 79 | </pre> |
| 85 | 80 | |
| 86 | 81 | ## Costs per month |