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/07 20:47:33 UTC

svn commit: r1358619 - in /incubator/ambari/trunk: ./ hmc/html/ hmc/html/upgradeStack/ hmc/js/ hmc/js/upgradeStack/ hmc/php/conf/ hmc/php/frontend/

Author: yusaku
Date: Sat Jul  7 18:47:32 2012
New Revision: 1358619

URL: http://svn.apache.org/viewvc?rev=1358619&view=rev
Log:
AMBARI-613. Do not force Hadoop stack upgrade when a new version is available. Show Hadoop stack version info (currently installed and latest available) (Contributed by yusaku)

Added:
    incubator/ambari/trunk/hmc/js/upgradeStack/index.js
Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/hmc/html/_router.php
    incubator/ambari/trunk/hmc/html/uninstallWizard.php
    incubator/ambari/trunk/hmc/html/upgradeStack/index.php
    incubator/ambari/trunk/hmc/js/configureServicesUtils.js
    incubator/ambari/trunk/hmc/js/upgradeStack/deploy.js
    incubator/ambari/trunk/hmc/js/upgradeStack/reconfigure.js
    incubator/ambari/trunk/hmc/js/upgradeStack/uninstall.js
    incubator/ambari/trunk/hmc/js/utils.js
    incubator/ambari/trunk/hmc/php/conf/MessageResources-en.inc
    incubator/ambari/trunk/hmc/php/frontend/fetchClusterServices.php

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1358619&r1=1358618&r2=1358619&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Sat Jul  7 18:47:32 2012
@@ -6,6 +6,10 @@ characters wide.
 
 Release 1.0.0 - unreleased
 
+  AMBARI-613. Do not force Hadoop stack upgrade when a new version is available.
+  Show Hadoop stack version info (currently installed and latest available).
+  (yusaku)
+
   AMBARI-612. Allow upgrading the database and add versions for ambari and
   hadoop stacks. (mahadev)
 

Modified: incubator/ambari/trunk/hmc/html/_router.php
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/html/_router.php?rev=1358619&r1=1358618&r2=1358619&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/html/_router.php (original)
+++ incubator/ambari/trunk/hmc/html/_router.php Sat Jul  7 18:47:32 2012
@@ -131,12 +131,6 @@ if (sizeof($clusters) == 0) {
         }
         $clusterState = 'UNINSTALL_FAILED';
         break;
