[teiid-commits] teiid SVN: r2511 - in branches/7.1.x/console/src/main: java/org/teiid/rhq/plugin and 2 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Aug 31 15:10:36 EDT 2010


Author: tejones
Date: 2010-08-31 15:10:36 -0400 (Tue, 31 Aug 2010)
New Revision: 2511

Modified:
   branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
   branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
   branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/DeploymentUtils.java
   branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
   branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
Log:
TEIID-1196: Added 'Deploy VDB via URL" operation to the Data Services (RuntimeEngine) node

Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java	2010-08-31 18:26:04 UTC (rev 2510)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java	2010-08-31 19:10:36 UTC (rev 2511)
@@ -22,6 +22,7 @@
 package org.teiid.rhq.admin;
 
 import java.lang.reflect.Method;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -54,6 +55,7 @@
 import org.teiid.adminapi.impl.RequestMetadata;
 import org.teiid.adminapi.impl.RequestMetadataMapper;
 import org.teiid.rhq.plugin.objects.ExecutedResult;
+import org.teiid.rhq.plugin.util.DeploymentUtils;
 import org.teiid.rhq.plugin.util.PluginConstants;
 import org.teiid.rhq.plugin.util.ProfileServiceUtil;
 import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
@@ -64,6 +66,8 @@
 	private static ManagedComponent mc = null;
 	private static final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
 	private static final MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
+	
+	private static final String VDB_EXT = ".vdb";
 
 	public DQPManagementView() {
 	}
@@ -225,6 +229,30 @@
 				final String msg = "Exception executing operation: " + Platform.Operations.KILL_REQUEST; //$NON-NLS-1$
 				LOG.error(msg, e);
 			}
