modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
| 48 +++++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
| 3
modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
| 8 -
3 files changed, 42 insertions(+), 17 deletions(-)
New commits:
commit b9029136b21154a2572c1794807de2ca9a30e2a2
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 25 17:52:00 2013 -0500
Operations are now created in a new transaction. Also, change the way the
configuration is updated.
The steps for a full configuration update:
1) Invoke config update operation on the plugin
2) Update the JMX port on the storage node entity
3) Restart the storage node server
4) Update the connection settings for the storage node if JMX port changed
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index 7a7eda4..7d861f1 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -35,6 +35,8 @@ import java.util.Queue;
import javax.ejb.EJB;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
@@ -134,6 +136,9 @@ public class StorageNodeManagerBean implements
StorageNodeManagerLocal, StorageN
@EJB
private ConfigurationManagerLocal configurationManager;
+ @EJB
+ private StorageNodeManagerLocal storageNodeManger;
+
@Override
public void linkResource(Resource resource) {
List<StorageNode> storageNodes = this.getStorageNodes();
@@ -658,31 +663,49 @@ public class StorageNodeManagerBean implements
StorageNodeManagerLocal, StorageN
parameters);
if (result) {
+ //2. Update the JMX port
+ //this is a fast operation compared to the restart
+ storageNode.setJmxPort(storageNodeConfiguration.getJmxPort());
+ entityManager.merge(storageNode);
+
+ //3. Restart the storage node
+ result = runOperationAndWaitForResult(subject, storageNodeResource,
RESTART_OPERATION,
+ new Configuration());
+
+ //4. Update the plugin configuration to talk with the new server
+ //Up to this point communication with the storage node should not have
been affected by the intermediate
+ //changes
Configuration storageNodePluginConfig =
configurationManager.getPluginConfiguration(subject,
storageNodeResource.getId());
String existingJMXPort =
storageNodePluginConfig.getSimpleValue("jmxPort");
- storageNodePluginConfig.setSimpleValue("jmxPort",
storageNodeConfiguration.getJmxPort() + "");
+ String newJMXPort = storageNodeConfiguration.getJmxPort() +
"";
- String existingConnectionURL =
storageNodePluginConfig.getSimpleValue("connectorAddress");
- String newConnectionURL = existingConnectionURL.replace(":" +
existingJMXPort + "/", ":"
- + storageNodeConfiguration.getJmxPort() + "/");
- storageNodePluginConfig.setSimpleValue("connectorAddress",
newConnectionURL);
+ if (!existingJMXPort.equals(newJMXPort)) {
+ storageNodePluginConfig.setSimpleValue("jmxPort",
newJMXPort);
- configurationManager.updatePluginConfiguration(subject,
storageNodeResource.getId(),
- storageNodePluginConfig);
+ String existingConnectionURL =
storageNodePluginConfig.getSimpleValue("connectorAddress");
+ String newConnectionURL = existingConnectionURL.replace(":"
+ existingJMXPort + "/", ":"
+ + storageNodeConfiguration.getJmxPort() + "/");
+ storageNodePluginConfig.setSimpleValue("connectorAddress",
newConnectionURL);
- storageNode.setJmxPort(storageNodeConfiguration.getJmxPort());
- entityManager.merge(storageNode);
- entityManager.flush();
+ configurationManager.updatePluginConfiguration(subject,
storageNodeResource.getId(),
+ storageNodePluginConfig);
+ }
- return runOperationAndWaitForResult(subject, storageNodeResource,
RESTART_OPERATION, null);
+ return result;
}
}
return false;
}
+ @Override
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public void scheduleOperationInNewTransaction(Subject subject,
ResourceOperationSchedule schedule) {
+ operationManager.scheduleResourceOperation(subject, schedule);
+ }
+
private boolean runOperationAndWaitForResult(Subject subject, Resource
storageNodeResource, String operationToRun,
Configuration parameters) {
@@ -696,8 +719,7 @@ public class StorageNodeManagerBean implements
StorageNodeManagerLocal, StorageN
newSchedule.setDescription("Run by StorageNodeManagerBean");
newSchedule.setParameters(parameters);
- operationManager.scheduleResourceOperation(subject, newSchedule);
- entityManager.flush();
+ storageNodeManger.scheduleOperationInNewTransaction(subject, newSchedule);
//waiting for the operation result then return it
int iteration = 0;
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
index 69b16c4..15fa85c 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
@@ -28,6 +28,7 @@ import org.rhq.core.domain.cloud.StorageNode;
import org.rhq.core.domain.cloud.StorageNodeConfigurationComposite;
import org.rhq.core.domain.cloud.StorageNodeLoadComposite;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
+import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
@@ -178,4 +179,6 @@ public interface StorageNodeManagerLocal {
*/
ResourceGroup getStorageNodeGroup();
+ void scheduleOperationInNewTransaction(Subject subject, ResourceOperationSchedule
schedule);
+
}
diff --git a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
index a42040d..f5a4f6d 100644
--- a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
@@ -132,10 +132,10 @@
<operation name="updateConfiguration" description="Updates the node
configuration. Will require a separate server restart for the settings to take
effect.">
<parameters>
- <c:simple-property name="jmxPort" type="integer"
description="JMX port JVM option."/>
- <c:simple-property name="heapSize" type="string"
description="The heap size to be used for both -Xms and -Xmx JVM options."/>
- <c:simple-property name="heapNewSize" type="string"
description="The heap new size to be used be used with -Xmn JVM option."/>
- <c:simple-property name="threadStackSize" type="integer"
description="The thread stack size. This memory is allocated to each thread off heap.
The
+ <c:simple-property name="jmxPort" type="integer"
required="false" description="JMX port JVM option."/>
+ <c:simple-property name="heapSize" type="string"
required="false" description="The heap size to be used for both -Xms and
-Xmx JVM options."/>
+ <c:simple-property name="heapNewSize" type="string"
required="false" description="The heap new size to be used be used with
-Xmn JVM option."/>
+ <c:simple-property name="threadStackSize" type="integer"
required="false" description="The thread stack size. This memory is
allocated to each thread off heap. The
value
should be an integer that will be interpreted in kilobytes."/>
<c:simple-property name="restartIfRequired" type="boolean"
required="true" default="false" description="If [true] then
restart the server at the end of the update if and if only the updates made require a
restart. If [false] the server will not be restarted regardless of the updates
made."/>
</parameters>