Skip to content

Commit

Permalink
parameter JMX methods
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed May 2, 2008
1 parent 52b2b71 commit 4c09297
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
Expand Up @@ -50,5 +50,7 @@ public interface IParameterService {
public void rereadParameters();

public Date getLastTimeParameterWereCached();

public Map<String,String> getAllParameters();

}
Expand Up @@ -174,6 +174,10 @@ private Map<String, String> getParameters() {
}
return parameters;
}

public Map<String, String> getAllParameters() {
return getParameters();
}

public Date getLastTimeParameterWereCached() {
return lastTimeParameterWereCached;
Expand Down
Expand Up @@ -19,20 +19,73 @@
*/
package org.jumpmind.symmetric.service.jmx;

import java.util.Map;

import org.jumpmind.symmetric.service.IParameterService;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedOperationParameter;
import org.springframework.jmx.export.annotation.ManagedOperationParameters;
import org.springframework.jmx.export.annotation.ManagedResource;

@ManagedResource(description = "The management interface for nodes")
public class NodeManagementService {

IParameterService parameterService;

@ManagedOperation(description = "Reload supported parameters from file or database")
public void rereadParameters() {
this.parameterService.rereadParameters();
this.parameterService.rereadParameters();
}

@ManagedOperation(description = "Update a parameter for this node only")
@ManagedOperationParameters( {
@ManagedOperationParameter(name = "key", description = "The name of the parameter"),
@ManagedOperationParameter(name = "value", description = "The value for the parameter") })
public void updateParameter(String key, String value) {
this.parameterService.saveParameter(key, value);
}

@ManagedOperation(description = "Update a parameter for all nodes")
@ManagedOperationParameters( {
@ManagedOperationParameter(name = "key", description = "The name of the parameter"),
@ManagedOperationParameter(name = "value", description = "The value for the parameter") })
public void updateParameterForAll(String key, String value) {
this.parameterService.saveParameter(IParameterService.ALL, IParameterService.ALL, key, value);
}

@ManagedOperation(description = "Update a parameter for all nodes in a group")
@ManagedOperationParameters( {
@ManagedOperationParameter(name = "nodeGroup", description = "The name of the node group"),
@ManagedOperationParameter(name = "key", description = "The name of the parameter"),
@ManagedOperationParameter(name = "value", description = "The value for the parameter") })
public void updateParameterForNodeGroup(String nodeGroup, String key, String value) {
this.parameterService.saveParameter(IParameterService.ALL, nodeGroup, key, value);
}

@ManagedOperation(description = "Update a parameter for a specific node")
@ManagedOperationParameters( {
@ManagedOperationParameter(name = "externalId", description = "The name of the external id of node"),
@ManagedOperationParameter(name = "nodeGroup", description = "The name of the node group"),
@ManagedOperationParameter(name = "key", description = "The name of the parameter"),
@ManagedOperationParameter(name = "value", description = "The value for the parameter") })
public void updateParameterForNodeGroup(String externalId, String nodeGroup, String key, String value) {
this.parameterService.saveParameter(externalId, nodeGroup, key, value);
}

@ManagedAttribute(description = "The parameters configured for this SymmetricDS instance")
public String getPropertiesList() {
StringBuilder buffer = new StringBuilder();
Map<String, String> params = parameterService.getAllParameters();
for (String key : params.keySet()) {
buffer.append(key).append("=").append(params.get(key)).append("<br/>");
}
return buffer.toString();
}

@ManagedOperationParameters( {
@ManagedOperationParameter(name = "nodeGroupId", description = "The node group id for a node"),
@ManagedOperationParameter(name = "externalId", description = "The external id for a node") })
public void setParameterService(IParameterService parameterService) {
this.parameterService = parameterService;
}
Expand Down

0 comments on commit 4c09297

Please sign in to comment.