All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JavaGroups.Util

java.lang.Object
   |
   +----JavaGroups.Util

public class Util
extends Object
Collection of various utility routines that can not be assigned to other classes.


Constructor Index

 o Util()

Method Index

 o Array2String(boolean[])
 o Array2String(int[])
 o Array2String(long[])
 o Crash()
 o DefragmentBuffer(byte[][])
Concatenates smaller fragments into entire buffers.
 o DumpStack(boolean)
 o FragmentBuffer(byte[], int)
Fragments a byte buffer into smaller fragments of (max.) frag_size.
 o main(String[])
 o ObjectFromByteBuffer(byte[])
Creates an object from a byte buffer
 o ObjectToByteBuffer(Object)
Serializes an object into a byte buffer.
 o PeekViews(Channel, int, long)
Peeks for view on the channel until n views have been received or timeout has elapsed.
 o PickSubset(Vector, double)
Selects a random subset of members according to subset_percentage and returns them.
 o Print(String)
 o PrintEvent(Event)
 o PrintFragments(byte[][])
 o PrintMessage(Message)
Tries to read an object from the message's buffer and prints it
 o PrintMethodCall(Message)
Tries to read a MethodCall object from the message's buffer and prints it.
 o PrintThreads()
 o Sleep(long)
 o SleepRandom(long)
Sleeps between 1 and timeout milliseconds, chosen randomly.

Constructors

 o Util
 public Util()

Methods

 o ObjectFromByteBuffer
 public static Object ObjectFromByteBuffer(byte buffer[]) throws Exception
Creates an object from a byte buffer

 o ObjectToByteBuffer
 public static byte[] ObjectToByteBuffer(Object obj) throws Exception
Serializes an object into a byte buffer. The object has to implement interface Serializable.

 o Sleep
 public static void Sleep(long timeout)
 o SleepRandom
 public static void SleepRandom(long timeout)
Sleeps between 1 and timeout milliseconds, chosen randomly. Timeout must be > 1

 o DumpStack
 public static void DumpStack(boolean exit)
 o Crash
 public static void Crash()
 o PrintEvent
 public static String PrintEvent(Event evt)
 o PrintMessage
 public static String PrintMessage(Message msg)
Tries to read an object from the message's buffer and prints it

 o PrintMethodCall
 public static String PrintMethodCall(Message msg)
Tries to read a MethodCall object from the message's buffer and prints it. Returns empty string if object is not a method call

 o Print
 public static void Print(String msg)
 o PrintThreads
 public static void PrintThreads()
 o FragmentBuffer
 public static byte[][] FragmentBuffer(byte buf[],
                                       int frag_size)
Fragments a byte buffer into smaller fragments of (max.) frag_size. Example: a byte buffer of 1024 bytes and a frag_size of 248 gives 4 fragments of 248 bytes each and 1 fragment of 32 bytes.

Returns:
An array of byte buffers (byte[]).
 o DefragmentBuffer
 public static byte[] DefragmentBuffer(byte fragments[][])
Concatenates smaller fragments into entire buffers.

Parameters:
fragments - An array of byte buffers (byte[])
Returns:
A byte buffer
 o PrintFragments
 public static void PrintFragments(byte frags[][])
 o PeekViews
 public static View PeekViews(Channel channel,
                              int number_of_views,
                              long timeout)
Peeks for view on the channel until n views have been received or timeout has elapsed. Used to determine the view in which we want to start work. Usually, we start as only member in our own view (1st view) and the next view (2nd view) will be the full view of all members, or a timeout if we're the first member. If a non-view (a message or block) is received, the method returns immediately.

Parameters:
channel - The channel used to peek for views. Has to be operational.
number_of_views - The number of views to wait for. 2 is a good number to ensure that, if there are other members, we start working with them included in our view.
timeout - Number of milliseconds to wait until view is forced to return. A value of <= 0 means wait forever.
 o Array2String
 public static String Array2String(long array[])
 o Array2String
 public static String Array2String(int array[])
 o Array2String
 public static String Array2String(boolean array[])
 o PickSubset
 public static Vector PickSubset(Vector members,
                                 double subset_percentage)
Selects a random subset of members according to subset_percentage and returns them. Picks no member twice from the same membership. If the percentage is smaller than 1 -> picks 1 member.

 o main
 public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index