-      case 'UPGRADE_STACK_PENDING':
-        if ($requestPage != 'upgradeStack/index.php') {
-          eval(redirectToPage($requestPage, 'upgradeStack/index.php'));
-        }
-        $clusterState = 'UPGRADE_STACK_PENDING';
-        break;
       case 'UPGRADE_STACK_UNINSTALL_IN_PROGRESS':
         if ($requestPage != 'upgradeStack/uninstall.php') {
           eval(redirectToPage($requestPage, 'upgradeStack/uninstall.php'));

Modified: incubator/ambari/trunk/hmc/html/uninstallWizard.php
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/html/uninstallWizard.php?rev=1358619&r1=1358618&r2=1358619&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/html/uninstallWizard.php (original)
+++ incubator/ambari/trunk/hmc/html/uninstallWizard.php Sat Jul  7 18:47:32 2012
@@ -74,7 +74,6 @@
     <!-- Javascript Scaffolding -->
     <script type="text/javascript">
 
-    var freshInstall = false;
     var nodesAction = "uninstall";
     var clusterName = "<?php echo $clusterName; ?>";
 

Modified: incubator/ambari/trunk/hmc/html/upgradeStack/index.php
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/html/upgradeStack/index.php?rev=1358619&r1=1358618&r2=1358619&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/html/upgradeStack/index.php (original)
+++ incubator/ambari/trunk/hmc/html/upgradeStack/index.php Sat Jul  7 18:47:32 2012
@@ -26,17 +26,30 @@
 </head>
 <body class="yui3-skin-sam">
   <?php require "../_topnav.php"; ?>
-
+  <?php require "../_utils.php"; ?>
   <div id="content">
       <div class="alert alert-info" style="margin-top:40px;padding:20px">
         <h2><?php echo $RES['upgradeStack.index.pageSummary.header'] ?></h2>
         <p><?php echo $RES['upgradeStack.index.pageSummary.body'] ?></p>
-        <p style="font-weight:bold">Upgrading from HDP Version X to Y</p>
-        <a href="uninstall.php" class="btn btn-large" id="submitButton"><?php echo $RES['upgradeStack.index.submit.label'] ?></a>
+        <p id="versionInfo" style="font-weight:bold"></p>
+        <div id="buttonGroup" style="margin-top:20px">
+          <a href="uninstall.php" class="btn btn-large btn-success" id="upgradeButton"><?php echo $RES['upgradeStack.index.submit.label'] ?></a>
+          <a href="../" class="btn btn-large" id="cancelButton" style="margin-left:10px"><?php echo $RES['upgradeStack.index.cancel.label'] ?></a>
+        </div>
       </div>
     </div>
   </div>
   <?php require "../_footer.php"; ?>
+  <script type="text/javascript">
+
+    var clusterName = '<?php echo $clusterName; ?>';
+
+    var jsFilesToLoad = [
+      'js/utils.js',
+      'js/upgradeStack/index.js'
+    ];
+  </script>
 
+  <?php require "../_bootstrapJs.php"; ?>
 </body>
 </html> 

Modified: incubator/ambari/trunk/hmc/js/configureServicesUtils.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/configureServicesUtils.js?rev=1358619&r1=1358618&r2=1358619&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/configureServicesUtils.js (original)
+++ incubator/ambari/trunk/hmc/js/configureServicesUtils.js Sat Jul  7 18:47:32 2012
@@ -138,6 +138,12 @@
 
     /////////////////// Submit related functions /////////////////////////////
 
+    var submitButtonSelector = '#configureClusterAdvancedSubmitButtonId';
+
+    this.setSubmitButtonSelector = function (selector) {
+      submitButtonSelector = selector;
+    };
+
     this.clearPasswordErrors = function () {
       for (var count = 0; count < passwordsArray.length; count++) {
         divId = "#" + passwordsArray[count]['verificationDivId'];
@@ -261,7 +267,7 @@
         }
       });
 
