Package pt.ulisboa.tecnico.sdis.zk
Class ZKNaming
- java.lang.Object
-
- pt.ulisboa.tecnico.sdis.zk.ZKNaming
-
public class ZKNaming extends Object
This class defines simple methods to bind service names to URI addresses: list, lookup, unbind, bind, rebind.- Author:
- Rui Claro
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(String path, String URI)Binds the specified path with a URIvoidbind(String path, String host, String port)Binds the specified path with a host port pairvoidbind(ZKRecord record)Binds the specified record containing a path and a URI pairCollection<ZKRecord>listRecords(String path)Returns a collection of records representing the child nodes of a zNode.ZKRecordlookup(String path)Returns the record associated with the specified path.voidrebind(String path, String URI)Rebinds the specified path with a URIvoidrebind(String path, String host, String port)Rebinds the specified path with a host port pairvoidrebind(ZKRecord record)Rebinds the specified record.voidunbind(String path, String URI)Destroys the binding for the specified path with a URI.voidunbind(String path, String host, String port)Destroys the binding for the specified path with a host port pair.voidunbind(ZKRecord record)Destroys the binding for the specified record.
-
-
-
Method Detail
-
bind
public void bind(ZKRecord record) throws ZKNamingException
Binds the specified record containing a path and a URI pair- Parameters:
record- record to register- Throws:
ZKNamingException- If bind fails
-
bind
public void bind(String path, String host, String port) throws ZKNamingException
Binds the specified path with a host port pair- Parameters:
path- Path to the zNodehost- service hostport- service port- Throws:
ZKNamingException- If bind fails
-
bind
public void bind(String path, String URI) throws ZKNamingException
Binds the specified path with a URI- Parameters:
path- Path to the zNodeURI- URI in the format host:port- Throws:
ZKNamingException- If bind fails
-
rebind
public void rebind(ZKRecord record) throws ZKNamingException
Rebinds the specified record. Existing record is overridden.- Parameters:
record- record to register- Throws:
ZKNamingException- If rebind fails
-
rebind
public void rebind(String path, String URI) throws ZKNamingException
Rebinds the specified path with a URI- Parameters:
path- Path to the zNodeURI- URI in the format host:port- Throws:
ZKNamingException- If rebind fails
-
rebind
public void rebind(String path, String host, String port) throws ZKNamingException
Rebinds the specified path with a host port pair- Parameters:
path- Path to the zNodehost- service hostport- service port- Throws:
ZKNamingException- If rebind fails
-
unbind
public void unbind(ZKRecord record) throws ZKNamingException
Destroys the binding for the specified record.- Parameters:
record- record to delete- Throws:
ZKNamingException- if unbind fails
-
unbind
public void unbind(String path, String URI) throws ZKNamingException
Destroys the binding for the specified path with a URI.- Parameters:
path- Path to the zNodeURI- URI in the format host:port- Throws:
ZKNamingException- if unbind fails
-
unbind
public void unbind(String path, String host, String port) throws ZKNamingException
Destroys the binding for the specified path with a host port pair.- Parameters:
path- Path to the zNodehost- service hostport- service port- Throws:
ZKNamingException- If unbind fails
-
lookup
public ZKRecord lookup(String path) throws ZKNamingException
Returns the record associated with the specified path.- Parameters:
path- Path to the zNode- Returns:
- Record object with associated path and URI
- Throws:
ZKNamingException- if lookup fails
-
listRecords
public Collection<ZKRecord> listRecords(String path) throws ZKNamingException
Returns a collection of records representing the child nodes of a zNode.- Parameters:
path- Path to the parent zNode- Returns:
- Collection of record matching the children of provided zNode
- Throws:
ZKNamingException- if listRecords fails
-
-