com.sleepycat.je.rep.utilint
Class RepUtils

java.lang.Object
  extended by com.sleepycat.je.rep.utilint.RepUtils

public class RepUtils
extends Object


Nested Class Summary
static interface RepUtils.ConsistencyPolicyFormat<T extends ReplicaConsistencyPolicy>
          ReplicaConsistencyPolicy must be stored as a String for use with ReplicationConfig and je.properties.
static class RepUtils.ExceptionAwareBlockingQueue<T>
          Like LinkedBlockingQueue, but provides a pollOrException() method that should be used instead of poll(), so that callers don't have to treat exception cases specially.
static class RepUtils.ExceptionAwareCountDownLatch
          Like CountDownLatch, but makes provision in the await for the await, or more specifically the new awaitOrException method to be exited via an exception.
 
Field Summary
static SocketChannel CHANNEL_EOF_MARKER
           
static boolean DEBUG_PRINT_THREAD
           
static boolean DEBUG_PRINT_TIME
           
 
Constructor Summary
RepUtils()
           
 
Method Summary
static void addConsistencyPolicyFormat(String name, RepUtils.ConsistencyPolicyFormat<?> format)
          Define a new ConsistencyPolicyFormat.
static Throwable chainExceptionCause(Throwable newt, Throwable oldt)
          Chains an old outstanding exception to the tail of a new one, so it's not lost.
static String getPropertyString(ReplicaConsistencyPolicy policy)
          Converts a policy into a string suitable for use as a property value in a je.properties file or elsewhere.
static ReplicaConsistencyPolicy getReplicaConsistencyPolicy(String propertyValue)
          Converts a property string into a policy instance.
static SocketChannel openBlockingChannel(InetSocketAddress addr, boolean tcpNoDelay, int timeout)
          An overloading of the above when the receive buffer size is to be defaulted.
static SocketChannel openBlockingChannel(InetSocketAddress addr, boolean tcpNoDelay, int receiveBufferSize, int timeout)
          Create a socket channel with the designated properties
static void shutdownChannel(NamedChannel namedChannel)
          Forces a shutdown of the channel ignoring any errors that may be encountered in the process.
static String writeTimesString(StatGroup stats)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_PRINT_THREAD

public static final boolean DEBUG_PRINT_THREAD
See Also:
Constant Field Values

DEBUG_PRINT_TIME

public static final boolean DEBUG_PRINT_TIME
See Also:
Constant Field Values

CHANNEL_EOF_MARKER

public static final SocketChannel CHANNEL_EOF_MARKER
Constructor Detail

RepUtils

public RepUtils()
Method Detail

addConsistencyPolicyFormat

public static void addConsistencyPolicyFormat(String name,
                                              RepUtils.ConsistencyPolicyFormat<?> format)
Define a new ConsistencyPolicyFormat. Should only be called outside of this class to add support custom policies for testing. Must be called when the system is quiescent, since the map is unsynchronized.

Parameters:
name - must be the first part of the policy string with a non-letter delimiter following it, or must be the entire policy string.
format - to register.

getPropertyString

public static String getPropertyString(ReplicaConsistencyPolicy policy)
                                throws IllegalArgumentException
Converts a policy into a string suitable for use as a property value in a je.properties file or elsewhere.

Parameters:
policy - the policy being converted.
Returns:
the formatted string representing the policy.
Throws:
IllegalArgumentException - if the specific policy does not have a property value format, via ReplicationConfig(Properties) ctor and setter.
See Also:
getReplicaConsistencyPolicy(String)

getReplicaConsistencyPolicy

public static ReplicaConsistencyPolicy getReplicaConsistencyPolicy(String propertyValue)
                                                            throws IllegalArgumentException
Converts a property string into a policy instance.

Parameters:
propertyValue - the formatted string representing the policy.
Returns:
the policy computed from the string
Throws:
IllegalArgumentException - via ReplicationConfig(Properties) ctor and setter.

shutdownChannel

public static void shutdownChannel(NamedChannel namedChannel)
Forces a shutdown of the channel ignoring any errors that may be encountered in the process.

Parameters:
namedChannel - the channel to be shutdown

openBlockingChannel

public static SocketChannel openBlockingChannel(InetSocketAddress addr,
                                                boolean tcpNoDelay,
                                                int receiveBufferSize,
                                                int timeout)
                                         throws IOException
Create a socket channel with the designated properties

Parameters:
addr - the remote endpoint socket address
tcpNoDelay - true, if the nagle algorithm is to be used
receiveBufferSize - the SO_RCVBUF value for the tcp window. A zero value indicates that the os level defaults should be used.
timeout - the SO_TIMEOUT to be associated with the channel
Returns:
the connected channel
Throws:
IOException

openBlockingChannel

public static SocketChannel openBlockingChannel(InetSocketAddress addr,
                                                boolean tcpNoDelay,
                                                int timeout)
                                         throws IOException
An overloading of the above when the receive buffer size is to be defaulted.

Throws:
IOException
See Also:
openBlockingChannel(InetSocketAddress, boolean, int, int)

chainExceptionCause

public static Throwable chainExceptionCause(Throwable newt,
                                            Throwable oldt)
Chains an old outstanding exception to the tail of a new one, so it's not lost.

Parameters:
newt - the new throwable
oldt - the old throwable
Returns:
the new throwable extended with the old cause

writeTimesString

public static String writeTimesString(StatGroup stats)


Copyright (c) 2004-2012 Oracle. All rights reserved.