Code coverage report for app/controllers/wizard/step7_controller.js

Statements: 53.42% (414 / 775)      Branches: 46.14% (239 / 518)      Functions: 53.85% (91 / 169)      Lines: 54.09% (403 / 745)      Ignored: none     

All files » app/controllers/wizard/ » step7_controller.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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141    1                                     1                                                   1                                                                                                                                                                                                                                                                   4               1 2                 9 5 5 5               1               1 8                 9 9 7 2     9       1 1                                                                             4 4 4 4 4 4   4 4 4 4 4 4                                         6             6 6 5 2   3 3     1             21 63                                     7 7               7     7 7 7                           5 4   1 1 2 6 6 4   2 2       1                                                                                                                                                                                       4 4   4 1       1   3 3         4                                               3 1   2 2   2 2   2 2   2 2 1 1 1     1                 2       2 2               1 1 1       4 4 4     4     4 4 4   4             4 4 4 4 4             4 4 4 4 4 4 4 4                                               4 4 4                                                                                                                                       4     4     4 4 4 4 4     4                                           3 3 6 6 3 3 3 3                   3 3                                                                         4 4                               4                   1 1   1 6 6 6                       6   1                   3 3 3                       3 6 6 6                   6   3                                                                                     4           4 4               4   4     4     4 4 4   4 4 4               4 4   4     4                 4         4 4                                                                   2 2 2 2 2 2 2 2 1                             2 2 2 2             2                   5 1 1   1 1 1 1 1   1                           3 3 3 3                       9 3 3 3 3 1 1   3 3             3                   4 4 4 4   4 2   2                   1 1                                                                     1 1 2 2 2   1 1 1 3 3 3               1 1                     5 5 5   5 15 15 15   5   10 10 10 10 10   8   2 2   2 2 2 2 2         5 15                   5                 2             2                           1 1 3 2         1                   8 5 5 3 1 1     5 5                                                                                                 1                   7     7   3 3 3   3 6 6                     3 3 2                   7 7 6     6   6 4   2   6     6   6                     13 13     13 12 3 3 3 3 3   12 12 12 12                                             9 9 2 7 6 6 2 4 2 4 4     2     1                                                                                             1                                 4     4 3   1                       2 2 1   1 1 1 1 1                         7 7   7             1 1     4 4       2 2   2 1   1 1         1 1                   1 1             1 2 2 2 1 1 1 1 1 1               2   1 1 1 1   1       1                                               5 5           1 1           1 1 1 1           3 3 2 2 1                                           2 2   2                                                                                                                                             3     3     3 1 2 2   1 1         1 1                                                                                                                                                                                                                                                                                                                                                                                                                                                           87 87 87 87   87 87               367 367 367 367 367 367 87   367                                                                               4   4                                                      
'use strict';
 
;require.register("controllers/wizard/step7_controller", 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');
 
  /**
   * By Step 7, we have the following information stored in App.db and set on this
   * controller by the router.
   *
   *   selectedServices: App.db.selectedServices (the services that the user selected in Step 4)
   *   masterComponentHosts: App.db.masterComponentHosts (master-components-to-hosts mapping the user selected in Step 5)
   *   slaveComponentHosts: App.db.slaveComponentHosts (slave-components-to-hosts mapping the user selected in Step 6)
   *
   */
 
  /**
   * @typedef {object} masterComponentHost
   * @property {string} component
   * @property {string} hostName
   * @property {boolean} isInstalled is component already installed on the this host or just going to be installed
   */
 
  /**
   * @typedef {object} topologyLocalDB
   * @property {object[]} hosts list of hosts with information of their disks usage and dirs
   * @property {masterComponentHost[]} masterComponentHosts
   * @property {?object[]} slaveComponentHosts
   */
 
  App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.EnhancedConfigsMixin, App.ToggleIsRequiredMixin, App.GroupsMappingMixin, App.AddSecurityConfigs, App.KDCCredentialsControllerMixin, {
 
    name: 'wizardStep7Controller',
 
    /**
     * Contains all field properties that are viewed in this step
     * @type {object[]}
     */
    stepConfigs: [],
 
    hash: null,
 
    selectedService: null,
 
    addMiscTabToPage: true,
 
    /**
     * Is Submit-click processing now
     * @type {bool}
     */
    submitButtonClicked: false,
 
    isRecommendedLoaded: false,
 
    /**
     * Indicates if all stepConfig objects are created
     */
    stepConfigsCreated: false,
 
    /**
     * Define state of next button on credentials tab
     */
    credentialsTabNextEnabled: false,
 
    /**
     * Define state of next button on databases tab
     */
    databasesTabNextEnabled: false,
 
    /**
     * used in services_config.js view to mark a config with security icon
     */
    secureConfigs: require('data/configs/wizards/secure_mapping'),
 
    /**
     * If configChangeObserver Modal is shown
     * @type {bool}
     */
    miscModalVisible: false,
 
    overrideToAdd: null,
 
    isInstaller: true, //todo: refactor using of this property
 
    /**
     * Is installer controller used
     * @type {bool}
     */
    isInstallWizard: Em.computed.equal('content.controllerName', 'installerController'),
 
    /**
     * Is add service controller used
     * @type {bool}
     */
    isAddServiceWizard: Em.computed.equal('content.controllerName', 'addServiceController'),
 
    /**
     * List of config groups
     * @type {object[]}
     */
    configGroups: [],
 
    /**
     * List of config group to be deleted
     * @type {object[]}
     */
    groupsToDelete: [],
 
    preSelectedConfigGroup: null,
 
    /**
     * Currently selected config group
     * @type {object}
     */
    selectedConfigGroup: null,
 
    /**
     * Config tags of actually installed services
     * @type {array}
     */
    serviceConfigTags: [],
 
    /**
     * Are applied to service configs loaded
     * @type {bool}
     */
    isAppliedConfigLoaded: true,
 
    /**
     * Is there validation issues
     * @type {bool}
     */
    hasErrors: false,
 
    /**
     * Total number of recommendation and validation issues
     * @type {number}
     */
    issuesCounter: 0,
 
    /**
     * Number of ui-side validation issues
     * @type {number}
     */
    validationsCounter: 0,
 
    /**
     * Tab objects to represent each config category tab
     */
    tabs: [],
 
    isConfigsLoaded: Em.computed.and('wizardController.stackConfigsLoaded', 'isAppliedConfigLoaded'),
 
    transitionInProgress: Em.computed.alias('App.router.btnClickInProgress'),
 
    /**
     * PreInstall Checks allowed only for Install
     * @type {boolean}
     */
    supportsPreInstallChecks: function () {
      return App.get('supports.preInstallChecks') && this.get('isInstallWizard');
    }.property('App.supports.preInstallChecks', 'wizardController.name'),
 
    /**
     * Number of errors in the configs in the selected service
     * @type {number}
     */
    errorsCount: function () {
      return this.get('selectedService.configsWithErrors').filter(function (c) {
        return Em.isNone(c.get('isInDefaultTheme'));
      }).length;
    }.property('selectedService.configsWithErrors.length'),
 
    /**
     * Should Next-button be disabled
     * @type {bool}
     */
    isSubmitDisabled: function () {
      if (!this.get('stepConfigs.length')) return true;
      Iif (this.get('submitButtonClicked')) return true;
      Iif (App.get('router.btnClickInProgress')) return true;
      return !this.get('stepConfigs').filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible") || !!this.get('configErrorList.criticalIssues.length');
    }.property('stepConfigs.@each.errorCount', 'miscModalVisible', 'submitButtonClicked', 'App.router.btnClickInProgress', 'configErrorList.criticalIssues.length'),
 
    /**
     * List of selected to install service names
     * @type {string[]}
     */
    selectedServiceNames: function () {
      return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).mapProperty('serviceName');
    }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
 
    /**
     * List of installed and selected to install service names
     * @type {string[]}
     */
    allSelectedServiceNames: function () {
      return this.get('content.services').filter(function (service) {
        return service.get('isInstalled') || service.get('isSelected');
      }).mapProperty('serviceName');
    }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
 
    /**
     * List of installed service names
     * @type {string[]}
     */
    installedServiceNames: function () {
      var serviceNames = this.get('content.services').filterProperty('isInstalled').mapProperty('serviceName');
      if (!this.get('isInstallWizard')) {
        serviceNames = serviceNames.filter(function (_serviceName) {
          return !App.get('services.noConfigTypes').contains(_serviceName);
        });
      }
      return serviceNames;
    }.property('content.services').cacheable(),
 
    installedServices: function () {
      var self = this;
      return App.StackService.find().toArray().toMapByCallback('serviceName', function (item) {
        return self.get('installedServiceNames').contains(item.get('serviceName'));
      });
    }.property('installedServiceNames.length'),
 
    requiredChanges: function () {
      return this.get('recommendations').filterProperty('isEditable', false);
    }.property('recommendatios.@each.isEditable'),
 
    /**
     * List of master components
     * @type {Ember.Enumerable}
     */
    masterComponentHosts: Em.computed.alias('content.masterComponentHosts'),
 
    /**
     * List of slave components
     * @type {Ember.Enumerable}
     */
    slaveComponentHosts: Em.computed.alias('content.slaveGroupProperties'),
 
    /**
     * Filter text will be located here
     * @type {string}
     */
    filter: '',
 
    /**
     * Defines if configs can be editable
     * @type {boolean}
     */
    canEdit: true,
 
    /**
     * list of dependencies that are user to set init value of config
     *
     * @type {Object}
     */
    configDependencies: function () {
      var dependencies = {};
      var hiveMetastore = App.configsCollection.getConfigByName('hive.metastore.uris', 'hive-site.xml');
      var clientPort = App.configsCollection.getConfigByName('clientPort', 'zoo.cfg.xml');
      var atlasTls = App.configsCollection.getConfigByName('atlas.enableTLS', 'application-properties.xml');
      var atlasHttpPort = App.configsCollection.getConfigByName('atlas.server.http.port', 'application-properties.xml');
      var atlasHttpsPort = App.configsCollection.getConfigByName('atlas.server.https.port', 'application-properties.xml');
 
      Iif (hiveMetastore) dependencies['hive.metastore.uris'] = hiveMetastore.recommendedValue;
      Iif (clientPort) dependencies.clientPort = clientPort.recommendedValue;
      Iif (atlasTls) dependencies['atlas.enableTLS'] = atlasTls.recommendedValue;
      Iif (atlasHttpPort) dependencies['atlas.server.http.port'] = atlasHttpPort.recommendedValue;
      Iif (atlasHttpsPort) dependencies['atlas.server.https.port'] = atlasHttpsPort.recommendedValue;
      return dependencies;
    }.property(),
 
    /**
     * List of filters for config properties to populate filter combobox
     */
    propertyFilters: [{
      attributeName: 'isOverridden',
      attributeValue: true,
      caption: 'common.combobox.dropdown.overridden'
    }, {
      attributeName: 'isFinal',
      attributeValue: true,
      caption: 'common.combobox.dropdown.final'
    }, {
      attributeName: 'hasIssues',
      attributeValue: true,
      caption: 'common.combobox.dropdown.issues'
    }],
 
    issuesFilterText: function () {
      return !this.get('transitionInProgress') && this.get('issuesFilterSelected') ? Em.I18n.t('installer.step7.showingPropertiesWithIssues') : '';
    }.property('isSubmitDisabled', 'submitButtonClicked', 'filterColumns.@each.selected'),
 
    /**
     * @type {string}
     */
    issuesFilterLinkText: function () {
      var issuesAttrSelected = this.get('issuesFilterSelected');
      if (!this.get('transitionInProgress')) {
        if (issuesAttrSelected) {
          return Em.I18n.t('installer.step7.showAllProperties');
        }
        Eif (this.get('hasStepConfigIssues')) {
          return Em.I18n.t('installer.step7.showPropertiesWithIssues');
        }
      }
      return '';
    }.property('isSubmitDisabled', 'submitButtonClicked', 'filterColumns.@each.selected'),
 
    /**
     * Dropdown menu items in filter combobox
     */
    filterColumns: function () {
      return this.get('propertyFilters').map(function (filter) {
        return Ember.Object.create({
          attributeName: filter.attributeName,
          attributeValue: filter.attributeValue,
          name: this.t(filter.caption),
          selected: false
        });
      }, this);
    }.property('propertyFilters'),
 
    /**
     * Clear controller's properties:
     *  <ul>
     *    <li>stepConfigs</li>
     *    <li>filter</li>
     *  </ul>
     *  and deselect all <code>filterColumns</code>
     * @method clearStep
     */
    clearStep: function clearStep() {
      this.abortRequests();
      this.setProperties({
        configValidationGlobalMessage: [],
        submitButtonClicked: false,
        isSubmitDisabled: true,
        isRecommendedLoaded: false,
        stepConfigsCreated: false,
        initialRecommendations: []
      });
      App.ServiceConfigGroup.find().filterProperty('isDefault', false).forEach(function (record) {
        App.configGroupsMapper.deleteRecord(record);
      });
      this.get('stepConfigs').clear();
      this.set('filter', '');
      this.get('filterColumns').setEach('selected', false);
    },
 
    clearLastSelectedService: function clearLastSelectedService() {
      this.get('tabs').filterProperty('selectedServiceName').setEach('selectedServiceName', null);
    },
 
    /**
     * Generate "finger-print" for current <code>stepConfigs[0]</code>
     * Used to determine, if user has some unsaved changes (comparing with <code>hash</code>)
     * @returns {string|null}
     * @method getHash
     */
    getHash: function getHash() {
      if (!this.get('stepConfigs')[0]) {
        return null;
      }
      var hash = {};
      this.get('stepConfigs').forEach(function (stepConfig) {
        stepConfig.configs.forEach(function (config) {
          hash[config.get('name')] = { value: config.get('value'), overrides: [], isFinal: config.get('isFinal') };
          if (!config.get('overrides')) return;
          if (!config.get('overrides.length')) return;
 
          config.get('overrides').forEach(function (override) {
            hash[config.get('name')].overrides.push(override.get('value'));
          });
        });
      });
      return JSON.stringify(hash);
    },
 
    /**
    * Are some changes available
    */
    hasChanges: function hasChanges() {
      return this.get('hash') !== this.getHash();
    },
 
    /**
     * load all overrides for all config groups
     *
     * @returns {*|$.ajax}
     */
    loadOverrides: function loadOverrides() {
      return App.ajax.send({
        name: 'service.serviceConfigVersions.get.current.not.default',
        sender: this,
        success: 'parseOverrides'
      });
    },
 
    /**
     * add overriden configs to stepConfigs
     *
     * @param data
     */
    parseOverrides: function parseOverrides(data) {
      var self = this;
      data.items.forEach(function (group) {
        var stepConfig = self.get('stepConfigs').findProperty('serviceName', group.service_name),
            serviceConfigs = stepConfig.get('configs'),
            configGroup = App.ServiceConfigGroup.find().filterProperty('serviceName', group.service_name).findProperty('name', group.group_name);
 
        var isEditable = self.get('canEdit') && configGroup.get('name') === stepConfig.get('selectedConfigGroup.name');
 
        group.configurations.forEach(function (config) {
          for (var prop in config.properties) {
            var fileName = App.config.getOriginalFileName(config.type);
            var serviceConfig = serviceConfigs.filterProperty('name', prop).findProperty('filename', fileName);
            if (serviceConfig && serviceConfig.get('isOriginalSCP')) {
              var value = App.config.formatPropertyValue(serviceConfig, config.properties[prop]);
              var isFinal = !!(config.properties_attributes && config.properties_attributes.final && config.properties_attributes.final[prop]);
 
              App.config.createOverride(serviceConfig, {
                "value": value,
                "savedValue": value,
                "isFinal": isFinal,
                "savedIsFinal": isFinal,
                "isEditable": isEditable
              }, configGroup);
            } else {
 
              serviceConfigs.push(App.config.createCustomGroupConfig({
                propertyName: prop,
                filename: fileName,
                value: config.properties[prop],
                savedValue: config.properties[prop],
                isEditable: isEditable
              }, configGroup));
            }
          }
        });
      });
      this.onLoadOverrides();
    },
 
    onLoadOverrides: function onLoadOverrides() {
      this.get('stepConfigs').forEach(function (stepConfig) {
        stepConfig.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName', stepConfig.get('serviceName')));
 
        stepConfig.get('configGroups').filterProperty('isDefault', false).forEach(function (configGroup) {
          configGroup.set('hash', this.get('wizardController').getConfigGroupHash(configGroup));
        }, this);
 
        this.addOverride(stepConfig);
        // override if a property isRequired or not
        this.overrideConfigIsRequired(stepConfig);
      }, this);
      console.timeEnd('loadConfigGroups execution time: ');
    },
 
    /**
     * Set <code>isEditable</code>-property to <code>serviceConfigProperty</code>
     * Based on user's permissions and selected config group
     * @param {Ember.Object} serviceConfigProperty
     * @param {bool} defaultGroupSelected
     * @returns {Ember.Object} Updated config-object
     * @method _updateIsEditableFlagForConfig
     */
    _updateIsEditableFlagForConfig: function _updateIsEditableFlagForConfig(serviceConfigProperty, defaultGroupSelected) {
      Eif (App.isAuthorized('AMBARI.ADD_DELETE_CLUSTERS')) {
        Iif (App.get('isKerberosEnabled') && serviceConfigProperty.get('isConfigIdentity') && !App.StackService.find().filterProperty('isSelected').mapProperty('serviceName').contains(Em.get(serviceConfigProperty, 'serviceName'))) {
          serviceConfigProperty.set('isEditable', false);
        } else if (defaultGroupSelected && !Em.get(serviceConfigProperty, 'group')) {
          Iif (serviceConfigProperty.get('serviceName') === 'MISC') {
            var service = App.config.get('serviceByConfigTypeMap')[App.config.getConfigTagFromFileName(serviceConfigProperty.get('filename'))];
            serviceConfigProperty.set('isEditable', service && !this.get('installedServiceNames').contains(service.get('serviceName')));
          } else {
            serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isEditable') && serviceConfigProperty.get('isReconfigurable'));
          }
        } else Eif (!(Em.get(serviceConfigProperty, 'group') && Em.get(serviceConfigProperty, 'group.name') === this.get('selectedConfigGroup.name'))) {
          serviceConfigProperty.set('isEditable', false);
        }
      } else {
        serviceConfigProperty.set('isEditable', false);
      }
      return serviceConfigProperty;
    },
 
    /**
     * Set configs with overrides, recommended defaults to stepConfig
     * @param {Ember.Object} stepConfig
     * @method loadComponentConfigs
     */
    addOverride: function addOverride(stepConfig) {
      var overrideToAdd = this.get('overrideToAdd');
      if (overrideToAdd) {
        overrideToAdd = stepConfig.get('configs').filterProperty('filename', overrideToAdd.filename).findProperty('name', overrideToAdd.name);
        if (overrideToAdd) {
          App.config.createOverride(overrideToAdd, { isEditable: true }, stepConfig.get('selectedConfigGroup'));
          this.set('overrideToAdd', null);
        }
      }
    },
 
    /**
     * On load function
     * @method loadStep
     */
    loadStep: function loadStep() {
      if (!this.get('isConfigsLoaded')) {
        return;
      }
      console.time('wizard loadStep: ');
      this.clearStep();
 
      var self = this;
      App.config.setPreDefinedServiceConfigs(this.get('addMiscTabToPage'));
 
      var storedConfigs = this.get('content.serviceConfigProperties');
      var configs = storedConfigs && storedConfigs.length ? storedConfigs : App.configsCollection.getAll();
 
      this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
      if (this.get('wizardController.name') === 'addServiceController' && !storedConfigs) {
        App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function (loadedConfigs) {
          configs = self.setInstalledServiceConfigs(configs, loadedConfigs, self.get('installedServiceNames'));
          self.applyServicesConfigs(configs);
        });
      } else {
        this.applyServicesConfigs(configs, true);
      }
    },
 
    /**
     * Update hawq configuration depending on the state of the cluster
     * @param {Array} configs
     */
    updateHawqConfigs: function updateHawqConfigs(configs) {
      Iif (this.get('wizardController.name') === 'addServiceController') {
        if (App.get('isHaEnabled')) this.addHawqConfigsOnNnHa(configs);
        if (App.get('isRMHaEnabled')) this.addHawqConfigsOnRMHa(configs);
      }
      if (this.get('content.hosts') && Object.keys(this.get('content.hosts')).length === 1) this.removeHawqStandbyHostAddressConfig(configs);
      return configs;
    },
 
    /**
     * Remove hawq_standby_address_host config from HAWQ configs
     * @param {Array} configs
     */
    removeHawqStandbyHostAddressConfig: function removeHawqStandbyHostAddressConfig(configs) {
      var hawqStandbyAddressHostIndex = configs.indexOf(configs.findProperty('name', 'hawq_standby_address_host'));
      Eif (hawqStandbyAddressHostIndex > -1) configs.removeAt(hawqStandbyAddressHostIndex);
      return configs;
    },
 
    applyServicesConfigs: function applyServicesConfigs(configs, isRestoring) {
      var self = this;
      console.time('applyServicesConfigs execution time: ');
      Iif (!this.get('installedServiceNames').contains('HAWQ') && this.get('allSelectedServiceNames').contains('HAWQ')) {
        this.updateHawqConfigs(configs);
      }
      Iif (App.get('isKerberosEnabled') && this.get('wizardController.name') === 'addServiceController') {
        this.addKerberosDescriptorConfigs(configs, this.get('wizardController.kerberosDescriptorConfigs') || [], isRestoring);
      }
      var stepConfigs = this.createStepConfigs();
      var serviceConfigs = this.renderConfigs(stepConfigs, configs);
      this.addUidAndGidRepresentations(serviceConfigs);
      // if HA is enabled -> Make some reconfigurations
      Iif (this.get('wizardController.name') === 'addServiceController') {
        this.updateComponentActionConfigs(configs, serviceConfigs);
        if (App.get('isHaEnabled')) {
          serviceConfigs = this._reconfigureServicesOnNnHa(serviceConfigs);
        }
      }
 
      var rangerService = App.StackService.find().findProperty('serviceName', 'RANGER');
      var isRangerServicePresent = rangerService && (rangerService.get('isInstalled') || rangerService.get('isSelected'));
      var infraSolrService = App.StackService.find().findProperty('serviceName', 'AMBARI_INFRA_SOLR');
      var isInfraSolrPresent = infraSolrService && (infraSolrService.get('isInstalled') || infraSolrService.get('isSelected'));
      Iif (isRangerServicePresent && (this.get('wizardController.name') === 'installerController' || this.get('wizardController.name') === 'addServiceController')) {
        this.setRangerPluginsEnabled(serviceConfigs);
        if (isInfraSolrPresent) {
          this.setSolrCloudOn(serviceConfigs);
        }
      }
 
      this.set('stepConfigs', serviceConfigs);
      this.set('stepConfigsCreated', true);
      this.updateConfigAttributesFromThemes();
      this.checkHostOverrideInstaller();
      this.selectProperService();
      var isInstallerWizard = this.get('isInstallWizard');
      var isRangerServiceAbsent = rangerService && !rangerService.get('isInstalled') && !rangerService.get('isSelected');
      Iif (isRangerServiceAbsent) {
        var isExternalRangerSetup;
        if (isInstallerWizard) {
          isExternalRangerSetup = configs.filterProperty('fileName', 'cluster-env.xml').findProperty('name', 'enable_external_ranger');
          if (Em.isNone(isExternalRangerSetup) || isExternalRangerSetup.value !== "true") {
            App.config.removeRangerConfigs(this.get('stepConfigs'));
          }
          console.timeEnd('applyServicesConfigs execution time: ');
          console.time('loadConfigRecommendations execution time: ');
          self.loadConfigRecommendations(null, self.completeConfigLoading.bind(self));
        } else {
          var mainController = App.get('router.mainController');
          var clusterController = App.get('router.clusterController');
          mainController.isLoading.call(clusterController, 'clusterEnv').done(function () {
            isExternalRangerSetup = clusterController.get("clusterEnv")["properties"]["enable_external_ranger"];
            if (isExternalRangerSetup !== "true") {
              App.config.removeRangerConfigs(self.get('stepConfigs'));
            }
            console.timeEnd('applyServicesConfigs execution time: ');
            console.time('loadConfigRecommendations execution time: ');
            self.loadConfigRecommendations(null, self.completeConfigLoading.bind(self));
          });
        }
      } else {
        console.timeEnd('applyServicesConfigs execution time: ');
        console.time('loadConfigRecommendations execution time: ');
        self.loadConfigRecommendations(null, self.completeConfigLoading.bind(self));
      }
    },
 
    /**
    * Sets the value of ranger-<service_name>-plugin-enabled to "Yes" if ranger authorization /
    * is supported for that service.
    * @param stepConfigs Object[]
    */
    setRangerPluginsEnabled: function setRangerPluginsEnabled(stepConfigs) {
      var rangerServiceConfigs = stepConfigs.findProperty('serviceName', 'RANGER').get('configs');
      var services = this.get('selectedServiceNames').filter(function (service) {
        return service != 'RANGER';
      });
 
      services.forEach(function (serviceName) {
        var pluginEnabledPropertyName = 'ranger-' + serviceName.toLowerCase() + '-plugin-enabled';
        var pluginEnabledProperty = rangerServiceConfigs.findProperty('name', pluginEnabledPropertyName);
        //Kafka and Storm plugins need to be enabled only if cluster is kerberized
        if (pluginEnabledProperty && (serviceName === 'STORM' || serviceName === 'KAFKA')) {
          if (App.get('isKerberosEnabled')) {
            Em.set(pluginEnabledProperty, 'value', 'Yes');
          }
        } else if (pluginEnabledProperty) {
          Em.set(pluginEnabledProperty, 'value', 'Yes');
        }
      });
    },
 
    setSolrCloudOn: function setSolrCloudOn(stepConfigs) {
      var rangerServiceConfigs = stepConfigs.findProperty('serviceName', 'RANGER').get('configs');
      var solrCloudEnabledProperty = rangerServiceConfigs.findProperty('name', 'is_solrCloud_enabled');
      Em.set(solrCloudEnabledProperty, 'value', 'true');
    },
 
    /**
     *
     * Makes installed service's configs resulting into component actions (add/delete) non editable on Add Service Wizard
     * @param configs Object[]
     * @param  stepConfigs Object[]
     * @private
     * @method updateComponentActionConfigs
     */
    updateComponentActionConfigs: function updateComponentActionConfigs(configs, stepConfigs) {
      App.ConfigAction.find().forEach(function (item) {
        var configName = item.get('configName');
        var fileName = item.get('fileName');
        var config = configs.filterProperty('filename', fileName).findProperty('name', configName);
        if (config) {
          var isServiceInstalled = App.Service.find().findProperty('serviceName', config.serviceName);
          // service already installed or is being added in add service wizard
          if (isServiceInstalled || stepConfigs.someProperty("serviceName", config.serviceName)) {
            var serviceConfigs = stepConfigs.findProperty('serviceName', config.serviceName).get('configs');
            var serviceConfig = serviceConfigs.filterProperty('filename', fileName).findProperty('name', configName);
            var notEditableText = " " + Em.I18n.t('installer.step7.addWizard.notEditable');
            serviceConfig.set('description', serviceConfig.get('description') + notEditableText);
            serviceConfig.set('isReconfigurable', false);
            serviceConfig.set('isEditable', false);
            serviceConfig.set('disabledAsComponentAction', true);
            config.isReconfigurable = false;
            config.isEditable = false;
            config.disabledAsComponentActio = true;
          }
        }
      }, this);
    },
 
    completeConfigLoading: function completeConfigLoading() {
      this.get('stepConfigs').forEach(function (service) {
        App.configTheme.resolveConfigThemeConditions(service.get('configs'));
      });
      this.clearRecommendationsByServiceName(App.StackService.find().filter(function (s) {
        return s.get('isSelected') && !s.get('isInstalled');
      }).mapProperty('serviceName'));
      this.saveInitialRecommendations();
      this.set('isRecommendedLoaded', true);
      console.timeEnd('loadConfigRecommendations execution time: ');
      console.timeEnd('wizard loadStep: ');
      Iif (this.get('content.skipConfigStep')) {
        App.router.send('next');
      }
      this.set('hash', this.getHash());
    },
 
    /**
     * Update initialValues only while loading recommendations first time
     *
     * @param serviceName
     * @returns {boolean}
     * @override
     */
    updateInitialOnRecommendations: function updateInitialOnRecommendations(serviceName) {
      return this._super(serviceName) && !this.get('isRecommendedLoaded');
    },
 
    /**
     * Mark descriptor properties in configuration object.
     *
     * @param {Object[]} configs - config properties to change
     * @param {App.ServiceConfigProperty[]} descriptor - parsed kerberos descriptor
     * @method addKerberosDescriptorConfigs
     */
    addKerberosDescriptorConfigs: function addKerberosDescriptorConfigs(configs, descriptor, isRestoring) {
      var servicesToBeInstalled = this.get('content.services').filterProperty('isSelected').mapProperty('serviceName');
      descriptor.forEach(function (item) {
        var service = item.get('serviceName');
        if (!servicesToBeInstalled.contains(service)) return false;
        var name = item.get('name');
        var filename = Em.get(item, 'filename');
        var property = configs.filterProperty('serviceName', service).findProperty('name', name);
        var propertyObj = {
          isSecureConfig: true,
          value: Em.get(isRestoring && property ? property : item, 'value'),
          defaultValue: Em.get(item, 'value'),
          displayName: name,
          isOverridable: false,
          isConfigIdentity: Em.get(item, 'isConfigIdentity'),
          isUserProperty: !!Em.get(item, 'isUserProperty'),
          category: (Em.get(item, 'isUserProperty') ? 'Custom ' : 'Advanced ') + filename
        };
        Eif (property) {
          Em.setProperties(property, $.extend(propertyObj, {
            savedValue: Em.get(item, 'value'),
            description: Em.get(item, 'isConfigIdentity') ? App.config.kerberosIdentitiesDescription(Em.get(property, 'description')) : Em.get(property, 'description')
          }));
        } else {
          configs.push(App.ServiceConfigProperty.create(App.config.getDefaultConfig(name, filename, propertyObj)));
        }
      });
    },
 
    /**
     * Load config groups
     * and (if some services are already installed) load config groups for installed services
     * @method checkHostOverrideInstaller
     */
    checkHostOverrideInstaller: function checkHostOverrideInstaller() {
      if (this.get('wizardController.name') !== 'kerberosWizardController' && this.get('content.configGroups.length')) {
        this.restoreConfigGroups(this.get('content.configGroups'));
      } else {
        if (this.get('installedServiceNames').length > 0 && !this.get('wizardController.areInstalledConfigGroupsLoaded')) {
          console.time('loadConfigGroups execution time: ');
          this.loadConfigGroups(this.get('allSelectedServiceNames')).done(this.loadOverrides.bind(this));
        } else {
          App.store.fastCommit();
          App.configGroupsMapper.map(null, false, this.get('allSelectedServiceNames'));
          this.onLoadOverrides();
        }
      }
    },
 
    /**
     * Create stepConfigs array with all info except configs list
     *
     * @return {Object[]}
     * @method createStepConfigs
     */
    createStepConfigs: function createStepConfigs() {
      var stepConfigs = [];
      App.config.get('preDefinedServiceConfigs').forEach(function (service) {
        var serviceName = service.get('serviceName');
        if (['MISC'].concat(this.get('allSelectedServiceNames')).contains(serviceName)) {
          var serviceConfig = App.config.createServiceConfig(serviceName);
          serviceConfig.set('showConfig', App.StackService.find(serviceName).get('isInstallable'));
          if (this.get('wizardController.name') === 'addServiceController') {
            serviceConfig.set('selected', !this.get('installedServiceNames').concat('MISC').contains(serviceName));
            if (serviceName === 'MISC') {
              serviceConfig.set('configCategories', serviceConfig.get('configCategories').rejectProperty('name', 'Notifications'));
            }
          } else if (this.get('wizardController.name') === 'kerberosWizardController') {
            serviceConfig.set('showConfig', true);
          }
          stepConfigs.pushObject(serviceConfig);
        }
      }, this);
      return stepConfigs;
    },
 
    /**
     * For Namenode HA, HAWQ service requires additional config parameters in hdfs-client.xml
     * This method ensures that these additional parameters are added to hdfs-client.xml
     * @param configs existing configs on cluster
     * @returns {Object[]} existing configs + additional config parameters in hdfs-client.xml
     */
    addHawqConfigsOnNnHa: function addHawqConfigsOnNnHa(configs) {
      var nameService = configs.findProperty('id', App.config.configId('dfs.nameservices', 'hdfs-site')).value;
      var propertyNames = ['dfs.nameservices', 'dfs.ha.namenodes.' + nameService, 'dfs.namenode.rpc-address.' + nameService + '.nn1', 'dfs.namenode.rpc-address.' + nameService + '.nn2', 'dfs.namenode.http-address.' + nameService + '.nn1', 'dfs.namenode.http-address.' + nameService + '.nn2'];
 
      propertyNames.forEach(function (propertyName, propertyIndex) {
        var propertyFromHdfs = configs.findProperty('id', App.config.configId(propertyName, 'hdfs-site'));
        var newProperty = App.config.createDefaultConfig(propertyName, 'hdfs-client.xml', true);
        Em.setProperties(newProperty, {
          serviceName: 'HAWQ',
          description: propertyFromHdfs.description,
          displayName: propertyFromHdfs.displayName,
          displayType: 'string',
          index: propertyIndex,
          isOverridable: false,
          isReconfigurable: false,
          value: propertyFromHdfs.value,
          recommendedValue: propertyFromHdfs.recommendedValue
        });
 
        configs.push(App.ServiceConfigProperty.create(newProperty));
      });
      return configs;
    },
 
    /**
     * For ResourceManager HA, HAWQ service requires additional config parameters in yarn-client.xml
     * This method ensures that these additional parameters are added to yarn-client.xml
     * @param configs existing configs on cluster
     * @returns {Object[]} existing configs + additional config parameters in yarn-client.xml
     */
    addHawqConfigsOnRMHa: function addHawqConfigsOnRMHa(configs) {
      var rmHost1 = configs.findProperty('id', App.config.configId('yarn.resourcemanager.hostname.rm1', 'yarn-site')).value;
      var rmHost2 = configs.findProperty('id', App.config.configId('yarn.resourcemanager.hostname.rm2', 'yarn-site')).value;
      var yarnConfigToBeAdded = [{
        name: 'yarn.resourcemanager.ha',
        displayName: 'yarn.resourcemanager.ha',
        description: 'Comma separated yarn resourcemanager host addresses with port',
        port: '8032'
      }, {
        name: 'yarn.resourcemanager.scheduler.ha',
        displayName: 'yarn.resourcemanager.scheduler.ha',
        description: 'Comma separated yarn resourcemanager scheduler addresses with port',
        port: '8030'
      }];
 
      yarnConfigToBeAdded.forEach(function (propertyDetails) {
        var newProperty = App.config.createDefaultConfig(propertyDetails.name, 'yarn-client.xml', true);
        var value = rmHost1 + ':' + propertyDetails.port + ',' + rmHost2 + ':' + propertyDetails.port;
        Em.setProperties(newProperty, {
          serviceName: 'HAWQ',
          description: propertyDetails.description,
          displayName: propertyDetails.displayName,
          isOverridable: false,
          isReconfigurable: false,
          value: value,
          recommendedValue: value
        });
 
        configs.push(App.ServiceConfigProperty.create(newProperty));
      });
      return configs;
    },
 
    /**
     * Set the uid property for user properties. The uid is later used to help map the user and uid values in adjacent columns
     * @param {object} miscSvc
     * @param {string} svcName
     * @private
     */
    _setUID: function _setUID(miscSvc, svcName) {
      var user = miscSvc.configs.findProperty('name', svcName + '_user');
      if (user) {
        var uid = miscSvc.configs.findProperty('name', user.value + '_uid');
        if (uid) {
          user.set('ugid', uid);
        }
      }
    },
 
    /**
     * Set the gid property for group properties. The gid is later used to help map the group and gid values in adjacent columns
     * @param {object} miscSvc
     * @param {string} svcName
     * @private
     */
    _setGID: function _setGID(miscSvc, svcName) {
      var group = miscSvc.configs.findProperty('name', svcName + '_group');
      if (group) {
        var gid = miscSvc.configs.findProperty('name', group.value + '_gid');
        if (gid) {
          group.set('ugid', gid);
        }
      }
    },
 
    /**
     * render configs, distribute them by service
     * and wrap each in ServiceConfigProperty object
     * @param stepConfigs
     * @param configs
     * @return {App.ServiceConfig[]}
     */
    renderConfigs: function renderConfigs(stepConfigs, configs) {
      var localDB = {
        hosts: this.get('wizardController.content.hosts'),
        masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
        slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts'),
        selectedStack: {}
      };
      var selectedRepoVersion, repoVersion;
      Iif (this.get('wizardController.name') === 'addServiceController') {
        repoVersion = App.RepositoryVersion.find().filter(function (i) {
          return i.get('stackVersionType') === App.get('currentStackName') && i.get('stackVersionNumber') === App.get('currentStackVersionNumber');
        })[0];
        if (repoVersion) {
          selectedRepoVersion = Em.get(repoVersion, 'repositoryVersion').split('-')[0];
        }
      } else {
        selectedRepoVersion = Em.getWithDefault(App.Stack.find().findProperty('isSelected', true) || {}, 'repositoryVersion', false);
      }
      Iif (selectedRepoVersion) {
        localDB.selectedStack = selectedRepoVersion;
      }
      var configsByService = {},
          dependencies = this.get('configDependencies');
 
      configs.forEach(function (_config) {
        Eif (!configsByService[_config.serviceName]) {
          configsByService[_config.serviceName] = [];
        }
        var serviceConfigProperty = App.ServiceConfigProperty.create(_config);
        this.updateHostOverrides(serviceConfigProperty, _config);
        Iif (this.get('wizardController.name') === 'addServiceController') {
          this._updateIsEditableFlagForConfig(serviceConfigProperty, true);
          //since the override_uid and ignore_groupusers_create changes are not saved to the database post install, they should be editable only
          //during initial cluster installation
          if (['override_uid', 'ignore_groupsusers_create'].contains(serviceConfigProperty.get('name'))) {
            serviceConfigProperty.set('isEditable', false);
          }
        }
        Eif (!this.get('content.serviceConfigProperties.length') && !serviceConfigProperty.get('hasInitialValue')) {
          App.ConfigInitializer.initialValue(serviceConfigProperty, localDB, dependencies);
        }
        configsByService[_config.serviceName].pushObject(serviceConfigProperty);
      }, this);
 
      stepConfigs.forEach(function (service) {
        if (service.get('serviceName') === 'YARN') {
          configsByService[service.get('serviceName')] = App.config.addYarnCapacityScheduler(configsByService[service.get('serviceName')]);
        }
        service.set('configs', configsByService[service.get('serviceName')] || []);
        if (['addServiceController', 'installerController'].contains(this.get('wizardController.name'))) {
          this.addHostNamesToConfigs(service, localDB.masterComponentHosts, localDB.slaveComponentHosts);
        }
      }, this);
      return stepConfigs;
    },
 
    addUidAndGidRepresentations: function addUidAndGidRepresentations(serviceConfigs) {
      //map the uids to the corresponding users
      var miscSvc = serviceConfigs.findProperty('serviceName', 'MISC');
      Iif (miscSvc) {
        //iterate through the list of users and groups and assign the uid/gid accordingly
        //user properties are servicename_user
        //uid properties are value of servicename_user + _uid
        //group properties are servicename_group
        //gid properties are value of servicename_group + _gid
        //we will map the users/uids and groups/gids based on this assumption
        this.get('selectedServiceNames').forEach(function (serviceName) {
          this._setUID(miscSvc, serviceName.toLowerCase());
          this._setGID(miscSvc, serviceName.toLowerCase());
        }, this);
 
        //for zookeeper, the user property name does not follow the convention that users for other services do. i.e. the user property name is not servicename_user as is the case with other services
        //the user property name is zk_user and not zookeeper_user, hence set the uid for zk_user separately
        this._setUID(miscSvc, 'zk');
        //the user property name is mapred_user and not mapreduce2_user for mapreduce2 service, hence set the uid for mapred_user separately
        this._setUID(miscSvc, 'mapred');
        //for haddop, the group property name does not follow the convention that groups for other services do. i.e. the group property name is not servicename_group as is the case with other services
        //the group property name is user_group and not zookeeper_group, hence set the gid for user_group separately
        this._setGID(miscSvc, 'user');
 
        // uid/gid properties are displayed in a separate column, hence prevent the properties from showing up on a separate line
        miscSvc.configs.filterProperty('displayType', 'uid_gid').setEach('isVisible', false);
      }
    },
 
    /**
     * Add host name properties to appropriate categories (for installer and add service)
     *
     * @param {Object} serviceConfig
     * @param {Object[]} masterComponents - info from localStorage
     * @param {Object[]} slaveComponents - info from localStorage
     */
    addHostNamesToConfigs: function addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents) {
      serviceConfig.get('configCategories').forEach(function (c) {
        Eif (c.showHost) {
          var componentName = c.name;
          var value = this.getComponentHostValue(componentName, masterComponents, slaveComponents);
          var stackComponent = App.StackServiceComponent.find(componentName);
          var hProperty = App.config.createHostNameProperty(serviceConfig.get('serviceName'), componentName, value, stackComponent);
          var newConfigName = Em.get(hProperty, 'name');
          if (!serviceConfig.get('configs').someProperty('name', newConfigName)) {
            serviceConfig.get('configs').push(App.ServiceConfigProperty.create(hProperty));
          }
        }
      }, this);
    },
 
    /**
     * Method to get host for master or slave component
     *
     * @param componentName
     * @param masterComponents
     * @param slaveComponents
     * @returns {Array}
     */
    getComponentHostValue: function getComponentHostValue(componentName, masterComponents, slaveComponents) {
      var value = [];
      var masters = masterComponents && masterComponents.filterProperty('component', componentName);
      Eif (masters.length) {
        value = masters.mapProperty('hostName');
      } else {
        var slaves = slaveComponents && slaveComponents.findProperty('componentName', componentName);
        if (slaves) {
          value = slaves.hosts.mapProperty('hostName');
        }
      }
      return value || [];
    },
 
    /**
     * create new child configs from overrides, attach them to parent config
     * override - value of config, related to particular host(s)
     * @param configProperty
     * @param storedConfigProperty
     */
    updateHostOverrides: function updateHostOverrides(configProperty, storedConfigProperty) {
      if (!Em.isEmpty(storedConfigProperty.overrides)) {
        var overrides = [];
        storedConfigProperty.overrides.forEach(function (overrideEntry) {
          // create new override with new value
          var newSCP = App.ServiceConfigProperty.create(configProperty);
          newSCP.set('value', overrideEntry.value);
          newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
          newSCP.set('parentSCP', configProperty);
          overrides.pushObject(newSCP);
        });
        configProperty.set('overrides', overrides);
      }
    },
 
    /**
     * When NameNode HA is enabled some configs based on <code>dfs.nameservices</code> should be changed
     * This happens only if service is added AFTER NN HA is enabled
     *
     * @param {App.ServiceConfig[]} serviceConfigs
     * @method _reconfigureServiceOnNnHa
     * @private
     * @returns {App.ServiceConfig[]}
     */
    _reconfigureServicesOnNnHa: function _reconfigureServicesOnNnHa(serviceConfigs) {
      var selectedServiceNames = this.get('selectedServiceNames');
      var nameServiceId = serviceConfigs.findProperty('serviceName', 'HDFS').configs.findProperty('name', 'dfs.nameservices');
      Eif (nameServiceId) {
        Em.A([{
          serviceName: 'HBASE',
          configToUpdate: 'hbase.rootdir'
        }, {
          serviceName: 'ACCUMULO',
          configToUpdate: 'instance.volumes'
        }, {
          serviceName: 'HAWQ',
          configToUpdate: 'hawq_dfs_url',
          regexPattern: /(^.*:[0-9]+)(?=\/)/,
          replacementValue: nameServiceId.get('value')
        }]).forEach(function (c) {
          if (selectedServiceNames.contains(c.serviceName) && nameServiceId) {
            var cfg = serviceConfigs.findProperty('serviceName', c.serviceName).configs.findProperty('name', c.configToUpdate);
            var regexPattern = /\/\/.*:[0-9]+/i;
            var replacementValue = '//' + nameServiceId.get('value');
            if (!Em.isNone(c.regexPattern) && !Em.isNone(c.replacementValue)) {
              regexPattern = c.regexPattern;
              replacementValue = c.replacementValue;
            }
            var newValue = cfg.get('value').replace(regexPattern, replacementValue);
            cfg.setProperties({
              value: newValue,
              recommendedValue: newValue
            });
          }
        });
      }
      return serviceConfigs;
    },
 
    /**
     * Select previously selected service if not within the tab for the first time
     * Select first addable service for <code>addServiceWizard</code>
     * Select first service at all in other cases
     * @method selectProperService
     */
    selectProperService: function selectProperService() {
      var activeTab = this.get('tabs').findProperty('isActive', true);
      var tabSelectedServiceName = activeTab ? activeTab.get('selectedServiceName') : null;
      var lastSelectedService = tabSelectedServiceName ? this.get('stepConfigs').findProperty('serviceName', tabSelectedServiceName) : null;
      Iif (tabSelectedServiceName && lastSelectedService) {
        this.set('selectedService', lastSelectedService);
      } else if (this.get('wizardController.name') === 'addServiceController') {
        this.set('selectedService', this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
      } else {
        this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
      }
    },
 
    /**
     * Load config tags
     * @return {$.ajax|null}
     * @method getConfigTags
     */
    getConfigTags: function getConfigTags(resetFlag) {
      Iif (resetFlag) this.set('isAppliedConfigLoaded', false);
      return App.ajax.send({
        name: 'config.tags',
        sender: this,
        success: 'getConfigTagsSuccess'
      });
    },
 
    getServicesConfigurations: function getServicesConfigurations() {
      var dfd = $.Deferred();
      var configs, servicesConfigurations;
      configs = this.get('wizardController').getConfigsAndFilenames(this, true).serviceConfigProperties;
      servicesConfigurations = configs.reduce(function (configTags, property) {
        var fileName = App.config.getConfigTagFromFileName(property.filename),
            configType;
        if (!configTags.someProperty('type', fileName)) {
          configTags.push({
            type: fileName,
            properties: {}
          });
        }
        configType = configTags.findProperty('type', fileName);
        configType.properties[property.name] = property.value;
        return configTags;
      }, []);
      dfd.resolve(servicesConfigurations);
      return dfd.promise();
    },
 
    /**
     * Success callback for config tags request
     * Updates <code>serviceConfigTags</code> with tags received from server
     * @param {object} data
     * @method getConfigTagsSuccess
     */
    getConfigTagsSuccess: function getConfigTagsSuccess(data) {
      var installedServiceSites = [];
      App.StackService.find().filterProperty('isInstalled').forEach(function (service) {
        Iif (!service.get('configTypes')) return;
        var configTypes = Object.keys(service.get('configTypes'));
        installedServiceSites = installedServiceSites.concat(configTypes);
      }, this);
      installedServiceSites = installedServiceSites.uniq();
      var serviceConfigTags = [];
      for (var site in data.Clusters.desired_configs) {
        Eif (data.Clusters.desired_configs.hasOwnProperty(site)) {
          Eif (installedServiceSites.contains(site) || site === 'cluster-env') {
            serviceConfigTags.push({
              siteName: site,
              tagName: data.Clusters.desired_configs[site].tag,
              newTagName: null
            });
          }
        }
      }
      this.set('serviceConfigTags', serviceConfigTags);
      this.set('isAppliedConfigLoaded', true);
    },
 
    /**
     * set configs actual values from server
     * @param configs
     * @param configsByTags
     * @param installedServiceNames
     * @method setInstalledServiceConfigs
     */
    setInstalledServiceConfigs: function setInstalledServiceConfigs(configs, configsByTags, installedServiceNames) {
      var configsMap = {};
      var finalAttrMap = {};
      var passwordAttrMap = {};
 
      configsByTags.forEach(function (configSite) {
        configsMap[configSite.type] = configSite.properties || {};
        finalAttrMap[configSite.type] = configSite.properties_attributes && configSite.properties_attributes.final || {};
        passwordAttrMap[configSite.type] = configSite.properties_attributes && configSite.properties_attributes.password || {};
      });
      var allConfigs = configs.filter(function (_config) {
        // filter out alert_notification configs on add service //TODO find better place for this!
        Iif (_config.filename === 'alert_notification') return false;
        Eif (['MISC'].concat(installedServiceNames).contains(_config.serviceName)) {
          var type = _config.filename ? App.config.getConfigTagFromFileName(_config.filename) : null;
          var mappedConfigValue = type && configsMap[type] ? configsMap[type][_config.name] : null;
          if (Em.isNone(mappedConfigValue)) {
            //for now ranger plugin properties are not sending by recommendations if they are missed - it should be added
            return _config.serviceName === 'MISC' || /^ranger-/.test(_config.filename);
          }
          Eif (_config.savedValue != mappedConfigValue) {
            _config.savedValue = App.config.formatPropertyValue(_config, mappedConfigValue);
          }
          _config.value = App.config.formatPropertyValue(_config, mappedConfigValue);
          _config.hasInitialValue = true;
          this.updateDependencies(_config);
          delete configsMap[type][_config.name];
          return true;
        }
        return true;
      }, this);
      //add user properties
      Em.keys(configsMap).forEach(function (filename) {
        Em.keys(configsMap[filename]).forEach(function (propertyName) {
          allConfigs.push(App.config.createDefaultConfig(propertyName, App.config.getOriginalFileName(filename), false, {
            value: configsMap[filename][propertyName],
            savedValue: configsMap[filename][propertyName],
            propertyType: passwordAttrMap[filename][propertyName] === 'true' ? ['PASSWORD'] : null,
            isFinal: finalAttrMap[filename][propertyName] === 'true',
            hasInitialValue: true
          }));
        });
      });
      return allConfigs;
    },
 
    /**
     * update dependencies according to current config value
     *
     * @param config
     */
    updateDependencies: function updateDependencies(config) {
      Iif (config.filename === 'hive-site.xml') {
        if (config.name === 'hive.metastore.uris') {
          this.get('configDependencies')['hive.metastore.uris'] = config.savedValue;
        } else if (config.name === 'clientPort') {
          this.get('configDependencies').clientPort = config.savedValue;
        }
      }
      Iif (config.filename === 'application-properties.xml') {
        if (this.get('configDependencies').hasOwnProperty(config.name)) {
          this.get('configDependencies')[config.name] = config.savedValue;
        }
      }
    },
 
    /**
     * Add group ids to <code>groupsToDelete</code>
     * Also save <code>groupsToDelete</code> to local storage
     * @param {Ember.Object[]} groups
     * @method setGroupsToDelete
     */
    setGroupsToDelete: function setGroupsToDelete(groups) {
      var groupsToDelete = this.get('groupsToDelete');
      groups.forEach(function (group) {
        if (!group.get('isTemporary')) {
          groupsToDelete.push({
            id: group.get('id')
          });
        }
      });
      this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
    },
 
    /**
     * Update <code>configGroups</code> with selected service configGroups
     * Also set default group to first position
     * Update <code>selectedConfigGroup</code> with new default group
     * @method selectedServiceObserver
     */
    selectedServiceObserver: function () {
      if (this.get('selectedService') && this.get('selectedService.serviceName') !== 'MISC') {
        var serviceGroups = this.get('selectedService.configGroups');
        serviceGroups.forEach(function (item, index, array) {
          if (item.isDefault) {
            array.unshift(item);
            array.splice(index + 1, 1);
          }
        });
        this.set('configGroups', serviceGroups);
        this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
      }
    }.observes('selectedService.configGroups.[]'),
 
    /**
     * load default groups for each service in case of initial load
     * @param serviceConfigGroups
     * @method restoreConfigGroups
     */
    restoreConfigGroups: function restoreConfigGroups(serviceConfigGroups) {
      var services = this.get('stepConfigs');
 
      services.forEach(function (service) {
        if (service.get('serviceName') === 'MISC') return;
        var serviceRawGroups = serviceConfigGroups.filterProperty('service_name', service.serviceName);
        if (serviceRawGroups.length) {
          App.store.safeLoadMany(App.ServiceConfigGroup, serviceRawGroups);
          serviceRawGroups.forEach(function (item) {
            var modelGroup = App.ServiceConfigGroup.find(item.id);
            modelGroup.set('properties', []);
            item.properties.forEach(function (propertyData) {
              var overriddenSCP,
                  parentSCP = service.configs.filterProperty('filename', propertyData.filename).filterProperty('isOriginalSCP').findProperty('name', propertyData.name);
              if (parentSCP) {
                App.config.createOverride(parentSCP, propertyData, modelGroup);
              } else {
                overriddenSCP = App.config.createCustomGroupConfig({
                  propertyName: propertyData.name,
                  filename: propertyData.filename,
                  value: propertyData.value,
                  savedValue: propertyData.value,
                  isEditable: false
                }, modelGroup);
                this.get('stepConfigs').findProperty('serviceName', service.serviceName).get('configs').pushObject(overriddenSCP);
              }
            }, this);
            modelGroup.set('hash', this.get('wizardController').getConfigGroupHash(modelGroup));
          }, this);
          service.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName', service.get('serviceName')));
        }
      }, this);
    },
 
    /**
     * Click-handler on config-group to make it selected
     * @param {object} event
     * @method selectConfigGroup
     */
    selectConfigGroup: function selectConfigGroup(event) {
      this.set('selectedConfigGroup', event.context);
    },
 
    /**
     * Rebuild list of configs switch of config group:
     * on default - display all configs from default group and configs from non-default groups as disabled
     * on non-default - display all from default group as disabled and configs from selected non-default group
     * @method switchConfigGroupConfigs
     */
    switchConfigGroupConfigs: function () {
      var serviceConfigs = this.get('selectedService.configs'),
          selectedGroup = this.get('selectedConfigGroup'),
          overrides = [];
      if (!selectedGroup) return;
 
      var displayedConfigGroups = this._getDisplayedConfigGroups();
      displayedConfigGroups.forEach(function (group) {
        overrides.pushObjects(group.get('properties'));
      });
      serviceConfigs.forEach(function (config) {
        this._setEditableValue(config);
        this._setOverrides(config, overrides);
      }, this);
    }.observes('selectedConfigGroup'),
 
    /**
     * Get list of config groups to display
     * Returns empty array if no <code>selectedConfigGroup</code>
     * @return {Array}
     * @method _getDisplayedConfigGroups
     */
    _getDisplayedConfigGroups: function _getDisplayedConfigGroups() {
      var selectedGroup = this.get('selectedConfigGroup');
      if (!selectedGroup) return [];
      return selectedGroup.get('isDefault') ? this.get('selectedService.configGroups').filterProperty('isDefault', false) : [this.get('selectedConfigGroup')];
    },
 
    /**
     * Set <code>isEditable</code> property to <code>config</code>
     * @param {Ember.Object} config
     * @return {Ember.Object} updated config-object
     * @method _setEditableValue
     */
    _setEditableValue: function _setEditableValue(config) {
      var selectedGroup = this.get('selectedConfigGroup');
      if (!selectedGroup) return config;
      Iif (App.get('isKerberosEnabled') && config.get('isConfigIdentity') && !App.StackService.find().filterProperty('isSelected').mapProperty('serviceName').contains(Em.get(config, 'serviceName'))) {
        config.set('isEditable', false);
      } else {
        var isEditable = config.get('isEditable'),
            isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
        if (isServiceInstalled) {
          isEditable = config.get('isReconfigurable') && selectedGroup.get('isDefault') && !config.get('disabledAsComponentAction');
        } else {
          isEditable = selectedGroup.get('isDefault') && !config.get('disabledAsComponentAction');
        }
        Iif (config.get('group')) {
          isEditable = config.get('group.name') === this.get('selectedConfigGroup.name');
        }
        config.set('isEditable', isEditable);
      }
      return config;
    },
 
    /**
     * Set <code>overrides</code> property to <code>config</code>
     * @param {Ember.Object} config
     * @param {Ember.Enumerable} overrides
     * @returns {Ember.Object}
     * @method _setOverrides
     */
    _setOverrides: function _setOverrides(config, overrides) {
      Iif (config.get('group')) return config;
      var selectedGroup = this.get('selectedConfigGroup'),
          overrideToAdd = this.get('overrideToAdd'),
          configOverrides = overrides.filterProperty('id', config.get('id'));
      if (!selectedGroup) return config;
      if (overrideToAdd && overrideToAdd.get('id') === config.get('id')) {
        var valueForOverride = config.get('widget') || config.get('displayType') === 'checkbox' ? config.get('value') : '';
        var group = this.get('selectedService.configGroups').findProperty('name', selectedGroup.get('name'));
        var newSCP = App.config.createOverride(config, { value: valueForOverride, recommendedValue: valueForOverride }, group);
        configOverrides.push(newSCP);
        this.set('overrideToAdd', null);
      }
      configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
      configOverrides.setEach('parentSCP', config);
      config.set('overrides', configOverrides);
      return config;
    },
 
    /**
     * @param serviceName
     * @returns {boolean}
     * @override
     */
    useInitialValue: function useInitialValue(serviceName) {
      return !App.Service.find(serviceName).get('serviceName', serviceName);
    },
 
    /**
     *
     * @param parentProperties
     * @param name
     * @param fileName
     * @param configGroup
     * @param savedValue
     * @returns {*}
     * @override
     */
    allowUpdateProperty: function allowUpdateProperty(parentProperties, name, fileName, configGroup, savedValue) {
      Iif (name.contains('proxyuser')) return true;
      if (['installerController'].contains(this.get('wizardController.name')) || !!(parentProperties && parentProperties.length)) {
        return true;
      } else if (['addServiceController'].contains(this.get('wizardController.name'))) {
        var stackProperty = App.configsCollection.getConfigByName(name, fileName);
        if (!stackProperty || !this.get('installedServices')[stackProperty.serviceName]) {
          return true;
        } else if (stackProperty.propertyDependsOn.length) {
          return stackProperty.propertyDependsOn.some(function (p) {
            var service = App.config.get('serviceByConfigTypeMap')[p.type];
            return service && !this.get('installedServices')[service.get('serviceName')];
          }, this);
        } else {
          return !Em.isNone(savedValue) && stackProperty.recommendedValue === savedValue;
        }
      }
      return true;
    },
 
    /**
     * remove config based on recommendations
     * @param config
     * @param configsCollection
     * @param parentProperties
     * @protected
     * @override
     */
    _removeConfigByRecommendation: function _removeConfigByRecommendation(config, configsCollection, parentProperties) {
      this._super(config, configsCollection, parentProperties);
      /**
       * need to update wizard info when removing configs for installed services;
       */
      var installedServices = this.get('installedServices'),
          wizardController = this.get('wizardController'),
          fileNamesToUpdate = wizardController ? wizardController.getDBProperty('fileNamesToUpdate') || [] : [],
          fileName = Em.get(config, 'filename'),
          serviceName = Em.get(config, 'serviceName');
      var modifiedFileNames = this.get('modifiedFileNames');
      if (modifiedFileNames && !modifiedFileNames.contains(fileName)) {
        modifiedFileNames.push(fileName);
      } else if (wizardController && installedServices[serviceName]) {
        if (!fileNamesToUpdate.contains(fileName)) {
          fileNamesToUpdate.push(fileName);
        }
      }
      if (wizardController) {
        wizardController.setDBProperty('fileNamesToUpdate', fileNamesToUpdate.uniq());
      }
    },
    /**
     * @method manageConfigurationGroup
     */
    manageConfigurationGroup: function manageConfigurationGroup() {
      App.router.get('manageConfigGroupsController').manageConfigurationGroups(this);
    },
 
    /**
     * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
     * @return {$.ajax|null}
     * @method checkMySQLHost
     */
    checkMySQLHost: function checkMySQLHost() {
      // get ambari database type and hostname
      return App.ajax.send({
        name: 'ambari.service',
        data: {
          fields: "?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database_name,hostComponents/RootServiceHostComponents/properties/server.jdbc.url,hostComponents/RootServiceHostComponents/properties/server.jdbc.database"
        },
        sender: this,
        success: 'getAmbariDatabaseSuccess'
      });
    },
 
    /**
     * Success callback for ambari database, get Ambari DB type and DB server hostname, then
     * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
     * @param {object} data
     * @method getAmbariDatabaseSuccess
     */
    getAmbariDatabaseSuccess: function getAmbariDatabaseSuccess(data) {
      var ambariServerDBType = Em.getWithDefault(data.hostComponents, '0.RootServiceHostComponents.properties', {})['server.jdbc.database'],
          ambariServerHostName = Em.getWithDefault(data.hostComponents, '0.RootServiceHostComponents.host_name', false),
          hiveConnectionURL = Em.getWithDefault(App.config.findConfigProperty(this.get('stepConfigs'), 'javax.jdo.option.ConnectionURL', 'hive-site.xml') || {}, 'value', '');
      if (ambariServerHostName) {
        this.set('mySQLServerConflict', ambariServerDBType.contains('mysql') && hiveConnectionURL.contains(ambariServerHostName));
      } else {
        this.set('mySQLServerConflict', false);
      }
    },
 
    /**
     * Check if new MySql database was chosen for Hive service
     * and it is not located on the same host as Ambari server
     * that using MySql database too.
     *
     * @method resolveHiveMysqlDatabase
     */
    resolveHiveMysqlDatabase: function resolveHiveMysqlDatabase() {
      var hiveService = this.get('content.services').findProperty('serviceName', 'HIVE');
      if (!hiveService || !hiveService.get('isSelected') || hiveService.get('isInstalled')) {
        return this.moveNext();
      }
      var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value;
      Eif (hiveDBType === 'New MySQL Database') {
        var self = this;
        return this.checkMySQLHost().done(function () {
          self.mySQLWarningHandler();
        });
      }
      return this.moveNext();
    },
 
    /**
     * Show warning popup about MySQL-DB issues (on post-submit)
     *
     * @returns {*}
     * @method mySQLWarningHandler
     */
    mySQLWarningHandler: function mySQLWarningHandler() {
      var self = this;
      Eif (this.get('mySQLServerConflict')) {
        // error popup before you can proceed
        return App.ModalPopup.show({
          header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
          body: Em.I18n.t('installer.step7.popup.mySQLWarning.body'),
          secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
          primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
          encodeBody: false,
          onPrimary: function onPrimary() {
            this._super();
            self.set('submitButtonClicked', false);
          },
          onSecondary: function onSecondary() {
            var parent = this;
            return App.ModalPopup.show({
              header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
              body: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'),
              onPrimary: function onPrimary() {
                this.hide();
                parent.hide();
                // go back to step 5: assign masters and disable default navigation warning
                if (self.get('isInstallWizard')) {
                  App.router.get('installerController').gotoStep(5, true);
                } else {
                  Eif (self.get('isAddServiceWizard')) {
                    App.router.get('addServiceController').gotoStep(2, true);
                  }
                }
              },
              onSecondary: function onSecondary() {
                this._super();
                self.set('submitButtonClicked', false);
              }
            });
          }
        });
      }
      return this.moveNext();
    },
 
    checkDatabaseConnectionTest: function checkDatabaseConnectionTest() {
      var deferred = $.Deferred();
      var configMap = [{
        serviceName: 'OOZIE',
        ignored: [Em.I18n.t('installer.step7.oozie.database.new')]
      }, {
        serviceName: 'HIVE',
        ignored: [Em.I18n.t('installer.step7.hive.database.new.mysql'), Em.I18n.t('installer.step7.hive.database.new.postgres')]
      }];
      configMap.forEach(function (config) {
        var isConnectionNotTested = false;
        var service = this.get('content.services').findProperty('serviceName', config.serviceName);
        if (service && service.get('isSelected') && !service.get('isInstalled')) {
          var serviceConfigs = this.get('stepConfigs').findProperty('serviceName', config.serviceName).configs;
          var serviceDatabase = serviceConfigs.findProperty('name', config.serviceName.toLowerCase() + '_database').get('value');
          Eif (!config.ignored.contains(serviceDatabase)) {
            var filledProperties = App.db.get('tmp', config.serviceName + '_connection');
            Eif (!filledProperties || App.isEmptyObject(filledProperties)) {
              isConnectionNotTested = true;
            } else {
              for (var key in filledProperties) {
                if (serviceConfigs.findProperty('name', key).get('value') !== filledProperties[key]) isConnectionNotTested = true;
              }
            }
          }
        }
        config.isCheckIgnored = isConnectionNotTested;
      }, this);
      var ignoredServices = configMap.filterProperty('isCheckIgnored', true);
      Eif (ignoredServices.length) {
        var displayedServiceNames = ignoredServices.mapProperty('serviceName').map(function (serviceName) {
          return this.get('content.services').findProperty('serviceName', serviceName).get('displayName');
        }, this);
        this.showDatabaseConnectionWarningPopup(displayedServiceNames, deferred);
      } else {
        deferred.resolve();
      }
      return deferred;
    },
 
    showChangesWarningPopup: function showChangesWarningPopup(goToNextStep) {
      return App.ModalPopup.show({
        header: Em.I18n.t('common.warning'),
        body: Em.I18n.t('services.service.config.exitChangesPopup.body'),
        secondary: Em.I18n.t('common.cancel'),
        primary: Em.I18n.t('yes'),
        onPrimary: function onPrimary() {
          if (goToNextStep) {
            goToNextStep();
            this.hide();
          }
        },
        onSecondary: function onSecondary() {
          this.hide();
          App.set('router.btnClickInProgress', false);
          App.set('router.backBtnClickInProgress', false);
        }
      });
    },
 
    showDatabaseConnectionWarningPopup: function showDatabaseConnectionWarningPopup(serviceNames, deferred) {
      var self = this;
      return App.ModalPopup.show({
        header: Em.I18n.t('installer.step7.popup.database.connection.header'),
        body: Em.I18n.t('installer.step7.popup.database.connection.body').format(serviceNames.join(', ')),
        secondary: Em.I18n.t('common.cancel'),
        primary: Em.I18n.t('common.proceedAnyway'),
        onPrimary: function onPrimary() {
          deferred.resolve();
          this._super();
        },
        onClose: function onClose() {
          this.onSecondary();
        },
        onSecondary: function onSecondary() {
          this._super();
          self.set('submitButtonClicked', false);
          App.set('router.nextBtnClickInProgress', false);
          deferred.reject();
        }
      });
    },
 
    showOozieDerbyWarningPopup: function showOozieDerbyWarningPopup(callback) {
      var self = this;
      if (this.get('selectedServiceNames').contains('OOZIE')) {
        var databaseType = Em.getWithDefault(App.config.findConfigProperty(this.get('stepConfigs'), 'oozie_database', 'oozie-env.xml') || {}, 'value', '');
        if (databaseType === Em.I18n.t('installer.step7.oozie.database.new')) {
          return App.ModalPopup.show({
            header: Em.I18n.t('common.warning'),
            body: Em.I18n.t('installer.step7.popup.oozie.derby.warning'),
            secondary: Em.I18n.t('common.cancel'),
            primary: Em.I18n.t('common.proceedAnyway'),
            onPrimary: function onPrimary() {
              this.hide();
              if (callback) {
                callback();
              }
            },
            onSecondary: function onSecondary() {
              App.set('router.nextBtnClickInProgress', false);
              self.set('submitButtonClicked', false);
              this.hide();
            },
            onClose: function onClose() {
              this.onSecondary();
            }
          });
        }
      }
      Eif (callback) {
        callback();
      }
      return false;
    },
 
    /**
     * Proceed to the next step
     **/
    moveNext: function moveNext() {
      App.set('router.nextBtnClickInProgress', false);
      App.router.send('next');
      this.set('submitButtonClicked', false);
    },
 
    /**
     * Click-handler on Next button
     * Disable "Submit"-button while server-side processes are running
     * @method submit
     */
    submit: function submit() {
      if (this.get('isSubmitDisabled') || App.get('router.nextBtnClickInProgress')) {
        return false;
      }
      App.set('router.nextBtnClickInProgress', true);
      if (this.get('supportsPreInstallChecks')) {
        var preInstallChecksController = App.router.get('preInstallChecksController');
        if (preInstallChecksController.get('preInstallChecksWhereRun')) {
          return this.postSubmit();
        }
        return preInstallChecksController.notRunChecksWarnPopup(this.postSubmit.bind(this));
      }
      return this.postSubmit();
    },
 
    postSubmit: function postSubmit() {
      var _this = this;
 
      this.set('submitButtonClicked', true);
      if (this.get('isInstallWizard')) {
        this.serverSideValidationCallback();
      } else {
        this.serverSideValidation().done(function () {
          _this.serverSideValidationCallback();
        }).fail(function (value) {
          if ("invalid_configs" === value) {
            if (_this.get('isAddServiceWizard')) {
              _this.get('configErrorList.issues').clear();
              _this.get('configErrorList.criticalIssues').clear();
            }
            _this.set('submitButtonClicked', false);
            App.set('router.nextBtnClickInProgress', false);
          } else {
            // Failed due to validation mechanism failure.
            // Should proceed with other checks
            _this.serverSideValidationCallback();
          }
        });
      }
    },
 
    /**
     * @method serverSideValidationCallback
     */
    serverSideValidationCallback: function serverSideValidationCallback() {
      var self = this;
      this.showOozieDerbyWarningPopup(function () {
        self.checkDatabaseConnectionTest().done(function () {
          self.resolveHiveMysqlDatabase();
        });
      });
    },
 
    toggleIssuesFilter: function toggleIssuesFilter() {
      var errorServices = [],
          issueServices = [];
 
      this.get('filterColumns').findProperty('attributeName', 'hasIssues').toggleProperty('selected');
 
      // if currently selected service does not have issue, jump to the first service with issue.
      if (this.get('selectedService.errorCount') === 0) {
        this.get('stepConfigs').filterProperty('showConfig', true).forEach(function (service) {
          Eif (service.get('errorCount') > 0) errorServices.push(service);
          Iif (service.get('hasConfigIssues') === true) issueServices.push(service);
        });
        Iif (errorServices.length === 0 && issueServices.length === 0) return;
        this.switchToService(errorServices.length > 0 ? errorServices[0] : issueServices[0]);
      }
    },
 
    switchToService: function switchToService(service) {
      this.set('selectedService', service);
      $('a[href="#' + service.serviceName + '"]').tab('show');
    },
 
    issuesFilterSelected: function () {
      return this.get('filterColumns').findProperty('attributeName', 'hasIssues').get('selected');
    }.property('filterColumns.@each.selected'),
 
    hasStepConfigIssues: function () {
      return !this.get('stepConfigs').filterProperty('showConfig', true).everyProperty('hasConfigIssues', false);
    }.property('stepConfigs.@each.hasConfigIssues'),
 
    checkDescriptor: function checkDescriptor() {
      if (App.get('isKerberosEnabled')) {
        return App.ajax.send({
          sender: self,
          name: 'admin.kerberize.cluster_descriptor_artifact'
        });
      }
      return $.Deferred().resolve().promise();
    },
 
    /**
     * Store status of kerberos descriptor located in cluster artifacts.
     * This status needed for Add Service Wizard to select appropriate method to create
     * or update descriptor.
     *
     * @param  {Boolean} isExists <code>true</code> if cluster descriptor present
     */
    storeClusterDescriptorStatus: function storeClusterDescriptorStatus(isExists) {
      this.get('wizardController').setDBProperty('isClusterDescriptorExists', isExists);
    },
 
    /**
    * Get all configs, that should be stored in kerberos_descriptor
    * @returns {Array}
    */
    getDescriptorConfigs: function getDescriptorConfigs() {
      return this.get('stepConfigs').reduce(function (allConfigs, service) {
        return allConfigs.concat(service.get('configs').filterProperty('isSecureConfig'));
      }, []);
    },
 
    selectService: function selectService(event) {
      this.get('stepConfigs').forEach(function (service) {
        service.set('isActive', service.get('serviceName') === event.context.serviceName);
      });
      this.set('selectedService', event.context);
      var activeTabs = this.get('tabs').findProperty('isActive', true);
      if (activeTabs) {
        activeTabs.set('selectedServiceName', event.context.serviceName);
      }
    },
 
    /**
     * Set initial state for <code>tabs</code>
     */
    initTabs: function initTabs() {
      var storedConfigs = this.get('content.serviceConfigProperties');
      var tabs = [Em.Object.create({
        name: 'credentials',
        displayName: 'Credentials',
        icon: 'glyphicon-lock',
        isActive: false,
        isDisabled: false,
        isSkipped: false,
        validateOnSwitch: false,
        tabView: App.CredentialsTabOnStep7View
      }), Em.Object.create({
        name: 'databases',
        displayName: 'Databases',
        icon: 'glyphicon-align-justify',
        isActive: false,
        isDisabled: false,
        isSkipped: false,
        validateOnSwitch: false,
        tabView: App.DatabasesTabOnStep7View
      }), Em.Object.create({
        name: 'directories',
        displayName: 'Directories',
        icon: 'glyphicon-folder-open',
        isActive: false,
        isDisabled: false,
        isSkipped: false,
        validateOnSwitch: false,
        selectedServiceName: null,
        tabView: App.DirectoriesTabOnStep7View
      }), Em.Object.create({
        name: 'accounts',
        displayName: 'Accounts',
        icon: 'glyphicon-user',
        isActive: false,
        isDisabled: false,
        isSkipped: false,
        validateOnSwitch: false,
        tabView: App.AccountsTabOnStep7View
      }), Em.Object.create({
        name: 'all-configurations',
        displayName: 'All Configurations',
        icon: 'glyphicon-wrench',
        isActive: false,
        isDisabled: false,
        isSkipped: false,
        validateOnSwitch: true,
        selectedServiceName: null,
        tabView: App.ServicesConfigView
      })];
 
      this.set('tabs', tabs);
 
      this.setSkippedTabs();
 
      if (storedConfigs && storedConfigs.length) {
        tabs.findProperty('name', 'all-configurations').set('isActive', true);
      } else {
        tabs.findProperty('isDisabled', false).set('isActive', true);
        this.disableTabs();
      }
    },
 
    setSkippedTabs: function setSkippedTabs() {
      var servicesWithCredentials = App.Tab.find().filterProperty('themeName', 'credentials').mapProperty('serviceName');
      var servicesWithDatabase = App.Tab.find().filterProperty('themeName', 'database').mapProperty('serviceName');
      var selectedServices = this.get('content.selectedServiceNames');
      var tabs = this.get('tabs');
      var disableCredentials = true;
      var disableDatabases = true;
 
      for (var i = 0; i < selectedServices.length; i++) {
        var serviceName = selectedServices[i];
        disableCredentials = disableCredentials && servicesWithCredentials.indexOf(serviceName) === -1;
        disableDatabases = disableDatabases && servicesWithDatabase.indexOf(serviceName) === -1;
        if (!disableCredentials && !disableDatabases) break;
      }
 
      tabs.findProperty('name', 'credentials').setProperties({
        isDisabled: disableCredentials,
        isSkipped: disableCredentials
      });
      tabs.findProperty('name', 'databases').setProperties({
        isDisabled: disableDatabases,
        isSkipped: disableDatabases
      });
    },
 
    /**
     * Get index of current (active) tab
     */
    currentTabIndex: function () {
      return this.get('tabs').findIndex(function (tab) {
        return tab.get('isActive');
      });
    }.property('tabs.@each.isActive'),
 
    /**
     * Get name of current (active) tab
     */
    currentTabName: function () {
      var activeTab = this.get('tabs').findProperty('isActive');
      return activeTab ? activeTab.get('name') : '';
    }.property('tabs.@each.isActive'),
 
    /**
     * Make selected tab active, show tab's content
     * @param event
     * @returns {boolean}
     */
    selectTab: function selectTab(event) {
      var tab = event.context;
      if (!tab.get('isDisabled')) {
        $('a[href=#' + tab.name + ']').tab('show');
        this.get('tabs').setEach('isActive', false);
        tab.set('isActive', true);
      }
      return false;
    },
 
    /**
     * Get disabled state for next button
     */
    isNextDisabled: function () {
      var tabName = this.get('currentTabName');
      switch (tabName) {
        case 'credentials':
          return !this.get('credentialsTabNextEnabled');
        case 'databases':
          return !this.get('databasesTabNextEnabled');
        case 'all-configurations':
          return this.get('isSubmitDisabled');
        default:
          return false;
      }
    }.property('tabs.@each.isActive', 'isSubmitDisabled', 'credentialsTabNextEnabled', 'databasesTabNextEnabled'),
 
    /**
     * Set isDisabled state for tabs
     */
    disableTabs: function () {
      this.get('tabs').rejectProperty('isSkipped').setEach('isDisabled', !this.get('tabs').findProperty('name', 'credentials').get('isDisabled') && !this.get('credentialsTabNextEnabled'));
    }.observes('credentialsTabNextEnabled'),
 
    /**
     * Select specified service and put property name in filter input
     * @param event - jQuery event
     */
    showConfigProperty: function showConfigProperty(event) {
      var serviceName = event.context.serviceName;
      var propertyName = event.context.propertyName || event.context.name;
      var stepConfig = this.get('stepConfigs').findProperty('serviceName', serviceName) || this.get('stepConfigs').findProperty('displayName', serviceName);
      this.set('selectedService', stepConfig);
      this.get('filterColumns').setEach('selected', false);
      Em.run.next(this, function () {
        this.set('filter', propertyName);
      });
 
      this.get('stepConfigs').setEach('isActive', false);
      stepConfig.set('isActive', true);
    },
 
    /**
     * Show bell animation
     */
    ringBell: function ringBell() {
      $('#issues-bell').addClass('animated');
      $('#issues-counter').addClass('animated');
      setTimeout(function () {
        $('#issues-bell').removeClass('animated');
      }, 2000);
      setTimeout(function () {
        $('#issues-counter').removeClass('animated');
      }, 300);
    },
 
    /**
     * Set <code>issuesCounter</code> and run bell animation if needed
     */
    setIssues: function () {
      var recommendations = this.get('changedProperties.length');
      var validations = this.get('stepConfigs').mapProperty('configsWithErrors.length').reduce(Em.sum, 0);
      var configErrorList = this.get('configErrorList');
      this.set('hasErrors', Boolean(validations + configErrorList.get('criticalIssues.length')));
      this.set('issuesCounter', recommendations + validations + configErrorList.get('issues.length') + configErrorList.get('criticalIssues.length'));
      if (validations !== this.get('validationsCounter')) {
        this.ringBell();
      }
      this.set('validationsCounter', validations);
    }.observes('changedProperties.length', 'stepConfigs.@each.configsWithErrors.length', 'configErrorList.issues.length', 'configErrorList.criticalIssues.length'),
 
    /**
     * Next button action handler
     */
    next: function next(index) {
      var tabs = this.get('tabs');
      var currentTabIndex = typeof index === 'number' ? index : this.get('currentTabIndex');
      if (tabs.length - 1 > currentTabIndex) {
        tabs[currentTabIndex].set('isActive', false);
        if (tabs[currentTabIndex + 1].get('isDisabled')) {
          this.next(++currentTabIndex);
        } else {
          tabs[currentTabIndex + 1].set('isActive', true);
        }
      } else {
        this.submit();
      }
    },
 
    /**
     * Back button action handler
     */
    back: function back(index) {
      var tabs = this.get('tabs');
      var currentTabIndex = typeof index === 'number' ? index : this.get('currentTabIndex');
      if (currentTabIndex > 0) {
        tabs[currentTabIndex].set('isActive', false);
        if (tabs[currentTabIndex - 1].get('isDisabled')) {
          this.back(--currentTabIndex);
        } else {
          tabs[currentTabIndex - 1].set('isActive', true);
        }
      } else {
        App.router.send('back');
      }
    },
 
    updateConfigAttributesFromThemes: function updateConfigAttributesFromThemes() {
      var _this2 = this;
 
      this.get('allSelectedServiceNames').forEach(function (serviceName) {
        return _this2.updateAttributesFromTheme(serviceName);
      });
    },
 
    validateOnTabSwitch: function () {
      var _this3 = this;
 
      var activeTab = this.get('tabs')[this.get('currentTabIndex')];
      if (activeTab && activeTab.get('validateOnSwitch')) {
        if (this.get('requestTimer')) {
          clearTimeout(this.get('requestTimer'));
        }
        if (this.get('validationRequest')) {
          this.get('validationRequest').abort();
        }
        if (this.get('recommendationsInProgress')) {
          this.valueObserver();
        } else {
          this.runServerSideValidation().done(function () {
            return _this3.set('validationRequest', null);
          });
        }
      }
    }.observes('currentTabIndex')
 
  });
});