package org.opennms.netmgt.ping;

import java.net.InetAddress;

import org.apache.log4j.Category;
import org.opennms.core.concurrent.BarrierSignaler;
import org.opennms.core.utils.ThreadCategory;
import org.opennms.protocols.icmp.ICMPEchoPacket;

public class SinglePingResponseCallback implements PingResponseCallback {
    BarrierSignaler bs = new BarrierSignaler(1);
    Throwable error = null;
    Long responseTime = null;
    
	public void handleResponse(InetAddress address, ICMPEchoPacket packet) {
	    info("got response for address " + address + ", thread " + packet.getTID() + ", seq " + packet.getSequenceId() + " with a responseTime "+packet.getPingRTT());
	    responseTime = packet.getPingRTT();
	    bs.signalAll();
	}

    private Category log() {
        return ThreadCategory.getInstance(this.getClass());
    }

	public void handleTimeout(InetAddress address, ICMPEchoPacket packet) {
	    info("timed out pinging address " + address + ", thread " + packet.getTID() + ", seq " + packet.getSequenceId());
	    bs.signalAll();
	}

    public void handleError(InetAddress address, ICMPEchoPacket pr, Throwable t) {
        info("an error occurred pinging " + address, t);
        error = t;
        bs.signalAll();
    }

    public void waitFor(long timeout) throws InterruptedException {
        bs.waitFor(timeout);
    }
    
    public void waitFor() throws InterruptedException {
        info("waiting to finish");
        bs.waitFor();
    }

    public Long getResponseTime() {
        return responseTime;
    }
    
    public void info(String msg) {
        log().info(msg);
    }
    public void info(String msg, Throwable t) {
        log().info(msg, t);
    }

}

@@ -61,42 +61,8 @@
 s;%0A%0A
-import org.apache.log4j.Category;%0A
 impo
@@ -158,58 +158,8 @@
 ory;
-%0Aimport org.opennms.protocols.icmp.ICMPEchoPacket;
 %0A%0Apu
@@ -234,16 +234,24 @@
 k %7B%0A    
+private 
 BarrierS
@@ -291,16 +291,24 @@
 1);%0A    
+private 
 Throwabl
@@ -327,16 +327,24 @@
 ll;%0A    
+private 
 Long res
@@ -365,18 +365,135 @@
 ll;%0A    
-%0A%09
+private InetAddress m_host;%0A    %0A%09public SinglePingResponseCallback(InetAddress host) %7B%0A%09    m_host = host;%0A    %7D%0A%0A    
 public v
@@ -1475,16 +1475,39 @@
 %22waiting
+ for ping to %22+m_host+%22
  to fini

Add ip address to 'waitFor' log message