use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.
the class GossipRouter method dumpAddresssMappings.
@ManagedOperation(description = "Dumps the address mappings")
public String dumpAddresssMappings() {
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, ConcurrentMap<Address, Entry>> entry : address_mappings.entrySet()) {
String group = entry.getKey();
Map<Address, Entry> val = entry.getValue();
if (val == null)
continue;
sb.append(group).append(":\n");
for (Map.Entry<Address, Entry> entry2 : val.entrySet()) {
Address logical_addr = entry2.getKey();
Entry val2 = entry2.getValue();
if (val2 == null)
continue;
sb.append(String.format(" %s: %s (client_addr: %s, uuid:%s)\n", val2.logical_name, val2.phys_addr, val2.client_addr, logical_addr));
}
}
return sb.toString();
}
use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.
the class GossipRouter method start.
/**
* Lifecycle operation. Called after create(). When this method is called, the managed attributes
* have already been set.<br>
* Brings the Router into a fully functional state.
*/
@ManagedOperation(description = "Lifecycle operation. Called after create(). When this method is called, " + "the managed attributes have already been set. Brings the Router into a fully functional state.")
public void start() throws Exception {
if (!running.compareAndSet(false, true))
return;
if (jmx)
JmxConfigurator.register(this, Util.getMBeanServer(), "jgroups:name=GossipRouter");
InetAddress tmp = bind_addr != null ? InetAddress.getByName(bind_addr) : null;
server = use_nio ? new NioServer(thread_factory, socket_factory, tmp, port, port, null, 0) : new TcpServer(thread_factory, socket_factory, tmp, port, port, null, 0);
server.receiver(this);
server.start();
server.addConnectionListener(this);
Runtime.getRuntime().addShutdownHook(new Thread(GossipRouter.this::stop));
}
use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.
the class Discovery method dumpCache.
@ManagedOperation(description = "Reads data from local caches and dumps them to a file")
public void dumpCache(String output_filename) throws Exception {
Map<Address, PhysicalAddress> cache_contents = (Map<Address, PhysicalAddress>) down_prot.down(new Event(Event.GET_LOGICAL_PHYSICAL_MAPPINGS, false));
List<PingData> list = new ArrayList<>(cache_contents.size());
for (Map.Entry<Address, PhysicalAddress> entry : cache_contents.entrySet()) {
Address addr = entry.getKey();
PhysicalAddress phys_addr = entry.getValue();
PingData data = new PingData(addr, true, NameCache.get(addr), phys_addr).coord(addr.equals(local_addr));
list.add(data);
}
OutputStream out = new FileOutputStream(output_filename);
write(list, out);
}
use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.
the class ResourceDMBean method findMethods.
protected void findMethods(Object instance) {
// find all methods but don't include methods from Object class
List<Method> methods = new ArrayList<>(Arrays.asList(instance.getClass().getMethods()));
methods.removeAll(OBJECT_METHODS);
for (Method method : methods) {
// does method have @ManagedAttribute annotation?
if (method.isAnnotationPresent(ManagedAttribute.class) || method.isAnnotationPresent(Property.class)) {
exposeManagedAttribute(method, instance);
} else // or @ManagedOperation
if (method.isAnnotationPresent(ManagedOperation.class) || expose_all) {
ManagedOperation op = method.getAnnotation(ManagedOperation.class);
ops.add(new MBeanOperationInfo(op != null ? op.description() : "", method));
}
}
}
use of org.jgroups.annotations.ManagedOperation in project JGroups by belaban.
the class SHARED_LOOPBACK method dumpRoutingTable.
@ManagedOperation(description = "Dumps the contents of the routing table")
public static String dumpRoutingTable() {
StringBuilder sb = new StringBuilder();
for (Map.Entry<AsciiString, Map<Address, SHARED_LOOPBACK>> entry : routing_table.entrySet()) {
AsciiString cluster_name = entry.getKey();
Set<Address> mbrs = entry.getValue().keySet();
sb.append(cluster_name).append(": ").append(mbrs).append("\n");
}
return sb.toString();
}
Aggregations