org.archive.util
Class JEMBeanHelper

java.lang.Object
  extended by org.archive.util.JEMBeanHelper

public class JEMBeanHelper
extends java.lang.Object

JEMBeanHelper is a utility class for the MBean implementation which wants to add management of a JE environment to its capabilities. MBean implementations can contain a JEMBeanHelper instance to get MBean metadata for JE and to set attributes, get attributes, and invoke operations.

com.sleepycat.je.jmx.JEMonitor and the example program jmx.JEApplicationMBean are two MBean implementations which provide support different application use cases. See those classes for examples of how to use JEMBeanHelper.

This class was copied from the bdb je 2.0 jmx examples.


Field Summary
static java.lang.String ATT_CACHE_PERCENT
           
static java.lang.String ATT_CACHE_SIZE
           
static java.lang.String ATT_ENV_HOME
           
static java.lang.String ATT_IS_READ_ONLY
           
static java.lang.String ATT_IS_SERIALIZABLE
           
static java.lang.String ATT_IS_TRANSACTIONAL
           
static java.lang.String ATT_LOCK_TIMEOUT
           
static java.lang.String ATT_OPEN
           
static java.lang.String ATT_SET_READ_ONLY
           
static java.lang.String ATT_SET_SERIALIZABLE
           
static java.lang.String ATT_SET_TRANSACTIONAL
           
static java.lang.String ATT_TXN_TIMEOUT
           
(package private) static java.lang.String OP_CHECKPOINT
           
(package private) static java.lang.String OP_CLEAN
           
(package private) static java.lang.String OP_DB_NAMES
           
(package private) static java.lang.String OP_DB_STAT
           
(package private) static java.lang.String OP_ENV_STAT
           
(package private) static java.lang.String OP_ENV_STAT_STR
           
(package private) static java.lang.String OP_EVICT
           
(package private) static java.lang.String OP_LOCK_STAT
           
(package private) static java.lang.String OP_LOCK_STAT_STR
           
(package private) static java.lang.String OP_SYNC
           
(package private) static java.lang.String OP_TXN_STAT
           
 
Constructor Summary
JEMBeanHelper(com.sleepycat.je.EnvironmentConfig config, java.io.File environmentHome, boolean canConfigure)
          Instantiate a helper, specifying environment home and open capabilities.
 
