use of org.apache.curator.x.discovery.ServiceType in project oozie by apache.
the class FixedJsonInstanceSerializer method deserialize.
@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();
}
Aggregations