org.apache.jcs.utils.discovery
Class UDPDiscoverySender

java.lang.Object
  extended by org.apache.jcs.utils.discovery.UDPDiscoverySender

public class UDPDiscoverySender
extends Object

This is a generic sender for the UDPDiscovery process.

Author:
Aaron Smuts

Constructor Summary
UDPDiscoverySender(String host, int port)
          Constructor for the UDPDiscoverySender object
 
Method Summary
 void destroy()
          Closes the socket connection.
 void finalize()
          Just being careful about closing the socket.
 void passiveBroadcast(String host, int port, ArrayList cacheNames)
          This sends a message broadcasting out that the host and port is available for connections.
protected  void passiveBroadcast(String host, int port, ArrayList cacheNames, long listenerId)
          This allows you to set the sender id.
 void removeBroadcast(String host, int port, ArrayList cacheNames)
          This sends a message broadcasting our that the host and port is no longer available.
protected  void removeBroadcast(String host, int port, ArrayList cacheNames, long listenerId)
          This allows you to set the sender id.
 void requestBroadcast()
          Ask other to broadcast their info the the multicast address.
 void send(UDPDiscoveryMessage message)
          Send messages.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UDPDiscoverySender

public UDPDiscoverySender(String host,
                          int port)
                   throws IOException
Constructor for the UDPDiscoverySender object

This sender can be used to send multiple messages.

When you are done sending, you should destroy the socket sender.

Parameters:
host -
port -
Throws:
IOException
Method Detail

destroy

public void destroy()
Closes the socket connection.


finalize

public void finalize()
              throws Throwable
Just being careful about closing the socket.

Overrides:
finalize in class Object
Throws:
Throwable

send

public void send(UDPDiscoveryMessage message)
          throws IOException
Send messages.

Parameters:
message -
Throws:
IOException

requestBroadcast

public void requestBroadcast()
                      throws IOException
Ask other to broadcast their info the the multicast address. If a lateral is non receiving it can use this. This is also called on startup so we can get info.

Throws:
IOException

passiveBroadcast

public void passiveBroadcast(String host,
                             int port,
                             ArrayList cacheNames)
                      throws IOException
This sends a message broadcasting out that the host and port is available for connections.

It uses the vmid as the requesterDI

Parameters:
host -
port -
cacheNames -
Throws:
IOException

passiveBroadcast

protected void passiveBroadcast(String host,
                                int port,
                                ArrayList cacheNames,
                                long listenerId)
                         throws IOException
This allows you to set the sender id. This is mainly for testing.

Parameters:
host -
port -
cacheNames - names of the cache regions
listenerId -
Throws:
IOException

removeBroadcast

public void removeBroadcast(String host,
                            int port,
                            ArrayList cacheNames)
                     throws IOException
This sends a message broadcasting our that the host and port is no longer available.

It uses the vmid as the requesterID

Parameters:
host - host
port - port
cacheNames - names of the cache regions
Throws:
IOException - on error

removeBroadcast

protected void removeBroadcast(String host,
                               int port,
                               ArrayList cacheNames,
                               long listenerId)
                        throws IOException
This allows you to set the sender id. This is mainly for testing.

Parameters:
host - host
port - port
cacheNames - names of the cache regions
listenerId - listener ID
Throws:
IOException - on error


Copyright © 2002-2012 Apache Software Foundation. All Rights Reserved.