* @param timeInMillis time last seen
* @param state whether record was added through dynamic discovery
*/
- LastSeenHost(InetSocketAddress address, long timeInMillis, STATE state) {
+ public LastSeenHost(InetSocketAddress address, long timeInMillis, STATE state) {
this.address = address;
this.timeInMillis = timeInMillis;
this.state = state;
*
* @param host
*/
- LastSeenHost(InetSocketAddress host) {
+ public LastSeenHost(InetSocketAddress host) {
this(host, System.currentTimeMillis(), STATE.DYNAMIC);
}
+ /**
+ * Construct a new instance of with user-defined STATE.
+ *
+ * @param host
+ */
+ public LastSeenHost(InetSocketAddress host, STATE state) {
+ this(host, System.currentTimeMillis(), state);
+ }
/**
* Formatted string representation of InetAddress and timestamp.
* @return the representation
java.util.Enumeration<String> keys = this._serviceToAddressMap.keys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
-
- // XXX: special handling for "all" target - never remove it
LastSeenHost host = _serviceToAddressMap.get(key);
if (host != null && host.state == LastSeenHost.STATE.DYNAMIC) {
if (host.timeInMillis < expireTime) {
return result;
}
- public void put(String service, LastSeenHost host) {
- this._serviceToAddressMap.put(service, host);
+ /**
+ * Add an entry to the known services list.
+ * @param service Service name at this unique host IP address/port combination
+ * @param host new host record
+ * @return Host record previously associated with this service, or null if key didn't exist
+ */
+ public LastSeenHost put(String service, LastSeenHost host) {
+ return this._serviceToAddressMap.put(service, host);
}
+ /**
+ * Get the host record associated with a service.
+ * @param service Service name required
+ * @return Host record associated with this service, or null if service isn't known
+ */
public LastSeenHost get(String service) {
return this._serviceToAddressMap.get(service);
}
+
+ /**
+ *
+ * @param service
+ * @return
+ */
+ public boolean containsService(String service) {
+ return this._serviceToAddressMap.containsKey(service);
+ }
}