org.ow2.jonas.discovery.jgroups.utils
Class JGroupsDiscoveryUtils

java.lang.Object
  extended by org.ow2.jonas.discovery.base.DiscHelper
      extended by org.ow2.jonas.discovery.jgroups.utils.JGroupsDiscoveryUtils

public class JGroupsDiscoveryUtils
extends DiscHelper


Field Summary
static String DEF_GROUP_NAME
          Default group name for discovery channel.
static String DEFAULT_DOMAIN_NAME
          The default domain name.
static String DEFAULT_JONAS_NAME
          The jonas name.
static String DEFAULT_SERVER_ID
          The default server Id.
static String DEFAULT_STACK_FILENAME
          Default file name for the stack.
static String DISCOVERY_GREETING_IP
          The default greeting Ip.
static String DISCOVERY_GREETING_PORT_DEFAULT
          The default greeting port name.
static String DISCOVERY_GREETING_TIMEOUT_DEFAULT
          The default JGroups discovery timeout.
static String DISCOVERY_IS_CLUSTERD
          The default key for discovery master started by clusterd.
static String DISCOVERY_IS_MASTER
          The default key for discovery master started by JOnAS server.
static String DISCOVERY_IS_SLAVE
          The default key for discovery slave started by JOnAS server.
static String DISCOVERY_PROTOCOL_VERSION
          The JGroups discovery version.
static boolean duplicateExceptionName
          Used by greeting receiver and communication manager.
static String JGROUPS_CONFIG_PROPERTY
          default Jgroups discovery configuration file property name.
 
Method Summary
static Object bytesToObject(Data data)
          Convert network datas into a discovey communication object.
static void closeChannel()
          Close JGroups channel.
static void connectChannel()
          Connect the channel.
static DiscGreeting createDiscGreeting(boolean startup)
          Create a discovery greeting message.
static DiscEvent createNotifMessage(String state)
          Create a discovery event to notify about a state change of the event sender
static DiscEvent createNotifMessageForClusterd(String state)
          Create a discovery event to notify about a state change of the event sender
static void disconnectChannel()
          dDsconnect the channel.
 org.ow2.util.cluster.jgroups.IChannel getChannel()
          Gets the channel
static DiscoveryUtils getInstance()
          Gets Discovery utils instance.
static String getMulticastAddress()
          Gets Multicast address.
static String getMulticastPort()
          Gets Multicast port.
static void init(String srvName, String domain, String discoveryType, String confFileName, String discoveryGroup, MBeanServer beanServer, String[] connUrls, long reconnectionTimeout)
          Initializes properties of the discovery(groupname, stackfile, channel...).
static Data objectToBytes(Serializable obj)
          Construct a byte[] containing type info about a DiscMessage object to be sent, plus the content of this message.
static void send(org.jgroups.Address dest, Serializable msg)
          Sends a given message to the given dest.
 void setChannel(org.ow2.util.cluster.jgroups.IChannel channel)
          Sets the channel
 
Methods inherited from class org.ow2.jonas.discovery.base.DiscHelper
bytesToObject, objectToBytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

duplicateExceptionName

public static boolean duplicateExceptionName
Used by greeting receiver and communication manager. to handle duplicate server name exception


JGROUPS_CONFIG_PROPERTY

public static final String JGROUPS_CONFIG_PROPERTY
default Jgroups discovery configuration file property name.

See Also:
Constant Field Values

DEFAULT_STACK_FILENAME

public static final String DEFAULT_STACK_FILENAME
Default file name for the stack.

See Also:
Constant Field Values

DEFAULT_JONAS_NAME

public static final String DEFAULT_JONAS_NAME
The jonas name.

See Also:
Constant Field Values

DEFAULT_DOMAIN_NAME

public static final String DEFAULT_DOMAIN_NAME
The default domain name.

See Also:
Constant Field Values

DEFAULT_SERVER_ID

public static final String DEFAULT_SERVER_ID
The default server Id.

See Also:
Constant Field Values

DISCOVERY_GREETING_PORT_DEFAULT

public static final String DISCOVERY_GREETING_PORT_DEFAULT
The default greeting port name.

See Also:
Constant Field Values

DISCOVERY_GREETING_IP

public static final String DISCOVERY_GREETING_IP
The default greeting Ip.

See Also:
Constant Field Values

DISCOVERY_PROTOCOL_VERSION

public static final String DISCOVERY_PROTOCOL_VERSION
The JGroups discovery version.

See Also:
Constant Field Values

DISCOVERY_GREETING_TIMEOUT_DEFAULT

public static final String DISCOVERY_GREETING_TIMEOUT_DEFAULT
The default JGroups discovery timeout.

