Example usage for javax.management ObjectName getKeyProperty

List of usage examples for javax.management ObjectName getKeyProperty

Introduction

In this page you can find the example usage for javax.management ObjectName getKeyProperty.

Prototype

public String getKeyProperty(String property) 

Source Link

Document

Obtains the value associated with a key in a key property.

Usage

From source file:org.apache.geode.management.internal.beans.DistributedSystemBridge.java

public void addRegion(ObjectName proxyName, RegionMXBean regionProxy, FederationComponent fedComp) {

    String fullPath = proxyName.getKeyProperty("name");
    ObjectName distributedRegionObjectName = MBeanJMXAdapter.getDistributedRegionMbeanNameInternal(fullPath);

    synchronized (distrRegionMap) {
        DistributedRegionBridge bridge = distrRegionMap.get(distributedRegionObjectName);
        if (bridge != null) {
            FederationComponent newObj = fedComp;
            bridge.addProxyToMap(proxyName, regionProxy, newObj);
        } else {/*from  www .  j  ava2  s .c  o  m*/
            FederationComponent newObj = fedComp;
            bridge = new DistributedRegionBridge(proxyName, regionProxy, newObj);
            DistributedRegionMXBean mbean = new DistributedRegionMBean(bridge);

            service.registerInternalMBean(mbean, distributedRegionObjectName);
            distrRegionMap.put(distributedRegionObjectName, bridge);
        }
    }
}

From source file:org.apache.geode.management.internal.beans.DistributedSystemBridge.java

public void updateRegion(ObjectName proxyName, FederationComponent oldValue, FederationComponent newValue) {

    String fullPath = proxyName.getKeyProperty("name");
    ObjectName distributedRegionObjectName = MBeanJMXAdapter.getDistributedRegionMbeanNameInternal(fullPath);

    DistributedRegionBridge bridge = distrRegionMap.get(distributedRegionObjectName);
    if (bridge != null) {
        FederationComponent newProxy = newValue;
        FederationComponent oldProxy = null;
        if (oldValue != null) {
            oldProxy = oldValue;//from   ww  w . java 2 s .c o  m
        }
        bridge.updateRegion(newProxy, oldProxy);
    }
}

From source file:org.apache.catalina.core.ContainerBase.java

public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
    oname = name;/*from   w w  w.j  av a2 s  .c  o  m*/
    mserver = server;
    if (name == null) {
        return null;
    }

    domain = name.getDomain();

    type = name.getKeyProperty("type");
    if (type == null) {
        type = name.getKeyProperty("j2eeType");
    }

    String j2eeApp = name.getKeyProperty("J2EEApplication");
    String j2eeServer = name.getKeyProperty("J2EEServer");
    if (j2eeApp == null) {
        j2eeApp = "none";
    }
    if (j2eeServer == null) {
        j2eeServer = "none";
    }
    suffix = ",J2EEApplication=" + j2eeApp + ",J2EEServer=" + j2eeServer;
    return name;
}

From source file:org.apache.geode.management.internal.beans.DistributedSystemBridge.java

public void removeLockService(ObjectName proxyName, LockServiceMXBean lockServiceProxy,
        FederationComponent fedComp) {//from  w  w w .j a  v a 2s . com

    String lockServiceName = proxyName.getKeyProperty("name");

    ObjectName distributedLockObjectName = MBeanJMXAdapter.getDistributedLockServiceName(lockServiceName);

    synchronized (distrLockServiceMap) {
        if (distrLockServiceMap.get(distributedLockObjectName) != null) {
            DistributedLockServiceBridge bridge = distrLockServiceMap.get(distributedLockObjectName);

            if (bridge.removeProxyFromMap(proxyName, lockServiceProxy)) {
                service.unregisterMBean(distributedLockObjectName);
                distrLockServiceMap.remove(distributedLockObjectName);
            }

        } else {
            return;
        }
    }
}

From source file:org.apache.geode.management.internal.beans.DistributedSystemBridge.java

public void addLockService(ObjectName proxyName, LockServiceMXBean lockServiceProxy,
        FederationComponent fedComp) {/*from w  w w  .j  av a2  s . c  o  m*/

    String lockServiceName = proxyName.getKeyProperty("name");

    ObjectName distributedLockObjectName = MBeanJMXAdapter.getDistributedLockServiceName(lockServiceName);

    synchronized (distrLockServiceMap) {
        if (distrLockServiceMap.get(distributedLockObjectName) != null) {
            DistributedLockServiceBridge bridge = distrLockServiceMap.get(distributedLockObjectName);
            bridge.addProxyToMap(proxyName, lockServiceProxy);
        } else {

            DistributedLockServiceBridge bridge = new DistributedLockServiceBridge(proxyName, lockServiceProxy,
                    fedComp);
            DistributedLockServiceMXBean mbean = new DistributedLockServiceMBean(bridge);

            service.registerInternalMBean(mbean, distributedLockObjectName);
            distrLockServiceMap.put(distributedLockObjectName, bridge);
        }
    }
}

From source file:org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.java

/**
 * function used for getting a Gateway Receiver from mBean for giving member and update the
 * gateway receiver for respective member object
 *///from w  ww  .j  av  a  2s.c om
private void updateGatewayReceiver(ObjectName mbeanName) throws IOException {

    try {
        String memberName = mbeanName.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);

        if (cluster.getMembersHMap().containsKey(memberName)) {
            Cluster.Member existingMember = cluster.getMembersHMap().get(memberName);
            Cluster.GatewayReceiver gatewayReceiver = initGatewayReceiver(mbeanName);
            existingMember.setGatewayReceiver(gatewayReceiver);
        } else {
            Cluster.Member member = new Cluster.Member();
            member.setName(memberName);
            member.setId(memberName);
            Cluster.GatewayReceiver gatewayReceiver = initGatewayReceiver(mbeanName);
            member.setGatewayReceiver(gatewayReceiver);
            cluster.getMembersHMap().put(memberName, member);
        }
    } catch (InstanceNotFoundException | ReflectionException | MBeanException | AttributeNotFoundException
            | IntrospectionException infe) {
        logger.warn(infe);
    }
}

