Java Doc for Util.java in  » Net » JGroups-2.4.1-sp3 » org » jgroups » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » JGroups 2.4.1 sp3 » org.jgroups.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jgroups.util.Util

Util
public class Util (Code)
Collection of various utility routines that can not be assigned to other classes.
author:
   Bela Ban
version:
   $Id: Util.java,v 1.105.2.3 2007/04/12 20:24:45 bstansberry Exp $


Field Summary
final public static  StringDIAG_GROUP
    
static  booleanJGROUPS_COMPAT
    
final public static  intMAX_PORT
    
static  booleanresolve_dns
    


Method Summary
public static  booleanacquire(Sync sync)
     Attempts to acquire the given Sync, suppressing any InterruptedException.
public static  StringactiveThreads()
    
public static  booleanall(Collection c, Object obj)
    
public static  Stringarray2String(long[] array)
    
public static  Stringarray2String(int[] array)
    
public static  Stringarray2String(boolean[] array)
    
public static  Stringarray2String(Object[] array)
    
public static  LinkedListbyteBufferToMessageList(byte[] buffer, int offset, int length)
    
public static  voidcheckBufferSize(String buf_name, long val)
    
public static  booleancheckForLinux()
    
public static  booleancheckForSolaris()
    
public static  booleancheckForWindows()
    
public static  voidclose(InputStream inp)
    
public static  voidclose(OutputStream out)
    
public static  voidclose(Socket s)
    
public static  voidclose(DatagramSocket my_sock)
    
public static  byte[]collectionToByteBuffer(Collection c)
    
