Skip to content

Commit

Permalink
completely simplified instanceIndex calculation (read from env)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch-si.com>
  • Loading branch information
thjaeckle committed Nov 12, 2018
1 parent 693e473 commit cdcc1ff
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 38 deletions.
Expand Up @@ -34,7 +34,6 @@ public final class ClusterConfigReader extends AbstractConfigReader {
*/
public static final Duration DEFAULT_MAJORITY_CHECK_DELAY = Duration.ofSeconds(30L);

private static final String PATH_INSTANCE_INDEX = "instance-index";
private static final String PATH_NUMBER_OF_SHARDS = "number-of-shards";
private static final String PATH_MAJORITY_CHECK = "majority-check";
private static final String PATH_MAJORITY_CHECK_ENABLED = path(PATH_MAJORITY_CHECK, "enabled");
Expand All @@ -44,16 +43,6 @@ public final class ClusterConfigReader extends AbstractConfigReader {
super(config);
}

/**
* Retrieve the instance index of the cluster node.
*
* @return instance index.
*/
public String instanceIndex() {
return getIfPresent(PATH_INSTANCE_INDEX, config::getString)
.orElseThrow(() -> new IllegalStateException("Could not determine the 'instance-index' of this cluster node"));
}

/**
* Retrieve the number of shards in a cluster.
*
Expand Down
Expand Up @@ -24,15 +24,6 @@ public interface ServiceConfigReader {
*/
ClusterConfigReader cluster();

/**
* Get the index of this service instance.
*
* @return the instance index.
*/
default String instanceIndex() {
return cluster().instanceIndex();
}

/**
* Retrieve a health configuration reader.
*
Expand Down
Expand Up @@ -41,6 +41,7 @@
import org.eclipse.ditto.services.models.things.ThingsMessagingConstants;
import org.eclipse.ditto.services.utils.cache.Cache;
import org.eclipse.ditto.services.utils.cluster.ShardRegionExtractor;
import org.eclipse.ditto.services.utils.config.ConfigUtil;
import org.eclipse.ditto.signals.commands.things.ThingCommand;

import akka.actor.ActorContext;
Expand Down Expand Up @@ -105,7 +106,7 @@ public ActorRef startEnforcerActor(final ActorContext context, final ConciergeCo
final ActorRef enforcerShardRegion = startShardRegion(context.system(), configReader.cluster(), enforcerProps);

// start cache updaters
final String instanceIndex = configReader.instanceIndex();
final String instanceIndex = ConfigUtil.instanceIdentifier();
final Props policyCacheUpdateActorProps =
PolicyCacheUpdateActor.props(policyEnforcerCache, pubSubMediator, instanceIndex);
context.actorOf(policyCacheUpdateActorProps, PolicyCacheUpdateActor.ACTOR_NAME);
Expand Down
Expand Up @@ -6,11 +6,6 @@ ditto {
port = ${?HTTP_PORT}
}

cluster {
instance-index = 0
instance-index = ${?INSTANCE_INDEX}
}

mongo {
hostname = "localhost"
hostname = ${?DOCKER_HOST}
Expand Down
2 changes: 0 additions & 2 deletions services/concierge/starter/src/main/resources/concierge.conf
Expand Up @@ -11,8 +11,6 @@ ditto {
}

cluster {
instance-index = ${?INSTANCE_INDEX}

# as a rule of thumb: should be factor ten of the amount of cluster nodes available
# be aware that it must be the same as for all other services (e.g. search-updater)
number-of-shards = 30
Expand Down
Expand Up @@ -24,8 +24,6 @@ ditto {
}

cluster {
instance-index = ${?INSTANCE_INDEX}

# as a rule of thumb: should be factor ten of the amount of cluster nodes available
# be aware that it must be the same as for all other services (e.g. search-updater)
number-of-shards = 30
Expand Down
2 changes: 0 additions & 2 deletions services/gateway/starter/src/main/resources/gateway.conf
Expand Up @@ -16,8 +16,6 @@ ditto {
}

cluster {
instance-index = ${?INSTANCE_INDEX}

# as a rule of thumb: should be factor ten of the amount of cluster nodes available
# be aware that it must be the same as for all other services (e.g. search-updater)
number-of-shards = 30
Expand Down
2 changes: 0 additions & 2 deletions services/policies/starter/src/main/resources/policies.conf
Expand Up @@ -19,8 +19,6 @@ ditto {
}

cluster {
instance-index = ${?INSTANCE_INDEX}

# as a rule of thumb: should be factor ten of the amount of cluster nodes available
number-of-shards = 30
number-of-shards = ${?CLUSTER_NUMBER_OF_SHARDS}
Expand Down
2 changes: 0 additions & 2 deletions services/things/starter/src/main/resources/things.conf
Expand Up @@ -22,8 +22,6 @@ ditto {
}

cluster {
instance-index = ${?INSTANCE_INDEX}

# as a rule of thumb: should be factor ten of the amount of cluster nodes available
# be aware that it must be the same as for all other services (e.g. search-updater)
number-of-shards = 30
Expand Down
Expand Up @@ -26,8 +26,6 @@ ditto {
}

cluster {
instance-index = ${?INSTANCE_INDEX}

# enables the majority check that solves network partitions automatically
majority-check.enabled = false
majority-check.enabled = ${?CLUSTER_MAJORITY_CHECK_ENABLED}
Expand Down

0 comments on commit cdcc1ff

Please sign in to comment.