PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/hazelcast/src/main/java/com/hazelcast/jmx/MemberMBean.java

https://bitbucket.org/gabral6_gmailcom/hazelcast
Java | 77 lines | 35 code | 10 blank | 32 comment | 1 complexity | 840be6c2cd9e6f3daf4724be42d7ea35 MD5 | raw file
 1/*
 2 * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License");
 5 * you may not use this file except in compliance with the License.
 6 * You may obtain a copy of the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.hazelcast.jmx;
18
19import com.hazelcast.core.Member;
20
21import javax.management.ObjectName;
22import java.net.InetAddress;
23
24/**
25 * The instrumentation MBean for a member.
26 *
27 * @author Marco Ferrante, DISI - University of Genoa
28 */
29@JMXDescription("A member of the cluster")
30public class MemberMBean extends AbstractMBean<Member> {
31
32    private ObjectName name;
33
34    public MemberMBean(Member managedObject, ManagementService managementService) {
35        super(managedObject, managementService);
36    }
37//	public ObjectName getObjectName() throws Exception {
38//		String memberName = "Local";
39//    	if (!getManagedObject().localMember()) {
40//    		// String concatenation is not a performance issue,
41//    		// used only during registration
42//    		memberName =  '"' + getManagedObject().getInetAddress().getHostAddress()
43//    				+ ":" + getManagedObject().getPort() + '"';
44//    	}
45//    	return getParentName().getNested("Member", memberName).buildObjectName();
46//	}
47
48    @Override
49    public ObjectNameSpec getNameSpec() {
50        String memberName = "Local";
51        if (!getManagedObject().localMember()) {
52            // String concatenation is not a performance issue,
53            // used only during registration
54            memberName = '"' + getManagedObject().getInetAddress().getHostAddress()
55                    + ":" + getManagedObject().getPort() + '"';
56        }
57        return getParentName().getNested("Member", memberName);
58    }
59
60    @JMXDescription("The network Port")
61    @JMXAttribute("Port")
62    public int getPort() {
63        return getManagedObject().getInetSocketAddress().getPort();
64    }
65
66    @JMXAttribute("InetAddress")
67    @JMXDescription("The network address")
68    public InetAddress getInetAddress() {
69        return getManagedObject().getInetSocketAddress().getAddress();
70    }
71
72    @JMXAttribute("LiteMember")
73    @JMXDescription("The member is a lite member")
74    public boolean isSuperClient() {
75        return getManagedObject().isLiteMember();
76    }
77}