Java Code Examples for org.apache.curator.x.discovery.ServiceInstanceBuilder#id()
The following examples show how to use
org.apache.curator.x.discovery.ServiceInstanceBuilder#id() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZooKeeperDiscovery.java From soabase with Apache License 2.0 | 6 votes |
private ServiceInstance<Payload> buildInstance(String serviceName, HostAndPort mainPort, Payload payload, String id, String address) throws Exception { ServiceInstanceBuilder<Payload> builder = ServiceInstance.<Payload>builder() .name(serviceName) .payload(payload) .address(mainPort.getHostText()) .port(mainPort.getPort()) ; if ( id != null ) { builder = builder.id(id); } if ( address != null ) { builder = builder.address(address); } else if ( bindAddress != null ) { builder = builder.address(bindAddress); } return builder.build(); }
Example 2
Source File: JsonServiceInstanceMarshaller.java From curator with Apache License 2.0 | 6 votes |
static<T> ServiceInstance<T> readInstance(JsonNode node, DiscoveryContext<T> context) throws Exception { ServiceInstanceBuilder<T> builder = ServiceInstance.builder(); builder.name(node.get("name").asText()); builder.id(node.get("id").asText()); builder.address(node.get("address").asText()); builder.registrationTimeUTC(node.get("registrationTimeUTC").asLong()); builder.serviceType(ServiceType.valueOf(node.get("serviceType").asText())); builder.payload(context.unMarshallJson(node.get("payload"))); Integer port = getInteger(node, "port"); Integer sslPort = getInteger(node, "sslPort"); if ( port != null ) { builder.port(port); } if ( sslPort != null ) { builder.sslPort(sslPort); } return builder.build(); }
Example 3
Source File: DrillServiceInstanceHelper.java From Bats with Apache License 2.0 | 5 votes |
@Override public ServiceInstance<DrillbitEndpoint> deserialize(byte[] bytes) throws Exception { DrillServiceInstance i = DrillServiceInstance.parseFrom(bytes); ServiceInstanceBuilder<DrillbitEndpoint> b = ServiceInstance.<DrillbitEndpoint>builder(); b.id(i.getId()); b.name(ExecConstants.SERVICE_NAME); b.registrationTimeUTC(i.getRegistrationTimeUTC()); b.payload(i.getEndpoint()); return b.build(); }
Example 4
Source File: ServiceInstanceHelper.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public ServiceInstance<NodeEndpoint> deserialize(byte[] bytes) throws Exception { DremioServiceInstance i = DremioServiceInstance.parseFrom(bytes); ServiceInstanceBuilder<NodeEndpoint> b = ServiceInstance.<NodeEndpoint>builder(); b.id(i.getId()); b.name(i.getName()); b.registrationTimeUTC(i.getRegistrationTimeUTC()); b.payload(i.getEndpoint()); return b.build(); }
Example 5
Source File: FixedJsonInstanceSerializer.java From incubator-sentry with Apache License 2.0 | 4 votes |
@Override public ServiceInstance<T> deserialize(final byte[] pBytes) throws Exception { final ByteArrayInputStream bais = new ByteArrayInputStream(pBytes); final JsonNode rootNode = mMapper.readTree(bais); final ServiceInstanceBuilder<T> builder = ServiceInstance.builder(); { final String address = getTextField(rootNode, "address"); if (address != null) { builder.address(address); } } { final String id = getTextField(rootNode, "id"); if (id != null) { builder.id(id); } } { final String name = getTextField(rootNode, "name"); if (name != null) { builder.name(name); } } { final Integer port = getIntegerField(rootNode, "port"); if (port != null) { builder.port(port); } } { final Integer sslPort = getIntegerField(rootNode, "sslPort"); if (sslPort != null) { builder.sslPort(sslPort); } } { final Long registrationTimeUTC = getLongField(rootNode, "registrationTimeUTC"); if (registrationTimeUTC != null) { builder.registrationTimeUTC(registrationTimeUTC); } } { final T payload = getObject(rootNode, "payload", mPayloadClass); if (payload != null) { builder.payload(payload); } } { final ServiceType serviceType = getObject(rootNode, "serviceType", ServiceType.class); if (serviceType != null) { builder.serviceType(serviceType); } } { final UriSpec uriSpec = getObject(rootNode, "uriSpec", UriSpec.class); if (uriSpec != null) { builder.uriSpec(uriSpec); } } return builder.build(); }