mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-24 14:38:45 +00:00
bug4811: refactored combination and defaults for replication configuration, separating better between outbound and inbound
This commit is contained in:
+2
-2
@@ -20,7 +20,7 @@ import com.sap.sailing.landscape.impl.BearerTokenReplicationCredentials;
|
||||
import com.sap.sailing.landscape.procedures.StartSailingAnalyticsMaster;
|
||||
import com.sap.sse.common.Duration;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.landscape.ReplicationConfiguration;
|
||||
import com.sap.sse.landscape.InboundReplicationConfiguration;
|
||||
import com.sap.sse.landscape.aws.AwsLandscape;
|
||||
import com.sap.sse.landscape.aws.Tags;
|
||||
import com.sap.sse.landscape.aws.impl.AwsRegion;
|
||||
@@ -68,7 +68,7 @@ public class TestProcedures {
|
||||
.setCommaSeparatedEmailAddressesToNotifyOfStartup("axel.uhl@sap.com")
|
||||
.setTags(Optional.of(Tags.with("Hello", "World")))
|
||||
.setOptionalTimeout(optionalTimeout)
|
||||
.setReplicationConfiguration(ReplicationConfiguration.builder()
|
||||
.setReplicationConfiguration(InboundReplicationConfiguration.builder()
|
||||
.setCredentials(new BearerTokenReplicationCredentials(securityServiceReplicationBearerToken))
|
||||
.build())
|
||||
.setRabbitConfiguration(landscape.getDefaultRabbitConfiguration(region))
|
||||
|
||||
+13
-3
@@ -3,6 +3,7 @@ package com.sap.sailing.landscape.procedures;
|
||||
import com.sap.sailing.landscape.SailingAnalyticsReplica;
|
||||
import com.sap.sailing.landscape.impl.SailingAnalyticsReplicaImpl;
|
||||
import com.sap.sse.landscape.ProcessConfigurationVariable;
|
||||
import com.sap.sse.landscape.aws.orchestration.OutboundReplicationConfiguration;
|
||||
|
||||
public class StartSailingAnalyticsReplica<ShardingKey>
|
||||
extends StartSailingAnalyticsHost<ShardingKey, SailingAnalyticsReplica<ShardingKey>> {
|
||||
@@ -27,9 +28,18 @@ public class StartSailingAnalyticsReplica<ShardingKey>
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOutputReplicationExchangeName() {
|
||||
return isOutputReplicationExchangeNameSet() ? super.getOutputReplicationExchangeName()
|
||||
: (super.getOutputReplicationExchangeName() + DEFAULT_REPLICA_OUTPUT_REPLICATION_EXCHANGE_NAME_SUFFIX);
|
||||
public OutboundReplicationConfiguration getOutboundReplicationConfiguration() {
|
||||
final OutboundReplicationConfiguration.Builder resultBuilder;
|
||||
if (super.getOutboundReplicationConfiguration() != null) {
|
||||
resultBuilder = OutboundReplicationConfiguration.copy(super.getOutboundReplicationConfiguration());
|
||||
} else {
|
||||
resultBuilder = OutboundReplicationConfiguration.builder();
|
||||
}
|
||||
if (!isOutboundReplicationExchangeNameSet()) {
|
||||
// We assume here that the superclass implementation will default the exchange name to the server name
|
||||
resultBuilder.setOutboundReplicationExchangeName(super.getOutboundReplicationConfiguration() + DEFAULT_REPLICA_OUTPUT_REPLICATION_EXCHANGE_NAME_SUFFIX);
|
||||
}
|
||||
return resultBuilder.build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.sap.sse.landscape.aws.orchestration;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sse.landscape.ProcessConfigurationVariable;
|
||||
import com.sap.sse.landscape.UserDataProvider;
|
||||
import com.sap.sse.landscape.aws.orchestration.impl.OutboundReplicationConfigurationImpl;
|
||||
import com.sap.sse.landscape.rabbitmq.RabbitMQEndpoint;
|
||||
|
||||
public interface OutboundReplicationConfiguration extends UserDataProvider {
|
||||
interface Builder {
|
||||
Builder setOutboundReplicationExchangeName(String outboundReplicationExchangeName);
|
||||
Builder setOutboundRabbitMQEndpoint(RabbitMQEndpoint rabbitMQEndpoint);
|
||||
OutboundReplicationConfiguration build();
|
||||
}
|
||||
|
||||
static Builder builder() {
|
||||
return new OutboundReplicationConfigurationImpl.BuilderImpl();
|
||||
}
|
||||
|
||||
static Builder copy(OutboundReplicationConfiguration outboundReplicationConfiguration) {
|
||||
return new OutboundReplicationConfigurationImpl.BuilderImpl(
|
||||
outboundReplicationConfiguration.getOutboundReplicationExchangeName(),
|
||||
outboundReplicationConfiguration.getOutboundRabbitMQEndpoint());
|
||||
}
|
||||
|
||||
String getOutboundReplicationExchangeName();
|
||||
|
||||
RabbitMQEndpoint getOutboundRabbitMQEndpoint();
|
||||
|
||||
@Override
|
||||
default Map<ProcessConfigurationVariable, String> getUserData() {
|
||||
final Map<ProcessConfigurationVariable, String> result = new HashMap<>();
|
||||
if (getOutboundReplicationExchangeName() != null) {
|
||||
result.put(ProcessConfigurationVariable.REPLICATION_HOST, getOutboundReplicationExchangeName());
|
||||
}
|
||||
if (getOutboundRabbitMQEndpoint() != null) {
|
||||
result.put(ProcessConfigurationVariable.REPLICATION_PORT, Integer.toString(getOutboundRabbitMQEndpoint().getPort()));
|
||||
if (getOutboundRabbitMQEndpoint().getNodeName() != null) {
|
||||
result.put(ProcessConfigurationVariable.REPLICATION_HOST, getOutboundRabbitMQEndpoint().getNodeName());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+59
-24
@@ -16,7 +16,7 @@ import com.sap.sse.landscape.Landscape;
|
||||
import com.sap.sse.landscape.ProcessConfigurationVariable;
|
||||
import com.sap.sse.landscape.Region;
|
||||
import com.sap.sse.landscape.Release;
|
||||
import com.sap.sse.landscape.ReplicationConfiguration;
|
||||
import com.sap.sse.landscape.InboundReplicationConfiguration;
|
||||
import com.sap.sse.landscape.SecurityGroup;
|
||||
import com.sap.sse.landscape.UserDataProvider;
|
||||
import com.sap.sse.landscape.application.ApplicationMasterProcess;
|
||||
@@ -92,8 +92,13 @@ extends StartHost<ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT>
|
||||
* {@link #getServerName() server name}.</li>
|
||||
* <li>The {@link #getOptionalTimeout() optional timeout} defaults to an {@link Optional#empty() empty optional},
|
||||
* meaning that waiting for the instance won't timeout by default.</li>
|
||||
* <li>The {@link #getOutputReplicationExchangeName() output replication exchange name} defaults to the
|
||||
* {@link #getServerName() server name}.
|
||||
* <li>The {@link #getOutboundReplicationConfiguration() output replication}
|
||||
* {@link OutboundReplicationConfiguration#getOutboundReplicationExchangeName() exchange name} defaults to the
|
||||
* {@link #getServerName() server name}.</li>
|
||||
* <li>The {@link #getOutboundReplicationConfiguration() output replication}
|
||||
* {@link OutboundReplicationConfiguration#getOutboundRabbitMQEndpoint() RabbitMQ endpoint} defaults to the
|
||||
* {@link #getInboundReplicationConfiguration() inbound}
|
||||
* {@link InboundReplicationConfiguration#getInboundRabbitMQEndpoint() RabbitMQ endpoint}.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Axel Uhl (D043530)
|
||||
@@ -170,14 +175,12 @@ extends StartHost<ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT>
|
||||
|
||||
Builder<T, ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT> setDatabaseName(String databaseName);
|
||||
|
||||
Optional<ReplicationConfiguration> getReplicationConfiguration();
|
||||
Optional<InboundReplicationConfiguration> getInboundReplicationConfiguration();
|
||||
|
||||
Builder<T, ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT> setReplicationConfiguration(
|
||||
ReplicationConfiguration replicationConfiguration);
|
||||
InboundReplicationConfiguration replicationConfiguration);
|
||||
|
||||
String getOutputReplicationExchangeName();
|
||||
|
||||
Builder<T, ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT> setOutputReplicationExchangeName(String outputReplicationExchangeName);
|
||||
Builder<T, ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT> setOutboundReplicationConfiguration(OutboundReplicationConfiguration outboundReplicationConfiguration);
|
||||
|
||||
RabbitMQEndpoint getRabbitConfiguration();
|
||||
|
||||
@@ -201,6 +204,8 @@ extends StartHost<ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT>
|
||||
Builder<T, ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT> setOptionalTimeout(Optional<Duration> optionalTimeout);
|
||||
|
||||
HostSupplier<ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT> getHostSupplier();
|
||||
|
||||
OutboundReplicationConfiguration getOutboundReplicationConfiguration();
|
||||
}
|
||||
|
||||
protected abstract static class BuilderImpl<T extends StartAwsHost<ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT>, ShardingKey,
|
||||
@@ -224,8 +229,8 @@ extends StartHost<ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT>
|
||||
private String databaseName;
|
||||
private Database databaseConfiguration;
|
||||
private RabbitMQEndpoint rabbitConfiguration;
|
||||
private String outputReplicationExchangeName;
|
||||
private Optional<ReplicationConfiguration> replicationConfiguration = Optional.empty();
|
||||
private Optional<InboundReplicationConfiguration> inboundReplicationConfiguration = Optional.empty();
|
||||
private OutboundReplicationConfiguration outboundReplicationConfiguration;
|
||||
private String commaSeparatedEmailAddressesToNotifyOfStartup;
|
||||
private Optional<Duration> optionalTimeout;
|
||||
|
||||
@@ -419,29 +424,60 @@ extends StartHost<ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT>
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOutputReplicationExchangeName() {
|
||||
return isOutputReplicationExchangeNameSet() ? outputReplicationExchangeName : getServerName();
|
||||
protected boolean isOutboundReplicationExchangeNameSet() {
|
||||
return outboundReplicationConfiguration != null && outboundReplicationConfiguration.getOutboundReplicationExchangeName() != null;
|
||||
}
|
||||
|
||||
protected boolean isOutputReplicationExchangeNameSet() {
|
||||
return outputReplicationExchangeName != null;
|
||||
protected boolean isInboundReplicationRabbitMQEndpointSet() {
|
||||
return inboundReplicationConfiguration != null && inboundReplicationConfiguration.isPresent()
|
||||
&& inboundReplicationConfiguration.get().getInboundRabbitMQEndpoint() != null;
|
||||
}
|
||||
|
||||
protected boolean isOutboundReplicationRabbitMQEndpointSet() {
|
||||
return outboundReplicationConfiguration != null && outboundReplicationConfiguration.getOutboundRabbitMQEndpoint() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutboundReplicationConfiguration getOutboundReplicationConfiguration() {
|
||||
final OutboundReplicationConfiguration.Builder resultBuilder;
|
||||
if (outboundReplicationConfiguration != null) {
|
||||
resultBuilder = OutboundReplicationConfiguration.copy(outboundReplicationConfiguration);
|
||||
} else {
|
||||
resultBuilder = OutboundReplicationConfiguration.builder();
|
||||
}
|
||||
if (!isOutboundReplicationExchangeNameSet()) {
|
||||
resultBuilder.setOutboundReplicationExchangeName(getServerName());
|
||||
}
|
||||
if (!isOutboundReplicationRabbitMQEndpointSet()) {
|
||||
getInboundReplicationConfiguration().ifPresent(irc->resultBuilder.setOutboundRabbitMQEndpoint(irc.getInboundRabbitMQEndpoint()));
|
||||
}
|
||||
return resultBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<T, ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT> setOutputReplicationExchangeName(String outputReplicationExchangeName) {
|
||||
this.outputReplicationExchangeName = outputReplicationExchangeName;
|
||||
public Builder<T, ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT> setOutboundReplicationConfiguration(OutboundReplicationConfiguration outboundReplicationConfiguration) {
|
||||
this.outboundReplicationConfiguration = outboundReplicationConfiguration;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ReplicationConfiguration> getReplicationConfiguration() {
|
||||
return replicationConfiguration;
|
||||
public Optional<InboundReplicationConfiguration> getInboundReplicationConfiguration() {
|
||||
final InboundReplicationConfiguration.Builder resultBuilder;
|
||||
if (inboundReplicationConfiguration == null || !inboundReplicationConfiguration.isPresent()) {
|
||||
resultBuilder = InboundReplicationConfiguration.builder();
|
||||
} else {
|
||||
resultBuilder = InboundReplicationConfiguration.copy(inboundReplicationConfiguration.get());
|
||||
}
|
||||
return !isInboundReplicationRabbitMQEndpointSet()
|
||||
? Optional.of(resultBuilder
|
||||
.setInboundRabbitMQEndpoint(getLandscape().getDefaultRabbitConfiguration(getRegion()))
|
||||
.build())
|
||||
: inboundReplicationConfiguration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<T, ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT> setReplicationConfiguration(ReplicationConfiguration replicationConfiguration) {
|
||||
this.replicationConfiguration = Optional.of(replicationConfiguration);
|
||||
public Builder<T, ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT> setReplicationConfiguration(InboundReplicationConfiguration replicationConfiguration) {
|
||||
this.inboundReplicationConfiguration = Optional.of(replicationConfiguration);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -483,11 +519,10 @@ extends StartHost<ShardingKey, MetricsT, MasterProcessT, ReplicaProcessT, HostT>
|
||||
this.hostSupplier = builder.getHostSupplier();
|
||||
builder.getRelease().ifPresent(this::addUserData);
|
||||
addUserData(builder.getDatabaseConfiguration());
|
||||
addUserData(builder.getRabbitConfiguration());
|
||||
addUserData(builder.getOutboundReplicationConfiguration());
|
||||
addUserData(ProcessConfigurationVariable.SERVER_NAME, builder.getServerName());
|
||||
addUserData(ProcessConfigurationVariable.REPLICATION_CHANNEL, builder.getOutputReplicationExchangeName());
|
||||
addUserData(ProcessConfigurationVariable.SERVER_STARTUP_NOTIFY, builder.getCommaSeparatedEmailAddressesToNotifyOfStartup());
|
||||
builder.getReplicationConfiguration().ifPresent(this::addUserData);
|
||||
builder.getInboundReplicationConfiguration().ifPresent(this::addUserData);
|
||||
}
|
||||
|
||||
protected static <ShardingKey,
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.sap.sse.landscape.aws.orchestration.impl;
|
||||
|
||||
import com.sap.sse.landscape.aws.orchestration.OutboundReplicationConfiguration;
|
||||
import com.sap.sse.landscape.rabbitmq.RabbitMQEndpoint;
|
||||
|
||||
public class OutboundReplicationConfigurationImpl implements OutboundReplicationConfiguration {
|
||||
private final String outboundReplicationExchangeName;
|
||||
private final RabbitMQEndpoint outboundRabbitMQEndpoint;
|
||||
|
||||
public static class BuilderImpl implements Builder {
|
||||
private String outboundReplicationExchangeName;
|
||||
private RabbitMQEndpoint outboundRabbitMQEndpoint;
|
||||
|
||||
public BuilderImpl() {
|
||||
}
|
||||
|
||||
public BuilderImpl(String outboundReplicationExchangeName, RabbitMQEndpoint outboundRabbitMQEndpoint) {
|
||||
this.outboundReplicationExchangeName = outboundReplicationExchangeName;
|
||||
this.outboundRabbitMQEndpoint = outboundRabbitMQEndpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setOutboundReplicationExchangeName(String outboundReplicationExchangeName) {
|
||||
this.outboundReplicationExchangeName = outboundReplicationExchangeName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setOutboundRabbitMQEndpoint(RabbitMQEndpoint outboundRabbitMQEndpoint) {
|
||||
this.outboundRabbitMQEndpoint = outboundRabbitMQEndpoint;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutboundReplicationConfiguration build() {
|
||||
return new OutboundReplicationConfigurationImpl(outboundReplicationExchangeName, outboundRabbitMQEndpoint);
|
||||
}
|
||||
}
|
||||
|
||||
public OutboundReplicationConfigurationImpl(String outboundReplicationExchangeName,
|
||||
RabbitMQEndpoint outboundRabbitMQEndpoint) {
|
||||
super();
|
||||
this.outboundReplicationExchangeName = outboundReplicationExchangeName;
|
||||
this.outboundRabbitMQEndpoint = outboundRabbitMQEndpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOutboundReplicationExchangeName() {
|
||||
return outboundReplicationExchangeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RabbitMQEndpoint getOutboundRabbitMQEndpoint() {
|
||||
return outboundRabbitMQEndpoint;
|
||||
}
|
||||
|
||||
}
|
||||
+39
-14
@@ -3,7 +3,7 @@ package com.sap.sse.landscape;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sse.landscape.impl.ReplicationConfigurationImpl;
|
||||
import com.sap.sse.landscape.impl.InboundReplicationConfigurationImpl;
|
||||
import com.sap.sse.landscape.rabbitmq.RabbitMQEndpoint;
|
||||
|
||||
/**
|
||||
@@ -16,35 +16,54 @@ import com.sap.sse.landscape.rabbitmq.RabbitMQEndpoint;
|
||||
* will apply.
|
||||
* <p>
|
||||
*
|
||||
* This replication configuration, and in particular the {@link #getMasterExchangeName() exchange name} it is providing,
|
||||
* only make sense in the context of a {@link RabbitMQEndpoint}. The {@link Landscape}
|
||||
* This replication configuration, and in particular the {@link #getInboundMasterExchangeName() exchange name} it is providing,
|
||||
* only make sense in the context of a {@link RabbitMQEndpoint}.
|
||||
*
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
*/
|
||||
public interface ReplicationConfiguration extends UserDataProvider {
|
||||
public interface InboundReplicationConfiguration extends UserDataProvider {
|
||||
public static interface Builder {
|
||||
Builder setMasterHostname(String masterHostname);
|
||||
String getMasterHostname();
|
||||
Builder setMasterHttpPort(int masterHttpPort);
|
||||
Builder setMasterExchangeName(String masterExchangeName);
|
||||
int getMasterHttpPort();
|
||||
Builder setInboundMasterExchangeName(String inboundMasterExchangeName);
|
||||
String getInboundMasterExchangeName();
|
||||
Builder setReplicableIds(Iterable<String> replicableIds);
|
||||
Iterable<String> getReplicableIds();
|
||||
Builder setCredentials(ReplicationCredentials credentials);
|
||||
ReplicationConfiguration build();
|
||||
ReplicationCredentials getReplicationCredentials();
|
||||
Builder setInboundRabbitMQEndpoint(RabbitMQEndpoint inboundRabbitMQEndpoint);
|
||||
RabbitMQEndpoint getInboundRabbitMQEndpoint();
|
||||
InboundReplicationConfiguration build();
|
||||
}
|
||||
|
||||
static Builder builder() {
|
||||
return new ReplicationConfigurationImpl.BuilderImpl();
|
||||
return new InboundReplicationConfigurationImpl.BuilderImpl();
|
||||
}
|
||||
|
||||
|
||||
static Builder copy(InboundReplicationConfiguration inboundReplicationConfiguration) {
|
||||
return new InboundReplicationConfigurationImpl.BuilderImpl(
|
||||
inboundReplicationConfiguration.getMasterHostname(),
|
||||
inboundReplicationConfiguration.getMasterHttpPort(),
|
||||
inboundReplicationConfiguration.getInboundMasterExchangeName(),
|
||||
inboundReplicationConfiguration.getReplicableIds(),
|
||||
inboundReplicationConfiguration.getReplicationCredentials(),
|
||||
inboundReplicationConfiguration.getInboundRabbitMQEndpoint());
|
||||
}
|
||||
|
||||
String getMasterHostname();
|
||||
|
||||
Integer getMasterHttpPort();
|
||||
|
||||
String getMasterExchangeName();
|
||||
String getInboundMasterExchangeName();
|
||||
|
||||
Iterable<String> getReplicableIds();
|
||||
|
||||
ReplicationCredentials getCredentials();
|
||||
ReplicationCredentials getReplicationCredentials();
|
||||
|
||||
RabbitMQEndpoint getInboundRabbitMQEndpoint();
|
||||
|
||||
default Map<ProcessConfigurationVariable, String> getUserData() {
|
||||
final Map<ProcessConfigurationVariable, String> result = new HashMap<>();
|
||||
@@ -54,14 +73,20 @@ public interface ReplicationConfiguration extends UserDataProvider {
|
||||
if (getMasterHttpPort() != null) {
|
||||
result.put(ProcessConfigurationVariable.REPLICATE_MASTER_SERVLET_PORT, "" + getMasterHttpPort());
|
||||
}
|
||||
if (getMasterExchangeName() != null) {
|
||||
result.put(ProcessConfigurationVariable.REPLICATE_MASTER_EXCHANGE_NAME, getMasterExchangeName());
|
||||
if (getInboundMasterExchangeName() != null) {
|
||||
result.put(ProcessConfigurationVariable.REPLICATE_MASTER_EXCHANGE_NAME, getInboundMasterExchangeName());
|
||||
}
|
||||
if (getReplicableIds() != null) {
|
||||
result.put(ProcessConfigurationVariable.REPLICATE_ON_START, String.join(",", getReplicableIds()));
|
||||
}
|
||||
if (getCredentials() != null) {
|
||||
result.putAll(getCredentials().getUserData());
|
||||
if (getReplicationCredentials() != null) {
|
||||
result.putAll(getReplicationCredentials().getUserData());
|
||||
}
|
||||
if (getInboundRabbitMQEndpoint() != null) {
|
||||
result.put(ProcessConfigurationVariable.REPLICATE_MASTER_QUEUE_PORT, Integer.toString(getInboundRabbitMQEndpoint().getPort()));
|
||||
if (getInboundRabbitMQEndpoint().getNodeName() != null) {
|
||||
result.put(ProcessConfigurationVariable.REPLICATE_MASTER_QUEUE_HOST, getInboundRabbitMQEndpoint().getNodeName());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
package com.sap.sse.landscape.impl;
|
||||
|
||||
import com.sap.sse.landscape.InboundReplicationConfiguration;
|
||||
import com.sap.sse.landscape.ReplicationCredentials;
|
||||
import com.sap.sse.landscape.rabbitmq.RabbitMQEndpoint;
|
||||
|
||||
public class InboundReplicationConfigurationImpl implements InboundReplicationConfiguration {
|
||||
public static class BuilderImpl implements Builder {
|
||||
private String masterHostname;
|
||||
private Integer masterHttpPort;
|
||||
private String inboundMasterExchangeName;
|
||||
private Iterable<String> replicableIds;
|
||||
private ReplicationCredentials replicationCredentials;
|
||||
private RabbitMQEndpoint inboundRabbitMQEndpoint;
|
||||
|
||||
public BuilderImpl() {
|
||||
}
|
||||
|
||||
public BuilderImpl(String masterHostname, Integer masterHttpPort, String masterExchangeName,
|
||||
Iterable<String> replicableIds, ReplicationCredentials credentials,
|
||||
RabbitMQEndpoint inboundRabbitMQEndpoint) {
|
||||
super();
|
||||
this.masterHostname = masterHostname;
|
||||
this.masterHttpPort = masterHttpPort;
|
||||
this.inboundMasterExchangeName = masterExchangeName;
|
||||
this.replicableIds = replicableIds;
|
||||
this.replicationCredentials = credentials;
|
||||
this.inboundRabbitMQEndpoint = inboundRabbitMQEndpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMasterHostname() {
|
||||
return masterHostname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMasterHttpPort() {
|
||||
return masterHttpPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInboundMasterExchangeName() {
|
||||
return inboundMasterExchangeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> getReplicableIds() {
|
||||
return replicableIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplicationCredentials getReplicationCredentials() {
|
||||
return replicationCredentials;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RabbitMQEndpoint getInboundRabbitMQEndpoint() {
|
||||
return inboundRabbitMQEndpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setMasterHostname(String masterHostname) {
|
||||
this.masterHostname = masterHostname;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setMasterHttpPort(int masterHttpPort) {
|
||||
this.masterHttpPort = masterHttpPort;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setInboundMasterExchangeName(String masterExchangeName) {
|
||||
this.inboundMasterExchangeName = masterExchangeName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setReplicableIds(Iterable<String> replicableIds) {
|
||||
this.replicableIds = replicableIds;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setCredentials(ReplicationCredentials credentials) {
|
||||
this.replicationCredentials = credentials;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setInboundRabbitMQEndpoint(RabbitMQEndpoint inboundRabbitMQEndpoint) {
|
||||
this.inboundRabbitMQEndpoint = inboundRabbitMQEndpoint;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InboundReplicationConfiguration build() {
|
||||
return new InboundReplicationConfigurationImpl(masterHostname, masterHttpPort, inboundMasterExchangeName, replicableIds, replicationCredentials, inboundRabbitMQEndpoint);
|
||||
}
|
||||
}
|
||||
|
||||
private final String masterHostname;
|
||||
private final Integer masterHttpPort;
|
||||
private final String masterExchangeName;
|
||||
private final Iterable<String> replicableIds;
|
||||
private final ReplicationCredentials credentials;
|
||||
private final RabbitMQEndpoint inboundRabbitMQEndpoint;
|
||||
|
||||
public InboundReplicationConfigurationImpl(String masterHostname, Integer masterHttpPort, String masterExchangeName,
|
||||
Iterable<String> replicableIds, ReplicationCredentials credentials, RabbitMQEndpoint inboundRabbitMQEndpoint) {
|
||||
this.masterHostname = masterHostname;
|
||||
this.masterHttpPort = masterHttpPort;
|
||||
this.masterExchangeName = masterExchangeName;
|
||||
this.replicableIds = replicableIds;
|
||||
this.credentials = credentials;
|
||||
this.inboundRabbitMQEndpoint = inboundRabbitMQEndpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMasterHostname() {
|
||||
return masterHostname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getMasterHttpPort() {
|
||||
return masterHttpPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInboundMasterExchangeName() {
|
||||
return masterExchangeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> getReplicableIds() {
|
||||
return replicableIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplicationCredentials getReplicationCredentials() {
|
||||
return credentials;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RabbitMQEndpoint getInboundRabbitMQEndpoint() {
|
||||
return inboundRabbitMQEndpoint;
|
||||
}
|
||||
}
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
package com.sap.sse.landscape.impl;
|
||||
|
||||
import com.sap.sse.landscape.ReplicationConfiguration;
|
||||
import com.sap.sse.landscape.ReplicationCredentials;
|
||||
|
||||
public class ReplicationConfigurationImpl implements ReplicationConfiguration {
|
||||
public static class BuilderImpl implements Builder {
|
||||
private String masterHostname;
|
||||
private Integer masterHttpPort;
|
||||
private String masterExchangeName;
|
||||
private Iterable<String> replicableIds;
|
||||
private ReplicationCredentials credentials;
|
||||
|
||||
@Override
|
||||
public Builder setMasterHostname(String masterHostname) {
|
||||
this.masterHostname = masterHostname;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setMasterHttpPort(int masterHttpPort) {
|
||||
this.masterHttpPort = masterHttpPort;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setMasterExchangeName(String masterExchangeName) {
|
||||
this.masterExchangeName = masterExchangeName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setReplicableIds(Iterable<String> replicableIds) {
|
||||
this.replicableIds = replicableIds;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setCredentials(ReplicationCredentials credentials) {
|
||||
this.credentials = credentials;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplicationConfiguration build() {
|
||||
return new ReplicationConfigurationImpl(masterHostname, masterHttpPort, masterExchangeName, replicableIds, credentials);
|
||||
}
|
||||
}
|
||||
|
||||
private final String masterHostname;
|
||||
private final Integer masterHttpPort;
|
||||
private final String masterExchangeName;
|
||||
private final Iterable<String> replicableIds;
|
||||
private final ReplicationCredentials credentials;
|
||||
|
||||
public ReplicationConfigurationImpl(String masterHostname, Integer masterHttpPort, String masterExchangeName,
|
||||
Iterable<String> replicableIds, ReplicationCredentials credentials) {
|
||||
this.masterHostname = masterHostname;
|
||||
this.masterHttpPort = masterHttpPort;
|
||||
this.masterExchangeName = masterExchangeName;
|
||||
this.replicableIds = replicableIds;
|
||||
this.credentials = credentials;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMasterHostname() {
|
||||
return masterHostname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getMasterHttpPort() {
|
||||
return masterHttpPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMasterExchangeName() {
|
||||
return masterExchangeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> getReplicableIds() {
|
||||
return replicableIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplicationCredentials getCredentials() {
|
||||
return credentials;
|
||||
}
|
||||
}
|
||||
+3
-19
@@ -1,11 +1,5 @@
|
||||
package com.sap.sse.landscape.rabbitmq;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sse.landscape.ProcessConfigurationVariable;
|
||||
import com.sap.sse.landscape.UserDataProvider;
|
||||
|
||||
/**
|
||||
* Shall allow a client to connect to a RabbitMQ service which may or may not be replicated. For now, we assume that the
|
||||
* connectivity information required consists of a port and a hostname which in Rabbit / Erlang terminology may be
|
||||
@@ -13,13 +7,14 @@ import com.sap.sse.landscape.UserDataProvider;
|
||||
* <p>
|
||||
*
|
||||
* The interface can be implemented easily by a lambda providing the {@link #getNodeName() node name}, such as
|
||||
* {@code rabbit.internal.sapsailing.com}.
|
||||
* {@code rabbit.internal.sapsailing.com} because the {@link #getPort()} method is defaulted to return the default
|
||||
* port {@code 5672}.
|
||||
*
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface RabbitMQEndpoint extends UserDataProvider {
|
||||
public interface RabbitMQEndpoint {
|
||||
int DEFAULT_PORT = 5672;
|
||||
|
||||
default int getPort() {
|
||||
@@ -27,15 +22,4 @@ public interface RabbitMQEndpoint extends UserDataProvider {
|
||||
}
|
||||
|
||||
String getNodeName();
|
||||
|
||||
/**
|
||||
* Renders the RabbitMQ configuration as a set of variable assignments usable in either an {@code env.sh} file or in the
|
||||
* AWS EC2 instance user data (which eventually get appended to an {@code env.sh} file).
|
||||
*/
|
||||
default Map<ProcessConfigurationVariable, String> getUserData() {
|
||||
final Map<ProcessConfigurationVariable, String> result = new HashMap<>();
|
||||
result.put(ProcessConfigurationVariable.REPLICATE_MASTER_QUEUE_HOST, getNodeName());
|
||||
result.put(ProcessConfigurationVariable.REPLICATE_MASTER_QUEUE_PORT, ""+getPort());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user