Method Summary
 java.lang.Object getAttribute(com.sleepycat.je.Environment targetEnv, java.lang.String attributeName)
          Get an attribute value for the given environment.
 java.util.List<javax.management.MBeanAttributeInfo> getAttributeList(com.sleepycat.je.Environment targetEnv)
          Get MBean attribute metadata for this environment.
 java.io.File getEnvironmentHome()
          Return the target environment directory.
 com.sleepycat.je.Environment getEnvironmentIfOpen()
          Return an Environment only if the environment has already been opened in this process.
 com.sleepycat.je.EnvironmentConfig getEnvironmentOpenConfig()
          If the helper was instantiated with canConfigure==true, it shows environment configuration attributes.
 boolean getNeedReset()
          Tell the MBean if the available set of functionality has changed.
 javax.management.MBeanNotificationInfo[] getNotificationInfo(com.sleepycat.je.Environment targetEnv)
          No notifications are supported.
 java.util.List<javax.management.MBeanOperationInfo> getOperationList(com.sleepycat.je.Environment targetEnv)
          Get mbean operation metadata for this environment.
 java.lang.Object invoke(com.sleepycat.je.Environment targetEnv, java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
          Invoke an operation for the given environment.
 void setAttribute(com.sleepycat.je.Environment targetEnv, javax.management.Attribute attribute)
          Set an attribute value for the given environment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATT_ENV_HOME

public static final java.lang.String ATT_ENV_HOME
See Also:
Constant Field Values

ATT_OPEN

public static final java.lang.String ATT_OPEN
See Also:
Constant Field Values

ATT_IS_READ_ONLY

public static final java.lang.String ATT_IS_READ_ONLY
See Also:
Constant Field Values

ATT_IS_TRANSACTIONAL

public static final java.lang.String ATT_IS_TRANSACTIONAL
See Also:
Constant Field Values

ATT_CACHE_SIZE

public static final java.lang.String ATT_CACHE_SIZE
See Also:
Constant Field Values

ATT_CACHE_PERCENT

public static final java.lang.String ATT_CACHE_PERCENT
See Also:
Constant Field Values

ATT_LOCK_TIMEOUT

public static final java.lang.String ATT_LOCK_TIMEOUT
See Also:
Constant Field Values

ATT_IS_SERIALIZABLE

public static final java.lang.String ATT_IS_SERIALIZABLE
See Also:
Constant Field Values

ATT_TXN_TIMEOUT

public static final java.lang.String ATT_TXN_TIMEOUT
See Also:
Constant Field Values

ATT_SET_READ_ONLY

public static final java.lang.String ATT_SET_READ_ONLY
See Also:
Constant Field Values

ATT_SET_TRANSACTIONAL

public static final java.lang.String ATT_SET_TRANSACTIONAL
See Also:
Constant Field Values

ATT_SET_SERIALIZABLE

public static final java.lang.String ATT_SET_SERIALIZABLE
See Also:
Constant Field Values

OP_CLEAN

static final java.lang.String OP_CLEAN
See Also:
Constant Field Values

OP_EVICT

static final java.lang.String OP_EVICT
See Also:
Constant Field Values

OP_CHECKPOINT

static final java.lang.String OP_CHECKPOINT
See Also:
Constant Field Values

OP_SYNC

static final java.lang.String OP_SYNC
See Also:
Constant Field Values

OP_ENV_STAT

static final java.lang.String OP_ENV_STAT
See Also:
Constant Field Values

OP_ENV_STAT_STR

static final java.lang.String OP_ENV_STAT_STR
See Also:
Constant Field Values

OP_LOCK_STAT

static final java.lang.String OP_LOCK_STAT
See Also:
Constant Field Values

OP_LOCK_STAT_STR

static final java.lang.String OP_LOCK_STAT_STR
See Also:
Constant Field Values

OP_TXN_STAT

static final java.lang.String OP_TXN_STAT
See Also:
Constant Field Values

OP_DB_NAMES

static final java.lang.String OP_DB_NAMES
See Also:
Constant Field Values

OP_DB_STAT

static final java.lang.String OP_DB_STAT
See Also:
Constant Field Values
Constructor Detail

JEMBeanHelper

public JEMBeanHelper(com.sleepycat.je.EnvironmentConfig config,
                     java.io.File environmentHome,
                     boolean canConfigure)
Instantiate a helper, specifying environment home and open capabilities.

Parameters:
environmentHome - home directory of the target JE environment.
canConfigure - If true, the helper will show environment configuration attributes.
Method Detail

getEnvironmentHome

public java.io.File getEnvironmentHome()
Return the target environment directory.

Returns:
the environment directory.

getEnvironmentOpenConfig

public com.sleepycat.je.EnvironmentConfig getEnvironmentOpenConfig()
If the helper was instantiated with canConfigure==true, it shows environment configuration attributes. Those attributes are returned within this EnvironmentConfig object for use in opening environments.

Returns:
EnvironmentConfig object which saves configuration attributes recorded through MBean attributes.

getEnvironmentIfOpen

public com.sleepycat.je.Environment getEnvironmentIfOpen()
Return an Environment only if the environment has already been opened in this process. A helper method for MBeans which want to only access open environments.

Returns:
Environment if already open, null if not open.

getNeedReset

public boolean getNeedReset()
Tell the MBean if the available set of functionality has changed.

Returns:
true if the MBean should regenerate its JE metadata.

getAttributeList

public java.util.List<javax.management.MBeanAttributeInfo> getAttributeList(com.sleepycat.je.Environment targetEnv)
Get MBean attribute metadata for this environment.

Parameters:
targetEnv - The target JE environment. May be null if the environment is not open.
Returns:
list of MBeanAttributeInfo objects describing the available attributes.

getAttribute

public java.lang.Object getAttribute(com.sleepycat.je.Environment targetEnv,
                                     java.lang.String attributeName)
                              throws javax.management.AttributeNotFoundException,
                                     javax.management.MBeanException
Get an attribute value for the given environment. Check JEMBeanHelper.getNeedReset() after this call because the helper may detect that the environment has changed and that the MBean metadata should be reset.

Parameters:
targetEnv - The target JE environment. May be null if the environment is not open.
attributeName - attribute name.
Returns:
attribute value.
Throws:
javax.management.AttributeNotFoundException
javax.management.MBeanException

setAttribute

public void setAttribute(com.sleepycat.je.Environment targetEnv,
                         javax.management.Attribute attribute)
                  throws javax.management.AttributeNotFoundException,
                         javax.management.InvalidAttributeValueException
Set an attribute value for the given environment.

Parameters:
targetEnv - The target JE environment. May be null if the environment is not open.
attribute - name/value pair
Throws:
javax.management.AttributeNotFoundException
javax.management.InvalidAttributeValueException

getOperationList

public java.util.List<javax.management.MBeanOperationInfo> getOperationList(com.sleepycat.je.Environment targetEnv)
Get mbean operation metadata for this environment.

Parameters:
targetEnv - The target JE environment. May be null if the environment is not open.
Returns:
List of MBeanOperationInfo describing available operations.

invoke

public java.lang.Object invoke(com.sleepycat.je.Environment targetEnv,
                               java.lang.String actionName,
                               java.lang.Object[] params,
                               java.lang.String[] signature)
                        throws javax.management.MBeanException
Invoke an operation for the given environment.

Parameters:
targetEnv - The target JE environment. May be null if the environment is not open.
actionName - operation name.
params - operation parameters. May be null.
signature - operation signature. May be null.
Returns:
the operation result
Throws:
javax.management.MBeanException

getNotificationInfo

public javax.management.MBeanNotificationInfo[] getNotificationInfo(com.sleepycat.je.Environment targetEnv)
No notifications are supported.

Returns:
List of MBeanNotificationInfo for available notifications.


Copyright © 2003-2011 Internet Archive. All Rights Reserved.