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