See Also:
Constant Field Values

DISCOVERY_IS_MASTER

public static final String DISCOVERY_IS_MASTER
The default key for discovery master started by JOnAS server.

See Also:
Constant Field Values

DISCOVERY_IS_SLAVE

public static final String DISCOVERY_IS_SLAVE
The default key for discovery slave started by JOnAS server.

See Also:
Constant Field Values

DISCOVERY_IS_CLUSTERD

public static final String DISCOVERY_IS_CLUSTERD
The default key for discovery master started by clusterd.

See Also:
Constant Field Values

DEF_GROUP_NAME

public static final String DEF_GROUP_NAME
Default group name for discovery channel.

See Also:
Constant Field Values
Method Detail

getChannel

public org.ow2.util.cluster.jgroups.IChannel getChannel()
Gets the channel

Returns:
the channel.

setChannel

public void setChannel(org.ow2.util.cluster.jgroups.IChannel channel)
Sets the channel

Parameters:
channel - the channel to set

init

public static void init(String srvName,
                        String domain,
                        String discoveryType,
                        String confFileName,
                        String discoveryGroup,
                        MBeanServer beanServer,
                        String[] connUrls,
                        long reconnectionTimeout)
                 throws Throwable
Initializes properties of the discovery(groupname, stackfile, channel...).

Parameters:
srvName - The host name of discovery.
domain - The domain name of discovery's host.
discoveryType - The discovery type.
confFileName - The file name of JGroups stack.
discoveryGroup - The group of JGroups discovery (channel connection)
beanServer - The Mbean server of discovery's host.
connUrls - Connectors urls of discovery hosts.
Throws:
Throwable

connectChannel

public static void connectChannel()
                           throws org.jgroups.ChannelException
Connect the channel.

Throws:
org.jgroups.ChannelException

disconnectChannel

public static void disconnectChannel()
                              throws org.jgroups.ChannelException
dDsconnect the channel.

Throws:
org.jgroups.ChannelException

createDiscGreeting

public static DiscGreeting createDiscGreeting(boolean startup)
                                       throws UnknownHostException
Create a discovery greeting message.

Parameters:
startup - - true: means that is a greeting message at the point of start up of the discovery service. false: means this is a reply to a previous greeting message.
Returns:
a Discovery Greeting message.
Throws:
UnknownHostException - If host is unknown

bytesToObject

public static Object bytesToObject(Data data)
                            throws IOException,
                                   ClassNotFoundException
Convert network datas into a discovey communication object.

Parameters:
data -
Returns:
DiscGreeting || DiscMessage || DiscEvent
Throws:
IOException
ClassNotFoundException

objectToBytes

public static Data objectToBytes(Serializable obj)
                          throws IOException
Construct a byte[] containing type info about a DiscMessage object to be sent, plus the content of this message.

Parameters:
obj - Object to be send. Only supported DiscMessage objects.
Returns:
Null if the object is not an instance of DiscMessage or one of its subclasses.
Throws:
IOException - Could not create an ObjectOutputStream to write into the underlying ByteArrayOutputStream.

createNotifMessage

public static DiscEvent createNotifMessage(String state)
                                    throws Exception
Create a discovery event to notify about a state change of the event sender

Parameters:
state - - RUNNING if the sender notifies that it gets running - STOPPING if the sender notifies that it stops running
Returns:
a Discovery event (notification)
Throws:
Exception - is thrown if the jmx service is not reached.

createNotifMessageForClusterd

public static DiscEvent createNotifMessageForClusterd(String state)
                                               throws Exception
Create a discovery event to notify about a state change of the event sender

Parameters:
state - - RUNNING if the sender notifies that it gets running - STOPPING if the sender notifies that it stops running
Returns:
a Discovery event (notification)
Throws:
Exception - is thrown if the jmx service is not reached.

send

public static void send(org.jgroups.Address dest,
                        Serializable msg)
                 throws Exception
Sends a given message to the given dest.

Parameters:
dest - The message destination.
msg - The message to send.
Throws:
Exception - Any.

closeChannel

public static void closeChannel()
Close JGroups channel.


getMulticastAddress

public static String getMulticastAddress()
                                  throws Exception
Gets Multicast address.

Returns:
Multicast address
Throws:
Exception

getMulticastPort

public static String getMulticastPort()
                               throws Exception
Gets Multicast port.

Returns:
Multicast address
Throws:
Exception

getInstance

public static DiscoveryUtils getInstance()
Gets Discovery utils instance.

Returns:


Copyright © 2010 OW2 Consortium. All Rights Reserved.