[infinispan-commits] Infinispan SVN: r801 - in trunk/core/src: main/java/org/infinispan/interceptors and 5 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Wed Sep 9 11:12:28 EDT 2009
Author: galder.zamarreno at jboss.com
Date: 2009-09-09 11:12:27 -0400 (Wed, 09 Sep 2009)
New Revision: 801
Modified:
trunk/core/src/main/java/org/infinispan/distribution/DistributionManagerImpl.java
trunk/core/src/main/java/org/infinispan/interceptors/InvalidationInterceptor.java
trunk/core/src/main/java/org/infinispan/interceptors/TxInterceptor.java
trunk/core/src/main/java/org/infinispan/interceptors/base/JmxStatsCommandInterceptor.java
trunk/core/src/main/java/org/infinispan/jmx/ResourceDMBean.java
trunk/core/src/main/java/org/infinispan/jmx/annotations/ManagedAttribute.java
trunk/core/src/main/java/org/infinispan/remoting/rpc/RpcManagerImpl.java
trunk/core/src/test/java/org/infinispan/jmx/ActivationAndPassivationInterceptorMBeanTest.java
trunk/core/src/test/java/org/infinispan/jmx/RpcManagerMBeanTest.java
Log:
[ISPN-190] (Remove name from @ManagedAttribute) Done and fixed those tests that were calling setter/getter methods via invoke() calls, which is not allowed.
Modified: trunk/core/src/main/java/org/infinispan/distribution/DistributionManagerImpl.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/distribution/DistributionManagerImpl.java 2009-09-09 10:50:49 UTC (rev 800)
+++ trunk/core/src/main/java/org/infinispan/distribution/DistributionManagerImpl.java 2009-09-09 15:12:27 UTC (rev 801)
@@ -93,7 +93,7 @@
private InterceptorChain interceptorChain;
private InvocationContextContainer icc;
private volatile boolean joinTaskSubmitted = false;
- @ManagedAttribute(name = "Joined", description = "If true, the node has successfully joined the grid and is considered to hold state. If false, the join process is still in progress.")
+ @ManagedAttribute(description = "If true, the node has successfully joined the grid and is considered to hold state. If false, the join process is still in progress.")
volatile boolean joinComplete = false;
final List<Address> leavers = new CopyOnWriteArrayList<Address>();
volatile Future<Void> leaveTaskFuture;
@@ -363,7 +363,7 @@
}
}
- @ManagedAttribute(name = "ClusterSize", description = "Size of the cluster in number of nodes")
+ @ManagedAttribute(description = "Size of the cluster in number of nodes")
public String getClusterSize() {
return rpcManager.getTransport().getMembers().size() + "";
}
Modified: trunk/core/src/main/java/org/infinispan/interceptors/InvalidationInterceptor.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/interceptors/InvalidationInterceptor.java 2009-09-09 10:50:49 UTC (rev 800)
+++ trunk/core/src/main/java/org/infinispan/interceptors/InvalidationInterceptor.java 2009-09-09 15:12:27 UTC (rev 801)
@@ -72,8 +72,8 @@
private final AtomicLong invalidations = new AtomicLong(0);
protected Map<GlobalTransaction, List<VisitableCommand>> txMods;
private CommandsFactory commandsFactory;
- @ManagedAttribute(name = "StatisticsEnabled", description = "Enables or disables the gathering of statistics by this component", writable = true)
- private boolean statsEnabled;
+ @ManagedAttribute(description = "Enables or disables the gathering of statistics by this component", writable = true)
+ private boolean statisticsEnabled;
@Inject
public void injectDependencies(CommandsFactory commandsFactory) {
@@ -218,7 +218,7 @@
}
private void incrementInvalidations() {
- if (statsEnabled) invalidations.incrementAndGet();
+ if (statisticsEnabled) invalidations.incrementAndGet();
}
private boolean isPutForExternalRead(InvocationContext ctx) {
@@ -235,11 +235,11 @@
}
public boolean getStatisticsEnabled() {
- return this.statsEnabled;
+ return this.statisticsEnabled;
}
public void setStatisticsEnabled(boolean enabled) {
- this.statsEnabled = enabled;
+ this.statisticsEnabled = enabled;
}
@ManagedAttribute(description = "number of invalidations")
Modified: trunk/core/src/main/java/org/infinispan/interceptors/TxInterceptor.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/interceptors/TxInterceptor.java 2009-09-09 10:50:49 UTC (rev 800)
+++ trunk/core/src/main/java/org/infinispan/interceptors/TxInterceptor.java 2009-09-09 15:12:27 UTC (rev 801)
@@ -53,8 +53,8 @@
private final AtomicLong prepares = new AtomicLong(0);
private final AtomicLong commits = new AtomicLong(0);
private final AtomicLong rollbacks = new AtomicLong(0);
- @ManagedAttribute(name = "StatisticsEnabled", description = "Enables or disables the gathering of statistics by this component", writable = true)
- private boolean statsEnabled;
+ @ManagedAttribute(description = "Enables or disables the gathering of statistics by this component", writable = true)
+ private boolean statisticsEnabled;
@Inject
@@ -81,7 +81,7 @@
if (!command.isOnePhaseCommit()) {
transactionLog.logPrepare(command);
}
- if (this.statsEnabled) prepares.incrementAndGet();
+ if (this.statisticsEnabled) prepares.incrementAndGet();
Object result = invokeNextInterceptor(ctx, command);
if (command.isOnePhaseCommit()) {
transactionLog.logOnePhaseCommit(ctx.getGlobalTransaction(), command.getModifications());
@@ -91,7 +91,7 @@
@Override
public Object visitCommitCommand(TxInvocationContext ctx, CommitCommand command) throws Throwable {
- if (this.statsEnabled) commits.incrementAndGet();
+ if (this.statisticsEnabled) commits.incrementAndGet();
Object result = invokeNextInterceptor(ctx, command);
transactionLog.logCommit(command.getGlobalTransaction());
return result;
@@ -99,7 +99,7 @@
@Override
public Object visitRollbackCommand(TxInvocationContext ctx, RollbackCommand command) throws Throwable {
- if (this.statsEnabled) rollbacks.incrementAndGet();
+ if (this.statisticsEnabled) rollbacks.incrementAndGet();
transactionLog.rollback(command.getGlobalTransaction());
return invokeNextInterceptor(ctx, command);
}
@@ -216,11 +216,11 @@
}
public void setStatisticsEnabled(boolean enabled) {
- this.statsEnabled = enabled;
+ this.statisticsEnabled = enabled;
}
public boolean isStatisticsEnabled() {
- return this.statsEnabled;
+ return this.statisticsEnabled;
}
@ManagedAttribute(description = "number of transaction prepares")
Modified: trunk/core/src/main/java/org/infinispan/interceptors/base/JmxStatsCommandInterceptor.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/interceptors/base/JmxStatsCommandInterceptor.java 2009-09-09 10:50:49 UTC (rev 800)
+++ trunk/core/src/main/java/org/infinispan/interceptors/base/JmxStatsCommandInterceptor.java 2009-09-09 15:12:27 UTC (rev 801)
@@ -33,8 +33,8 @@
* @since 4.0
*/
public abstract class JmxStatsCommandInterceptor extends CommandInterceptor implements JmxStatisticsExposer {
- @ManagedAttribute(name = "StatisticsEnabled", description = "Enables or disables the gathering of statistics by this component", writable = true)
- private boolean statsEnabled = false;
+ @ManagedAttribute(description = "Enables or disables the gathering of statistics by this component", writable = true)
+ private boolean statisticsEnabled = false;
@Start
public void checkStatisticsUsed() {
@@ -47,14 +47,14 @@
* @return true if statistics are captured
*/
public boolean getStatisticsEnabled() {
- return statsEnabled;
+ return statisticsEnabled;
}
/**
* @param enabled whether gathering statistics for JMX are enabled.
*/
public void setStatisticsEnabled(boolean enabled) {
- statsEnabled = enabled;
+ statisticsEnabled = enabled;
}
/**
Modified: trunk/core/src/main/java/org/infinispan/jmx/ResourceDMBean.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/jmx/ResourceDMBean.java 2009-09-09 10:50:49 UTC (rev 800)
+++ trunk/core/src/main/java/org/infinispan/jmx/ResourceDMBean.java 2009-09-09 15:12:27 UTC (rev 801)
@@ -258,11 +258,10 @@
+ ", but is annotated with @ManagedAttribute: will be ignored");
} else {
MBeanAttributeInfo info = null;
- // Is name field of @ManagedAttributed used?
- String attributeName = attr.name().length() > 0 ? attr.name().trim() : null;
+ String attributeName = null;
boolean writeAttribute = false;
if (isSetMethod(method)) { // setter
- attributeName = (attributeName == null) ? methodName.substring(3) : attributeName;
+ attributeName = methodName.substring(3);
info = new MBeanAttributeInfo(attributeName, method.getParameterTypes()[0]
.getCanonicalName(), attr.description(), true, true, false);
writeAttribute = true;
@@ -272,14 +271,12 @@
boolean hasSetter = atts.containsKey(attributeName);
// we found is method
if (methodName.startsWith("is")) {
- attributeName = (attributeName == null) ? methodName.substring(2)
- : attributeName;
+ attributeName = methodName.substring(2);
info = new MBeanAttributeInfo(attributeName, method.getReturnType()
.getCanonicalName(), attr.description(), true, hasSetter, true);
} else {
// this has to be get
- attributeName = (attributeName == null) ? methodName.substring(3)
- : attributeName;
+ attributeName = methodName.substring(3);
info = new MBeanAttributeInfo(attributeName, method.getReturnType()
.getCanonicalName(), attr.description(), true, hasSetter, false);
}
Modified: trunk/core/src/main/java/org/infinispan/jmx/annotations/ManagedAttribute.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/jmx/annotations/ManagedAttribute.java 2009-09-09 10:50:49 UTC (rev 800)
+++ trunk/core/src/main/java/org/infinispan/jmx/annotations/ManagedAttribute.java 2009-09-09 15:12:27 UTC (rev 801)
@@ -32,6 +32,7 @@
* is optionally annotated with an @MBean annotation, or inherits such an annotation from a superclass.
*
* @author (various)
+ * @author Galder Zamarreño
* @since 4.0
*/
@Retention(RetentionPolicy.RUNTIME)
@@ -39,7 +40,5 @@
public @interface ManagedAttribute {
String description() default "";
- String name() default "";
-
boolean writable() default false;
}
Modified: trunk/core/src/main/java/org/infinispan/remoting/rpc/RpcManagerImpl.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/remoting/rpc/RpcManagerImpl.java 2009-09-09 10:50:49 UTC (rev 800)
+++ trunk/core/src/main/java/org/infinispan/remoting/rpc/RpcManagerImpl.java 2009-09-09 15:12:27 UTC (rev 801)
@@ -48,7 +48,7 @@
private Transport t;
private final AtomicLong replicationCount = new AtomicLong(0);
private final AtomicLong replicationFailures = new AtomicLong(0);
- @ManagedAttribute(name = "StatisticsEnabled", description = "Enables or disables the gathering of statistics by this component", writable = true)
+ @ManagedAttribute(description = "Enables or disables the gathering of statistics by this component", writable = true)
boolean statisticsEnabled = false; // by default, don't gather statistics.
private volatile Address currentStateTransferSource;
private boolean stateTransferEnabled;
@@ -298,8 +298,8 @@
this.statisticsEnabled = statisticsEnabled;
}
- @ManagedAttribute(name = "Address", description = "The network address associated with this instance")
- public String getAddressForDisplay() {
+ @ManagedAttribute(description = "The network address associated with this instance")
+ public String getAddress() {
if (t == null || !isStatisticsEnabled()) return "N/A";
Address address = t.getAddress();
return address == null ? "N/A" : address.toString();
Modified: trunk/core/src/test/java/org/infinispan/jmx/ActivationAndPassivationInterceptorMBeanTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/jmx/ActivationAndPassivationInterceptorMBeanTest.java 2009-09-09 10:50:49 UTC (rev 800)
+++ trunk/core/src/test/java/org/infinispan/jmx/ActivationAndPassivationInterceptorMBeanTest.java 2009-09-09 15:12:27 UTC (rev 801)
@@ -15,6 +15,7 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
+import javax.management.Attribute;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.util.HashMap;
@@ -64,9 +65,9 @@
}
public void testDisbaleStatistics() throws Exception {
- threadMBeanServer.invoke(activationInterceptorObjName, "setStatisticsEnabled", new Object[]{Boolean.FALSE}, new String[]{"boolean"});
+ threadMBeanServer.setAttribute(activationInterceptorObjName, new Attribute("StatisticsEnabled", Boolean.FALSE));
assert threadMBeanServer.getAttribute(activationInterceptorObjName, "Activations").toString().equals("N/A");
- threadMBeanServer.invoke(activationInterceptorObjName, "setStatisticsEnabled", new Object[]{Boolean.TRUE}, new String[]{"boolean"});
+ threadMBeanServer.setAttribute(activationInterceptorObjName, new Attribute("StatisticsEnabled", Boolean.TRUE));
}
public void testActivationOnGet() throws Exception {
Modified: trunk/core/src/test/java/org/infinispan/jmx/RpcManagerMBeanTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/jmx/RpcManagerMBeanTest.java 2009-09-09 10:50:49 UTC (rev 800)
+++ trunk/core/src/test/java/org/infinispan/jmx/RpcManagerMBeanTest.java 2009-09-09 15:12:27 UTC (rev 801)
@@ -16,6 +16,7 @@
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
+import javax.management.Attribute;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.util.ArrayList;
@@ -78,7 +79,7 @@
assert mBeanServer.getAttribute(rpcManager1, "ReplicationCount").equals("N/A");
assert mBeanServer.getAttribute(rpcManager1, "ReplicationCount").equals("N/A");
- mBeanServer.invoke(rpcManager1, "setStatisticsEnabled", new Object[]{Boolean.TRUE}, new String[]{"boolean"});
+ mBeanServer.setAttribute(rpcManager1, new Attribute("StatisticsEnabled", Boolean.TRUE));
assert mBeanServer.getAttribute(rpcManager1, "StatisticsEnabled").equals(Boolean.TRUE);
assert mBeanServer.getAttribute(rpcManager2, "StatisticsEnabled").equals(Boolean.FALSE);
@@ -88,7 +89,6 @@
assert mBeanServer.getAttribute(rpcManager1, "ReplicationFailures").equals("0");
mBeanServer.getAttribute(rpcManager1, "ReplicationCount").equals("N/A");
-
//now resume statistics
mBeanServer.invoke(rpcManager1, "resetStatistics", new Object[0], new String[0]);
assert mBeanServer.getAttribute(rpcManager1, "ReplicationCount").equals("0");
More information about the infinispan-commits
mailing list