Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added ability to set JMX attrs via probe.sh (https://issues.jboss.org…

  • Loading branch information...
commit 0be7f6f16b869d41146f32d0d03d8e940b7ed2e2 1 parent 76fad92
@belaban authored
View
25 bin/probe.sh
@@ -4,28 +4,5 @@
# Probe [-help] [-addr <addr>] [-port <port>] [-ttl <ttl>] [-timeout <timeout>]
-BIN=`dirname $0`
-LIB=$BIN/../lib
-
-LIBS=$LIB/log4j.jar
-
-#echo $CLASSPATH
-
-CLASSPATH=$BIN/../classes:$CLASSPATH:$LIBS
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false;
-case "`uname`" in
- CYGWIN*)
- cygwin=true
- ;;
-esac
-
-if [ $cygwin = "true" ]; then
- CP=`cygpath -wp $CLASSPATH`
-else
- CP=$CLASSPATH
-fi
-
-java -classpath $CP org.jgroups.tests.Probe $*
+jgroups.sh org.jgroups.tests.Probe $*
View
28 doc/manual/en/modules/advanced.xml
@@ -1610,34 +1610,6 @@ On view change V:
</para>
<section>
- <title>Discovery</title>
- <para>
- A discovery protocol (e.g. PING, TCPPING, MPING etc) is run at startup, to discover the initial
- membership, and periodically by the merge protocol, to detect partitioned subclusters.
- </para>
- <para>
- When we send a multicast discovery request to a large cluster, every node in the cluster might
- possibly reply with a discovery response sent back to the sender. So, in a cluster of 300 nodes,
- the discovery requester might be up to 299 discovery responses ! Even worse, because num_ping_requests
- in Discovery is by default set to 2, so we're sending 2 discovery requests, we might receive up to
- num_ping_requests * (N-1) discovery responses, even though we might be able to find out the
- coordinator after a few responses already !
- </para>
- <para>
- To reduce the large number of responses, we can set a max_rank property: the value defines which
- members are going to send a discovery response. The rank is the index of a member in a cluster: in
- {A,B,C,D,E}, A's index is 1, B's index is 2 and so on. A max_rank of 3 would trigger discovery
- responses from only A, B and C, but not from D or E.
- </para>
- <para>
- We highly recommend setting max_rank in large clusters.
- </para>
- <para>
- This functionality was implemented in
- <ulink url="https://jira.jboss.org/browse/JGRP-1181">https://jira.jboss.org/browse/JGRP-1181</ulink>.
- </para>
- </section>
- <section>
<title>Failure detection protocols</title>
<para>
Failure detection protocols determine when a member is unresponsive, and subsequently
View
118 src/org/jgroups/JChannel.java
@@ -16,6 +16,7 @@
import org.w3c.dom.Element;
import java.io.*;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.DatagramSocket;
import java.net.ServerSocket;
@@ -1013,25 +1014,7 @@ private TimeScheduler getTimer() {
Map<String, String> map=new HashMap<String, String>(2);
for(String key: keys) {
if(key.startsWith("jmx")) {
- Map<String, Object> tmp_stats;
- int index=key.indexOf("=");
- if(index > -1) {
- List<String> list=null;
- String protocol_name=key.substring(index +1);
- index=protocol_name.indexOf(".");
- if(index > -1) {
- String rest=protocol_name;
- protocol_name=protocol_name.substring(0, index);
- String attrs=rest.substring(index +1); // e.g. "num_sent,msgs,num_received_msgs"
- list=Util.parseStringList(attrs, ",");
- }
-
- tmp_stats=dumpStats(protocol_name, list);
- }
- else
- tmp_stats=dumpStats();
-
- map.put("jmx", tmp_stats != null? Util.mapToString(tmp_stats) : "null");
+ handleJmx(map, key);
continue;
}
if(key.equals("socks")) {
@@ -1066,36 +1049,47 @@ private TimeScheduler getTimer() {
return new String[]{"jmx", "invoke=<operation>[<args>]", "\nop=<operation>[<args>]", "socks"};
}
- String getOpenSockets() {
- Map<Object, String> socks=getSocketFactory().getSockets();
- TP transport=getProtocolStack().getTransport();
- if(transport != null && transport.isSingleton()) {
- Map<Object,String> tmp=transport.getSocketFactory().getSockets();
- if(tmp != null)
- socks.putAll(tmp);
- }
-
- StringBuilder sb=new StringBuilder();
- if(socks != null) {
- for(Map.Entry<Object,String> entry: socks.entrySet()) {
- Object key=entry.getKey();
- if(key instanceof ServerSocket) {
- ServerSocket tmp=(ServerSocket)key;
- sb.append(tmp.getInetAddress()).append(":").append(tmp.getLocalPort())
- .append(" ").append(entry.getValue()).append(" [tcp]");
- }
- else if(key instanceof DatagramSocket) {
- DatagramSocket sock=(DatagramSocket)key;
- sb.append(sock.getLocalAddress()).append(":").append(sock.getLocalPort())
- .append(" ").append(entry.getValue()).append(" [udp]");
- }
- else {
- sb.append(key).append(" ").append(entry.getValue());
+ protected void handleJmx(Map<String, String> map, String input) {
+ Map<String, Object> tmp_stats;
+ int index=input.indexOf("=");
+ if(index > -1) {
+ List<String> list=null;
+ String protocol_name=input.substring(index +1);
+ index=protocol_name.indexOf(".");
+ if(index > -1) {
+ String rest=protocol_name;
+ protocol_name=protocol_name.substring(0, index);
+ String attrs=rest.substring(index +1); // e.g. "num_sent,msgs,num_received_msgs"
+ list=Util.parseStringList(attrs, ",");
+
+ // check if there are any attribute-sets in the list
+ for(Iterator<String> it=list.iterator(); it.hasNext();) {
+ String tmp=it.next();
+ index=tmp.indexOf("=");
+ if(index != -1) {
+ String attrname=tmp.substring(0, index);
+ String attrvalue=tmp.substring(index+1);
+ Protocol prot=prot_stack.findProtocol(protocol_name);
+ Field field=Util.getField(prot.getClass(), attrname);
+ if(field != null) {
+ Object value=MethodCall.convert(attrvalue, field.getType());
+ if(value != null)
+ prot.setValue(attrname, value);
+ }
+ else {
+ if(log.isWarnEnabled())
+ log.warn("Field \"" + attrname + "\" not found in protocol " + protocol_name);
+ }
+ it.remove();
+ }
}
- sb.append("\n");
}
+ tmp_stats=dumpStats(protocol_name, list);
}
- return sb.toString();
+ else
+ tmp_stats=dumpStats();
+
+ map.put("jmx", tmp_stats != null? Util.mapToString(tmp_stats) : "null");
}
/**
@@ -1144,6 +1138,38 @@ private void handleOperation(Map<String, String> map, String operation) throws E
if(retval != null)
map.put(prot_name + "." + method_name, retval.toString());
}
+
+ String getOpenSockets() {
+ Map<Object, String> socks=getSocketFactory().getSockets();
+ TP transport=getProtocolStack().getTransport();
+ if(transport != null && transport.isSingleton()) {
+ Map<Object,String> tmp=transport.getSocketFactory().getSockets();
+ if(tmp != null)
+ socks.putAll(tmp);
+ }
+
+ StringBuilder sb=new StringBuilder();
+ if(socks != null) {
+ for(Map.Entry<Object,String> entry: socks.entrySet()) {
+ Object key=entry.getKey();
+ if(key instanceof ServerSocket) {
+ ServerSocket tmp=(ServerSocket)key;
+ sb.append(tmp.getInetAddress()).append(":").append(tmp.getLocalPort())
+ .append(" ").append(entry.getValue()).append(" [tcp]");
+ }
+ else if(key instanceof DatagramSocket) {
+ DatagramSocket sock=(DatagramSocket)key;
+ sb.append(sock.getLocalAddress()).append(":").append(sock.getLocalPort())
+ .append(" ").append(entry.getValue()).append(" [udp]");
+ }
+ else {
+ sb.append(key).append(" ").append(entry.getValue());
+ }
+ sb.append("\n");
+ }
+ }
+ return sb.toString();
+ }
}
View
15 tests/other/org/jgroups/tests/Probe.java
@@ -172,12 +172,13 @@ public static void main(String[] args) {
static void help() {
System.out.println("Probe [-help] [-addr <addr>] [-ipv6] [-bind_addr <addr>] " +
- "[-port <port>] [-ttl <ttl>] [-timeout <timeout>] [-weed_out_duplicates] [-match pattern]" +
- "[key[=value]]*\n\n" +
- "Examples:\n" +
- "probe.sh keys // dumps all valid commands\n" +
- "probe.sh jmx=NAKACK // dumps JMX info about all NAKACK protocols\n" +
- "probe.sh op=STABLE.runMessageGarbageCollection // invokes the method in all STABLE protocols\n" +
- "probe.sh jmx=UDP.oob,thread_pool // dumps all attrs of UDP starting with oob* or thread_pool*");
+ "[-port <port>] [-ttl <ttl>] [-timeout <timeout>] [-weed_out_duplicates] [-match pattern]" +
+ "[key[=value]]*\n\n" +
+ "Examples:\n" +
+ "probe.sh keys // dumps all valid commands\n" +
+ "probe.sh jmx=NAKACK // dumps JMX info about all NAKACK protocols\n" +
+ "probe.sh op=STABLE.runMessageGarbageCollection // invokes the method in all STABLE protocols\n" +
+ "probe.sh jmx=UDP.oob,thread_pool // dumps all attrs of UDP starting with oob* or thread_pool*\n" +
+ "probe.sh jmx=FLUSH.bypass=true\n");
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.