Skip to content

Commit

Permalink
Merge pull request #80 from scalecube/update/dependencies
Browse files Browse the repository at this point in the history
Updated seed dependencies
  • Loading branch information
artem-v authored Jan 22, 2020
2 parents 8b9e9bc + eb850b3 commit 5008184
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 46 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM openjdk:8
LABEL maintainer="[email protected]"

ARG EXECUTABLE_JAR
ENV JMX_PORT 5678

WORKDIR /opt/scalecube

Expand All @@ -12,8 +13,6 @@ ENV DEFAULT_JAVA_OPTS="-server \
-Dsun.rmi.dgc.server.gcInterval=3600000"

ENV DEFAULT_JMX_OPTS="-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=5678 \
-Dcom.sun.management.jmxremote.rmi.port=5678 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.local.only=false \
Expand All @@ -27,7 +26,7 @@ COPY target/lib lib
COPY target/${EXECUTABLE_JAR}.jar app.jar

# jmx server port
EXPOSE 5678
EXPOSE $JMX_PORT

# Cluster control port and communication port.
EXPOSE 4801 4802
Expand All @@ -37,5 +36,7 @@ $DEFAULT_JAVA_OPTS \
$JAVA_OPTS \
$DEFAULT_JMX_OPTS \
$DEFAULT_OOM_OPTS \
-Dcom.sun.management.jmxremote.port=$JMX_PORT \
-Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT \
-Dlog4j.configurationFile=log4j2.xml \
-jar app.jar $PROGRAM_ARGS
46 changes: 33 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -9,7 +11,7 @@
</parent>

<artifactId>scalecube-seed</artifactId>
<version>0.1.21-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>

<name>ScaleCube Seed</name>

Expand All @@ -22,15 +24,22 @@
</scm>

<properties>
<checkstyle.skip>false</checkstyle.skip>

<mainClass>io.scalecube.seed.SeedRunner</mainClass>
<scalecube-services.version>2.8.9</scalecube-services.version>
<scalecube-config.version>0.3.11</scalecube-config.version>
<reactor.version>Californium-SR8</reactor.version>

<scalecube-services.version>2.8.10-RC2</scalecube-services.version>
<scalecube-config.version>0.3.14</scalecube-config.version>
<jackson.version>2.10.0.pr1</jackson.version>
<log4j.version>2.11.1</log4j.version>
<slf4j.version>1.7.25</slf4j.version>
<netty.version>4.1.36.Final</netty.version>
<reactor-netty.version>0.8.8.RELEASE</reactor-netty.version>
<netty.version>4.1.37.Final</netty.version>
<reactor.version>Dysprosium-RELEASE</reactor.version>
<reactor-netty.version>0.9.0.RELEASE</reactor-netty.version>

<scalecube-app-utils.version>0.0.4</scalecube-app-utils.version>
<dockerfile.maven.extension.version>1.4.13</dockerfile.maven.extension.version>
<dockerfile.maven.version>1.4.13</dockerfile.maven.version>
</properties>

<dependencyManagement>
Expand All @@ -41,17 +50,16 @@
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>

<!-- Netty -->
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
<version>${reactor-netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<artifactId>netty-bom</artifactId>
<version>${netty.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- Reactor -->
<dependency>
<groupId>io.projectreactor</groupId>
Expand Down Expand Up @@ -86,6 +94,18 @@
<version>${scalecube-config.version}</version>
</dependency>

<!-- Jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>

<!-- Logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down
51 changes: 21 additions & 30 deletions src/main/java/io/scalecube/seed/SeedRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
import io.scalecube.services.Microservices;
import io.scalecube.services.ServiceEndpoint;
import io.scalecube.services.discovery.ScalecubeServiceDiscovery;
import io.scalecube.services.discovery.api.ServiceDiscovery;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -36,39 +37,33 @@ public class SeedRunner {
* @param args program arguments
*/
public static void main(String[] args) {
LOGGER.info("Reading seed configuration");
ConfigRegistry configRegistry = ConfigBootstrap.configRegistry();

Config config =
configRegistry
.objectProperty(SeedRunner.class.getPackage().getName(), Config.class)
.objectProperty(Config.class.getPackage().getName(), Config.class)
.value()
.orElseThrow(() -> new IllegalStateException("Couldn't load config"));

LOGGER.info(DECORATOR);
LOGGER.info("Starting Seed, {}", config);
LOGGER.info(DECORATOR);

//noinspection ConstantConditions
Microservices.builder()
.discovery(serviceEndpoint -> newServiceDiscovery(config, serviceEndpoint))
.discovery(defServiceDiscovery(config))
.start()
.doOnNext(SeedRunner::newLogo)
.block()
.onShutdown()
.block();
}

private static ScalecubeServiceDiscovery newServiceDiscovery(
Config config, ServiceEndpoint serviceEndpoint) {
return new ScalecubeServiceDiscovery(serviceEndpoint)
.options(
opts ->
opts.membership(cfg -> cfg.seedMembers(config.seedAddresses()))
.transport(cfg -> cfg.port(config.discoveryPort))
.memberHost(config.memberHost)
.memberPort(config.memberPort)
.memberAlias(config.memberAlias));
private static Function<ServiceEndpoint, ServiceDiscovery> defServiceDiscovery(Config config) {
return endpoint ->
new ScalecubeServiceDiscovery(endpoint)
.options(opts -> opts.memberAlias(config.memberAlias()))
.transport(opts -> opts.port(config.discoveryPort()))
.membership(opts -> opts.seedMembers(config.seedAddresses()));
}

private static void newLogo(Microservices microservices) {
Expand All @@ -82,29 +77,25 @@ public static class Config {

Integer discoveryPort;
List<String> seeds;
String memberHost;
Integer memberPort;
String memberAlias;

Address[] seedAddresses() {
return Optional.ofNullable(seeds)
.map(
seeds ->
seeds.stream()
.filter(Objects::nonNull)
.filter(s -> !s.isEmpty())
.map(Address::from)
.toArray(Address[]::new))
.orElse(new Address[0]);
public Integer discoveryPort() {
return discoveryPort;
}

public String memberAlias() {
return memberAlias;
}

List<Address> seedAddresses() {
return seeds.stream().map(Address::from).collect(Collectors.toList());
}

@Override
public String toString() {
return new StringJoiner(", ", Config.class.getSimpleName() + "[", "]")
.add("discoveryPort=" + discoveryPort)
.add("seeds=" + seeds)
.add("memberHost='" + memberHost + "'")
.add("memberPort=" + memberPort)
.add("memberAlias=" + memberAlias)
.toString();
}
Expand Down

0 comments on commit 5008184

Please sign in to comment.