|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jgroups.util.Util
public class Util
Collection of various utility routines that can not be assigned to other classes.
Nested Class Summary | |
---|---|
static class |
Util.AddressScope
|
Field Summary | |
---|---|
protected static int |
CCHM_CONCURRENCY_LEVEL
|
protected static int |
CCHM_INITIAL_CAPACITY
|
protected static float |
CCHM_LOAD_FACTOR
|
static int |
MAX_LIST_PRINT_SIZE
The max size of an address list, e.g. |
static int |
MAX_PORT
|
protected static java.util.ResourceBundle |
resource_bundle
|
Constructor Summary | |
---|---|
Util()
|
Method Summary | ||
---|---|---|
protected static void |
_printThreads(java.lang.management.ThreadMXBean bean,
long[] ids,
java.lang.StringBuilder sb)
|
|
static java.lang.String |
activeThreads()
|
|
static void |
addFlush(Channel ch,
FLUSH flush)
|
|
static boolean |
all(java.util.Collection c,
java.lang.Object obj)
Returns true if all elements of c match obj |
|
static java.lang.String |
array2String(boolean[] array)
|
|
static java.lang.String |
array2String(int[] array)
|
|
static java.lang.String |
array2String(long[] array)
|
|
static java.lang.String |
array2String(java.lang.Object[] array)
|
|
static java.lang.String |
array2String(short[] array)
|
|
static void |
assertEquals(java.lang.Object val1,
java.lang.Object val2)
|
|
static void |
assertEquals(java.lang.String message,
java.lang.Object val1,
java.lang.Object val2)
|
|
static void |
assertFalse(boolean condition)
|
|
static void |
assertFalse(java.lang.String message,
boolean condition)
|
|
static void |
assertNotNull(java.lang.Object val)
|
|
static void |
assertNotNull(java.lang.String message,
java.lang.Object val)
|
|
static void |
assertNull(java.lang.String message,
java.lang.Object val)
|
|
static void |
assertTrue(boolean condition)
|
|
static void |
assertTrue(java.lang.String message,
boolean condition)
|
|
static java.lang.String |
attributeNameToMethodName(java.lang.String attr_name)
|
|
static java.lang.String |
bold(java.lang.String msg)
|
|
static Message |
byteBufferToMessage(byte[] buffer,
int offset,
int length)
|
|
static boolean |
checkForHp()
|
|
static boolean |
checkForLinux()
|
|
static boolean |
checkForMac()
|
|
static boolean |
checkForSolaris()
|
|
static boolean |
checkForWindows()
|
|
static void |
checkIfValidAddress(java.net.InetAddress bind_addr,
java.lang.String prot_name)
|
|
static byte |
clearFlags(byte bits,
byte flag)
|
|
static void |
close(Channel... channels)
|
|
static void |
close(Channel ch)
|
|
static void |
close(Connection conn)
|
|
static void |
close(java.net.DatagramSocket my_sock)
|
|
static void |
close(java.io.InputStream inp)
|
|
static void |
close(java.io.OutputStream out)
|
|
static void |
close(java.net.ServerSocket s)
|
|
static void |
close(java.net.Socket s)
|
|
static byte[] |
collectionToByteBuffer(java.util.Collection<Address> c)
|
|
static java.lang.String[] |
components(java.lang.String path,
java.lang.String separator)
|
|
static java.util.List<Range> |
computeFragOffsets(byte[] buf,
int frag_size)
|
|
static java.util.List<Range> |
computeFragOffsets(int offset,
int length,
int frag_size)
Given a buffer and a fragmentation size, compute a list of fragmentation offset/length pairs, and return them in a list. |
|
static void |
connect(java.net.Socket sock,
java.net.SocketAddress dest,
int sock_conn_timeout)
Utility method. |
|
static
|
contains(T key,
T[] list)
|
|
static boolean |
containsViewId(java.util.Collection<View> views,
ViewId vid)
|
|
static void |
crash()
|
|
static byte[] |
createAuthenticationDigest(java.lang.String passcode,
long t1,
double q1)
|
|
static JChannel |
createChannel(Protocol... prots)
|
|
static
|
createConcurrentMap()
|
|
static
|
createConcurrentMap(int initial_capacity)
|
|
static
|
createConcurrentMap(int initial_capacity,
float load_factor,
int concurrency_level)
|
|
static java.net.DatagramSocket |
createDatagramSocket(SocketFactory factory,
java.lang.String service_name,
java.net.InetAddress addr,
int port)
Creates a DatagramSocket bound to addr. |
|
static byte[] |
createDigest(java.lang.String passcode,
long t1,
double q1)
|
|
static
|
createHashMap()
|
|
static java.net.MulticastSocket |
createMulticastSocket(SocketFactory factory,
java.lang.String service_name,
java.net.InetAddress mcast_addr,
int port,
Log log)
|
|
static Address |
createRandomAddress()
|
|
static Address |
createRandomAddress(java.lang.String name)
|
|
static java.net.ServerSocket |
createServerSocket(SocketFactory factory,
java.lang.String service_name,
java.net.InetAddress bind_addr,
int start_port)
|
|
static java.net.ServerSocket |
createServerSocket(SocketFactory factory,
java.lang.String service_name,
java.net.InetAddress bind_addr,
int start_port,
int end_port)
Finds first available port starting at start_port and returns server socket. |
|
static java.lang.Object[][] |
createTimer()
|
|
static View |
createView(Address coord,
long id,
Address... members)
|
|
static long |
decode(byte[] buf)
|
|
static byte[] |
decodeLength(byte len)
|
|
static long[] |
decodeLongSequence(byte[] buf)
|
|
static byte[] |
defragmentBuffer(byte[][] fragments)
Concatenates smaller fragments into entire buffers. |
|
static java.util.List<View> |
detectDifferentViews(java.util.Map<Address,View> map)
|
|
static java.util.Collection<Address> |
determineActualMergeCoords(java.util.Map<Address,View> map)
Similar to determineMergeCoords(java.util.Map) but only actual coordinators are counted: an actual
coord is when the sender of a view is the first member of that view |
|
static java.util.List<Address> |
determineLeftMembers(java.util.List<Address> old_mbrs,
java.util.List<Address> new_mbrs)
Returns all members that left between 2 views. |
|
static java.util.Collection<Address> |
determineMergeCoords(java.util.Map<Address,View> map)
This is the same or a subset of determineMergeParticipants(java.util.Map) and contains only members
which are currently sub-partition coordinators. |
|
static java.util.Collection<Address> |
determineMergeParticipants(java.util.Map<Address,View> map)
Determines the members which take part in a merge. |
|
static
|
different(T one,
T two)
|
|
static int |
discardUntilNewLine(java.io.InputStream in)
Reads and discards all characters from the input stream until a \r\n or EOF is encountered |
|
static java.lang.String |
dumpQueue(Queue q)
Debugging method used to dump the content of a protocol queue in a condensed form. |
|
static java.lang.String |
dumpThreads()
|
|
static byte[] |
encode(long num)
|
|
static byte |
encodeLength(byte len1,
byte len2)
Encodes the number of bytes needed into a single byte. |
|
static byte[] |
encodeLongSequence(long highest_delivered,
long highest_received)
Encode the highest delivered and received seqnos. |
|
static boolean |
fileExists(java.lang.String fname)
|
|
static java.util.List<java.lang.Class<?>> |
findClassesAnnotatedWith(java.lang.String packageName,
java.lang.Class<? extends java.lang.annotation.Annotation> a)
|
|
static
|
findClassesAssignableFrom(java.lang.String packageName,
java.lang.Class<T> assignableFrom)
|
|
static java.lang.String |
format(double value)
|
|
static byte[][] |
fragmentBuffer(byte[] buf,
int frag_size)
|
|
static byte[][] |
fragmentBuffer(byte[] buf,
int frag_size,
int length)
Fragments a byte buffer into smaller fragments of (max.) frag_size. |
|
static java.lang.String |
generateList(java.util.Collection c,
java.lang.String separator)
|
|
static java.lang.String |
generateLocalName()
|
|
static java.net.InetAddress |
getAddress(java.net.NetworkInterface intf,
Util.AddressScope scope)
Returns the first address on the given interface on the current host, which satisfies scope |
|
static java.net.InetAddress |
getAddress(Util.AddressScope scope)
Returns the first address on any interface of the current host, which satisfies scope |
|
static java.util.Collection<java.net.InetAddress> |
getAllAvailableAddresses()
|
|
static java.util.List<java.net.NetworkInterface> |
getAllAvailableInterfaces()
|
|
static java.lang.reflect.Field[] |
getAllDeclaredFields(java.lang.Class clazz)
|
|
static java.lang.reflect.Field[] |
getAllDeclaredFieldsWithAnnotations(java.lang.Class clazz,
java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
|
|
static java.lang.reflect.Method[] |
getAllDeclaredMethods(java.lang.Class clazz)
|
|
static java.lang.reflect.Method[] |
getAllDeclaredMethodsWithAnnotations(java.lang.Class clazz,
java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
|
|
static java.net.InetAddress |
getBindAddress(java.util.Properties props)
Returns the address of the interface to use defined by bind_addr and bind_interface |
|
protected static byte |
getByteAt(long num,
int index)
|
|
static Address |
getCoordinator(View view)
|
|
static java.lang.reflect.Field |
getField(java.lang.Class clazz,
java.lang.String field_name)
|
|
static java.lang.Object |
getField(java.lang.reflect.Field field,
java.lang.Object target)
|
|
static StackType |
getIpStackType()
|
|
static java.net.InetAddress |
getLocalhost(StackType ip_version)
IP related utilities |
|
static javax.management.MBeanServer |
getMBeanServer()
|
|
static java.lang.String |
getMessage(java.lang.String key)
|
|
static java.lang.String |
getMessage(java.lang.String key,
java.lang.Object... args)
|
|
static java.net.InetAddress |
getNonLoopbackAddress()
Returns the first non-loopback address on any interface on the current host. |
|
static java.lang.String |
getProperty(java.lang.String s)
|
|
static java.lang.String |
getProperty(java.lang.String[] system_props,
java.util.Properties props,
java.lang.String prop_name,
boolean ignore_sysprops,
java.lang.String default_value)
Returns a value associated wither with one or more system properties, or found in the props map |
|
static int |
getRank(java.util.Collection<Address> members,
Address addr)
|
|
static int |
getRank(View view,
Address addr)
Returns the rank of a member in a given view |
|
static java.io.InputStream |
getResourceAsStream(java.lang.String name,
java.lang.Class clazz)
|
|
static short |
getScope(Message msg)
|
|
static java.lang.String |
getStackTrace(java.lang.Throwable t)
|
|
static short |
incrCounter()
|
|
static boolean |
interfaceHasIPAddresses(java.net.NetworkInterface intf,
StackType ip_version)
A function to check if an interface supports an IP version (i.e has addresses defined for that IP version). |
|
static boolean |
interruptAndWaitToDie(java.lang.Thread t)
|
|
static boolean |
interruptAndWaitToDie(java.lang.Thread t,
long timeout)
|
|
static boolean |
isBindAddressPropertyIgnored()
|
|
static boolean |
isCoordinator(JChannel ch)
|
|
static boolean |
isCoordinator(View view,
Address local_addr)
|
|
static boolean |
isFlagSet(byte bits,
byte flag)
|
|
static boolean |
isStackAvailable(boolean ipv4)
|
|
static int |
keyPress(java.lang.String msg)
|
|
static java.util.List<Address> |
leftMembers(java.util.Collection<Address> old_list,
java.util.Collection<Address> new_list)
|
|
static java.util.List<Address> |
leftMembers(View one,
View two)
Returns a list of members which left from view one to two |
|
static java.lang.Class |
loadClass(java.lang.String classname,
java.lang.Class clazz)
Tries to load the class from the current thread's context class loader. |
|
static java.lang.String |
mapToString(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> map)
|
|
static boolean |
match(long[] a1,
long[] a2)
|
|
static
|
match(T obj1,
T obj2)
|
|
static java.lang.String |
md5(java.lang.String source)
Converts a java.lang.String in to a MD5 hashed String |
|
static Buffer |
messageToByteBuffer(Message msg)
|
|
static java.lang.String |
methodNameToAttributeName(java.lang.String methodName)
|
|
static Buffer |
msgListToByteBuffer(java.util.List<Message> xmit_list)
Marshalls a list of messages. |
|
static
|
newElements(java.util.List<T> old_list,
java.util.List<T> new_list)
|
|
static java.util.List<Address> |
newMembers(java.util.List<Address> old_list,
java.util.List<Address> new_list)
|
|
static java.lang.Object |
objectFromByteBuffer(byte[] buffer)
Creates an object from a byte buffer |
|
static java.lang.Object |
objectFromByteBuffer(byte[] buffer,
int offset,
int length)
|
|
static java.lang.Object |
objectFromStream(java.io.DataInput in)
|
|
static byte[] |
objectToByteBuffer(java.lang.Object obj)
Serializes/Streams an object into a byte buffer. |
|
static void |
objectToStream(java.lang.Object obj,
java.io.DataOutput out)
|
|
static java.util.List<IpAddress> |
parseCommaDelimitedHosts(java.lang.String hosts,
int port_range)
Input is "daddy[8880],sindhu[8880],camille[5555]. |
|
static java.util.List<java.net.InetSocketAddress> |
parseCommaDelimitedHosts2(java.lang.String hosts,
int port_range)
Input is "daddy[8880],sindhu[8880],camille[5555]. |
|
static int[] |
parseCommaDelimitedInts(java.lang.String s)
Parses comma-delimited longs; e.g., 2000,4000,8000. |
|
static long[] |
parseCommaDelimitedLongs(java.lang.String s)
Parses comma-delimited longs; e.g., 2000,4000,8000. |
|
static java.util.List<java.lang.String> |
parseCommaDelimitedStrings(java.lang.String l)
e.g. |
|
static java.util.List<java.net.NetworkInterface> |
parseInterfaceList(java.lang.String s)
|
|
static java.util.concurrent.RejectedExecutionHandler |
parseRejectionPolicy(java.lang.String rejection_policy)
|
|
static java.lang.String |
parseString(java.nio.ByteBuffer buf)
|
|
static java.lang.String |
parseString(java.nio.ByteBuffer buf,
boolean discard_whitespace)
|
|
static java.lang.String |
parseString(java.io.DataInput in)
|
|
static java.util.List<java.lang.String> |
parseStringList(java.lang.String l,
java.lang.String separator)
|
|
static
|
pickNext(java.util.List<T> list,
T obj)
Returns the object next to element in list |
|
static
|
pickNext(java.util.List<T> list,
T obj,
int num)
Returns the next min(N,list.size()) elements after obj |
|
static java.lang.Object |
pickRandomElement(java.util.List list)
|
|
static java.lang.Object |
pickRandomElement(java.lang.Object[] array)
|
|
static java.util.List<Address> |
pickSubset(java.util.List<Address> members,
double subset_percentage)
Selects a random subset of members according to subset_percentage and returns them. |
|
static
|
print(java.util.Collection<T> objs)
|
|
static java.lang.String |
print(java.util.List<java.net.NetworkInterface> interfaces)
|
|
static
|
print(java.util.Map<T,T> map)
|
|
static java.lang.String |
print(java.lang.Throwable t)
|
|
static java.lang.String |
printBytes(double bytes)
|
|
static java.lang.String |
printBytes(long bytes)
MByte nowadays doesn't mean 1024 * 1024 bytes, but 1 million bytes, see http://en.wikipedia.org/wiki/Megabyte |
|
static java.lang.String |
printEvent(Event evt)
|
|
static void |
printFragments(byte[][] frags)
|
|
static
|
printListWithDelimiter(java.util.Collection<T> list,
java.lang.String delimiter)
|
|
static
|
printListWithDelimiter(java.util.Collection<T> list,
java.lang.String delimiter,
int limit)
|
|
static
|
printMapWithDelimiter(java.util.Map<T,T> map,
java.lang.String delimiter)
|
|
static java.lang.String |
printMessage(Message msg)
Tries to read an object from the message's buffer and prints it |
|
static java.lang.String |
printPingData(java.util.List<PingData> rsps)
|
|
static java.lang.String |
printStackTrace(java.lang.Throwable t)
Use with caution: lots of overhead |
|
static void |
printThreads()
|
|
static java.lang.String |
printTime(long time,
java.util.concurrent.TimeUnit unit)
|
|
static java.lang.String |
printViews(java.util.Collection<View> views)
|
|
static void |
prompt(java.lang.String s)
|
|
static long |
random(long range)
Returns a random value in the range [1 - range] |
|
static Address |
readAddress(java.io.DataInput in)
|
|
static java.util.Collection<? extends Address> |
readAddresses(java.io.DataInput in,
java.lang.Class cl)
|
|
static AuthToken |
readAuthToken(java.io.DataInput in)
|
|
static byte[] |
readByteBuffer(java.io.DataInput in)
|
|
static double |
readBytesDouble(java.lang.String input)
|
|
static int |
readBytesInteger(java.lang.String input)
|
|
static long |
readBytesLong(java.lang.String input)
|
|
static java.lang.Class<?> |
readClass(java.io.DataInput in)
|
|
static java.lang.String |
readContents(java.io.InputStream input)
|
|
static double |
readDoubleFromStdin(java.lang.String message)
|
|
static java.lang.String |
readFile(java.lang.String filename)
|
|
static byte[] |
readFileContents(java.io.InputStream input)
|
|
static byte[] |
readFileContents(java.lang.String filename)
|
|
static Streamable |
readGenericStreamable(java.io.DataInput in)
|
|
static int |
readIntFromStdin(java.lang.String message)
|
|
static java.lang.String |
readLine(java.io.InputStream in)
Reads a line of text. |
|
static long |
readLong(java.io.DataInput in)
|
|
static long |
readLongFromStdin(java.lang.String message)
|
|
static long[] |
readLongSequence(java.io.DataInput in)
|
|
static int |
readNewLine(java.nio.ByteBuffer buf)
|
|
static java.lang.Object |
readObject(java.io.DataInput in)
|
|
static Streamable |
readStreamable(java.lang.Class clazz,
java.io.DataInput in)
|
|
static java.lang.String |
readString(java.io.DataInput in)
|
|
static java.lang.String |
readStringFromStdin(java.lang.String message)
|
|
static View |
readView(java.io.DataInput in)
|
|
static ViewId |
readViewId(java.io.DataInput in)
|
|
static void |
registerChannel(JChannel channel,
java.lang.String name)
|
|
static java.lang.String |
replaceProperties(java.lang.String string,
java.util.Properties props)
Go through the input string and replace any occurance of ${p} with the props.getProperty(p) value. |
|
static void |
runAsync(java.lang.Runnable task,
ThreadFactory factory,
java.lang.String thread_name)
Runs a task on a separate thread |
|
static boolean |
sameHost(Address one,
Address two)
Checks whether 2 Addresses are on the same host |
|
static void |
setField(java.lang.reflect.Field field,
java.lang.Object target,
java.lang.Object value)
|
|
static byte |
setFlag(byte bits,
byte flag)
|
|
static void |
setScope(Message msg,
short scope)
|
|
static java.lang.String |
sha(java.lang.String source)
Converts a java.lang.String in to a SHA hashed String |
|
static java.lang.String |
shortName(java.net.InetAddress hostname)
|
|
static java.lang.String |
shortName(java.lang.String hostname)
|
|
static void |
shutdown(Channel ch)
Drops messages to/from other members and then closes the channel. |
|
static int |
size(Address addr)
|
|
static int |
size(byte[] buf)
|
|
static long |
size(java.util.Collection<? extends Address> addrs)
Returns the marshalled size of a Collection of Addresses. |
|
static byte |
size(long number)
|
|
static byte |
size(long hd,
long hr)
Writes 2 longs, where the second long needs to be >= the first (we only write the delta !) |
|
static int |
size(java.lang.String s)
|
|
static int |
size(View view)
|
|
static int |
size(ViewId vid)
|
|
static long |
sizeOf(java.lang.Object inst)
|
|
static int |
sizeOf(Streamable inst)
|
|
static long |
sizeOf(java.lang.String classname)
|
|
static void |
sleep(long timeout)
Sleep for timeout msecs. |
|
static void |
sleep(long msecs,
boolean busy_sleep)
On most UNIX systems, the minimum sleep time is 10-20ms. |
|
static void |
sleep(long timeout,
int nanos)
|
|
static void |
sleepRandom(long floor,
long ceiling)
Sleeps between floor and ceiling milliseconds, chosen randomly |
|
static java.util.List<java.lang.String> |
split(java.lang.String input,
int separator)
|
|
static boolean |
startFlush(Channel c)
|
|
static boolean |
startFlush(Channel c,
int numberOfAttempts,
long randomSleepTimeoutFloor,
long randomSleepTimeoutCeiling)
|
|
static boolean |
startFlush(Channel c,
java.util.List<Address> flushParticipants)
|
|
static boolean |
startFlush(Channel c,
java.util.List<Address> flushParticipants,
int numberOfAttempts,
long randomSleepTimeoutFloor,
long randomSleepTimeoutCeiling)
|
|
static Streamable |
streamableFromByteBuffer(java.lang.Class<? extends Streamable> cl,
byte[] buffer)
|
|
static Streamable |
streamableFromByteBuffer(java.lang.Class<? extends Streamable> cl,
byte[] buffer,
int offset,
int length)
|
|
static byte[] |
streamableToByteBuffer(Streamable obj)
|
|
static java.lang.String |
substituteVariable(java.lang.String val)
Replaces variables of ${var:default} with System.getProperty(var, default). |
|
static boolean |
tossWeightedCoin(double probability)
Tosses a coin weighted with probability and returns true or false. |
|
static java.net.InetAddress |
validateBindAddressFromInterface(java.net.InetAddress bind_addr,
java.lang.String bind_interface_str)
Method used by PropertyConverters.BindInterface to check that a bind_address is consistent with a specified interface Idea: 1. |
|
static void |
verifyRejectionPolicy(java.lang.String str)
|
|
static void |
waitUntilAllChannelsHaveSameSize(long timeout,
long interval,
Channel... channels)
Blocks until all channels have the same view |
|
static void |
writeAddress(Address addr,
java.io.DataOutput out)
|
|
static void |
writeAddresses(java.util.Collection<? extends Address> v,
java.io.DataOutput out)
Writes a Vector of Addresses. |
|
static void |
writeAuthToken(AuthToken token,
java.io.DataOutput out)
|
|
static void |
writeByteBuffer(byte[] buf,
java.io.DataOutput out)
|
|
static void |
writeByteBuffer(byte[] buf,
int offset,
int length,
java.io.DataOutput out)
|
|
static void |
writeClass(java.lang.Class<?> classObject,
java.io.DataOutput out)
|
|
static void |
writeFully(java.nio.ByteBuffer buf,
java.nio.channels.WritableByteChannel out)
if we were to register for OP_WRITE and send the remaining data on readyOps for this channel we have to either block the caller thread or queue the message buffers that may arrive while waiting for OP_WRITE. |
|
static void |
writeGenericStreamable(Streamable obj,
java.io.DataOutput out)
|
|
static void |
writeLong(long num,
java.io.DataOutput out)
|
|
static void |
writeLongSequence(long highest_delivered,
long highest_received,
java.io.DataOutput out)
|
|
static void |
writeObject(java.lang.Object obj,
java.io.DataOutput out)
|
|
static void |
writeStreamable(Streamable obj,
java.io.DataOutput out)
|
|
static void |
writeString(java.nio.ByteBuffer buf,
java.lang.String s)
|
|
static void |
writeString(java.lang.String s,
java.io.DataOutput out)
|
|
static void |
writeView(View view,
java.io.DataOutput out)
|
|
static void |
writeViewId(ViewId vid,
java.io.DataOutput out)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_PORT
protected static int CCHM_INITIAL_CAPACITY
protected static float CCHM_LOAD_FACTOR
protected static int CCHM_CONCURRENCY_LEVEL
public static int MAX_LIST_PRINT_SIZE
protected static java.util.ResourceBundle resource_bundle
Constructor Detail |
---|
public Util()
Method Detail |
---|
public static void assertTrue(boolean condition)
public static void assertTrue(java.lang.String message, boolean condition)
public static void assertFalse(boolean condition)
public static void assertFalse(java.lang.String message, boolean condition)
public static void assertEquals(java.lang.String message, java.lang.Object val1, java.lang.Object val2)
public static void assertEquals(java.lang.Object val1, java.lang.Object val2)
public static void assertNotNull(java.lang.String message, java.lang.Object val)
public static void assertNotNull(java.lang.Object val)
public static void assertNull(java.lang.String message, java.lang.Object val)
public static java.lang.String bold(java.lang.String msg)
public static java.lang.String getMessage(java.lang.String key)
public static java.lang.String getMessage(java.lang.String key, java.lang.Object... args)
public static void waitUntilAllChannelsHaveSameSize(long timeout, long interval, Channel... channels) throws TimeoutException
timeout
- How long to wait (max in ms)interval
- Check every interval mschannels
- The channels which should form the view. The expected view size is channels.length.
Must be non-null
TimeoutException
public static void addFlush(Channel ch, FLUSH flush)
public static void setScope(Message msg, short scope)
public static short getScope(Message msg)
public static byte[] createAuthenticationDigest(java.lang.String passcode, long t1, double q1) throws java.io.IOException, java.security.NoSuchAlgorithmException
java.io.IOException
java.security.NoSuchAlgorithmException
public static byte[] createDigest(java.lang.String passcode, long t1, double q1) throws java.io.IOException, java.security.NoSuchAlgorithmException
java.io.IOException
java.security.NoSuchAlgorithmException
public static void connect(java.net.Socket sock, java.net.SocketAddress dest, int sock_conn_timeout) throws java.io.IOException
sock
- dest
- sock_conn_timeout
-
java.io.IOException
public static void close(java.io.InputStream inp)
public static void close(java.io.OutputStream out)
public static void close(java.net.Socket s)
public static void close(java.net.ServerSocket s)
public static void close(java.net.DatagramSocket my_sock)
public static void close(Channel ch)
public static void close(Channel... channels)
public static void close(Connection conn)
public static void shutdown(Channel ch) throws java.lang.Exception
java.lang.Exception
public static byte setFlag(byte bits, byte flag)
public static boolean isFlagSet(byte bits, byte flag)
public static byte clearFlags(byte bits, byte flag)
public static java.lang.Object objectFromByteBuffer(byte[] buffer) throws java.lang.Exception
java.lang.Exception
public static java.lang.Object objectFromByteBuffer(byte[] buffer, int offset, int length) throws java.lang.Exception
java.lang.Exception
public static byte[] objectToByteBuffer(java.lang.Object obj) throws java.lang.Exception
java.lang.Exception
public static void objectToStream(java.lang.Object obj, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static java.lang.Object objectFromStream(java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static Streamable streamableFromByteBuffer(java.lang.Class<? extends Streamable> cl, byte[] buffer) throws java.lang.Exception
java.lang.Exception
public static Streamable streamableFromByteBuffer(java.lang.Class<? extends Streamable> cl, byte[] buffer, int offset, int length) throws java.lang.Exception
java.lang.Exception
public static byte[] streamableToByteBuffer(Streamable obj) throws java.lang.Exception
java.lang.Exception
public static byte[] collectionToByteBuffer(java.util.Collection<Address> c) throws java.lang.Exception
java.lang.Exception
public static void writeAuthToken(AuthToken token, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static AuthToken readAuthToken(java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static void writeView(View view, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static View readView(java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static void writeViewId(ViewId vid, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static ViewId readViewId(java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static void writeAddress(Address addr, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static Address readAddress(java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static int size(Address addr)
public static int size(View view)
public static int size(ViewId vid)
public static int size(java.lang.String s)
public static int size(byte[] buf)
public static void writeAddresses(java.util.Collection<? extends Address> v, java.io.DataOutput out) throws java.lang.Exception
v
- A Collectionout
-
java.lang.Exception
public static java.util.Collection<? extends Address> readAddresses(java.io.DataInput in, java.lang.Class cl) throws java.lang.Exception
in
- cl
- The type of Collection, e.g. ArrayList.class
java.lang.Exception
public static long size(java.util.Collection<? extends Address> addrs)
addrs
- Collection
public static void writeStreamable(Streamable obj, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static Streamable readStreamable(java.lang.Class clazz, java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static void writeGenericStreamable(Streamable obj, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static Streamable readGenericStreamable(java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static void writeClass(java.lang.Class<?> classObject, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static java.lang.Class<?> readClass(java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static void writeObject(java.lang.Object obj, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static java.lang.Object readObject(java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static void writeString(java.lang.String s, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static java.lang.String readString(java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static java.lang.String readFile(java.lang.String filename) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public static java.lang.String readContents(java.io.InputStream input)
public static byte[] readFileContents(java.lang.String filename) throws java.io.IOException
java.io.IOException
public static byte[] readFileContents(java.io.InputStream input) throws java.io.IOException
java.io.IOException
public static java.lang.String parseString(java.io.DataInput in)
public static java.lang.String readStringFromStdin(java.lang.String message) throws java.lang.Exception
java.lang.Exception
public static long readLongFromStdin(java.lang.String message) throws java.lang.Exception
java.lang.Exception
public static double readDoubleFromStdin(java.lang.String message) throws java.lang.Exception
java.lang.Exception
public static int readIntFromStdin(java.lang.String message) throws java.lang.Exception
java.lang.Exception
public static void writeByteBuffer(byte[] buf, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static void writeByteBuffer(byte[] buf, int offset, int length, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static byte[] readByteBuffer(java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static Buffer messageToByteBuffer(Message msg) throws java.lang.Exception
java.lang.Exception
public static Message byteBufferToMessage(byte[] buffer, int offset, int length) throws java.lang.Exception
java.lang.Exception
public static Buffer msgListToByteBuffer(java.util.List<Message> xmit_list) throws java.lang.Exception
xmit_list
- LinkedListjava.lang.Exception
public static <T> boolean match(T obj1, T obj2)
public static boolean match(long[] a1, long[] a2)
public static <T> boolean different(T one, T two)
public static void sleep(long timeout)
public static void sleep(long timeout, int nanos)
public static void sleep(long msecs, boolean busy_sleep)
public static int keyPress(java.lang.String msg)
public static long random(long range)
public static void sleepRandom(long floor, long ceiling)
public static boolean tossWeightedCoin(double probability)
public static java.lang.String dumpThreads()
protected static void _printThreads(java.lang.management.ThreadMXBean bean, long[] ids, java.lang.StringBuilder sb)
public static boolean interruptAndWaitToDie(java.lang.Thread t)
public static boolean interruptAndWaitToDie(java.lang.Thread t, long timeout)
public static java.lang.String dumpQueue(Queue q)
public static java.lang.String printStackTrace(java.lang.Throwable t)
public static java.lang.String getStackTrace(java.lang.Throwable t)
public static java.lang.String print(java.lang.Throwable t)
public static void crash()
public static java.lang.String printEvent(Event evt)
public static java.lang.String printMessage(Message msg)
public static java.lang.String mapToString(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> map)
public static void printThreads()
public static java.lang.String activeThreads()
public static java.lang.String printBytes(long bytes)
bytes
-
public static java.lang.String printTime(long time, java.util.concurrent.TimeUnit unit)
public static java.lang.String format(double value)
public static long readBytesLong(java.lang.String input)
public static int readBytesInteger(java.lang.String input)
public static double readBytesDouble(java.lang.String input)
public static java.lang.String printBytes(double bytes)
public static java.util.List<java.lang.String> split(java.lang.String input, int separator)
public static java.lang.String[] components(java.lang.String path, java.lang.String separator)
public static byte[][] fragmentBuffer(byte[] buf, int frag_size, int length)
byte[]
).public static byte[][] fragmentBuffer(byte[] buf, int frag_size)
public static java.util.List<Range> computeFragOffsets(int offset, int length, int frag_size)
frag_size
-
public static java.util.List<Range> computeFragOffsets(byte[] buf, int frag_size)
public static byte[] defragmentBuffer(byte[][] fragments)
fragments
- An array of byte buffers (byte[]
)
public static void printFragments(byte[][] frags)
public static byte[] encode(long num)
protected static byte getByteAt(long num, int index)
public static long decode(byte[] buf)
public static void writeLong(long num, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static long readLong(java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static byte[] encodeLongSequence(long highest_delivered, long highest_received)
highest_delivered
- highest_received
-
public static byte size(long number)
public static byte size(long hd, long hr)
hd
- hr
-
public static long[] decodeLongSequence(byte[] buf)
public static void writeLongSequence(long highest_delivered, long highest_received, java.io.DataOutput out) throws java.lang.Exception
java.lang.Exception
public static long[] readLongSequence(java.io.DataInput in) throws java.lang.Exception
java.lang.Exception
public static byte encodeLength(byte len1, byte len2)
len1
- The number of bytes needed to store a long. Must be between 0 and 8len2
- The number of bytes needed to store a long. Must be between 0 and 8
public static byte[] decodeLength(byte len)
public static <T> java.lang.String printListWithDelimiter(java.util.Collection<T> list, java.lang.String delimiter)
public static <T> java.lang.String printListWithDelimiter(java.util.Collection<T> list, java.lang.String delimiter, int limit)
public static <T> java.lang.String printMapWithDelimiter(java.util.Map<T,T> map, java.lang.String delimiter)
public static java.lang.String array2String(long[] array)
public static java.lang.String array2String(short[] array)
public static java.lang.String array2String(int[] array)
public static java.lang.String array2String(boolean[] array)
public static java.lang.String array2String(java.lang.Object[] array)
public static boolean all(java.util.Collection c, java.lang.Object obj)
public static java.util.List<Address> leftMembers(View one, View two)
one
- two
-
public static java.util.List<Address> leftMembers(java.util.Collection<Address> old_list, java.util.Collection<Address> new_list)
public static java.util.List<Address> newMembers(java.util.List<Address> old_list, java.util.List<Address> new_list)
public static <T> java.util.List<T> newElements(java.util.List<T> old_list, java.util.List<T> new_list)
public static java.util.List<Address> pickSubset(java.util.List<Address> members, double subset_percentage)
public static <T> boolean contains(T key, T[] list)
public static boolean containsViewId(java.util.Collection<View> views, ViewId vid)
public static java.util.List<View> detectDifferentViews(java.util.Map<Address,View> map)
public static java.util.Collection<Address> determineMergeParticipants(java.util.Map<Address,View> map)
map
-
public static java.util.Collection<Address> determineMergeCoords(java.util.Map<Address,View> map)
determineMergeParticipants(java.util.Map)
and contains only members
which are currently sub-partition coordinators.
map
-
public static java.util.Collection<Address> determineActualMergeCoords(java.util.Map<Address,View> map)
determineMergeCoords(java.util.Map)
but only actual coordinators are counted: an actual
coord is when the sender of a view is the first member of that view
map
-
public static int getRank(View view, Address addr)
view
- The viewaddr
- The address of a member
public static int getRank(java.util.Collection<Address> members, Address addr)
public static java.lang.Object pickRandomElement(java.util.List list)
public static java.lang.Object pickRandomElement(java.lang.Object[] array)
public static <T> T pickNext(java.util.List<T> list, T obj)
T
- list
- obj
-
public static <T> java.util.List<T> pickNext(java.util.List<T> list, T obj, int num)
public static View createView(Address coord, long id, Address... members)
public static JChannel createChannel(Protocol... prots) throws java.lang.Exception
java.lang.Exception
public static Address createRandomAddress()
public static Address createRandomAddress(java.lang.String name)
public static java.lang.Object[][] createTimer()
public static java.util.List<Address> determineLeftMembers(java.util.List<Address> old_mbrs, java.util.List<Address> new_mbrs)
public static java.lang.String printViews(java.util.Collection<View> views)
public static <T> java.lang.String print(java.util.Collection<T> objs)
public static <T> java.lang.String print(java.util.Map<T,T> map)
public static java.lang.String printPingData(java.util.List<PingData> rsps)
public static void writeFully(java.nio.ByteBuffer buf, java.nio.channels.WritableByteChannel out) throws java.lang.Exception
java.lang.Exception
public static long sizeOf(java.lang.String classname)
public static long sizeOf(java.lang.Object inst)
public static int sizeOf(Streamable inst)
public static java.lang.Class loadClass(java.lang.String classname, java.lang.Class clazz) throws java.lang.ClassNotFoundException
classname
- Desired class.clazz
- Class object used to obtain a class loader
if no context class loader is available.
java.lang.ClassNotFoundException
public static java.lang.reflect.Field[] getAllDeclaredFields(java.lang.Class clazz)
public static java.lang.reflect.Field[] getAllDeclaredFieldsWithAnnotations(java.lang.Class clazz, java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
public static java.lang.reflect.Method[] getAllDeclaredMethods(java.lang.Class clazz)
public static java.lang.reflect.Method[] getAllDeclaredMethodsWithAnnotations(java.lang.Class clazz, java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
public static java.lang.reflect.Field getField(java.lang.Class clazz, java.lang.String field_name)
public static void setField(java.lang.reflect.Field field, java.lang.Object target, java.lang.Object value)
public static java.lang.Object getField(java.lang.reflect.Field field, java.lang.Object target)
public static <T> java.util.Set<java.lang.Class<T>> findClassesAssignableFrom(java.lang.String packageName, java.lang.Class<T> assignableFrom) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public static java.util.List<java.lang.Class<?>> findClassesAnnotatedWith(java.lang.String packageName, java.lang.Class<? extends java.lang.annotation.Annotation> a) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public static java.io.InputStream getResourceAsStream(java.lang.String name, java.lang.Class clazz)
public static boolean sameHost(Address one, Address two)
public static boolean fileExists(java.lang.String fname)
public static void verifyRejectionPolicy(java.lang.String str) throws java.lang.Exception
java.lang.Exception
public static java.util.concurrent.RejectedExecutionHandler parseRejectionPolicy(java.lang.String rejection_policy)
public static int[] parseCommaDelimitedInts(java.lang.String s)
public static long[] parseCommaDelimitedLongs(java.lang.String s)
public static java.util.List<java.lang.String> parseCommaDelimitedStrings(java.lang.String l)
public static java.util.List<IpAddress> parseCommaDelimitedHosts(java.lang.String hosts, int port_range) throws java.net.UnknownHostException
java.net.UnknownHostException
public static java.util.List<java.net.InetSocketAddress> parseCommaDelimitedHosts2(java.lang.String hosts, int port_range)
public static java.util.List<java.lang.String> parseStringList(java.lang.String l, java.lang.String separator)
public static java.lang.String parseString(java.nio.ByteBuffer buf)
public static java.lang.String parseString(java.nio.ByteBuffer buf, boolean discard_whitespace)
public static int readNewLine(java.nio.ByteBuffer buf)
public static int discardUntilNewLine(java.io.InputStream in)
in
-
public static java.lang.String readLine(java.io.InputStream in) throws java.io.IOException
java.io.IOException
- If an I/O error occurspublic static void writeString(java.nio.ByteBuffer buf, java.lang.String s)
public static java.util.List<java.net.NetworkInterface> parseInterfaceList(java.lang.String s) throws java.lang.Exception
s
-
java.lang.Exception
public static java.lang.String print(java.util.List<java.net.NetworkInterface> interfaces)
public static java.lang.String shortName(java.lang.String hostname)
public static boolean startFlush(Channel c, java.util.List<Address> flushParticipants, int numberOfAttempts, long randomSleepTimeoutFloor, long randomSleepTimeoutCeiling)
public static boolean startFlush(Channel c, java.util.List<Address> flushParticipants)
public static boolean startFlush(Channel c, int numberOfAttempts, long randomSleepTimeoutFloor, long randomSleepTimeoutCeiling)
public static boolean startFlush(Channel c)
public static java.lang.String shortName(java.net.InetAddress hostname)
public static java.lang.String generateLocalName()
public static short incrCounter()
public static <K,V> java.util.concurrent.ConcurrentMap<K,V> createConcurrentMap(int initial_capacity, float load_factor, int concurrency_level)
public static <K,V> java.util.concurrent.ConcurrentMap<K,V> createConcurrentMap(int initial_capacity)
public static <K,V> java.util.concurrent.ConcurrentMap<K,V> createConcurrentMap()
public static <K,V> java.util.Map<K,V> createHashMap()
public static java.net.ServerSocket createServerSocket(SocketFactory factory, java.lang.String service_name, java.net.InetAddress bind_addr, int start_port)
public static java.net.ServerSocket createServerSocket(SocketFactory factory, java.lang.String service_name, java.net.InetAddress bind_addr, int start_port, int end_port) throws java.lang.Exception
java.lang.Exception
public static java.net.DatagramSocket createDatagramSocket(SocketFactory factory, java.lang.String service_name, java.net.InetAddress addr, int port) throws java.lang.Exception
addr
- The InetAddress to which the socket should be bound. If null, the socket will not be bound.port
- The port which the socket should use. If 0, a random port will be used. If > 0, but port is already
in use, it will be incremented until an unused port is found, or until MAX_PORT is reached.
java.lang.Exception
public static java.net.MulticastSocket createMulticastSocket(SocketFactory factory, java.lang.String service_name, java.net.InetAddress mcast_addr, int port, Log log) throws java.io.IOException
java.io.IOException
public static java.net.InetAddress getBindAddress(java.util.Properties props) throws java.net.UnknownHostException, java.net.SocketException
props
-
java.net.UnknownHostException
java.net.SocketException
public static java.net.InetAddress validateBindAddressFromInterface(java.net.InetAddress bind_addr, java.lang.String bind_interface_str) throws java.net.UnknownHostException, java.net.SocketException
java.net.UnknownHostException
java.net.SocketException
public static boolean checkForLinux()
public static boolean checkForHp()
public static boolean checkForSolaris()
public static boolean checkForWindows()
public static boolean checkForMac()
public static void prompt(java.lang.String s)
public static java.net.InetAddress getLocalhost(StackType ip_version) throws java.net.UnknownHostException
java.net.UnknownHostException
public static java.net.InetAddress getNonLoopbackAddress() throws java.net.SocketException
java.net.SocketException
public static java.net.InetAddress getAddress(Util.AddressScope scope) throws java.net.SocketException
java.net.SocketException
public static java.net.InetAddress getAddress(java.net.NetworkInterface intf, Util.AddressScope scope)
intf
- the interface to be checkedpublic static boolean interfaceHasIPAddresses(java.net.NetworkInterface intf, StackType ip_version) throws java.net.UnknownHostException
intf
-
java.net.UnknownHostException
public static StackType getIpStackType()
public static boolean isStackAvailable(boolean ipv4)
public static java.util.List<java.net.NetworkInterface> getAllAvailableInterfaces() throws java.net.SocketException
java.net.SocketException
public static java.util.Collection<java.net.InetAddress> getAllAvailableAddresses()
public static void checkIfValidAddress(java.net.InetAddress bind_addr, java.lang.String prot_name) throws java.lang.Exception
java.lang.Exception
public static java.lang.String getProperty(java.lang.String[] system_props, java.util.Properties props, java.lang.String prop_name, boolean ignore_sysprops, java.lang.String default_value)
system_props
- props
- List of properties read from the configuration fileprop_name
- The name of the property, will be removed from props if foundignore_sysprops
- If true, system properties are not used and the values will only be retrieved from
props (not system_props)default_value
- Used to return a default value if the properties or system properties didn't have the value
public static boolean isBindAddressPropertyIgnored()
public static boolean isCoordinator(JChannel ch)
public static boolean isCoordinator(View view, Address local_addr)
public static Address getCoordinator(View view)
public static javax.management.MBeanServer getMBeanServer()
public static void registerChannel(JChannel channel, java.lang.String name)
public static java.lang.String generateList(java.util.Collection c, java.lang.String separator)
public static java.lang.String replaceProperties(java.lang.String string, java.util.Properties props)
string
- -
the string with possible ${} referencesprops
- -
the source for ${x} property ref values, null means use
System.getProperty()
{@link
- java.security.AccessControlException}
when not authorised to retrieved system propertiespublic static java.lang.String substituteVariable(java.lang.String val)
val
-
public static java.lang.String getProperty(java.lang.String s)
public static java.lang.String md5(java.lang.String source)
source
- the source String
public static java.lang.String sha(java.lang.String source)
source
- the source String
public static java.lang.String methodNameToAttributeName(java.lang.String methodName)
public static java.lang.String attributeNameToMethodName(java.lang.String attr_name)
public static void runAsync(java.lang.Runnable task, ThreadFactory factory, java.lang.String thread_name)
task
- factory
- group
- thread_name
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |