Code coverage report for app/utils/configs/control_flow_initializer_mixin.js

Statements: 80% (8 / 10)      Branches: 50% (3 / 6)      Functions: 71.43% (5 / 7)      Lines: 80% (8 / 10)      Ignored: none     

All files » app/utils/configs/ » control_flow_initializer_mixin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125    1                                     1 1                                 1                                       15                             2                 5                           2                                                      
'use strict';
 
;require.register("utils/configs/control_flow_initializer_mixin", function (exports, require, module) {
  /**
   * 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.
   */
 
  var App = require('app');
  var stringUtils = require('utils/string_utils');
 
  /**
   * Mixin with preconfigured initializers that helps to build conditional execution
   * based on exit code from App.ConfigInitializerClass._initializerFlowCode.
   * Each control flow initializer should has attribute <b>isChecker: true</b>
   * Each handler should return exit code value based on App.ConfigInitializerClass._initializerFlowCode.
   *
   * There are few methods:
   * @see App.ConfigInitializerClass.flowNext
   * @see App.ConfigInitializerClass.flowSkipNext
   * @see App.ConfigInitializerClass.flowSkipAll
   *
   * For details and examples @see App.AddComponentConfigInitializer
   *
   * @mixin App.ControlFlowInitializerMixin
   */
  App.ControlFlowInitializerMixin = Em.Mixin.create({
 
    initializerTypes: [{
      name: 'namenode_ha_enabled',
      method: '_initNameNodeHACheck'
    }, {
      name: 'resourcemanager_ha_enabled',
      method: '_initResourceManagerHACheck'
    }, {
      name: 'hdp_stack_version_checker',
      method: '_initHDPStackVersionCheck'
    }],
 
    /**
     * Control flow initializer based on minimal stack version.
     *
     * @param  {string} minStackVersionNumber
     * @return {object}
     */
    getHDPStackVersionControl: function getHDPStackVersionControl(minStackVersionNumber) {
      return { type: 'hdp_stack_version_checker', isChecker: true, stackVersion: minStackVersionNumber };
    },
 
    /**
     * getHDPStackVersionControl handler.
     * When stack version satisfies passed minStackVersionNumber computation process will continue.
     * If not all next computation will be skipped.
     *
     * @param  {configProperty} configProperty
     * @param  {topologyLocalDB} localDB
     * @param  {dependencies} dependencies
     * @param  {initializer} initializer
     * @return {number} _initializerFlowCode exit code
     */
    _initHDPStackVersionCheck: function _initHDPStackVersionCheck(configProperty, localDB, dependencies, initializer) {
      return stringUtils.compareVersions(App.get('currentStackVersionNumber'), initializer.stackVersion) > -1 ? this.flowNext() : this.flowSkipAll();
    },
 
    /**
     * Control flow initializer based on NameNode HA Status.
     *
     * @return {initializer}
     */
    getNameNodeHAControl: function getNameNodeHAControl() {
      return { type: 'namenode_ha_enabled', isChecker: true };
    },
 
    /**
     * getNameNodeHAControl handler.
     * When NameNode HA enabled next computation will be performed, either next will be skipped.
     *
     * @param  {configProperty} configProperty
     * @param  {topologyLocalDB} localDB
     * @param  {dependencies} dependencies
     * @param  {initializer} initializer
     * @return {number} _initializerFlowCode exit code
     */
    _initNameNodeHACheck: function _initNameNodeHACheck(configProperty, localDB, dependencies) {
      return App.get('isHaEnabled') ? this.flowNext() : this.flowSkipNext();
    },
 
    /**
     * Control flow initializer based on ResourceManager HA Status.
     *
     * @return {initializer}
     */
    getResourceManagerHAControl: function getResourceManagerHAControl(trueBranch, falseBranch) {
      return { type: 'resourcemanager_ha_enabled', isChecker: true };
    },
 
    /**
     * getResourceManagerHAControl handler.
     * When ResourceManager HA enabled next computation will be performed, either next will be skipped.
     *
     * @param  {configProperty} configProperty
     * @param  {topologyLocalDB} localDB
     * @param  {dependencies} dependencies
     * @param  {initializer} initializer
     * @return {number} _initializerFlowCode exit code
     */
    _initResourceManagerHACheck: function _initResourceManagerHACheck(configProperty, localDB, dependencies) {
      return App.get('isRMHaEnabled') ? this.flowNext() : this.flowSkipNext();
    }
 
  });
});