modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java | 12 +++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
New commits: commit d9dce65588a6e5c69d31fec1c21ebaaaae2ecefd Author: John Sanda jsanda@redhat.com Date: Sat Aug 17 14:36:04 2013 -0400
add a check to see if the node is already decommissioned
If has C* has already been decommissioned, i.e., its operation mode is DECOMMISSIONED, then trying the decommission operation again will result in C* throwing an exception which we could interpret as a failed operation. This makes the resource operation idempotent.
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java index a82992e..7455f5e 100644 --- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java +++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java @@ -273,10 +273,16 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper try { EmsConnection emsConnection = getEmsConnection(); EmsBean storageService = emsConnection.getBean("org.apache.cassandra.db:type=StorageService"); - Class<?>[] emptyParams = new Class<?>[0];
- EmsOperation operation = storageService.getOperation("decommission", emptyParams); - operation.invoke((Object[]) emptyParams); + EmsAttribute operationModeAttr = storageService.getAttribute("OperationMode"); + String operationMode = (String) operationModeAttr.refresh(); + if (operationMode.equals("DECOMMISSIONED")) { + log.info("The storage node at " + getResourceContext().getResourceKey() + " is already decommissioned."); + } else { + Class<?>[] emptyParams = new Class<?>[0]; + EmsOperation operation = storageService.getOperation("decommission", emptyParams); + operation.invoke((Object[]) emptyParams); + } } catch (EmsInvocationException e) { result.setErrorMessage("Decommission operation failed: " + ThrowableUtil.getAllMessages(e)); }
rhq-commits@lists.fedorahosted.org