Examples of MBeanServer


Examples of javax.management.MBeanServer

public class ClusterWrapperBean {

    public Cluster getCluster(String serverName, String hostName, boolean loadMembers) throws Exception {
        Cluster cluster = null;

        MBeanServer mBeanServer = new Registry().getMBeanServer();
        ObjectName membershipOName = new ObjectName(serverName +":type=ClusterMembership,host=" + hostName);
        ObjectName receiverOName = new ObjectName(serverName +":type=ClusterReceiver,host=" + hostName);
        ObjectName senderOName = new ObjectName(serverName +":type=ClusterSender,host=" + hostName);

        //
        // should be just one set, this is just to find out if this instance
        // is cluster-enabled and the cluster supports JMX
        //
        Set clusters = mBeanServer.queryMBeans(new ObjectName("*:type=Cluster,host=" + hostName), null);
        Set membership = mBeanServer.queryMBeans(membershipOName, null);
        if (clusters != null && clusters.size() > 0 && membership != null && membership.size() > 0) {
            ObjectName clusterOName = ((ObjectInstance) clusters.iterator().next()).getObjectName();
            cluster = new Cluster();

            cluster.setName(JmxTools.getStringAttr(mBeanServer, clusterOName, "clusterName"));
            cluster.setInfo(JmxTools.getStringAttr(mBeanServer, clusterOName, "info"));
            cluster.setManagerClassName(JmxTools.getStringAttr(mBeanServer, clusterOName, "managerClassName"));

            cluster.setMcastAddress(JmxTools.getStringAttr(mBeanServer, membershipOName, "mcastAddr"));
            cluster.setMcastBindAddress(JmxTools.getStringAttr(mBeanServer, membershipOName, "mcastBindAddress"));
            cluster.setMcastClusterDomain(JmxTools.getStringAttr(mBeanServer, membershipOName, "mcastClusterDomain"));
            cluster.setMcastDropTime(JmxTools.getLongAttr(mBeanServer, membershipOName, "mcastDropTime"));
            cluster.setMcastFrequency(JmxTools.getLongAttr(mBeanServer, membershipOName, "mcastFrequency"));
            cluster.setMcastPort(JmxTools.getIntAttr(mBeanServer, membershipOName, "mcastPort"));
            cluster.setMcastSoTimeout(JmxTools.getIntAttr(mBeanServer, membershipOName, "mcastSoTimeout"));
            cluster.setMcastTTL(JmxTools.getIntAttr(mBeanServer, membershipOName, "mcastTTL"));

            cluster.setTcpListenAddress(JmxTools.getStringAttr(mBeanServer, receiverOName, "tcpListenAddress"));
            cluster.setTcpListenPort(JmxTools.getIntAttr(mBeanServer, receiverOName, "tcpListenPort"));
            cluster.setNrOfMsgsReceived(JmxTools.getLongAttr(mBeanServer, receiverOName, "nrOfMsgsReceived"));
            cluster.setTotalReceivedBytes(JmxTools.getLongAttr(mBeanServer, receiverOName, "totalReceivedBytes"));
//            cluster.setTcpSelectorTimeout(getLongAttr(mBeanServer, receiverOName, "tcpSelectorTimeout"));
//            cluster.setTcpThreadCount(getIntAttr(mBeanServer, receiverOName, "tcpThreadCount"));

            cluster.setSenderAckTimeout(JmxTools.getLongAttr(mBeanServer, senderOName, "ackTimeout"));
            cluster.setSenderAutoConnect(((Boolean) mBeanServer.getAttribute(senderOName, "autoConnect")).booleanValue());
            cluster.setSenderFailureCounter(JmxTools.getLongAttr(mBeanServer, senderOName, "failureCounter"));
            cluster.setSenderNrOfRequests(JmxTools.getLongAttr(mBeanServer, senderOName, "nrOfRequests"));
            cluster.setSenderReplicationMode(JmxTools.getStringAttr(mBeanServer, senderOName, "replicationMode"));
            cluster.setSenderTotalBytes(JmxTools.getLongAttr(mBeanServer, senderOName, "totalBytes"));

            if (loadMembers) {
                ObjectName senders[] = (ObjectName[]) mBeanServer.getAttribute(senderOName, "senderObjectNames");
                for (int i = 0; i < senders.length; i++) {

                    ClusterSender sender;

                    if ("pooled".equals(cluster.getSenderReplicationMode())) {
                        sender = new PooledClusterSender();
                    } else if ("synchronous".equals(cluster.getSenderReplicationMode())) {
                        sender = new SyncClusterSender();
                    } else if ("asynchronous".equals(cluster.getSenderReplicationMode()) ||
                            "fastasyncqueue".equals(cluster.getSenderReplicationMode())) {
                        sender = new AsyncClusterSender();
                    } else {
                        sender = new ClusterSender();
                    }
                    ObjectName localSenderOName = senders[i];

                    sender.setAddress(JmxTools.getStringAttr(mBeanServer, localSenderOName, "address"));
                    sender.setPort(JmxTools.getIntAttr(mBeanServer, localSenderOName, "port"));

                    sender.setAvgMessageSize(JmxTools.getLongAttr(mBeanServer, localSenderOName, "avgMessageSize", -1));
                    sender.setAvgProcessingTime(JmxTools.getLongAttr(mBeanServer, localSenderOName, "avgProcessingTime", -1));

                    sender.setConnectCounter(JmxTools.getLongAttr(mBeanServer, localSenderOName, "connectCounter"));
                    sender.setDisconnectCounter(JmxTools.getLongAttr(mBeanServer, localSenderOName, "disconnectCounter"));
                    sender.setConnected(((Boolean) mBeanServer.getAttribute(localSenderOName, "connected")).booleanValue());
                    sender.setKeepAliveTimeout(JmxTools.getLongAttr(mBeanServer, localSenderOName, "keepAliveTimeout"));
                    sender.setNrOfRequests(JmxTools.getLongAttr(mBeanServer, localSenderOName, "nrOfRequests"));
                    sender.setTotalBytes(JmxTools.getLongAttr(mBeanServer, localSenderOName, "totalBytes"));
                    sender.setResend(((Boolean) mBeanServer.getAttribute(localSenderOName, "resend")).booleanValue());
                    sender.setSuspect(((Boolean) mBeanServer.getAttribute(localSenderOName, "suspect")).booleanValue());

                    if (sender instanceof PooledClusterSender) {
                        ((PooledClusterSender) sender).setMaxPoolSocketLimit(JmxTools.getIntAttr(mBeanServer, localSenderOName, "maxPoolSocketLimit"));
                    }

View Full Code Here

Examples of javax.management.MBeanServer

        channel=new JChannel(this.props);
        channel.setReceiver(this);
        channel.connect(this.groupname);

        if(jmx) {
            MBeanServer server=Util.getMBeanServer();
            if(server == null)
                throw new Exception("No MBeanServers found; need to run with an MBeanServer present, or inside JDK 5");
            JmxConfigurator.registerChannel(channel, server, "jgroups", channel.getClusterName() , true);
        }
        start();
View Full Code Here

Examples of javax.management.MBeanServer

     *
     * @throws Exception - this method does not handle any of the exceptions that may be thrown when querying MBean server.
     */
    private synchronized void initialize() throws Exception {

        MBeanServer server = getContainerWrapper().getResourceResolver().getMBeanServer();
        String serverName = getContainerWrapper().getTomcatContainer().getName();
        Set threadPools = server.queryMBeans(new ObjectName(serverName + ":type=ThreadPool,*"), null);
        poolNames = new ArrayList(threadPools.size());
        for (Iterator it = threadPools.iterator(); it.hasNext();) {

            ThreadPoolObjectName threadPoolObjectName = new ThreadPoolObjectName();
            ObjectName threadPoolName = ((ObjectInstance) it.next()).getObjectName();

            String name = threadPoolName.getKeyProperty("name");

            threadPoolObjectName.setThreadPoolName(threadPoolName);
            ObjectName grpName = server.getObjectInstance(
                    new ObjectName(threadPoolName.getDomain() + ":type=GlobalRequestProcessor,name=" + name)).getObjectName();
            threadPoolObjectName.setGlobalRequestProcessorName(grpName);

            //
            // unfortunately exact workers could not be found at the time of testing
            // so we filter out the relevant workers within the loop
            //
            Set workers = server.queryMBeans(new ObjectName(threadPoolName.getDomain() + ":type=RequestProcessor,*"), null);

            for (Iterator wrkIt = workers.iterator(); wrkIt.hasNext();) {
                ObjectName wrkName = ((ObjectInstance) wrkIt.next()).getObjectName();
                if (name.equals(wrkName.getKeyProperty("worker"))) {
                    threadPoolObjectName.getRequestProcessorNames().add(wrkName);
                }
            }

            poolNames.add(threadPoolObjectName);
        }

        Set executors = server.queryMBeans(new ObjectName(serverName + ":type=Executor,*"), null);
        executorNames = new ArrayList(executors.size());
        for (Iterator it = executors.iterator(); it.hasNext();) {
            ObjectName executorName = ((ObjectInstance) it.next()).getObjectName();
            executorNames.add(executorName);
        }

        // Register with MBean server
        server.addNotificationListener(new ObjectName("JMImplementation:type=MBeanServerDelegate"), this, null, null);

    }
View Full Code Here

Examples of javax.management.MBeanServer

            initialize();
        }

        List threadPools = new ArrayList(poolNames.size());

        MBeanServer server = getContainerWrapper().getResourceResolver().getMBeanServer();

        for (Iterator it = executorNames.iterator(); it.hasNext();) {
            ObjectName executorName = (ObjectName) it.next();

            ThreadPool threadPool = new ThreadPool();
View Full Code Here

Examples of javax.management.MBeanServer

            initialize();
        }

        List connectors = new ArrayList(poolNames.size());

        MBeanServer server = getContainerWrapper().getResourceResolver().getMBeanServer();

        for (Iterator it = poolNames.iterator(); it.hasNext();) {

            ThreadPoolObjectName threadPoolObjectName = (ThreadPoolObjectName) it.next();
            boolean remoteAddrAvailable = true;
View Full Code Here

Examples of javax.management.MBeanServer

    public List getApplicationResources() throws NamingException {
        logger.info("Reading GLOBAL resources");
        List resources = new ArrayList();

        MBeanServer server = getMBeanServer();
        if (server != null) {
            try {
                Set dsNames = server.queryNames(new ObjectName("Catalina:type=Resource,resourcetype=Global,*"), null);
                for (Iterator it = dsNames.iterator(); it.hasNext();) {
                    ObjectName objectName = (ObjectName) it.next();
                    ApplicationResource resource = new ApplicationResource();

                    logger.info("reading resource: " + objectName);
View Full Code Here

Examples of javax.management.MBeanServer

public class RuntimeInfoAccessorBean {

    private Log logger = LogFactory.getLog(RuntimeInfoAccessorBean.class);

    public RuntimeInformation getRuntimeInformation() throws Exception {
        MBeanServer mBeanServer = new Registry().getMBeanServer();
        RuntimeInformation ri = new RuntimeInformation();

        try {
            ObjectName runtimeOName = new ObjectName("java.lang:type=Runtime");
            ri.setStartTime(JmxTools.getLongAttr(mBeanServer, runtimeOName, "StartTime"));
View Full Code Here

Examples of javax.management.MBeanServer

    private Log logger = LogFactory.getLog(this.getClass());

    public List getPools() throws Exception {

        List memoryPools = new LinkedList();
        MBeanServer mBeanServer = new Registry().getMBeanServer();
        Set memoryOPools = mBeanServer.queryMBeans(new ObjectName("java.lang:type=MemoryPool,*"), null);

        //
        // totals
        //
        long totalInit = 0;
        long totalMax = 0;
        long totalUsed = 0;
        long totalCommitted = 0;

        for (Iterator it = memoryOPools.iterator(); it.hasNext();) {
            ObjectInstance oi = (ObjectInstance) it.next();
            ObjectName oName = oi.getObjectName();
            MemoryPool memoryPool = new MemoryPool();
            memoryPool.setName(JmxTools.getStringAttr(mBeanServer, oName, "Name"));
            memoryPool.setType(JmxTools.getStringAttr(mBeanServer, oName, "Type"));

            CompositeDataSupport cd = (CompositeDataSupport) mBeanServer.getAttribute(oName, "Usage");
            //
            // It seems that "Usage" attribute of one of the pools may turn into null intermittently. We better have a
            // dip in the graph then an NPE though.
            //
            if (cd != null) {
View Full Code Here

Examples of javax.management.MBeanServer

        return result;
    }

    public static boolean isThreadingEnabled() {
        try {
            MBeanServer mBeanServer = new Registry().getMBeanServer();
            ObjectName threadingOName = new ObjectName("java.lang:type=Threading");
            Set s = mBeanServer.queryMBeans(threadingOName, null);
            return s != null && s.size() > 0;
        } catch (MalformedObjectNameException e) {
            return false;
        }
    }
View Full Code Here

Examples of javax.management.MBeanServer

    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {

        List threads = null;
        int executionStackDepth = 1;

        MBeanServer mBeanServer = new Registry().getMBeanServer();
        ObjectName threadingOName = new ObjectName("java.lang:type=Threading");

        long[] deadlockedIds = (long[]) mBeanServer.invoke(threadingOName, "findMonitorDeadlockedThreads", null, null);
        long[] allIds = (long[]) mBeanServer.getAttribute(threadingOName, "AllThreadIds");

        if (allIds != null) {
            threads = new ArrayList(allIds.length);

            for (int i = 0; i < allIds.length; i++) {
                CompositeData cd = (CompositeData) mBeanServer.invoke(threadingOName, "getThreadInfo",
                        new Object[]{new Long(allIds[i]), new Integer(executionStackDepth)}, new String[]{"long", "int"});

                if (cd != null) {
                    SunThread st = new SunThread();
                    st.setId(JmxTools.getLongAttr(cd, "threadId"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.