From source file:org.apache.catalina.core.StandardDefaultContext.java

public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
    oname = name;/*  w  ww  . ja v a2 s  .  c om*/
    mserver = server;
    domain = name.getDomain();

    type = name.getKeyProperty("type");
    if (type == null) {
        type = name.getKeyProperty("j2eeType");
    }

    String j2eeApp = name.getKeyProperty("J2EEApplication");
    String j2eeServer = name.getKeyProperty("J2EEServer");
    if (j2eeApp == null) {
        j2eeApp = "none";
    }
    if (j2eeServer == null) {
        j2eeServer = "none";
    }
    suffix = ",J2EEApplication=" + j2eeApp + ",J2EEServer=" + j2eeServer;
    return name;
}

From source file:org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.java

/**
 * function used for getting list of Gateway Senders from mBean for giving member and update the
 * list of gateway senders for respective member object
 *//* www  .j  av  a 2s  .c  o  m*/
private void updateAsyncEventQueue(ObjectName mbeanName) throws IOException {
    try {
        String memberName = mbeanName.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);

        if (cluster.getMembersHMap().containsKey(memberName)) {
            Cluster.Member existingMember = cluster.getMembersHMap().get(memberName);
            Cluster.AsyncEventQueue asyncQ = initAsyncEventQueue(mbeanName);
            for (Iterator<Cluster.AsyncEventQueue> it = existingMember.getAsyncEventQueueList().iterator(); it
                    .hasNext();) {
                Cluster.AsyncEventQueue exisAsyncEventQueue = it.next();
                if ((exisAsyncEventQueue.getId()).equals(asyncQ.getId())) {
                    it.remove();
                    break;
                }
            }

            // Add async event queue
            existingMember.getAsyncEventQueueList().add(asyncQ);
        } else {
            Cluster.Member member = new Cluster.Member();
            member.setName(memberName);
            member.setId(memberName);

            Cluster.AsyncEventQueue asyncQ = initAsyncEventQueue(mbeanName);
            member.getAsyncEventQueueList().add(asyncQ);

            cluster.getMembersHMap().put(memberName, member);
        }
    } catch (InstanceNotFoundException | ReflectionException | AttributeNotFoundException
            | IntrospectionException | MBeanException infe) {
        logger.warn(infe);
    }
}

From source file:org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.java

/**
 * function used to get attribute values of Cluster Member and map them to cluster member vo
 * //from  w w  w  . j  av  a 2s  . c o  m
 * @param mbeanName Cluster Member MBean
 */
private void updateClusterMember(ObjectName mbeanName) throws IOException {

    try {
        String memberName = mbeanName.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);

        Cluster.Member clusterMember = cluster.getMembersHMap().get(memberName);

        if (clusterMember != null) // checking if member exists or not
        {
            cluster.getDeletedMembers().remove(memberName);
        } else {
            clusterMember = new Cluster.Member();
            cluster.getMembersHMap().put(memberName, clusterMember);
        }

        // initialize member and add to cluster's member list
        clusterMember = initializeMember(mbeanName, clusterMember);
        ArrayList<Cluster.Member> memberArrList = (ArrayList<Cluster.Member>) cluster.getPhysicalToMember()
                .get(clusterMember.getHost());
        if (memberArrList != null) {
            if (!memberArrList.contains(clusterMember)) {
                memberArrList.add(clusterMember);
            }
        } else {
            ArrayList<Cluster.Member> memberList = new ArrayList<Cluster.Member>();
            memberList.add(clusterMember);
            cluster.getPhysicalToMember().put(clusterMember.getHost(), memberList);
        }
    } catch (InstanceNotFoundException | ReflectionException infe) {
        logger.warn(infe);
    }
}

From source file:org.apache.geode.tools.pulse.internal.data.JMXDataUpdater.java

/**
 * function used for getting list of Gateway Senders from mBean for giving member and update the
 * list of gateway senders for respective member object
 *//*from  w w  w . j  a v  a 2  s  .co  m*/
private void updateGatewaySender(ObjectName mbeanName) throws IOException {

    try {
        String memberName = mbeanName.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);

        if (cluster.getMembersHMap().containsKey(memberName)) {
            Cluster.Member existingMember = cluster.getMembersHMap().get(memberName);
            Cluster.GatewaySender gatewaySender = initGatewaySender(mbeanName);
            for (Iterator<Cluster.GatewaySender> it = existingMember.getGatewaySenderList().iterator(); it
                    .hasNext();) {
                Cluster.GatewaySender exisGatewaySender = it.next();
                if ((exisGatewaySender.getId()).equals(gatewaySender.getId())) {
                    it.remove();
                    break;
                }
            }

            // Add gateway sender
            existingMember.getGatewaySenderList().add(gatewaySender);

        } else {
            Cluster.Member member = new Cluster.Member();
            member.setName(memberName);
            member.setId(memberName);
            Cluster.GatewaySender gatewaySender = initGatewaySender(mbeanName);
            member.getGatewaySenderList().add(gatewaySender);
            cluster.getMembersHMap().put(memberName, member);
        }
    } catch (InstanceNotFoundException | ReflectionException | AttributeNotFoundException
            | IntrospectionException | MBeanException infe) {
        logger.warn(infe);
    }
}