|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.veraxsystems.icmp.ping.handlers.BlockingPing
public class BlockingPing
The implementation of PingResponseHandler
for synchronous processing of ICMP EchoRequests
using asynchronous Ping.echo
method.
The synchronous (blocking) BlockingPing.echo
method is defined by this class.
It sends several ICMP EchoRequests to the set of address provided as input parameter. At the end of
request processing the appropriate overridden methods of PingResponseHandler
are executed.
Each received result is converted to PingResult
object and assigned to appropriate
entry of internal result array. Additionally, the count down semaphore is decreased
so BlockingPing.echo
method waits until all requests are processed - this way the
synchronous behavior is achieved.
Constructor Summary | |
---|---|
BlockingPing()
|
Method Summary | |
---|---|
PingResult[] |
echo(java.net.InetAddress[] addresses,
byte[] dataToSend,
int dataLength,
int timeout)
Send the set of ICMP echo requests. |
void |
handleException(PingRequest request,
java.lang.Exception exception)
Method called by Ping in case exception occurred when receiving ICMP echo response. |
void |
handleResponse(PingRequest request,
IcmpEchoResponse response)
Method called by Ping on receiving proper ICMP echo response. |
void |
handleTimeout(PingRequest request)
Method called by Ping in case timeout occurred when receiving ICMP echo response. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BlockingPing()
Method Detail |
---|
public void handleResponse(PingRequest request, IcmpEchoResponse response)
PingResponseHandler
handleResponse
in interface PingResponseHandler
request
- the descriptor of request issued by echo()
methodresponse
- ICMP response receivedpublic void handleTimeout(PingRequest request)
PingResponseHandler
handleTimeout
in interface PingResponseHandler
request
- the descriptor of request issued by echo()
methodpublic void handleException(PingRequest request, java.lang.Exception exception)
PingResponseHandler
Ping
class so it is very probable it
will not work any more.
handleException
in interface PingResponseHandler
request
- the descriptor of request issued by echo()
methodexception
- exception occurredpublic PingResult[] echo(java.net.InetAddress[] addresses, byte[] dataToSend, int dataLength, int timeout) throws PingErrorException
Each echo result is placed in array of results corresponding to addresses
parameter (it means for each input host
the result is placed in corresponding element of result array).
Each request timeout is calculated separately - it means that its calculation starts in the moment
when request is sent (not when echo
method is called). Such behavior leads to
situation that echo
execution lasts slightly longer than timeout specified.
Method reports exception when either Ping
is not initialized or current thread is interrupted.
addresses
- array of host addresses send ICMP echo requestsdataToSend
- data to be send as part of ICMP message (when null the default data is used)dataLength
- length of data to be senttimeout
- expressed in milliseconds time to wait for echo response
PingErrorException
- issued if Ping class is not initialized or thread is interrupted
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |