PL-7117 ClusterManager per-class usage performance statistics (fix review: javadoc, jmx operation descriptions, handle class name is null)

This commit is contained in:
Andrey Subbotin 2016-06-01 12:29:17 +04:00
parent 273d4ab610
commit af6613068b
4 changed files with 29 additions and 24 deletions

View File

@ -16,6 +16,7 @@
*/ */
package com.haulmont.cuba.core.app; package com.haulmont.cuba.core.app;
import com.haulmont.bali.util.Preconditions;
import com.haulmont.cuba.core.global.GlobalConfig; import com.haulmont.cuba.core.global.GlobalConfig;
import com.haulmont.cuba.core.global.Resources; import com.haulmont.cuba.core.global.Resources;
import com.haulmont.cuba.core.sys.AppContext; import com.haulmont.cuba.core.sys.AppContext;
@ -276,7 +277,7 @@ public class ClusterManager implements ClusterManagerAPI, AppContext.Listener {
} }
@Override @Override
public String printClusterStatesStat() { public String printSharedStateStat() {
StringBuilder clusterStateStat = new StringBuilder(); StringBuilder clusterStateStat = new StringBuilder();
for (Map.Entry<String, ClusterListener> entry : listeners.entrySet()) { for (Map.Entry<String, ClusterListener> entry : listeners.entrySet()) {
byte[] data = null; byte[] data = null;
@ -309,6 +310,7 @@ public class ClusterManager implements ClusterManagerAPI, AppContext.Listener {
@Override @Override
public long getSentMessages(String className) { public long getSentMessages(String className) {
Preconditions.checkNotNullArgument(className, "Message class is null");
MessageStat stat = messagesStat.get(className); MessageStat stat = messagesStat.get(className);
if (stat != null) { if (stat != null) {
return stat.getSentMessages(); return stat.getSentMessages();
@ -318,6 +320,7 @@ public class ClusterManager implements ClusterManagerAPI, AppContext.Listener {
@Override @Override
public long getSentBytes(String className) { public long getSentBytes(String className) {
Preconditions.checkNotNullArgument(className, "Message class is null");
MessageStat stat = messagesStat.get(className); MessageStat stat = messagesStat.get(className);
if (stat != null) { if (stat != null) {
return stat.getSentBytes(); return stat.getSentBytes();
@ -327,6 +330,7 @@ public class ClusterManager implements ClusterManagerAPI, AppContext.Listener {
@Override @Override
public long getReceivedMessages(String className) { public long getReceivedMessages(String className) {
Preconditions.checkNotNullArgument(className, "Message class is null");
MessageStat stat = messagesStat.get(className); MessageStat stat = messagesStat.get(className);
if (stat != null) { if (stat != null) {
return stat.getReceivedMessages(); return stat.getReceivedMessages();
@ -336,6 +340,7 @@ public class ClusterManager implements ClusterManagerAPI, AppContext.Listener {
@Override @Override
public long getReceivedBytes(String className) { public long getReceivedBytes(String className) {
Preconditions.checkNotNullArgument(className, "Message class is null");
MessageStat stat = messagesStat.get(className); MessageStat stat = messagesStat.get(className);
if (stat != null) { if (stat != null) {
return stat.getReceivedBytes(); return stat.getReceivedBytes();

View File

@ -105,37 +105,37 @@ public interface ClusterManagerAPI {
int getMessagesCount(); int getMessagesCount();
/** /**
* Serialize cluster state and get state statistics * Shared state statistics
* @return statistic * @return statistics
*/ */
String printClusterStatesStat(); String printSharedStateStat();
/** /**
* Sent/received messages statistic * Sent/received messages statistics
* @return statistic * @return statistics
*/ */
String printMessagesStat(); String printMessagesStat();
/** /**
* Get sent messages count statistic for specified {@param className} * Get sent messages count for specified {@param className}
* @return messages count * @return messages count
*/ */
long getSentMessages(String className); long getSentMessages(String className);
/** /**
* Get sent bytes statistic for specified {@param className} * Get sent bytes for specified {@param className}
* @return size in bytes * @return size in bytes
*/ */
long getSentBytes(String className); long getSentBytes(String className);
/** /**
* Get received messages count statistic for specified {@param className} * Get received messages count for specified {@param className}
* @return messages count * @return messages count
*/ */
long getReceivedMessages(String className); long getReceivedMessages(String className);
/** /**
* Get received bytes statistic for specified {@param className} * Get received bytes for specified {@param className}
* @return size in bytes * @return size in bytes
*/ */
long getReceivedBytes(String className); long getReceivedBytes(String className);

View File

@ -21,8 +21,8 @@ import com.haulmont.cuba.core.app.ClusterManagerAPI;
import org.apache.commons.lang.exception.ExceptionUtils; import org.apache.commons.lang.exception.ExceptionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.inject.Inject; import javax.inject.Inject;
@Component("cuba_ClusterManagerMBean") @Component("cuba_ClusterManagerMBean")
@ -83,8 +83,8 @@ public class ClusterManager implements ClusterManagerMBean {
} }
@Override @Override
public String printClusterStatesStat() { public String printSharedStateStat() {
return clusterManager.printClusterStatesStat(); return clusterManager.printSharedStateStat();
} }
@Override @Override
@ -94,21 +94,21 @@ public class ClusterManager implements ClusterManagerMBean {
@Override @Override
public long getSentMessages(String className) { public long getSentMessages(String className) {
return clusterManager.getSentMessages(className); return className == null ? -1 : clusterManager.getSentMessages(className);
} }
@Override @Override
public long getSentBytes(String className) { public long getSentBytes(String className) {
return clusterManager.getSentBytes(className); return className == null ? -1 : clusterManager.getSentBytes(className);
} }
@Override @Override
public long getReceivedMessages(String className) { public long getReceivedMessages(String className) {
return clusterManager.getReceivedMessages(className); return className == null ? -1 : clusterManager.getReceivedMessages(className);
} }
@Override @Override
public long getReceivedBytes(String className) { public long getReceivedBytes(String className) {
return clusterManager.getReceivedBytes(className); return className == null ? -1 : clusterManager.getReceivedBytes(className);
} }
} }

View File

@ -61,21 +61,21 @@ public interface ClusterManagerMBean {
*/ */
int getMessagesCount(); int getMessagesCount();
@ManagedOperation(description = "Serialize cluster state and get state statistics") @ManagedOperation(description = "Shared state statistics")
String printClusterStatesStat(); String printSharedStateStat();
@ManagedOperation(description = "Sent/received messages statistic") @ManagedOperation(description = "Sent/received messages statistics")
String printMessagesStat(); String printMessagesStat();
@ManagedOperation(description = "Get sent messages count statistic for specified class") @ManagedOperation(description = "Get sent messages count for specified class")
long getSentMessages(String className); long getSentMessages(String className);
@ManagedOperation(description = "Get sent bytes statistic for specified class") @ManagedOperation(description = "Get sent bytes for specified class")
long getSentBytes(String className); long getSentBytes(String className);
@ManagedOperation(description = "Get received messages count statistic for specified class") @ManagedOperation(description = "Get received messages count for specified class")
long getReceivedMessages(String className); long getReceivedMessages(String className);
@ManagedOperation(description = "Get received bytes statistic for specified class") @ManagedOperation(description = "Get received bytes for specified class")
long getReceivedBytes(String className); long getReceivedBytes(String className);
} }