Search in sources :

Example 1 with ManagedOperation

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();
}
Also used : InetAddress(java.net.InetAddress) PhysicalAddress(org.jgroups.PhysicalAddress) Address(org.jgroups.Address) ConcurrentMap(java.util.concurrent.ConcurrentMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) ManagedOperation(org.jgroups.annotations.ManagedOperation)

Example 2 with ManagedOperation

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));
}
Also used : InetAddress(java.net.InetAddress) ManagedOperation(org.jgroups.annotations.ManagedOperation)

Example 3 with ManagedOperation

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);
}
Also used : IpAddress(org.jgroups.stack.IpAddress) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) ManagedOperation(org.jgroups.annotations.ManagedOperation)

Example 4 with ManagedOperation

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));
        }
    }
}
Also used : Method(java.lang.reflect.Method) Property(org.jgroups.annotations.Property) ManagedAttribute(org.jgroups.annotations.ManagedAttribute) ManagedOperation(org.jgroups.annotations.ManagedOperation)

Example 5 with ManagedOperation

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();
}
Also used : PhysicalAddress(org.jgroups.PhysicalAddress) Address(org.jgroups.Address) AsciiString(org.jgroups.util.AsciiString) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) ManagedOperation(org.jgroups.annotations.ManagedOperation)

Aggregations

ManagedOperation (org.jgroups.annotations.ManagedOperation)15 Address (org.jgroups.Address)5 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 IpAddress (org.jgroups.stack.IpAddress)3 InetAddress (java.net.InetAddress)2 InetSocketAddress (java.net.InetSocketAddress)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 JChannel (org.jgroups.JChannel)2 PhysicalAddress (org.jgroups.PhysicalAddress)2 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 Method (java.lang.reflect.Method)1 ServerSocket (java.net.ServerSocket)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 View (org.jgroups.View)1 ManagedAttribute (org.jgroups.annotations.ManagedAttribute)1 Property (org.jgroups.annotations.Property)1