+		} else if (operationName.equals(Platform.Operations.DEPLOY_VDB_BY_URL)) {
+			String vdbUrl = (String) valueMap.get(Operation.Value.VDB_URL);
+			String deployName = (String) valueMap.get(Operation.Value.VDB_DEPLOY_NAME);
+			Object vdbVersion = valueMap.get(Operation.Value.VDB_VERSION);
+			//strip off vdb extension if user added it
+			if (deployName.endsWith(VDB_EXT)){  
+				deployName = deployName.substring(0, deployName.lastIndexOf(VDB_EXT));  
+			}
+			if (vdbVersion!=null){
+				deployName = deployName + "." + ((Integer)vdbVersion).toString() + VDB_EXT; //$NON-NLS-1$ 
+			}
+			//add vdb extension if there was no version
+			if (!deployName.endsWith(VDB_EXT)){ 
+				deployName = deployName + VDB_EXT;  
+			}
+	
+			try {
+				URL url = new URL(vdbUrl);
+				DeploymentUtils.deployArchive(deployName, connection.getDeploymentManager(), url, false);
+			} catch (Exception e) {
+				final String msg = "Exception executing operation: " + Platform.Operations.DEPLOY_VDB_BY_URL; //$NON-NLS-1$
+				LOG.error(msg, e);
+				throw new RuntimeException(e);
+			}
 		}
 	}
 

Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java	2010-08-31 18:26:04 UTC (rev 2510)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java	2010-08-31 19:10:36 UTC (rev 2511)
@@ -104,6 +104,10 @@
 			valueMap.put(Operation.Value.TRANSACTION_ID, configuration.getSimple(Operation.Value.TRANSACTION_ID).getLongValue());
 		} else if (name.equals(Platform.Operations.KILL_SESSION)) {
 			valueMap.put(Operation.Value.SESSION_ID, configuration.getSimple(Operation.Value.SESSION_ID).getLongValue());
+		} else if (name.equals(Platform.Operations.DEPLOY_VDB_BY_URL)) {
+			valueMap.put(Operation.Value.VDB_URL, configuration.getSimple(Operation.Value.VDB_URL).getStringValue());
+			valueMap.put(Operation.Value.VDB_DEPLOY_NAME, configuration.getSimple(Operation.Value.VDB_DEPLOY_NAME).getStringValue());
+			valueMap.put(Operation.Value.VDB_VERSION, configuration.getSimple(Operation.Value.VDB_VERSION).getIntegerValue());
 		}
 	}
 

Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/DeploymentUtils.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/DeploymentUtils.java	2010-08-31 18:26:04 UTC (rev 2510)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/DeploymentUtils.java	2010-08-31 19:10:36 UTC (rev 2511)
@@ -42,8 +42,8 @@
     private static final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
 
     public static boolean hasCorrectExtension(String archiveFileName, ResourceType resourceType) {
-        String expectedExtension = "vdb";
-        int lastPeriod = archiveFileName.lastIndexOf(".");
+        String expectedExtension = "vdb"; //$NON-NLS-1$
+        int lastPeriod = archiveFileName.lastIndexOf("."); //$NON-NLS-1$
         String extension = (lastPeriod != -1) ? archiveFileName.substring(lastPeriod + 1) : null;
         // Use File.equals() to compare the extensions so case-sensitivity is correct for this platform.
         return (extension != null && new File(extension).equals(new File(expectedExtension)));
@@ -63,16 +63,47 @@
     public static void deployArchive(DeploymentManager deploymentManager, File archiveFile, boolean deployExploded)
         throws Exception {
         String archiveFileName = archiveFile.getName();
-        LOG.debug("Deploying '" + archiveFileName + "' (deployExploded=" + deployExploded + ")...");
+        LOG.debug("Deploying '" + archiveFileName + "' (deployExploded=" + deployExploded + ")..."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         URL contentURL;
         try {
             contentURL = archiveFile.toURI().toURL();
         }
         catch (MalformedURLException e) {
-            throw new IllegalArgumentException("Failed to convert archive file path '" + archiveFile + "' to URL.", e);
+            throw new IllegalArgumentException("Failed to convert archive file path '" + archiveFile + "' to URL.", e); //$NON-NLS-1$ //$NON-NLS-2$
         }
         
-        DeploymentProgress progress = null;
+        deployAndStart(deploymentManager, contentURL, archiveFileName);
+    }
+
+    /**
+     * Deploys (i.e. distributes then starts) the specified archive file.
+     *
+     * @param fileName
+     * @param deploymentManager
+     * @param archiveUrl
+     * @param deployExploded
+     * 
+     * @return
+     *
+     * @throws Exception if the deployment fails for any reason
+     */
+    public static void deployArchive(String fileName, DeploymentManager deploymentManager, URL contentURL, boolean deployExploded)
+        throws Exception {
+        String archiveFileName = fileName;
+        LOG.debug("Deploying '" + archiveFileName + "' (deployExploded=" + deployExploded + ")..."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+         
+        deployAndStart(deploymentManager, contentURL, archiveFileName);
+    }
+
+	/**
+	 * @param deploymentManager
+	 * @param contentURL
+	 * @param archiveFileName
+	 * @throws Exception
+	 */
+	private static void deployAndStart(DeploymentManager deploymentManager,
+			URL contentURL, String archiveFileName) throws Exception {
+		DeploymentProgress progress = null;
         DeploymentStatus distributeStatus;
         Exception distributeFailure = null;
         try {
@@ -80,14 +111,14 @@
             distributeStatus = run(progress);
             if (distributeStatus.isFailed()) {
                 distributeFailure = (distributeStatus.getFailure() != null) ? distributeStatus.getFailure() :
-                        new Exception("Distribute failed for unknown reason.");
+                        new Exception("Distribute failed for unknown reason."); //$NON-NLS-1$
             }
         }
         catch (Exception e) {
             distributeFailure = e;
         }
         if (distributeFailure != null) {
-            throw new Exception("Failed to distribute '" + contentURL + "' to '" + archiveFileName + "' - cause: "
+            throw new Exception("Failed to distribute '" + contentURL + "' to '" + archiveFileName + "' - cause: "  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                     + ThrowableUtil.getAllMessages(distributeFailure));
         }
 
@@ -100,15 +131,15 @@
             startStatus = run(progress);
             if (startStatus.isFailed()) {
                 startFailure = (startStatus.getFailure() != null) ? startStatus.getFailure() :
-                        new Exception("Start failed for unknown reason.");
+                        new Exception("Start failed for unknown reason."); //$NON-NLS-1$
             }
         }
         catch (Exception e) {
             startFailure = e;
         }
         if (startFailure != null) {
-            LOG.error("Failed to start deployment " + Arrays.asList(deploymentNames)
-                + " during deployment of '" + archiveFileName + "'. Backing out the deployment...", startFailure);
+            LOG.error("Failed to start deployment " + Arrays.asList(deploymentNames) //$NON-NLS-1$
+                + " during deployment of '" + archiveFileName + "'. Backing out the deployment...", startFailure); //$NON-NLS-1$ //$NON-NLS-2$
             // If start failed, the app is invalid, so back out the deployment.
             DeploymentStatus removeStatus;
             Exception removeFailure = null;
@@ -117,24 +148,24 @@
                 removeStatus = run(progress);
                 if (removeStatus.isFailed()) {
                     removeFailure = (removeStatus.getFailure() != null) ? removeStatus.getFailure() :
-                        new Exception("Remove failed for unknown reason.");
+                        new Exception("Remove failed for unknown reason."); //$NON-NLS-1$
                 }
             }
             catch (Exception e) {
                 removeFailure = e;
             }
             if (removeFailure != null) {
-                LOG.error("Failed to remove deployment " + Arrays.asList(deploymentNames)
-                    + " after start failure.", removeFailure);
+                LOG.error("Failed to remove deployment " + Arrays.asList(deploymentNames) //$NON-NLS-1$
+                    + " after start failure.", removeFailure); //$NON-NLS-1$
             }
-            throw new Exception("Failed to start deployment " + Arrays.asList(deploymentNames)
-                + " during deployment of '" + archiveFileName + "' - cause: " +
+            throw new Exception("Failed to start deployment " + Arrays.asList(deploymentNames) //$NON-NLS-1$
+                + " during deployment of '" + archiveFileName + "' - cause: " + //$NON-NLS-1$ //$NON-NLS-2$
                     ThrowableUtil.getAllMessages(startFailure));
         }
         // If we made it this far, the deployment (distribution+start) was successful.
         return;
-    }
-
+	}
+    
     public static DeploymentStatus run(DeploymentProgress progress) {
         progress.run();
         return progress.getDeploymentStatus();

Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java	2010-08-31 18:26:04 UTC (rev 2510)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java	2010-08-31 19:10:36 UTC (rev 2511)
@@ -76,6 +76,7 @@
 				public final static String GET_SESSIONS = "getSessions"; //$NON-NLS-1$
 				public final static String GET_BUFFER_USAGE = "userBufferSpace"; //$NON-NLS-1$
 				public final static String GET_CACHE_STATS = "getCacheStatistics"; //$NON-NLS-1$
+				public final static String DEPLOY_VDB_BY_URL = "deployVdbByUrl"; //$NON-NLS-1$
 			}
 
 			public static interface Metrics {
@@ -225,7 +226,9 @@
 			public final static String TRANSACTION_ID = "transactionID"; //$NON-NLS-1$
 			public final static String REQUEST_ID = "requestID"; //$NON-NLS-1$
 			public final static String SESSION_ID = "sessionID"; //$NON-NLS-1$
-
+			public final static String VDB_URL = "vdbUrl"; //$NON-NLS-1$
+			public final static String VDB_DEPLOY_NAME = "vdbDeployName"; //$NON-NLS-1$
+			public final static String VDB_VERSION = "vdbVersion"; //$NON-NLS-1$
 			public final static String NAME = "Name"; //$NON-NLS-1$
 			public final static String VALUE = "Value"; //$NON-NLS-1$
 

Modified: branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml	2010-08-31 18:26:04 UTC (rev 2510)
+++ branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml	2010-08-31 19:10:36 UTC (rev 2511)
@@ -154,6 +154,19 @@
 				</c:list-property>
 			</results>
 		</operation>
+		
+		<operation name="deployVdbByUrl" displayName="Deploy a VDB via URL"
+			description="Deploy a VDB using a URL">
+			<parameters>
+				<c:simple-property displayName="VDB URL" name="vdbUrl"
+					type="file" required="true" description="The URL of the VDB to deploy" />
+				<c:simple-property displayName="VDB Deploy File Name" name="vdbDeployName"
+					type="string" required="true" description="The deployment file name to use. Must match the VDB Name you are deploying." />
+				<c:simple-property displayName="VDB Version" name="vdbVersion"
+					type="integer" required="false" description="The version to use for the deployed VDB (leave blank for overwrite of version one)" />
+			</parameters>
+		</operation>
+		
 
 		<operation name="terminateSession" displayName="Terminate Session"
 			description="Terminate a specified session">
@@ -266,7 +279,7 @@
 
         <metric displayName="Prepared Plan Cache # of Requests" defaultOn="true"
             displayType="detail" category="performance" property="PREPARED_PLAN_CACHE.requestCount"
-            description="Total number of requests made aginst cache" />
+            description="Total number of requests made against cache" />
             
         <metric displayName="ResultSet Cache Hit Ratio %" defaultOn="true"
             displayType="detail" category="performance" property="QUERY_SERVICE_RESULT_SET_CACHE.hitRatio"
@@ -278,7 +291,7 @@
 
         <metric displayName="ResultSet Cache  # of Requests" defaultOn="true"
             displayType="detail" category="performance" property="QUERY_SERVICE_RESULT_SET_CACHE.requestCount"
-            description="Total number of requests made aginst cache" />
+            description="Total number of requests made against cache" />
 
 		<resource-configuration>
 			<c:group name="teiidProperties" displayName="Runtime Engine Properties"



More information about the teiid-commits mailing list