Skip to content

Commit

Permalink
Update versions (#819)
Browse files Browse the repository at this point in the history
* Update versions.
* Set the cluster transport and its metadata explicitly.
  • Loading branch information
segabriel authored Aug 19, 2021
1 parent f0cda59 commit 413708c
Show file tree
Hide file tree
Showing 27 changed files with 286 additions and 80 deletions.
13 changes: 9 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@
</scm>

<properties>
<scalecube-cluster.version>2.6.9</scalecube-cluster.version>
<scalecube-cluster.version>2.6.10</scalecube-cluster.version>
<scalecube-commons.version>1.0.17</scalecube-commons.version>
<scalecube-security.version>1.0.19</scalecube-security.version>

<reactor.version>2020.0.6</reactor.version>
<reactor.version>2020.0.10</reactor.version>
<jackson.version>2.11.0</jackson.version>
<rsocket.version>1.0.4</rsocket.version>
<rsocket.version>1.0.5</rsocket.version>
<protostuff.version>1.6.0</protostuff.version>
<slf4j.version>1.7.30</slf4j.version>
<log4j.version>2.13.2</log4j.version>
<disruptor.version>3.4.2</disruptor.version>
<netty.version>4.1.63.Final</netty.version>
<netty.version>4.1.66.Final</netty.version>
<snakeyaml.version>1.26</snakeyaml.version>

<jsr305.version>3.0.2</jsr305.version>
Expand Down Expand Up @@ -116,6 +116,11 @@
<artifactId>scalecube-codec-jackson</artifactId>
<version>${scalecube-cluster.version}</version>
</dependency>
<dependency>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-transport-netty</artifactId>
<version>${scalecube-cluster.version}</version>
</dependency>

<!-- Reactor -->
<dependency>
Expand Down
5 changes: 5 additions & 0 deletions services-discovery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<artifactId>scalecube-codec-jackson</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-transport-netty</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
import io.scalecube.services.discovery.api.ServiceDiscovery;
import io.scalecube.services.discovery.api.ServiceDiscoveryContext;
import io.scalecube.services.discovery.api.ServiceDiscoveryEvent;
import io.scalecube.transport.netty.websocket.WebsocketTransportFactory;
import java.lang.management.ManagementFactory;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.UnaryOperator;
Expand All @@ -41,26 +39,16 @@ public final class ScalecubeServiceDiscovery implements ServiceDiscovery {

private static final Logger LOGGER = LoggerFactory.getLogger(ServiceDiscovery.class);

private final ServiceEndpoint serviceEndpoint;

private ClusterConfig clusterConfig;
private Cluster cluster;

// Sink
private final Sinks.Many<ServiceDiscoveryEvent> sink =
Sinks.many().multicast().directBestEffort();

/**
* Constructor.
*
* @param serviceEndpoint service endpoint
*/
public ScalecubeServiceDiscovery(ServiceEndpoint serviceEndpoint) {
this.serviceEndpoint = Objects.requireNonNull(serviceEndpoint, "serviceEndpoint");
this.clusterConfig =
ClusterConfig.defaultLanConfig()
.metadata(serviceEndpoint)
.transport(opts -> opts.transportFactory(new WebsocketTransportFactory()));
/** Constructor. */
public ScalecubeServiceDiscovery() {
this.clusterConfig = ClusterConfig.defaultLanConfig();
}

/**
Expand All @@ -69,7 +57,6 @@ public ScalecubeServiceDiscovery(ServiceEndpoint serviceEndpoint) {
* @param other other instance
*/
private ScalecubeServiceDiscovery(ScalecubeServiceDiscovery other) {
this.serviceEndpoint = other.serviceEndpoint;
this.clusterConfig = other.clusterConfig;
this.cluster = other.cluster;
}
Expand Down Expand Up @@ -255,7 +242,7 @@ private static JmxMonitorMBean start(ScalecubeServiceDiscovery instance) throws
jmxMBean.init();
ObjectName objectName =
new ObjectName(
String.format(OBJECT_NAME_FORMAT, instance.serviceEndpoint.id(), System.nanoTime()));
String.format(OBJECT_NAME_FORMAT, instance.cluster.member().id(), System.nanoTime()));
StandardMBean standardMBean = new StandardMBean(jmxMBean, MonitorMBean.class);
mbeanServer.registerMBean(standardMBean, objectName);
return jmxMBean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.scalecube.services.ServiceRegistration;
import io.scalecube.services.discovery.api.ServiceDiscovery;
import io.scalecube.services.discovery.api.ServiceDiscoveryEvent;
import io.scalecube.transport.netty.websocket.WebsocketTransportFactory;
import java.nio.ByteBuffer;
import java.time.Duration;
import java.util.ArrayList;
Expand Down Expand Up @@ -224,16 +225,20 @@ private Mono<ServiceDiscovery> newServiceDiscovery(
Address seedAddress, MetadataCodec metadataCodec) {
return Mono.fromCallable(
() ->
new ScalecubeServiceDiscovery(newServiceEndpoint())
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(newServiceEndpoint()))
.options(opts -> opts.metadataCodec(metadataCodec))
.gossip(cfg -> GOSSIP_CONFIG)
.membership(cfg -> MEMBERSHIP_CONFIG)
.membership(cfg -> cfg.seedMembers(seedAddress)));
}

private void startSeed(MetadataCodec metadataCodec) {
new ScalecubeServiceDiscovery(newServiceEndpoint())
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.membership(opts -> opts.seedMembers(SEED_ADDRESS))
.options(opts -> opts.metadata(newServiceEndpoint()))
.options(opts -> opts.metadataCodec(metadataCodec))
.gossip(cfg -> GOSSIP_CONFIG)
.membership(cfg -> MEMBERSHIP_CONFIG)
Expand Down
4 changes: 4 additions & 0 deletions services-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<artifactId>scalecube-services-discovery</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-transport-netty</artifactId>
</dependency>

<dependency>
<groupId>it.unimi.dsi</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.scalecube.services.discovery.ScalecubeServiceDiscovery;
import io.scalecube.services.exceptions.UnauthorizedException;
import io.scalecube.services.transport.rsocket.RSocketServiceTransport;
import io.scalecube.transport.netty.websocket.WebsocketTransportFactory;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -24,7 +25,12 @@ public class PrincipalMapperAuthExample {
public static void main(String[] args) {
Microservices service =
Microservices.builder()
.discovery("service", ScalecubeServiceDiscovery::new)
.discovery(
"service",
serviceEndpoint ->
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(serviceEndpoint)))
.transport(() -> new RSocketServiceTransport().authenticator(authenticator()))
.services(
ServiceInfo.fromServiceInstance(new SecuredServiceByApiKeyImpl())
Expand Down Expand Up @@ -152,7 +158,9 @@ private static ApiKey apiKeyPrincipalMapper(Map<String, String> authData) {

private static ScalecubeServiceDiscovery discovery(
Microservices service, ServiceEndpoint endpoint) {
return new ScalecubeServiceDiscovery(endpoint)
return new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(endpoint))
.membership(opts -> opts.seedMembers(service.discovery("service").address()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.scalecube.services.discovery.ScalecubeServiceDiscovery;
import io.scalecube.services.exceptions.UnauthorizedException;
import io.scalecube.services.transport.rsocket.RSocketServiceTransport;
import io.scalecube.transport.netty.websocket.WebsocketTransportFactory;
import java.time.Duration;
import java.util.HashMap;
import java.util.UUID;
Expand All @@ -22,7 +23,12 @@ public class ServiceTransportAuthExample {
public static void main(String[] args) {
Microservices service =
Microservices.builder()
.discovery("service", ScalecubeServiceDiscovery::new)
.discovery(
"service",
serviceEndpoint ->
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(serviceEndpoint)))
.transport(() -> new RSocketServiceTransport().authenticator(authenticator()))
.services(new SecuredServiceByUserProfileImpl())
.startAwait();
Expand Down Expand Up @@ -71,7 +77,9 @@ private static CredentialsSupplier credsSupplier() {

private static ScalecubeServiceDiscovery discovery(
Microservices service, ServiceEndpoint endpoint) {
return new ScalecubeServiceDiscovery(endpoint)
return new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(endpoint))
.membership(opts -> opts.seedMembers(service.discovery("service").address()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.scalecube.services.examples.helloworld.service.GreetingServiceImpl;
import io.scalecube.services.examples.helloworld.service.api.GreetingsService;
import io.scalecube.services.transport.rsocket.RSocketServiceTransport;
import io.scalecube.transport.netty.websocket.WebsocketTransportFactory;

public class Example1 {

Expand All @@ -22,7 +23,12 @@ public static void main(String[] args) {
// ScaleCube Node node with no members
Microservices seed =
Microservices.builder()
.discovery("seed", ScalecubeServiceDiscovery::new)
.discovery(
"seed",
serviceEndpoint ->
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(serviceEndpoint)))
.transport(RSocketServiceTransport::new)
.defaultContentType(PROTOSTUFF) // set explicit default data format
.startAwait();
Expand All @@ -35,7 +41,9 @@ public static void main(String[] args) {
.discovery(
"ms",
endpoint ->
new ScalecubeServiceDiscovery(endpoint)
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(endpoint))
.membership(cfg -> cfg.seedMembers(seedAddress)))
.transport(RSocketServiceTransport::new)
.services(new GreetingServiceImpl())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.scalecube.services.discovery.api.ServiceDiscoveryContext;
import io.scalecube.services.examples.helloworld.service.api.Greeting;
import io.scalecube.services.transport.rsocket.RSocketServiceTransport;
import io.scalecube.transport.netty.websocket.WebsocketTransportFactory;
import reactor.core.publisher.Mono;

public class CompositeDiscoveryExample {
Expand All @@ -24,7 +25,9 @@ public static void main(String[] args) {
.discovery(
"seed1",
serviceEndpoint ->
new ScalecubeServiceDiscovery(serviceEndpoint)
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(serviceEndpoint))
.options(opts -> opts.memberAlias("seed1")))
.transport(RSocketServiceTransport::new)
.startAwait();
Expand All @@ -34,7 +37,9 @@ public static void main(String[] args) {
.discovery(
"seed2",
serviceEndpoint ->
new ScalecubeServiceDiscovery(serviceEndpoint)
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(serviceEndpoint))
.options(opts -> opts.memberAlias("seed2")))
.transport(RSocketServiceTransport::new)
.startAwait();
Expand All @@ -47,7 +52,9 @@ public static void main(String[] args) {
.discovery(
"ms1",
endpoint ->
new ScalecubeServiceDiscovery(endpoint)
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(endpoint))
.options(opts -> opts.memberAlias("ms1"))
.membership(cfg -> cfg.seedMembers(seed1Address)))
.transport(RSocketServiceTransport::new)
Expand All @@ -59,7 +66,9 @@ public static void main(String[] args) {
.discovery(
"ms2",
endpoint ->
new ScalecubeServiceDiscovery(endpoint)
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(endpoint))
.options(opts -> opts.memberAlias("ms2"))
.membership(cfg -> cfg.seedMembers(seed2Address)))
.transport(RSocketServiceTransport::new)
Expand All @@ -71,13 +80,17 @@ public static void main(String[] args) {
.discovery(
"domain1",
endpoint ->
new ScalecubeServiceDiscovery(endpoint)
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(endpoint))
.options(opts -> opts.memberAlias("domain1"))
.membership(cfg -> cfg.seedMembers(seed1Address)))
.discovery(
"domain2",
endpoint ->
new ScalecubeServiceDiscovery(endpoint)
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(endpoint))
.options(opts -> opts.memberAlias("domain2"))
.membership(cfg -> cfg.seedMembers(seed2Address)))
.transport(RSocketServiceTransport::new)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.scalecube.services.ServiceInfo;
import io.scalecube.services.discovery.ScalecubeServiceDiscovery;
import io.scalecube.services.transport.rsocket.RSocketServiceTransport;
import io.scalecube.transport.netty.websocket.WebsocketTransportFactory;
import java.util.Collections;

public class ExceptionMapperExample {
Expand All @@ -18,7 +19,12 @@ public class ExceptionMapperExample {
public static void main(String[] args) throws InterruptedException {
Microservices ms1 =
Microservices.builder()
.discovery("ms1", ScalecubeServiceDiscovery::new)
.discovery(
"ms1",
serviceEndpoint ->
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(serviceEndpoint)))
.transport(RSocketServiceTransport::new)
.defaultErrorMapper(new ServiceAProviderErrorMapper()) // default mapper for whole node
.services(
Expand All @@ -36,7 +42,9 @@ public static void main(String[] args) throws InterruptedException {
.discovery(
"ms2",
endpoint ->
new ScalecubeServiceDiscovery(endpoint)
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(endpoint))
.membership(cfg -> cfg.seedMembers(address1)))
.transport(RSocketServiceTransport::new)
.services(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.scalecube.services.examples.helloworld.service.GreetingServiceImpl;
import io.scalecube.services.examples.helloworld.service.api.GreetingsService;
import io.scalecube.services.transport.rsocket.RSocketServiceTransport;
import io.scalecube.transport.netty.websocket.WebsocketTransportFactory;
import reactor.core.publisher.Mono;

/**
Expand All @@ -27,7 +28,12 @@ public static void main(String[] args) {
// ScaleCube Node node with no members
Microservices seed =
Microservices.builder()
.discovery("seed", ScalecubeServiceDiscovery::new)
.discovery(
"seed",
serviceEndpoint ->
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(serviceEndpoint)))
.transport(RSocketServiceTransport::new)
.startAwait();

Expand All @@ -39,7 +45,9 @@ public static void main(String[] args) {
.discovery(
"ms",
endpoint ->
new ScalecubeServiceDiscovery(endpoint)
new ScalecubeServiceDiscovery()
.transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory()))
.options(opts -> opts.metadata(endpoint))
.membership(cfg -> cfg.seedMembers(seedAddress)))
.transport(RSocketServiceTransport::new)
.services(new GreetingServiceImpl())
Expand Down
Loading

0 comments on commit 413708c

Please sign in to comment.