@Override public int hashCode() { int result = name != null ? name.hashCode() : 0; result = 31 * result + (id != null ? id.hashCode() : 0); result = 31 * result + (address != null ? address.hashCode() : 0); result = 31 * result + (port != null ? port.hashCode() : 0); result = 31 * result + (sslPort != null ? sslPort.hashCode() : 0); result = 31 * result + (payload != null ? payload.hashCode() : 0); result = 31 * result + (int)(registrationTimeUTC ^ (registrationTimeUTC >>> 32)); result = 31 * result + (serviceType != null ? serviceType.hashCode() : 0); result = 31 * result + (uriSpec != null ? uriSpec.hashCode() : 0); return result; }
@PUT @Path("v1/service/{name}/{id}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response putService(ServiceInstance<T> instance, @PathParam("name") String name, @PathParam("id") String id) { if ( !instance.getId().equals(id) || !instance.getName().equals(name) ) { log.info("Request where path id and/or name doesn't match entity"); return Response.status(Response.Status.BAD_REQUEST).build(); } if ( instance.getServiceType().isDynamic() ) { log.info("Service type cannot be dynamic"); return Response.status(Response.Status.BAD_REQUEST).build(); } try { context.getServiceDiscovery().registerService(instance); } catch ( Exception e ) { ThreadUtils.checkInterrupted(e); log.error("Trying to register service", e); return Response.serverError().build(); } return Response.status(Response.Status.CREATED).build(); }
localVariables.put(FIELD_SSL_PORT, nullCheck(serviceInstance.getSslPort())); localVariables.put(FIELD_REGISTRATION_TIME_UTC, nullCheck(serviceInstance.getRegistrationTimeUTC())); localVariables.put(FIELD_SERVICE_TYPE, (serviceInstance.getServiceType() != null) ? serviceInstance.getServiceType().name().toLowerCase() : ""); if ( serviceInstance.getSslPort() != null )
JsonObject payload = instance.getPayload(); record.setMetadata(payload); record.getMetadata().put("zookeeper-service-type", instance.getServiceType().toString()); record.getMetadata().put("zookeeper-address", instance.getAddress()); record.getMetadata().put("zookeeper-registration-time",
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(); }
localVariables.put(FIELD_SSL_PORT, nullCheck(serviceInstance.getSslPort())); localVariables.put(FIELD_REGISTRATION_TIME_UTC, nullCheck(serviceInstance.getRegistrationTimeUTC())); localVariables.put(FIELD_SERVICE_TYPE, (serviceInstance.getServiceType() != null) ? serviceInstance.getServiceType().name().toLowerCase() : ""); if ( serviceInstance.getSslPort() != null )
JsonObject payload = instance.getPayload(); record.setMetadata(payload); record.getMetadata().put("zookeeper-service-type", instance.getServiceType().toString()); record.getMetadata().put("zookeeper-address", instance.getAddress()); record.getMetadata().put("zookeeper-registration-time",
static<T> ObjectNode writeInstance(ObjectMapper mapper, ServiceInstance<T> instance, DiscoveryContext<T> context) { ObjectNode node = mapper.createObjectNode(); node.put("name", instance.getName()); node.put("id", instance.getId()); node.put("address", instance.getAddress()); putInteger(node, "port", instance.getPort()); putInteger(node, "sslPort", instance.getSslPort()); node.put("registrationTimeUTC", instance.getRegistrationTimeUTC()); node.put("serviceType", instance.getServiceType().name()); try { context.marshallJson(node, "payload", instance.getPayload()); } catch ( Exception e ) { ThreadUtils.checkInterrupted(e); throw new WebApplicationException(e); } return node; }
@Override public int hashCode() { int result = name != null ? name.hashCode() : 0; result = 31 * result + (id != null ? id.hashCode() : 0); result = 31 * result + (address != null ? address.hashCode() : 0); result = 31 * result + (port != null ? port.hashCode() : 0); result = 31 * result + (sslPort != null ? sslPort.hashCode() : 0); result = 31 * result + (payload != null ? payload.hashCode() : 0); result = 31 * result + (int)(registrationTimeUTC ^ (registrationTimeUTC >>> 32)); result = 31 * result + (serviceType != null ? serviceType.hashCode() : 0); result = 31 * result + (uriSpec != null ? uriSpec.hashCode() : 0); result = 31 * result + (enabled ? 1 : 0); return result; }
@Override public int hashCode() { int result = name != null ? name.hashCode() : 0; result = 31 * result + (id != null ? id.hashCode() : 0); result = 31 * result + (address != null ? address.hashCode() : 0); result = 31 * result + (port != null ? port.hashCode() : 0); result = 31 * result + (sslPort != null ? sslPort.hashCode() : 0); result = 31 * result + (payload != null ? payload.hashCode() : 0); result = 31 * result + (int)(registrationTimeUTC ^ (registrationTimeUTC >>> 32)); result = 31 * result + (serviceType != null ? serviceType.hashCode() : 0); result = 31 * result + (uriSpec != null ? uriSpec.hashCode() : 0); result = 31 * result + (enabled ? 1 : 0); return result; }