-      var submitButton = Y.one('#configureClusterAdvancedSubmitButtonId');
+      var submitButton = Y.one(submitButtonSelector);
 
       if (errorCount > 0) {
         Y.one(serviceDivId + 'ErrorCount').setContent('<span style="margin-left:4px" class="badge badge-important">' + errorCount + '</span>');

Modified: incubator/ambari/trunk/hmc/js/upgradeStack/deploy.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/upgradeStack/deploy.js?rev=1358619&r1=1358618&r2=1358619&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/upgradeStack/deploy.js (original)
+++ incubator/ambari/trunk/hmc/js/upgradeStack/deploy.js Sat Jul  7 18:47:32 2012
@@ -22,7 +22,7 @@
 
 (function() {
 
-  // initiates uninstall of stack and shows progress widget
+  // initiates deploy of new stack and shows progress widget
   function deployStack() {
     $.ajax({
       type: 'POST',
@@ -86,21 +86,23 @@
 
   }
 
+  function attachEventHandlers() {
+    $('#deploySubmitButton').click(function() {
+      App.ui.showLoadingOverlay();
+      deployStack();
+    });
 
-  $('#deploySubmitButton').click(function() {
-    App.ui.showLoadingOverlay();
-    deployStack();
-  });
-
-  // allow the user to go back to the reconfigure stage
-  $('#reconfigureStage').click(function() {
-    App.ui.showLoadingOverlay();
-    document.location.href = 'reconfigure.php';
-  });
+    // allow the user to go back to the reconfigure stage
+    $('#reconfigureStage').click(function() {
+      App.ui.showLoadingOverlay();
+      document.location.href = 'reconfigure.php';
+    });
+  }
 
   function renderPage(data) {
     var markup = App.ui.configureServicesUtil.getDeploySummaryMarkup(data);
     $('#deployDynamicRenderDivId').html(markup);
+    attachEventHandlers();
     App.ui.hideLoadingOverlay();
   }
 

Added: incubator/ambari/trunk/hmc/js/upgradeStack/index.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/upgradeStack/index.js?rev=1358619&view=auto
==============================================================================
--- incubator/ambari/trunk/hmc/js/upgradeStack/index.js (added)
+++ incubator/ambari/trunk/hmc/js/upgradeStack/index.js Sat Jul  7 18:47:32 2012
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+(function() {
+
+  App.ui.showLoadingOverlay();
+
+  function renderPage(data) {
+    $('#versionInfo').html(
+      'You are upgrading your Hadoop stack (HDP) from Version ' + data.versionInfo.currentStackVersion +
+      ' to ' + data.versionInfo.latestStackVersion + '.'
+    );
+    App.ui.hideLoadingOverlay();
+  }
+
+  // render the page
+  $.ajax({
+    type: 'GET',
+    url: '/hmc/php/frontend/fetchClusterServices.php?clusterName=' + App.props.clusterName,
+    data: {},
+    timeout: App.io.DEFAULT_AJAX_TIMEOUT_MS,
+    success: function (data) {
+      renderPage(data.response);
+    },
+    error: function (data) {
+      alert(App.io.DEFAULT_AJAX_ERROR_MESSAGE);
+    },
+  });
+
+})();
\ No newline at end of file

Modified: incubator/ambari/trunk/hmc/js/upgradeStack/reconfigure.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/upgradeStack/reconfigure.js?rev=1358619&r1=1358618&r2=1358619&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/upgradeStack/reconfigure.js (original)
+++ incubator/ambari/trunk/hmc/js/upgradeStack/reconfigure.js Sat Jul  7 18:47:32 2012
@@ -22,31 +22,68 @@
 
 (function() {
 
-  // initiates uninstall of stack and shows progress widget
-  function reconfigureStack() {
-    $.ajax({
-      type: 'POST',
-      url: '/hmc/php/frontend/uninstall.php?clusterName=' + App.props.clusterName +
-        '&action=uninstall&clusterDeployUser=root',
-      data: {},
-      timeout: App.io.DEFAULT_AJAX_TIMEOUT_MS,
-      success: function (data) {
-        redirectToDeploy(data.response);
-      },
-      error: function () {
-        alert(App.io.DEFAULT_AJAX_ERROR_MESSAGE);
+  function attachEventHandlers() {
+    App.ui.configureServicesUtil.setSubmitButtonSelector('#reconfigureSubmitButton');
+
+    $('#reconfigureSubmitButton').click(function() {
+
+      if ($(this).hasClass('disabled')) {
+        return;
       }
+
+      App.ui.showLoadingOverlay();
+
+      var opts = App.ui.configureServicesUtil.generateUserOpts();
+
+      $.ajax({
+        type: 'POST',
+        url: '/hmc/php/frontend/configureServices.php?clusterName=' + App.props.clusterName,
+        data: JSON.stringify(opts),
+        timeout: App.io.DEFAULT_AJAX_TIMEOUT_MS,
+        dataType: 'json',
+        success: function (data) {
+          if (data.result === 0) {
+            // server-side validation successful
+            // go to Deploy stage
+            document.location.href = 'deploy.php';
+          } else {
+            // server-side validation failed
+            App.ui.configureServicesUtil.handleConfigureServiceErrors(data);
+            App.ui.hideLoadingOverlay();
+          }
+        },
+        error: function () {
+          alert(App.io.DEFAULT_AJAX_ERROR_MESSAGE);
+        }
+      });
     });
-  }
 
-  function redirectToDeploy(response) {
-    document.location.href = 'deploy.php';
+    // register event handlers for dynamic validation
+    // when a key is pressed on a password field, perform password validation
+    $('#configureClusterAdvancedDynamicRenderDivId').on(
+      'keyup',
+      'input[type=password]',
+      function () {
+        App.ui.configureServicesUtil.checkPasswordCorrectness();
+        App.ui.configureServicesUtil.updateServiceErrorCount($(this).attr('name'));
+      }
+    );
+    // when a key is pressed on a text field, just clear the error
+    $('#configureClusterAdvancedDynamicRenderDivId').on(
+      'keyup',
+      'input[type=text],input[type=password]:not(.retypePassword)',
+      function () {
+        App.ui.configureServicesUtil.clearErrorReason('#' + $(this).attr('id'));
+        App.ui.configureServicesUtil.updateServiceErrorCount($(this).attr('name'));
+      }
+    );
   }
 
   function renderPage(data) {
     $('#configureClusterAdvancedDynamicRenderDivId').html(App.ui.configureServicesUtil.getOptionsSummaryMarkup(data, false));
     $('#configureServicesTabs a:first').tab('show');
     $('#configureClusterAdvancedCoreDivId').show();
+    attachEventHandlers();
     App.ui.hideLoadingOverlay();
   }
 
@@ -64,10 +101,6 @@
     }
   });
 
-  $('#reconfigureSubmitButton').click(function() {
-    App.ui.showLoadingOverlay();
-    reconfigureStack();
-  });
 
 })();
 

Modified: incubator/ambari/trunk/hmc/js/upgradeStack/uninstall.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/upgradeStack/uninstall.js?rev=1358619&r1=1358618&r2=1358619&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/upgradeStack/uninstall.js (original)
+++ incubator/ambari/trunk/hmc/js/upgradeStack/uninstall.js Sat Jul  7 18:47:32 2012
@@ -75,18 +75,20 @@
 
     server.respondWith(
       function (request) {
-        var body;
-        numCalled++;
-        if (numCalled == 1) {
-          body = initialResponse;
-        } else if (numCalled == 2) {
-          body = inProgressResponse;
-        } else if (numCalled == 3) {
-          body = successResponse;
-          //body = errorResponse;
-          server.restore();
-        }
+        var body = successResponse;
+
+//        numCalled++;
+//        if (numCalled == 1) {
+//          body = initialResponse;
+//        } else if (numCalled == 2) {
+//          body = inProgressResponse;
+//        } else if (numCalled == 3) {
+//          body = successResponse;
+//          //body = errorResponse;
+//          server.restore();
+//        }
         request.respond('200', { 'Content-Type': 'application/json' }, body);
+        server.restore();
       }
     );
 

Modified: incubator/ambari/trunk/hmc/js/utils.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/js/utils.js?rev=1358619&r1=1358618&r2=1358619&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/js/utils.js (original)
+++ incubator/ambari/trunk/hmc/js/utils.js Sat Jul  7 18:47:32 2012
@@ -186,9 +186,11 @@ function convertDisplayType(displayType)
 function executeStage(inputUrl, renderStageFunction) {
   Y.io(inputUrl, {
     method: 'GET',
-    timeout: 10000,
+    timeout: App.io.DEFAULT_AJAX_TIMEOUT_MS,
     on: {
       success: function (x, o) {
+        var responseJson;
+
         Y.log("RAW JSON DATA: " + o.responseText);
         // Process the JSON data returned from the server
         try {
@@ -222,12 +224,13 @@ function executeStage(inputUrl, renderSt
 }
 
 function submitDataAndProgressToNextScreen(url, requestData, submitButton, thisScreenId, nextScreenId, nextScreenRenderFunction, errorHandlerFunction) {
-  showLoadingImg();
+  App.ui.showLoadingOverlay();
+
   Y.io(url, {
 
     method: 'POST',
     data: Y.JSON.stringify(requestData),
-    timeout: 10000,
+    timeout: App.io.DEFAULT_AJAX_TIMEOUT_MS,
     on: {
       start: function (x, o) {
         submitButton.set('disabled', true);
@@ -240,6 +243,8 @@ function submitDataAndProgressToNextScre
         // hideLoadingImg();
       },
       success: function (x, o) {
+        var responseJson;
+
         submitButton.set('disabled', false);
         Y.log("RAW JSON DATA: " + o.responseText);
 
@@ -266,7 +271,7 @@ function submitDataAndProgressToNextScre
           } else {
             alert("Got error during submit data!" + responseJson.error);
           }
-          hideLoadingImg();
+          App.ui.hideLoadingOverlay();
           return;
         }
         responseJson = responseJson.response;
@@ -289,7 +294,7 @@ function PeriodicDataPoller(dataSourceCo
   /* Smoothe out the optional bits of this.dataSourceContext. */
   if (!this.dataSourceContext.pollInterval) {
     /* How often we poll. */
-    this.dataSourceContext.pollInterval = 5000;
+    this.dataSourceContext.pollInterval = DEFAULT_POLLING_INTERVAL_MS;
   }
   if (!this.dataSourceContext.maxFailedAttempts) {
     /* How many failed attempts before we stop polling. */
@@ -409,6 +414,7 @@ function titleCase(word) {
 
 // Create namespace and export functionality.
 // We'll remove globally defined functions and properties eventually
+// by wrapping in a closure.
 // For now we need to keep the non-namespaced global functions and properties
 // so that our existing code continues to work without major refactoring.
 
@@ -422,6 +428,7 @@ var App = App || {
     PeriodicDataPoller: PeriodicDataPoller,
     DEFAULT_AJAX_TIMEOUT_MS: 10000,
     FETCH_LOG_TIMEOUT_MS: 20000,
+    DEFAULT_POLLING_INTERVAL_MS: 5000,
     DEFAULT_AJAX_ERROR_MESSAGE: 'Failed to retrieve information from the server'
   },
   ui: {

Modified: incubator/ambari/trunk/hmc/php/conf/MessageResources-en.inc
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/php/conf/MessageResources-en.inc?rev=1358619&r1=1358618&r2=1358619&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/php/conf/MessageResources-en.inc (original)
+++ incubator/ambari/trunk/hmc/php/conf/MessageResources-en.inc Sat Jul  7 18:47:32 2012
@@ -77,9 +77,10 @@ $RES['uninstallWizard.pageSummary.body']
 $RES['uninstallWizard.wipeout.label']="Perform wipe out (delete all data)";
 $RES['uninstallWizard.submit.label']="Uninstall Cluster";
 $RES['initWizard.configureClusterAdvanced.validation.error']="We've encountered invalid settings.";
-$RES['upgradeStack.index.pageSummary.header']="Upgrade Your Hadoop Services";
-$RES['upgradeStack.index.pageSummary.body']="You have a pending upgrade of your Hadoop services.  You must complete the upgrade before you can continue.<br>We will walk you through the upgrade process with a step-by-step wizard.";
-$RES['upgradeStack.index.submit.label']="Get Started";
+$RES['upgradeStack.index.pageSummary.header']="Upgrade Your Hadoop Stack";
+$RES['upgradeStack.index.pageSummary.body']="A newer version of the Hadoop stack is available.<br>We will walk you through the upgrade process with a step-by-step wizard.";
+$RES['upgradeStack.index.submit.label']="Upgrade Now";
+$RES['upgradeStack.index.cancel.label']="I'll upgrade later";
 $RES['upgradeStack.uninstall.pageSummary.header']="Upgrade Step 1 - Uninstall Existing Hadoop Services";
 $RES['upgradeStack.uninstall.pageSummary.body']="First, we will uninstall the existing Hadoop services before we install the new version.  This will not delete your data.";
 $RES['upgradeStack.uninstall.submit.label']="Proceed";

Modified: incubator/ambari/trunk/hmc/php/frontend/fetchClusterServices.php
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/hmc/php/frontend/fetchClusterServices.php?rev=1358619&r1=1358618&r2=1358619&view=diff
==============================================================================
--- incubator/ambari/trunk/hmc/php/frontend/fetchClusterServices.php (original)
+++ incubator/ambari/trunk/hmc/php/frontend/fetchClusterServices.php Sat Jul  7 18:47:32 2012
@@ -200,6 +200,25 @@ if ($getConfigs == "true") {
   }
 }
 
+
+$versionInfo = array(
+  'currentManagerVersion' => $dbAccessor->getCurrentAmbariVersion(),
+  'currentStackVersion' => $dbAccessor->getCurrentClusterStackVersion($clusterName),
+  'previousManagerVersion' => $dbAccessor->getPreviousAmbariVersion(),
+  'latestStackVersion' => $dbAccessor->getLatestStackVersion()
+);
+foreach ($versionInfo as $key => $value) {
+  if ($value['result'] === 0) {
+    $versionInfo[$key] = $value['version'];
+  } else {
+    $gotError = "Error while getting version info: " . $value['error'] ;
+    $logger->log_error($gotError);
+    print (json_encode(array("result" => 1, "error" => $gotError)));
+    return;
+  }
+}
+
+
 $result = 0;
 $error = "";
 /* Create the output data... */
@@ -208,6 +227,7 @@ $jsonOutput = array(
     'error' => $error,
     'response' => array(
       'clusterName' => $clusterName,
+      'versionInfo' => $versionInfo,
       'managerHostName' => strtolower(exec('hostname -f')),
       'services' => $services )
   );