⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jembeanhelper.java

📁 这是个爬虫和lucece相结合最好了
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*-* See the file LICENSE for redistribution information.** Copyright (c) 2002-2005*      Sleepycat Software.  All rights reserved.** $Id: JEMBeanHelper.java 4644 2006-09-20 22:40:21Z paul_jack $*/package org.archive.util;import java.io.File;import java.util.ArrayList;import java.util.List;import javax.management.Attribute;import javax.management.AttributeNotFoundException;import javax.management.InvalidAttributeValueException;import javax.management.MBeanAttributeInfo;import javax.management.MBeanException;import javax.management.MBeanNotificationInfo;import javax.management.MBeanOperationInfo;import javax.management.MBeanParameterInfo;import com.sleepycat.je.CheckpointConfig;import com.sleepycat.je.Database;import com.sleepycat.je.DatabaseConfig;import com.sleepycat.je.DatabaseException;import com.sleepycat.je.DatabaseStats;import com.sleepycat.je.DbInternal;import com.sleepycat.je.Environment;import com.sleepycat.je.EnvironmentConfig;import com.sleepycat.je.EnvironmentMutableConfig;import com.sleepycat.je.StatsConfig;/** * 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. * <p> * 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. * <p>This class was copied from the bdb je 2.0 jmx examples. */public class JEMBeanHelper {    /*     * A note to JE developers: all available JE attributes and operations are     * described in the following static info arrays. New management     * functionality can be added to the helper by adding to the appropriate     * set of static definitions. For example, if we want to add a new JE     * attribute called "foo", which is available for open environments, we     * need to define a new MBeanAttributeInfo in the OPEN_ATTR array. The     * helper then needs to provide an implementation in set/getAttribute.     */        /* --------------------- Attributes -------------------------- */    /* Attribute names. */    public static final String ATT_ENV_HOME = "environmentHome";    public static final String ATT_OPEN = "isOpen";    public static final String ATT_IS_READ_ONLY = "isReadOnly";    public static final String ATT_IS_TRANSACTIONAL = "isTransactional";    public static final String ATT_CACHE_SIZE = "cacheSize";    public static final String ATT_CACHE_PERCENT = "cachePercent";    public static final String ATT_LOCK_TIMEOUT = "lockTimeout";    public static final String ATT_IS_SERIALIZABLE = "isSerializableIsolation";    public static final String ATT_TXN_TIMEOUT = "transactionTimeout";    public static final String ATT_SET_READ_ONLY = "openReadOnly";    public static final String ATT_SET_TRANSACTIONAL = "openTransactional";    public static final String ATT_SET_SERIALIZABLE =        "openSerializableIsolation";        /* COMMON_ATTR attributes are available for any environment. */    private static final MBeanAttributeInfo [] COMMON_ATTR = {                new MBeanAttributeInfo(ATT_ENV_HOME,                               "java.lang.String",                               "Environment home directory.",                               true,   // readable                               false,  // writable                               false), // isIs        new MBeanAttributeInfo(ATT_OPEN,                               "java.lang.Boolean",                               "True if this environment is open.",                               true,   // readable                               false,  // writable                               true)   // isIs    };    /* OPEN_ATTR attributes are available for all open environments. */    private static final MBeanAttributeInfo [] OPEN_ATTR = {        new MBeanAttributeInfo(ATT_IS_READ_ONLY,                               "java.lang.Boolean",                               "True if this environment is read only.",                               true,   // readable                               false,  // writable                               true),  // isIs        new MBeanAttributeInfo(ATT_IS_TRANSACTIONAL,                               "java.lang.Boolean",                             "True if this environment supports transactions.",                               true,   // readable                               false,  // writable                               true),  // isIs        new MBeanAttributeInfo(ATT_CACHE_SIZE,                               "java.lang.Long",                               "Cache size, in bytes.",                               true,   // readable                               true,   // writable                               false), // isIs        new MBeanAttributeInfo(ATT_CACHE_PERCENT,                               "java.lang.Integer",                               "By default, cache size is (cachePercent * " +                               "JVM maximum memory. To change the cache size "+                               "using a percentage of the heap size, set " +                               "the cache size to 0 and cachePercent to the "+                               "desired percentage value.",                               true,   // readable                               true,   // writable                               false), // isIs        new MBeanAttributeInfo(ATT_LOCK_TIMEOUT,                               "java.lang.Long",                               "Lock timeout, in microseconds.",                               true,   // readable                               false,  // writable                               false), // isIs    };    /*      * TRANSACTIONAL_ATTR attributes are available only for open, transactional     * environments.     */    private static final MBeanAttributeInfo [] TRANSACTIONAL_ATTR = {        new MBeanAttributeInfo(ATT_IS_SERIALIZABLE,                               "java.lang.Boolean",                               "True if this environment provides " +                               "Serializable (degree 3) isolation. The " +                               "default is RepeatableRead isolation.",                               true,   // readable                               false,  // writable                               true),  // isIs        new MBeanAttributeInfo(ATT_TXN_TIMEOUT,                               "java.lang.Long",                               "Transaction timeout, in seconds. A value " +                               "of 0 means there is no timeout.",                               true,   // readable                               false,  // writable                               false)  // isIs    };    /*      * CREATE_ATTR attributes are available when the mbean is configured to     * support configuration and opening by the mbean. They express the     * configuration settings.     */    private static final MBeanAttributeInfo [] CREATE_ATTR = {                new MBeanAttributeInfo(ATT_SET_READ_ONLY,                               "java.lang.Boolean",                               "True if this environment should be opened " +                               "in readonly mode.",                               true,   // readable                               true,   // writable                               false), // isIs        new MBeanAttributeInfo(ATT_SET_TRANSACTIONAL,                               "java.lang.Boolean",                               "True if this environment should be opened " +                               "in transactional mode.",                               true,   // readable                               true,   // writable                               false), // isIs        new MBeanAttributeInfo(ATT_SET_SERIALIZABLE,                               "java.lang.Boolean",                               "True if this environment should be opened " +                               "with serializableIsolation. The default is "+                               "false.",                               true,   // readable                               true,   // writable                               false), // isIs    };    /* --------------------- Operations  -------------------------- */    /* Operation names */    static final String OP_CLEAN = "cleanLog";    static final String OP_EVICT = "evictMemory";    static final String OP_CHECKPOINT = "checkpoint";    static final String OP_SYNC = "sync";    static final String OP_ENV_STAT = "getEnvironmentStats";    static final String OP_ENV_STAT_STR = "getEnvironmentStatsToString";    static final String OP_LOCK_STAT = "getLockStats";    static final String OP_LOCK_STAT_STR = "getLockStatsToString";    static final String OP_TXN_STAT = "getTxnStats";    static final String OP_DB_NAMES = "getDatabaseNames";    static final String OP_DB_STAT = "getDatabaseStats";    private static final MBeanOperationInfo OP_CLEAN_INFO =         new MBeanOperationInfo(OP_CLEAN,                               "Remove obsolete environment log files. " +                               "Zero or more log files will be cleaned as " +                               "necessary to bring the disk space " +                               "utilization of the environment above the " +                               "configured minimum utilization threshold " +                               "as determined by the setting " +                               "je.cleaner.minUtilization. Returns the " +                               "number of files cleaned, that will be " +                               "deleted at the next qualifying checkpoint.",                               new MBeanParameterInfo[0], // no params                               "java.lang.Integer",                               MBeanOperationInfo.UNKNOWN);    private static final MBeanOperationInfo OP_EVICT_INFO =         new MBeanOperationInfo(OP_EVICT,                               "Reduce cache usage to the threshold " +                               "determined by the setting " +                               "je.evictor.useMemoryFloor. ",                               new MBeanParameterInfo[0], // no params                               "void",                               MBeanOperationInfo.UNKNOWN);    /* parameter for checkpoint operation. */    private static final MBeanParameterInfo [] checkpointParams = {        new MBeanParameterInfo ("force", "java.lang.Boolean",                                "If true, force a checkpoint even if " +                                "there has been no activity since the last " +                                "checkpoint. Returns true if a checkpoint " +                                "executed.")    };    private static final MBeanOperationInfo OP_CHECKPOINT_INFO =         new MBeanOperationInfo(OP_CHECKPOINT,                               "Checkpoint the environment.",                               checkpointParams,                               "void",                               MBeanOperationInfo.UNKNOWN);    private static final MBeanOperationInfo OP_SYNC_INFO =         new MBeanOperationInfo(OP_SYNC,                               "Flush the environment to stable storage.",                               new MBeanParameterInfo[0], // no params                               "void",                               MBeanOperationInfo.UNKNOWN);    private static final MBeanParameterInfo [] statParams = {        new MBeanParameterInfo ("clear", "java.lang.Boolean",                                "If true, reset statistics after reading."),        new MBeanParameterInfo ("fast", "java.lang.Boolean",                                "If true, only return statistics which do " +                                "not require expensive computation.")    };    private static final MBeanOperationInfo OP_ENV_STAT_INFO =         new MBeanOperationInfo(OP_ENV_STAT,                               "Get environment statistics.",                               statParams,                               "com.sleepycat.je.EnvironmentStats",                               MBeanOperationInfo.INFO);        private static final MBeanOperationInfo OP_ENV_STAT_STR_INFO =         new MBeanOperationInfo(OP_ENV_STAT_STR,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -