org.apache.hadoop.registry.client.types
Class Endpoint

java.lang.Object
  extended by org.apache.hadoop.registry.client.types.Endpoint
All Implemented Interfaces:
Cloneable

@InterfaceAudience.Public
@InterfaceStability.Evolving
public final class Endpoint
extends Object
implements Cloneable

Description of a single service/component endpoint. It is designed to be marshalled as JSON.

Every endpoint can have more than one address entry, such as a list of URLs to a replicated service, or a (hostname, port) pair. Each of these address entries is represented as a string list, as that is the only reliably marshallable form of a tuple JSON can represent.


Field Summary
 List<Map<String,String>> addresses
          a list of address tuples —tuples whose format depends on the address type
 String addressType
          Type of address.
 String api
          API implemented at the end of the binding
 String protocolType
          Protocol type.
 
Constructor Summary
Endpoint()
          Create an empty instance.
Endpoint(Endpoint that)
          Create an endpoint from another endpoint.
Endpoint(String api, String addressType, String protocolType)
          Build an endpoint with an empty address list
Endpoint(String api, String addressType, String protocolType, List<Map<String,String>> addrs)
          Build an endpoint with a list of addresses
Endpoint(String api, String addressType, String protocolType, Map<String,String>... addrs)
          Build an endpoint with a list of addresses
Endpoint(String api, String addressType, String protocolType, Map<String,String> addr)
          Build an endpoint with a single address entry.
Endpoint(String api, String protocolType, URI... uris)
          Build an endpoint from a list of URIs; each URI is ASCII-encoded and added to the list of addresses.
 
Method Summary
 Object clone()
          Shallow clone: the lists of addresses are shared
 String toString()
           
 void validate()
          Validate the record by checking for null fields and other invalid conditions
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

api

public String api
API implemented at the end of the binding


addressType

public String addressType
Type of address. The standard types are defined in AddressTypes


protocolType

public String protocolType
Protocol type. Some standard types are defined in ProtocolTypes


addresses

public List<Map<String,String>> addresses
a list of address tuples —tuples whose format depends on the address type

Constructor Detail

Endpoint

public Endpoint()
Create an empty instance.


Endpoint

public Endpoint(Endpoint that)
Create an endpoint from another endpoint. This is a deep clone with a new list of addresses.

Parameters:
that - the endpoint to copy from

Endpoint

public Endpoint(String api,
                String addressType,
                String protocolType,
                List<Map<String,String>> addrs)
Build an endpoint with a list of addresses

Parameters:
api - API name
addressType - address type
protocolType - protocol type
addrs - addresses

Endpoint

public Endpoint(String api,
                String addressType,
                String protocolType)
Build an endpoint with an empty address list

Parameters:
api - API name
addressType - address type
protocolType - protocol type

Endpoint

public Endpoint(String api,
                String addressType,
                String protocolType,
                Map<String,String> addr)
Build an endpoint with a single address entry.

This constructor is superfluous given the varags constructor is equivalent for a single element argument. However, type-erasure in java generics causes javac to warn about unchecked generic array creation. This constructor, which represents the common "one address" case, does not generate compile-time warnings.

Parameters:
api - API name
addressType - address type
protocolType - protocol type
addr - address. May be null —in which case it is not added

Endpoint

public Endpoint(String api,
                String addressType,
                String protocolType,
                Map<String,String>... addrs)
Build an endpoint with a list of addresses

Parameters:
api - API name
addressType - address type
protocolType - protocol type
addrs - addresses. Null elements will be skipped

Endpoint

public Endpoint(String api,
                String protocolType,
                URI... uris)
Build an endpoint from a list of URIs; each URI is ASCII-encoded and added to the list of addresses.

Parameters:
api - API name
protocolType - protocol type
uris - URIs to convert to a list of tup;les
Method Detail

toString

public String toString()
Overrides:
toString in class Object

validate

public void validate()
Validate the record by checking for null fields and other invalid conditions

Throws:
NullPointerException - if a field is null when it MUST be set.
RuntimeException - on invalid entries

clone

public Object clone()
             throws CloneNotSupportedException
Shallow clone: the lists of addresses are shared

Overrides:
clone in class Object
Returns:
a cloned instance
Throws:
CloneNotSupportedException


Copyright © 2014 Apache Software Foundation. All Rights Reserved.