/** * Create address. * * @param host host * @param port port * @return address */ public static Address create(String host, int port) { return new Address(host, port); }
private Address toServicesAddress(io.scalecube.transport.Address address) { return Address.create(address.host(), address.port()); }
private Mono<ServiceTransportBootstrap> start(ServiceMethodRegistry methodRegistry) { return Mono.defer( () -> { this.transport = Optional.ofNullable(this.transport).orElseGet(ServiceTransport::getTransport); this.transportResources = transport.resources(numOfThreads); this.clientTransport = transport.clientTransport(transportResources); this.serverTransport = transport.serverTransport(transportResources); // bind service serverTransport transport return serverTransport .bind(servicePort, methodRegistry) .map( listenAddress -> { // prepare service host:port for exposing int port = listenAddress.getPort(); String host = Optional.ofNullable(serviceHost) .orElseGet(() -> Address.getLocalIpAddress().getHostAddress()); this.serviceAddress = InetSocketAddress.createUnresolved(host, port); return this; }); }); }
private Address toServicesAddress(io.scalecube.transport.Address address) { return Address.create(address.host(), address.port()); }
private Mono<ServiceTransportBootstrap> start(ServiceMethodRegistry methodRegistry) { return Mono.defer( () -> { this.transport = Optional.ofNullable(this.transport).orElseGet(ServiceTransport::getTransport); this.transportResources = transport.resources(numOfThreads); this.clientTransport = transport.clientTransport(transportResources); this.serverTransport = transport.serverTransport(transportResources); // bind service serverTransport transport return serverTransport .bind(servicePort, methodRegistry) .map( listenAddress -> { // prepare service host:port for exposing int port = listenAddress.getPort(); String host = Optional.ofNullable(serviceHost) .orElseGet(() -> Address.getLocalIpAddress().getHostAddress()); this.serviceAddress = InetSocketAddress.createUnresolved(host, port); return this; }); }); }
/** * Constructor for service reference. * * @param serviceMethodDefinition service method info * @param serviceRegistration service registration * @param serviceEndpoint service node info */ public ServiceReference( ServiceMethodDefinition serviceMethodDefinition, ServiceRegistration serviceRegistration, ServiceEndpoint serviceEndpoint) { this.endpointId = serviceEndpoint.id(); this.host = serviceEndpoint.host(); this.port = serviceEndpoint.port(); this.namespace = serviceRegistration.namespace(); this.contentTypes = Collections.unmodifiableSet(serviceEndpoint.contentTypes()); this.tags = mergeTags(serviceMethodDefinition, serviceRegistration, serviceEndpoint); this.action = serviceMethodDefinition.getAction(); this.mode = serviceMethodDefinition.getCommunicationMode(); this.qualifier = Qualifier.asString(namespace, action); this.address = Address.create(this.host(), this.port()); }
/** * Create address. * * @param hostAndPort host:port * @return address */ public static Address from(String hostAndPort) { String[] split = hostAndPort.split(":"); if (split.length != 2) { throw new IllegalArgumentException(); } String host = split[0]; int port = Integer.parseInt(split[1]); return new Address(host, port); }