You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2014/03/10 10:43:21 UTC

[10/20] git commit: moving persistence volume to an extension

moving persistence volume to an extension


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/4e958b93
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/4e958b93
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/4e958b93

Branch: refs/heads/master
Commit: 4e958b933edb4e3dd8cbc47c2708225c12ecaefe
Parents: 8705322
Author: Nirmal Fernando <ni...@apache.org>
Authored: Mon Mar 10 15:02:31 2014 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Mon Mar 10 15:02:31 2014 +0530

----------------------------------------------------------------------
 .../PersistenceVolumeExtensionExecutor.java     | 76 ++++++++++++++++++++
 1 file changed, 76 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4e958b93/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/executor/impl/PersistenceVolumeExtensionExecutor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/executor/impl/PersistenceVolumeExtensionExecutor.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/executor/impl/PersistenceVolumeExtensionExecutor.java
new file mode 100644
index 0000000..265fab0
--- /dev/null
+++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/executor/impl/PersistenceVolumeExtensionExecutor.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cartridge.agent.executor.impl;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cartridge.agent.config.CartridgeAgentConfiguration;
+import org.apache.stratos.cartridge.agent.executor.ExtensionExecutor;
+import org.apache.stratos.cartridge.agent.util.CartridgeAgentConstants;
+import org.apache.stratos.cartridge.agent.util.ExtensionUtils;
+import org.apache.stratos.common.util.CommandUtils;
+
+/**
+ * This extension is suppose to handle persistence storage related work.
+ * 
+ */
+public class PersistenceVolumeExtensionExecutor extends ExtensionExecutor {
+	
+	private static final Log log = LogFactory.getLog(PersistenceVolumeExtensionExecutor.class);
+
+	public PersistenceVolumeExtensionExecutor() {
+		super(PersistenceVolumeExtensionExecutor.class.getName());
+	}
+	
+	public PersistenceVolumeExtensionExecutor(List<String> fileNames) {
+		super.setFileNamesToBeExecuted(fileNames);
+	}
+
+	@Override
+	public void execute() {
+		try {
+            if(log.isDebugEnabled()) {
+                log.debug("Executing Extension: "+super.getId());
+            }
+            String persistanceMappingsPayload = CartridgeAgentConfiguration.getInstance().getPersistanceMappings();
+			if (persistanceMappingsPayload != null) {
+				String command = ExtensionUtils.prepareCommand(CartridgeAgentConstants.MOUNT_VOLUMES_SH);
+				// String payloadPath =
+				// System.getProperty(CartridgeAgentConstants.PARAM_FILE_PATH);
+				// add payload file path as argument so inside the script we can
+				// source
+				// it to get the env variables set by the startup script
+				CommandUtils.executeCommand(command + " "
+						+ persistanceMappingsPayload);
+			}
+        }
+		catch (Exception e) {
+            log.error("Could not execute extension: "+super.getId() , e);
+        }
+	}
+
+	@Override
+	public void cleanUp() {
+	}
+	
+	
+}