public static  java.util.ListcomputeFragOffsets(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.
public static  java.util.ListcomputeFragOffsets(byte[] buf, int frag_size)
    
public static  voidcrash()
    
public static  DatagramSocketcreateDatagramSocket(InetAddress addr, int port)
     Creates a DatagramSocket bound to addr.
public static  ServerSocketcreateServerSocket(int start_port)
    
public static  ServerSocketcreateServerSocket(InetAddress bind_addr, int start_port)
    
public static  byte[]defragmentBuffer(byte[] fragments)
     Concatenates smaller fragments into entire buffers.
public static  VectordetermineLeftMembers(Vector old_mbrs, Vector new_mbrs)
     Returns all members that left between 2 views.
public static  voiddoubleWrite(byte[] buf, OutputStream out)
     Makes sure that we detect when a peer connection is in the closed state (not closed while we send data, but before we send data).
public static  voiddoubleWrite(byte[] buf, int offset, int length, OutputStream out)
     Makes sure that we detect when a peer connection is in the closed state (not closed while we send data, but before we send data).
public static  StringdumpQueue(Queue q)
     Debugging method used to dump the content of a protocol queue in a condensed form.
public static  voiddumpStack(boolean exit)
    
public static  booleanfileExists(String fname)
    
public static  byte[][]fragmentBuffer(byte[] buf, int frag_size, int length)
     Fragments a byte buffer into smaller fragments of (max.) frag_size.
public static  byte[][]fragmentBuffer(byte[] buf, int frag_size)
    
public static  StringgenerateList(Collection c, String separator)
    
public static  ListgetAllAvailableInterfaces()
    
public static  InetAddressgetFirstNonLoopbackAddress()
    
public static  InetAddressgetFirstNonLoopbackIPv6Address()
    
public static  ThreadGroupgetGlobalThreadGroup()
    
public static  StringgetHostname()
    
public static  intgetJavaVersion()
    
public static  MBeanServergetMBeanServer()
    
public static  StringgetProperty(String[] system_props, Properties props, String prop_name, boolean ignore_sysprops, String default_value)
    
public static  InputStreamgetResourceAsStream(String name, Class clazz)
    
public static  StringgetStackTrace(Throwable t)
    
public static  booleanisBindAddressPropertyIgnored()
    
public static  ClassloadClass(String classname, Class clazz)
     Tries to load the class from the current thread's context class loader.
public static  voidlock(Sync sync)
     Acquires the given Sync, but will not throw an InterruptedException.
public static  voidmain(String args)
    
public static  booleanmatch(Object obj1, Object obj2)
    
public static  booleanmatch(long[] a1, long[] a2)
    
public static  StringmemStats(boolean gc)
    
public static  BuffermsgListToByteBuffer(LinkedList xmit_list)
     Marshalls a list of messages.
public static  ObjectobjectFromByteBuffer(byte[] buffer)
    
public static  ObjectobjectFromByteBuffer(byte[] buffer, int offset, int length)
    
public static  byte[]objectToByteBuffer(Object obj)
     Serializes/Streams an object into a byte buffer. The object has to implement interface Serializable or Externalizable or Streamable.
public static  ObjectoldObjectFromByteBuffer(byte[] buffer)
    
public static  ObjectoldObjectFromByteBuffer(byte[] buffer, int offset, int length)
    
public static  byte[]oldObjectToByteBuffer(Object obj)
     Serializes/Streams an object into a byte buffer. The object has to implement interface Serializable or Externalizable or Streamable.
public static  InetAddressparseBindAddress(Properties props, String property)
    
public static  booleanparseBoolean(Properties props, String property, boolean defaultValue)
    
public static  long[]parseCommaDelimitedLongs(String s)
     Parses comma-delimited longs; e.g., 2000,4000,8000.
public static  java.util.ListparseCommaDelimitedStrings(String l)
     e.g.
public static  intparseInt(Properties props, String property, int defaultValue)
    
public static  longparseLong(Properties props, String property, long defaultValue)
    
public static  ListparseStringList(String l, String separator)
    
public static  ObjectpickRandomElement(Vector list)
    
public static  VectorpickSubset(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.
public static  Stringprint(Throwable t)
    
public static  StringprintBytes(long bytes)
    
public static  StringprintBytes(double bytes)
    
public static  StringprintEvent(Event evt)
    
public static  voidprintFragments(byte[] frags)
    
public static  StringprintMembers(Vector v)
    
public static  StringprintMessage(Message msg)
    
public static  StringprintMethodCall(Message msg)
     Tries to read a MethodCall object from the message's buffer and prints it.
public static  StringprintStackTrace(Throwable t)
    
public static  voidprintThreads()
    
public static  voidprompt(String s)
    
public static  longrandom(long range)
    
public static  AddressreadAddress(DataInputStream in)
    
public static  CollectionreadAddresses(DataInputStream in, Class cl)
    
Parameters:
  in -
Parameters:
  cl - The type of Collection, e.g.
public static  AuthTokenreadAuthToken(DataInputStream in)
    
public static  byte[]readByteBuffer(DataInputStream in)
    
public static  StreamablereadGenericStreamable(DataInputStream in)
    
public static  ObjectreadObject(DataInputStream in)
    
public static  StreamablereadStreamable(Class clazz, DataInputStream in)
    
public static  StringreadString(DataInputStream in)
    
public static  voidrelease(Sync sync)
     Releases the given Sync, suppressing any Throwable.
public static  booleansameHost(Address one, Address two)
    
public static  StringshortName(String hostname)
    
public static  StringshortName(InetAddress hostname)
    
public static  intsize(Address addr)
    
public static  longsize(Collection addrs)
     Returns the marshalled size of a Collection of Addresses.
public static  longsizeOf(String classname)
    
public static  longsizeOf(Object inst)
    
public static  longsizeOf(Streamable inst)
    
public static  voidsleep(long timeout)
     Sleep for timeout msecs.
public static  voidsleep(long timeout, int nanos)
    
public static  voidsleep(long msecs, boolean busy_sleep)
     On most UNIX systems, the minimum sleep time is 10-20ms.
public static  voidsleepRandom(long timeout)
     Sleeps between 1 and timeout milliseconds, chosen randomly.
public static  StreamablestreamableFromByteBuffer(Class cl, byte[] buffer)
    
public static  StreamablestreamableFromByteBuffer(Class cl, byte[] buffer, int offset, int length)
    
public static  byte[]streamableToByteBuffer(Streamable obj)
    
public static  StringsubstituteVariable(String val)
     Replaces variables of ${var:default} with System.getProperty(var, default).
public static  booleantossWeightedCoin(double probability)
     Tosses a coin weighted with probability and returns true or false.
public static  voidunlock(Sync sync)
     Releases the given Sync, suppressing any Throwable.
public static  VectorunmodifiableVector(Vector v)
    
public static  voidwriteAddress(Address addr, DataOutputStream out)
    
public static  voidwriteAddresses(Collection v, DataOutputStream out)
     Writes a Vector of Addresses.
public static  voidwriteAuthToken(AuthToken token, DataOutputStream out)
    
public static  voidwriteByteBuffer(byte[] buf, DataOutputStream out)
    
public static  voidwriteFully(ByteBuffer buf, 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.
public static  voidwriteGenericStreamable(Streamable obj, DataOutputStream out)
    
public static  voidwriteObject(Object obj, DataOutputStream out)
    
public static  voidwriteStreamable(Streamable obj, DataOutputStream out)
    
public static  voidwriteString(String s, DataOutputStream out)
    

Field Detail
DIAG_GROUP
final public static String DIAG_GROUP(Code)



JGROUPS_COMPAT
static boolean JGROUPS_COMPAT(Code)



MAX_PORT
final public static int MAX_PORT(Code)



resolve_dns
static boolean resolve_dns(Code)





Method Detail
acquire
public static boolean acquire(Sync sync)(Code)
Attempts to acquire the given Sync, suppressing any InterruptedException.
Parameters:
  sync - the Sync true if the Sync was acquired, falseif an InterruptedException was caught and suppressed.



activeThreads
public static String activeThreads()(Code)



all
public static boolean all(Collection c, Object obj)(Code)
Returns true if all elements of c match obj



array2String
public static String array2String(long[] array)(Code)



array2String
public static String array2String(int[] array)(Code)



array2String
public static String array2String(boolean[] array)(Code)



array2String
public static String array2String(Object[] array)(Code)



byteBufferToMessageList
public static LinkedList byteBufferToMessageList(byte[] buffer, int offset, int length) throws Exception(Code)



checkBufferSize
public static void checkBufferSize(String buf_name, long val)(Code)
Verifies that val is <= max memory
Parameters:
  buf_name -
Parameters:
  val -



checkForLinux
public static boolean checkForLinux()(Code)



checkForSolaris
public static boolean checkForSolaris()(Code)



checkForWindows
public static boolean checkForWindows()(Code)



close
public static void close(InputStream inp)(Code)



close
public static void close(OutputStream out)(Code)



close
public static void close(Socket s)(Code)



close
public static void close(DatagramSocket my_sock)(Code)



collectionToByteBuffer
public static byte[] collectionToByteBuffer(Collection c) throws Exception(Code)



computeFragOffsets
public static java.util.List computeFragOffsets(int offset, int length, int frag_size)(Code)
Given a buffer and a fragmentation size, compute a list of fragmentation offset/length pairs, and return them in a list. Example:
Buffer is 10 bytes, frag_size is 4 bytes. Return value will be ({0,4}, {4,4}, {8,2}). This is a total of 3 fragments: the first fragment starts at 0, and has a length of 4 bytes, the second fragment starts at offset 4 and has a length of 4 bytes, and the last fragment starts at offset 8 and has a length of 2 bytes.
Parameters:
  frag_size - List. A List of offset/length pairs



computeFragOffsets
public static java.util.List computeFragOffsets(byte[] buf, int frag_size)(Code)



crash
public static void crash()(Code)



createDatagramSocket
public static DatagramSocket createDatagramSocket(InetAddress addr, int port) throws Exception(Code)
Creates a DatagramSocket bound to addr. If addr is null, socket won't be bound. If address is already in use, start_port will be incremented until a socket can be created.
Parameters:
  addr - The InetAddress to which the socket should be bound. If null, the socket will not be bound.
Parameters:
  port - The port which the socket should use. If 0, a random port will be used. If > 0, but port is alreadyin use, it will be incremented until an unused port is found, or until MAX_PORT is reached.



createServerSocket
public static ServerSocket createServerSocket(int start_port)(Code)
Finds first available port starting at start_port and returns server socket



createServerSocket
public static ServerSocket createServerSocket(InetAddress bind_addr, int start_port)(Code)



defragmentBuffer
public static byte[] defragmentBuffer(byte[] fragments)(Code)
Concatenates smaller fragments into entire buffers.
Parameters:
  fragments - An array of byte buffers (byte[]) A byte buffer



determineLeftMembers
public static Vector determineLeftMembers(Vector old_mbrs, Vector new_mbrs)(Code)
Returns all members that left between 2 views. All members that are element of old_mbrs but not element of new_mbrs are returned.



doubleWrite
public static void doubleWrite(byte[] buf, OutputStream out) throws Exception(Code)
Makes sure that we detect when a peer connection is in the closed state (not closed while we send data, but before we send data). Two writes ensure that, if the peer closed the connection, the first write will send the peer from FIN to RST state, and the second will cause a signal (IOException).



doubleWrite
public static void doubleWrite(byte[] buf, int offset, int length, OutputStream out) throws Exception(Code)
Makes sure that we detect when a peer connection is in the closed state (not closed while we send data, but before we send data). Two writes ensure that, if the peer closed the connection, the first write will send the peer from FIN to RST state, and the second will cause a signal (IOException).



dumpQueue
public static String dumpQueue(Queue q)(Code)
Debugging method used to dump the content of a protocol queue in a condensed form. Useful to follow the evolution of the queue's content in time.



dumpStack
public static void dumpStack(boolean exit)(Code)



fileExists
public static boolean fileExists(String fname)(Code)



fragmentBuffer
public static byte[][] fragmentBuffer(byte[] buf, int frag_size, int length)(Code)
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. An array of byte buffers (byte[]).



fragmentBuffer
public static byte[][] fragmentBuffer(byte[] buf, int frag_size)(Code)



generateList
public static String generateList(Collection c, String separator)(Code)



getAllAvailableInterfaces
public static List getAllAvailableInterfaces() throws SocketException(Code)



getFirstNonLoopbackAddress
public static InetAddress getFirstNonLoopbackAddress() throws SocketException(Code)



getFirstNonLoopbackIPv6Address
public static InetAddress getFirstNonLoopbackIPv6Address() throws SocketException(Code)



getGlobalThreadGroup
public static ThreadGroup getGlobalThreadGroup()(Code)



getHostname
public static String getHostname()(Code)



getJavaVersion
public static int getJavaVersion()(Code)



getMBeanServer
public static MBeanServer getMBeanServer()(Code)



getProperty
public static String getProperty(String[] system_props, Properties props, String prop_name, boolean ignore_sysprops, String default_value)(Code)
Returns a value associated wither with one or more system properties, or found in the props map
Parameters:
  system_props -
Parameters:
  props - List of properties read from the configuration file
Parameters:
  prop_name - The name of the property, will be removed from props if found
Parameters:
  ignore_sysprops - If true, system properties are not used and the values will only be retrieved fromprops (not system_props)
Parameters:
  default_value - Used to return a default value if the properties or system properties didn't have the value The value, or null if not found



getResourceAsStream
public static InputStream getResourceAsStream(String name, Class clazz)(Code)



getStackTrace
public static String getStackTrace(Throwable t)(Code)



isBindAddressPropertyIgnored
public static boolean isBindAddressPropertyIgnored()(Code)



loadClass
public static Class loadClass(String classname, Class clazz) throws ClassNotFoundException(Code)
Tries to load the class from the current thread's context class loader. If not successful, tries to load the class from the current instance.
Parameters:
  classname - Desired class.
Parameters:
  clazz - Class object used to obtain a class loaderif no context class loader is available. Class, or null on failure.



lock
public static void lock(Sync sync)(Code)
Acquires the given Sync, but will not throw an InterruptedException. If an InterruptedException is thrown while waiting to acquire, it will be ignored, and another attempt will be made to acquire, continuing until successful. If any InterruptedException is caught and ignored, before returning Thread.interrupt will be invoked, allowing the caller to be aware of the interruption.
Parameters:
  sync -



main
public static void main(String args) throws Exception(Code)



match
public static boolean match(Object obj1, Object obj2)(Code)



match
public static boolean match(long[] a1, long[] a2)(Code)



memStats
public static String memStats(boolean gc)(Code)



msgListToByteBuffer
public static Buffer msgListToByteBuffer(LinkedList xmit_list) throws IOException(Code)
Marshalls a list of messages.
Parameters:
  xmit_list - LinkedList Buffer
throws:
  IOException -



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



objectFromByteBuffer
public static Object objectFromByteBuffer(byte[] buffer, int offset, int length) throws Exception(Code)



objectToByteBuffer
public static byte[] objectToByteBuffer(Object obj) throws Exception(Code)
Serializes/Streams an object into a byte buffer. The object has to implement interface Serializable or Externalizable or Streamable. Only Streamable objects are interoperable w/ jgroups-me



oldObjectFromByteBuffer
public static Object oldObjectFromByteBuffer(byte[] buffer) throws Exception(Code)
For backward compatibility in JBoss 4.0.2



oldObjectFromByteBuffer
public static Object oldObjectFromByteBuffer(byte[] buffer, int offset, int length) throws Exception(Code)



oldObjectToByteBuffer
public static byte[] oldObjectToByteBuffer(Object obj) throws Exception(Code)
Serializes/Streams an object into a byte buffer. The object has to implement interface Serializable or Externalizable or Streamable. Only Streamable objects are interoperable w/ jgroups-me



parseBindAddress
public static InetAddress parseBindAddress(Properties props, String property) throws UnknownHostException(Code)



parseBoolean
public static boolean parseBoolean(Properties props, String property, boolean defaultValue)(Code)



parseCommaDelimitedLongs
public static long[] parseCommaDelimitedLongs(String s)(Code)
Parses comma-delimited longs; e.g., 2000,4000,8000. Returns array of long, or null.



parseCommaDelimitedStrings
public static java.util.List parseCommaDelimitedStrings(String l)(Code)
e.g. "bela,jeannette,michelle" --> List{"bela", "jeannette", "michelle"}



parseInt
public static int parseInt(Properties props, String property, int defaultValue)(Code)



parseLong
public static long parseLong(Properties props, String property, long defaultValue)(Code)



parseStringList
public static List parseStringList(String l, String separator)(Code)



pickRandomElement
public static Object pickRandomElement(Vector list)(Code)



pickSubset
public static Vector pickSubset(Vector members, double subset_percentage)(Code)
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.



print
public static String print(Throwable t)(Code)



printBytes
public static String printBytes(long bytes)(Code)



printBytes
public static String printBytes(double bytes)(Code)



printEvent
public static String printEvent(Event evt)(Code)



printFragments
public static void printFragments(byte[] frags)(Code)



printMembers
public static String printMembers(Vector v)(Code)



printMessage
public static String printMessage(Message msg)(Code)
Tries to read an object from the message's buffer and prints it



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



printStackTrace
public static String printStackTrace(Throwable t)(Code)
Use with caution: lots of overhead



printThreads
public static void printThreads()(Code)



prompt
public static void prompt(String s)(Code)



random
public static long random(long range)(Code)
Returns a random value in the range [1 - range]



readAddress
public static Address readAddress(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException(Code)



readAddresses
public static Collection readAddresses(DataInputStream in, Class cl) throws IOException, IllegalAccessException, InstantiationException(Code)

Parameters:
  in -
Parameters:
  cl - The type of Collection, e.g. Vector.class Collection of Address objects
throws:
  IOException -
throws:
  IllegalAccessException -
throws:
  InstantiationException -



readAuthToken
public static AuthToken readAuthToken(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException(Code)



readByteBuffer
public static byte[] readByteBuffer(DataInputStream in) throws IOException(Code)



readGenericStreamable
public static Streamable readGenericStreamable(DataInputStream in) throws IOException(Code)



readObject
public static Object readObject(DataInputStream in) throws Exception(Code)



readStreamable
public static Streamable readStreamable(Class clazz, DataInputStream in) throws IOException, IllegalAccessException, InstantiationException(Code)



readString
public static String readString(DataInputStream in) throws IOException(Code)



release
public static void release(Sync sync)(Code)
Releases the given Sync, suppressing any Throwable.
Parameters:
  sync - the Sync



sameHost
public static boolean sameHost(Address one, Address two)(Code)
Checks whether 2 Addresses are on the same host



shortName
public static String shortName(String hostname)(Code)



shortName
public static String shortName(InetAddress hostname)(Code)



size
public static int size(Address addr)(Code)



size
public static long size(Collection addrs)(Code)
Returns the marshalled size of a Collection of Addresses. Assumes elements are of the same type !
Parameters:
  addrs - Collection
long size



sizeOf
public static long sizeOf(String classname)(Code)



sizeOf
public static long sizeOf(Object inst)(Code)



sizeOf
public static long sizeOf(Streamable inst)(Code)



sleep
public static void sleep(long timeout)(Code)
Sleep for timeout msecs. Returns when timeout has elapsed or thread was interrupted



sleep
public static void sleep(long timeout, int nanos)(Code)



sleep
public static void sleep(long msecs, boolean busy_sleep)(Code)
On most UNIX systems, the minimum sleep time is 10-20ms. Even if we specify sleep(1), the thread will sleep for at least 10-20ms. On Windows, sleep() seems to be implemented as a busy sleep, that is the thread never relinquishes control and therefore the sleep(x) is exactly x ms long.



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



streamableFromByteBuffer
public static Streamable streamableFromByteBuffer(Class cl, byte[] buffer) throws Exception(Code)



streamableFromByteBuffer
public static Streamable streamableFromByteBuffer(Class cl, byte[] buffer, int offset, int length) throws Exception(Code)



streamableToByteBuffer
public static byte[] streamableToByteBuffer(Streamable obj) throws Exception(Code)



substituteVariable
public static String substituteVariable(String val)(Code)
Replaces variables of ${var:default} with System.getProperty(var, default). If no variables are found, returns the same string, otherwise a copy of the string with variables substituted
Parameters:
  val - A string with vars replaced, or the same string if no vars found



tossWeightedCoin
public static boolean tossWeightedCoin(double probability)(Code)
Tosses a coin weighted with probability and returns true or false. Example: if probability=0.8, chances are that in 80% of all cases, true will be returned and false in 20%.



unlock
public static void unlock(Sync sync)(Code)
Releases the given Sync, suppressing any Throwable. Same as @{link Util.release(Sync) }; just included as a logically named counterpart to Util.lock(Sync) .
Parameters:
  sync - the Sync



unmodifiableVector
public static Vector unmodifiableVector(Vector v)(Code)



writeAddress
public static void writeAddress(Address addr, DataOutputStream out) throws IOException(Code)



writeAddresses
public static void writeAddresses(Collection v, DataOutputStream out) throws IOException(Code)
Writes a Vector of Addresses. Can contain 65K addresses at most
Parameters:
  v - A Collection

Parameters:
  out -
throws:
  IOException -



writeAuthToken
public static void writeAuthToken(AuthToken token, DataOutputStream out) throws IOException(Code)



writeByteBuffer
public static void writeByteBuffer(byte[] buf, DataOutputStream out) throws IOException(Code)



writeFully
public static void writeFully(ByteBuffer buf, WritableByteChannel out) throws IOException(Code)
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. Instead of the above approach this method will continuously write to the channel until the buffer sent fully.



writeGenericStreamable
public static void writeGenericStreamable(Streamable obj, DataOutputStream out) throws IOException(Code)



writeObject
public static void writeObject(Object obj, DataOutputStream out) throws Exception(Code)



writeStreamable
public static void writeStreamable(Streamable obj, DataOutputStream out) throws IOException(Code)



writeString
public static void writeString(String s, DataOutputStream out) throws IOException(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.