import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
static final String ACTIVE_HOST_CACHE = "hosttracker.ActiveHosts";
static final String INACTIVE_HOST_CACHE = "hosttracker.InactiveHosts";
private static final Logger logger = LoggerFactory.getLogger(HostTracker.class);
- protected IHostFinder hostFinder;
+ protected final Set<IHostFinder> hostFinder = new CopyOnWriteArraySet<IHostFinder>();;
protected ConcurrentMap<InetAddress, HostNodeConnector> hostsDB;
/*
* Following is a list of hosts which have been requested by NB APIs to be
}
public void setArpHandler(IHostFinder hostFinder) {
- this.hostFinder = hostFinder;
+ if (this.hostFinder != null) {
+ this.hostFinder.add(hostFinder);
+ }
}
public void unsetArpHandler(IHostFinder hostFinder) {
- if (this.hostFinder == hostFinder) {
+ if (this.hostFinder != null) {
logger.debug("Arp Handler Service removed!");
- this.hostFinder = null;
+ this.hostFinder.remove(hostFinder);
}
}
networkAddress.getHostAddress());
/* host is not found, initiate a discovery */
-
- hostFinder.find(networkAddress);
+ for (IHostFinder hf : hostFinder) {
+ hf.find(networkAddress);
+ }
return null;
}
@Override
public void hostListener(HostNodeConnector host) {
-
- logger.debug("ARP received for Host: IP {}, MAC {}, {}", host.getNetworkAddress().getHostAddress(),
+ logger.debug("Received for Host: IP {}, MAC {}, {}", host.getNetworkAddress().getHostAddress(),
HexEncode.bytesToHexString(host.getDataLayerAddressBytes()), host);
if (hostExists(host)) {
HostNodeConnector existinghost = hostsDB.get(host.getNetworkAddress());
continue;
}
logger.debug("Sending the ARP from FailedARPReqList fors IP: {}", arphost.getHostIP().getHostAddress());
- hostFinder.find(arphost.getHostIP());
+ for (IHostFinder hf : hostFinder) {
+ hf.find(arphost.getHostIP());
+ }
}
}
}
logger.warn("ARPHandler Services are not available for Outstanding ARPs");
continue;
}
- hostFinder.find(arphost.getHostIP());
+ for (IHostFinder hf : hostFinder) {
+ hf.find(arphost.getHostIP());
+ }
arphost.sent_count++;
logger.debug("ARP Sent from ARPPending List, IP: {}", arphost.getHostIP().getHostAddress());
} else if (arphost.getSent_count() >= hostRetryCount) {
logger.trace("ARPHandler is not avaialable, can't send the probe");
continue;
}
- hostFinder.probe(host);
+ for (IHostFinder hf : hostFinder) {
+ hf.probe(host);
+ }
}
}
}
try {
byte[] dataLayerAddress = NetUtils.getBroadcastMACAddr();
host = new HostNodeConnector(dataLayerAddress, arphost.getHostIP(), nodeConnector, (short) 0);
- hostFinder.probe(host);
+ for (IHostFinder hf : hostFinder) {
+ hf.probe(host);
+ }
} catch (ConstructionException e) {
logger.debug("HostNodeConnector couldn't be created for Host: {}, NodeConnector: {}",
arphost.getHostIP(), nodeConnector);