2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 * Provides a mechanism for applications to do an inline Host Discovery as opposed
11 * to a delayed discovery
13 package org.opendaylight.controller.hosttracker.internal;
16 * This Class provides methods to discover Host through a blocking call
17 * mechanism. Applications can make use of these methods if they don't
18 * find a host in HostTracker's database and want to discover the host
19 * in the same thread without being called by a callback function.
21 import java.net.InetAddress;
22 import java.util.concurrent.Callable;
23 import java.util.concurrent.CountDownLatch;
25 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
27 public class HostTrackerCallable implements Callable<HostNodeConnector> {
29 InetAddress trackedHost;
30 HostTracker hostTracker;
31 protected CountDownLatch latch;
33 public HostTrackerCallable(HostTracker tracker, InetAddress inet) {
35 hostTracker = tracker;
36 latch = new CountDownLatch(1);
40 public HostNodeConnector call() throws Exception {
41 HostNodeConnector h = hostTracker.hostFind(trackedHost);
44 hostTracker.setCallableOnPendingARP(trackedHost, this);
46 return hostTracker.hostQuery(trackedHost);
49 public void wakeup() {
50 this.latch.countDown();