You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2012/07/17 02:56:52 UTC

svn commit: r1362328 - in /incubator/ambari/trunk: CHANGES.txt hmc/js/configureServices.js hmc/php/frontend/configUtils.php hmc/php/frontend/configureServices.php

Author: yusaku
Date: Tue Jul 17 00:56:52 2012
New Revision: 1362328

URL: http://svn.apache.org/viewvc?rev=1362328&view=rev
Log:
AMBARI-638. Weirdness with Custom Config page when the user goes back to previous stages (Contributed by yusaku)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/hmc/js/configureServices.js
    incubator/ambari/trunk/hmc/php/frontend/configUtils.php
    incubator/ambari/trunk/hmc/php/frontend/configureServices.php

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1362328&r1=1362327&r2=1362328&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Tue Jul 17 00:56:52 2012
@@ -69,6 +69,9 @@ Trunk (unreleased changes)
 
   BUG FIXES
 
+    AMBARI-638. Weirdness with Custom Config page when the user goes back to 
+    previous stages (yusaku)
+
     AMBARI-637. Cluster Install Wizard: the 7-step nav goes out of sync if the
     user goes back to Step 3 and moves forward (yusaku) 
 

Modified: incubator/ambari/trunk/hmc/js/configureServices.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/configureServices.js?rev=1362328&r1=1362327&r2=1362328&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/configureServices.js (original)
+++ incubator/ambari/trunk/hmc/js/configureServices.js Tue Jul 17 00:56:52 2012
@@ -19,6 +19,26 @@
  *
 */
 
+function validate() {
+  var opts = App.ui.configureServicesUtil.generateUserOpts();
+
+  $.ajax({
+    type: 'POST',
+    url: '../php/frontend/configureServices.php?clusterName=' + App.props.clusterName + "&validateOnly=1",
+    data: JSON.stringify(opts),
+    dataType: 'json',
+    timeout: App.io.DEFAULT_AJAX_TIMEOUT_MS,
+    success: function (data) {
+      if (data.result != 0) {
+        App.ui.configureServicesUtil.handleConfigureServiceErrors(data);
+      }
+    },
+    failure: function (data) {
+      alert(App.io.DEFAULT_AJAX_ERROR_MESSAGE);
+    }
+  });
+}
+
 Y.one('#configureClusterAdvancedSubmitButtonId').on('click',function (e) {
   
   if (this.hasClass('disabled')) {
@@ -66,7 +86,7 @@ function renderConfigureServicesInternal
   Y.one("#configureClusterAdvancedDynamicRenderDivId").setContent(App.ui.configureServicesUtil.getOptionsSummaryMarkup(optionsInfo, false));
   $('#configureServicesTabs a:first').tab('show');
   Y.one("#configureClusterAdvancedCoreDivId").show();
-  Y.one('#configureClusterAdvancedSubmitButtonId').simulate('click');  
+  validate();
   App.ui.hideLoadingOverlay();
 }
 

Modified: incubator/ambari/trunk/hmc/php/frontend/configUtils.php
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/php/frontend/configUtils.php?rev=1362328&r1=1362327&r2=1362328&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/php/frontend/configUtils.php (original)
+++ incubator/ambari/trunk/hmc/php/frontend/configUtils.php Tue Jul 17 00:56:52 2012
@@ -584,12 +584,10 @@ function sanitizeConfigs($requestObjFrom
  * @param $dbAccessor HMCDBAccessor
  * @param $logger HMCLogger
  * @param $clusterName
- * @param $requestObjFromUser
+ * @param $finalProperties
  * @return array|mixed
  */
-function validateAndPersistConfigsFromUser($dbAccessor, $logger, $clusterName, $requestObjFromUser) {
-  // sanitize and persist the user entered configs *******
-  $finalProperties = sanitizeConfigs($requestObjFromUser, $logger);
+function validateConfigsFromUser($dbAccessor, $logger, $clusterName, $finalProperties) {
 
   //Additional services that need to be enabled based on configuration.
   //Hack to handle mysql for hive
@@ -601,7 +599,7 @@ function validateAndPersistConfigsFromUs
   $cfgSuggestResult = $suggestProperties->verifyProperties($clusterName, $dbAccessor, $finalProperties);
   if ($cfgResult["result"] != 0 || $cfgSuggestResult["result"] != 0) {
     $mergedErrors = array( "result" => 1, "error" => "Some configuration parameters need your attention before you can proceed.",
-        "properties" => array());
+      "properties" => array());
 
     if (isset($cfgResult["properties"])) {
       $mergedErrors["properties"] = $cfgResult["properties"];
@@ -617,6 +615,24 @@ function validateAndPersistConfigsFromUs
     $logger->log_error("Got error when validating configs");
     return $mergedErrors;
   }
+  return $cfgSuggestResult;
+}
+
+/**
+ * @param $dbAccessor HMCDBAccessor
+ * @param $logger HMCLogger
+ * @param $clusterName
+ * @param $finalProperties
+ * @return array|mixed
+ */
+function validateAndPersistConfigsFromUser($dbAccessor, $logger, $clusterName, $finalProperties) {
+  // sanitize and persist the user entered configs *******
+
+  $result = validateConfigsFromUser($dbAccessor, $logger, $clusterName, $finalProperties);
+  if ($result["result"] != 0) {
+    return $result;
+  }
+
   if ($finalProperties["kerberos_install_type"] == "USER_SET_KERBEROS") {
     $dbResponse = $dbAccessor->setServiceEnabled($clusterName, "KERBEROS", FALSE);
     if ($dbResponse["result"] != 0) {

Modified: incubator/ambari/trunk/hmc/php/frontend/configureServices.php
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/php/frontend/configureServices.php?rev=1362328&r1=1362327&r2=1362328&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/php/frontend/configureServices.php (original)
+++ incubator/ambari/trunk/hmc/php/frontend/configureServices.php Tue Jul 17 00:56:52 2012
@@ -40,13 +40,25 @@ $requestObj = json_decode($requestdata, 
 $clusterName = $_GET['clusterName'];
 // TODO: Validate clusterName
 
-$result = validateAndPersistConfigsFromUser($dbAccessor, $logger, $clusterName, $requestObj);
-if ($result['result'] != 0) {
-  $logger->log_error("Failed to validate configs from user, error=" . $result["error"]);
-  print json_encode($result);
-  return;
-}
+$validateOnly = $_GET['validateOnly'];
+
+$finalProperties = sanitizeConfigs($requestObj, $logger);
 
+if ($validateOnly) {
+  $result = validateConfigsFromUser($dbAccessor, $logger, $clusterName, $finalProperties);
+  if ($result['result'] != 0) {
+    $logger->log_error("Failed to validate configs from user (validate only), error=" . $result["error"]);
+    print json_encode($result);
+    return;
+  }
+} else {
+  $result = validateAndPersistConfigsFromUser($dbAccessor, $logger, $clusterName, $finalProperties);
+  if ($result['result'] != 0) {
+    $logger->log_error("Failed to validate configs from user (validate and persist), error=" . $result["error"]);
+    print json_encode($result);
+    return;
+  }
+}
 $jsonOutput = array();
 $jsonOutput['clusterName'] = $clusterName;