Переглянути джерело

Merge pull request #12837 from miguelvazq/HPCC-21297

HPCC-21297 Create System Servers Widget

Reviewed-By: Gordon Smith <gordon.smith@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 5 роки тому
батько
коміт
c7747dc825

+ 2 - 2
esp/src/eclwatch/ClusterProcessesQueryWidget.js

@@ -346,11 +346,11 @@ define([
                     style: "width: 100%",
                     params: params.params,
                     closable: true,
-                    title: params.params.Machines.MachineInfoEx[0].DisplayType
+                    title: this.i18n.MachineInformation
                 });
                 this._tabContainer.addChild(retVal, "last");
             }
             return retVal;
-        },
+        }
     });
 });

+ 20 - 6
esp/src/eclwatch/MachineInformationWidget.js

@@ -239,18 +239,32 @@ define([
                             cbAutoRefresh: machineInformation.cbAutoRefresh
                         };
 
-                        arrayUtil.forEach(selection, function(item, idx){
+                        arrayUtil.forEach(selection, function(item, idx) {
                             MachineInformationCount++;
-                            request["Addresses." + idx] = item.Netaddress + "|:" + item.Type + ":" + item.Name + ":" + 2 + ":" + item.Parent.Directory + ":" + idx;
-                            request["Addresses.itemcount"] = MachineInformationCount;
+                            if (item.Component === "SystemServers") { //request params are unique for system servers vs cluster processes
+                                request["SystemServers"] = true;
+                                request["Addresses." + idx] = item.Netaddress + "|" + item.Netaddress + ":" + item.Type + ":" + item.Name + ":" + 2 + ":" + item.Directory;
+                                request["Addresses.itemcount"] = MachineInformationCount;
+
+                            } else {
+                                request["ClusterProcesses"] = true;
+                                request["Addresses." + idx] = item.Netaddress + "|:" + item.Type + ":" + item.Name + ":" + 2 + ":" + item.Parent.Directory + ":" + idx;
+                                request["Addresses.itemcount"] = MachineInformationCount;
+                            }
                         });
 
                         WsMachine.GetMachineInfo({
                             request: request
                         }).then(function(response){
-                            topic.publish("createClusterProcessPreflightTab", {
-                                response: response.GetMachineInfoResponse
-                            });
+                            if (request.ClusterProcesses) {
+                                topic.publish("createClusterProcessPreflightTab", {
+                                    response: response.GetMachineInfoResponse
+                                });
+                            } else {
+                                topic.publish("createSystemServersPreflightTab", {
+                                    response: response.GetMachineInfoResponse
+                                });
+                            }
                         });
                     } else if (type === "targets") {
                         var TargetClusterCount = 0;

+ 439 - 0
esp/src/eclwatch/SystemServersQueryWidget.js

@@ -0,0 +1,439 @@
+define([
+    "dojo/_base/declare",
+    "dojo/_base/lang",
+    "dojo/i18n",
+    "dojo/i18n!./nls/hpcc",
+    "dojo/_base/array",
+    "dojo/on",
+    "dojo/dom",
+    "dojo/dom-class",
+    "dojo/dom-construct",
+    "dojo/topic",
+
+    "dijit/registry",
+    "dijit/form/Button",
+    "dijit/ToolbarSeparator",
+    "dijit/Dialog",
+    "dijit/form/TextBox",
+
+    "dgrid/tree",
+    "dgrid/selector",
+
+    "hpcc/GridDetailsWidget",
+    "src/ESPPreflight",
+    "src/ESPRequest",
+    "src/WsTopology",
+    "src/Utility",
+    "src/ESPUtil",
+    "hpcc/DelayLoadWidget",
+    "hpcc/PreflightDetailsWidget",
+    "hpcc/RequestInformationWidget",
+    "hpcc/MachineInformationWidget",
+    "hpcc/IFrameWidget"
+], function (declare, lang, i18n, nlsHPCC, arrayUtil, on, dom, domClass, domConstruct, topic,
+    registry, Button, ToolbarSeparator, Dialog, TextBox,
+    tree, selector,
+    GridDetailsWidget, ESPPreflight, ESPRequest, WsTopology, Utility, ESPUtil, DelayLoadWidget, PreflightDetailsWidget, RequestInformationWidget, MachineInformationWidget, IFrameWidget) {
+    return declare("SystemServersQueryWidget", [GridDetailsWidget, ESPUtil.FormHelper], {
+        i18n: nlsHPCC,
+
+        gridTitle: nlsHPCC.title_SystemServers,
+        idProperty: "__hpcc_id",
+        machineFilter: null,
+        machineFilterLoaded: null,
+
+        init: function (params) {
+            var context = this;
+            if (this.inherited(arguments))
+                return;
+
+            this._refreshActionState();
+            this.refreshGrid();
+
+            this.machineFilter.disable(true);
+
+            this.machineFilter.on("apply", function (evt) {
+                var selection = context.grid.getSelected();
+                var selections = [];
+                for (var i = 0; i < selection.length; ++i) {
+                    var data = context.grid.row(selection[i].hpcc_id).data;
+                    selections.push(data);
+                }
+                context.machineFilter._onSubmitRequest("machine", selections);
+            });
+
+            dojo.destroy(this.id + "Open");
+            this.refreshActionState();
+
+            topic.subscribe("createSystemServersPreflightTab", function (topic) {
+                var pfTab = context.ensureMIPane(topic.response.Machines.MachineInfoEx[0].DisplayType + "- " + topic.response.TimeStamp, {
+                    params: topic.response
+                });
+                pfTab.init(topic.response, "machines");
+            });
+
+        },
+
+        initTab: function () {
+            var currSel = this.getSelectedChild();
+            if (currSel && !currSel.initalized) {
+                if (currSel.id === this.id + "_Grid") {
+                    this.refreshGrid()
+                } else if (currSel.id === this.systemServersQueryWidgetIframeWidget.id && !this.systemServersQueryWidgetIframeWidget.initalized) {
+                    this.systemServersQueryWidgetIframeWidget.init({
+                        src: ESPRequest.getBaseURL("WsTopology") + "/TpServiceQuery?Type=ALLSERVICES"
+                    });
+                } else {
+                    currSel.init(currSel.params);
+                }
+            }
+        },
+
+        _onRowDblClick: function (item) {
+            var nodeTab = this.ensureLogsPane(item.Name, {
+                params: item,
+                ParentName: item.Parent.Name,
+                LogDirectory: item.Parent.LogDirectory,
+                NetAddress: item.Netaddress,
+                OS: item.OS,
+                newPreflight: true
+            });
+            this.selectChild(nodeTab);
+        },
+
+        postCreate: function (args) {
+            var context = this;
+            this.inherited(arguments);
+            this.openButton = registry.byId(this.id + "Open");
+            this.refreshButton = registry.byId(this.id + "Refresh");
+            this.configurationButton = registry.byId(this.id + "Configuration");
+
+            this.machineFilter = new MachineInformationWidget({});
+
+            this.configurationButton = new Button({
+                label: "Open Configuration",
+                onClick: function(event) {
+                    context._onOpenConfiguration();
+                }
+            });
+
+            this.machineFilter.placeAt(this.openButton.domNode, "after");
+            this.configurationButton.placeAt(this.openButton.domNode, "after");
+
+            new ToolbarSeparator().placeAt(this.machineFilter.domNode, "before");
+
+            this.machineFilter.machineForm.set("style", "width:500px;");
+            dojo.destroy(this.id + "Open");
+
+            this.systemServersQueryWidgetIframeWidget = new IFrameWidget({
+                id: this.id + "_SystemServersQueryWidgetIframeWidget",
+                title: this.i18n.title_SystemServersLegacy,
+                style: "border: 0; width: 100%; height: 100%"
+            });
+            this.systemServersQueryWidgetIframeWidget.placeAt(this._tabContainer, "last");
+        },
+
+        createGrid: function (domID) {
+            var context = this;
+            var retVal = new declare([ESPUtil.Grid(true, true, false, true, false)])({
+                store: ESPPreflight.CreateSystemServersStore(),
+                columns: {
+                    col1: selector({
+                        width: 20,
+                        selectorType: 'checkbox',
+                        disabled: function (item) {
+                            return !item;
+                        },
+                    }),
+                    Configuration: {
+                        label: this.i18n.Configuration,
+                        renderHeaderCell: function (node) {
+                            domClass.add(node, "centerInCell");
+                            node.innerHTML = Utility.getImageHTML("configuration.png", context.i18n.Configuration);
+                        },
+                        width: 10,
+                        sortable: false,
+                        renderCell: function (object, value, node, options) {
+                            if (object.Directory) {
+                                domClass.add(node, "centerInCell");
+                                node.innerHTML = "<a href='#' />" + Utility.getImageHTML("configuration.png", context.i18n.Configuration) + "</a>";
+                            }
+                        },
+                    },
+                    Informational: {
+                        label: this.i18n.Informational,
+                        width: 40,
+                        renderHeaderCell: function (node) {
+                            domClass.add(node, "centerInCell");
+                            node.innerHTML = Utility.getImageHTML("information.png", context.i18n.Informational);
+                        },
+                        renderCell: function (object, value, node, options) {
+                            if (object.Informational === "SparkThorProcess") {
+                                domClass.add(node, "centerInCell");
+                                node.innerHTML = "<a href='#' />" + Utility.getImageHTML("information.png", context.i18n.Informational) + "</a>"
+                            }
+                        }
+                    },
+                    Logs: {
+                        label: this.i18n.Logs,
+                        width:90,
+                        children: [
+                            {
+                                label: this.i18n.AuditLogs,
+                                width: 40,
+                                id: "AuditLogs",
+                                renderCell: function (object, value, node, options) {
+                                    if (object.AuditLog) {
+                                        domClass.add(node, "centerInCell");
+                                        node.innerHTML = "<a href='#' />" + Utility.getImageHTML("base.gif", context.i18n.AuditLogs) + "</a>"
+                                    }
+                                },
+                            },
+                            {
+                                label: this.i18n.ComponentLogs,
+                                width: 60,
+                                id: "Logs",
+                                renderCell: function (object, value, node, options) {
+                                    if (object.Log) {
+                                        domClass.add(node, "centerInCell");
+                                        node.innerHTML = "<a href='#' />" + Utility.getImageHTML("base.gif", context.i18n.ComponentLogs) + "</a>"
+                                    }
+                                }
+                            }
+                        ]
+                    },
+                    Name: tree({
+                        formatter: function (_name, row) {
+                            var img = "";
+                            var name = _name;
+                            if (row.parent) {
+                                img = Utility.getImageHTML("folder.png");
+                                name = row.parent;
+                            }
+                            return img + "&nbsp;" + name;
+                        },
+                        collapseOnRefresh: false,
+                        label: this.i18n.Name,
+                        sortable: true,
+                        width: 150
+                    }),
+                    ChildQueue: {
+                        label: this.i18n.Queue,
+                        sortable: false,
+                        width: 100
+                    },
+                    Computer: {
+                        label: this.i18n.Node,
+                        sortable: false,
+                        width: 75
+                    },
+                    NetaddressWithPort: {
+                        label: this.i18n.NetworkAddress,
+                        sortable: false,
+                        width: 100
+                    },
+                    Directory: {
+                        label: this.i18n.Directory,
+                        sortable: false,
+                        width: 200
+                    }
+                }
+            }, domID);
+
+            retVal.on("dgrid-select", function (event) {
+                var selection = context.grid.getSelected();
+                for (var i = selection.length - 1; i >= 0; --i) {
+                    if (selection[i].Component) {
+                        context.machineFilter.disable(true);
+                    }  else {
+                        context.machineFilter.disable(false);
+                    }
+                }
+            });
+
+            retVal.on("dgrid-deselect", function (event) {
+                var selection = context.grid.getSelected();
+                if (selection.length === 0) {
+                    context.machineFilter.disable(true);
+                } else {
+                    context.machineFilter.disable(false);
+                }
+            });
+
+            retVal.on(".dgrid-row-url:click", function (evt) {
+                if (context._onRowDblClick) {
+                    var item = retVal.row(evt).data;
+                    context._onRowDblClick(item);
+                }
+            });
+
+            retVal.on(".dgrid-row:dblclick", function (evt) {
+                if (context._onRowDblClick) {
+                    var item = retVal.row(evt).data;
+                    context._onRowDblClick(item);
+                }
+            });
+
+            retVal.on(".dgrid-cell img:click", function (evt) {
+                var item = retVal.row(evt).data;
+                if (evt.target.title === "Audit Log" || evt.target.title === "Component Log") {
+                    context._onOpenLog(item)
+                } else {
+                    context._onOpenConfiguration(item);
+                }
+            });
+
+            retVal.on(".dgrid-cell:click", function(evt){
+                var cell = retVal.cell(evt)
+            });
+
+            retVal.onSelectionChanged(function (event) {
+                context.refreshActionState();
+            });
+
+            return retVal;
+        },
+
+        _onOpen: function (evt) {
+            var selections = this.grid.getSelected();
+            var firstTab = null;
+            for (var i = 0; i < selections.length; ++i) {
+                var tab = this.ensureLogsPane(selections[i], {
+                    Node: selections[i]
+                });
+                if (i === 0) {
+                    firstTab = tab;
+                }
+            }
+            if (firstTab) {
+                this.selectChild(firstTab);
+            }
+        },
+
+        _onOpenConfiguration: function (data) {
+            var context = this;
+            var selections = this.grid.getSelected();
+            var firstTab = null;
+
+            if (!data) {
+                data = this.grid.row(selections[0].hpcc_id).data;
+            }
+
+            WsTopology.TpGetComponentFile({
+                request: {
+                    FileType: "cfg",
+                    CompType: data.Type,
+                    NetAddress: data.Netaddress,
+                    Directory: data.Directory,
+                    OsType: data.OS
+                }
+            }).then(function(response) {
+                var tab = context.ensureConfigurationPane(data.Type + data.Name + "Configuration" , {
+                    Component: data.Type,
+                    Name: data.Name,
+                    Usergenerated: response
+                });
+
+                if (firstTab === null) {
+                    firstTab = tab;
+                }
+                if (firstTab) {
+                    context.selectChild(firstTab);
+                }
+            });
+        },
+
+        _onOpenLog: function (item) {
+            var nodeTab = this.ensureLogsPane(item.Name + ": " + item.Parent.LogDirectory, {
+                params: item,
+                ParentName: item.Parent.Name,
+                LogDirectory: item.Parent.LogDirectory,
+                NetAddress: item.Netaddress,
+                OS: item.OS,
+                newPreflight: true
+            });
+            this.selectChild(nodeTab);
+        },
+
+        _onRefresh: function () {
+            this.refreshGrid();
+        },
+
+        refreshGrid: function () {
+            this.grid.set("query", {
+                Type: "ALLSERVICES",
+            });
+        },
+
+        refreshActionState: function () {
+            var selection = this.grid.getSelected();
+            var isCluster = false;
+            var isNode = false;
+
+            for (var i = 0; i < selection.length; ++i) {
+                if (selection[i] && selection[i].type === "clusterProcess") {
+                    isCluster = true;
+                    isNode = false;
+                } else {
+                    isCluster = false;
+                    isNode = true;
+                }
+            }
+
+            this.openButton.set("disabled", !isNode);
+            this.configurationButton.set("disabled", !isCluster);
+        },
+
+        ensureConfigurationPane: function (id, params) {
+            id = this.createChildTabID(id);
+            var retVal = registry.byId(id);
+            if (!retVal) {
+                var context = this;
+                retVal = new DelayLoadWidget({
+                    id: id,
+                    title: "<b>" + params.Component + "</b>: " + params.Name + " " + context.i18n.Configuration,
+                    closable: true,
+                    delayWidget: "ECLSourceWidget",
+                    params: params
+
+                });
+                this.addChild(retVal, "last");
+            }
+            return retVal;
+        },
+
+        ensureLogsPane: function (id, params) {
+            id = this.createChildTabID(id);
+            var retVal = registry.byId(id);
+            if (!retVal) {
+                var context = this;
+                retVal = new DelayLoadWidget({
+                    id: id,
+                    title: "<b>" + params.NetAddress + "</b>: " + params.LogDirectory,
+                    closable: true,
+                    delayWidget: "LogWidget",
+                    params: params
+
+                });
+                this.addChild(retVal, "last");
+            }
+            return retVal;
+        },
+
+        ensureMIPane: function (id, params) {
+            id = this.createChildTabID(id);
+            var retVal = registry.byId(id);
+            if (!retVal) {
+                retVal = new PreflightDetailsWidget({
+                    id: id,
+                    style: "width: 100%",
+                    params: params.params,
+                    closable: true,
+                    title: this.i18n.MachineInformation
+                });
+                this._tabContainer.addChild(retVal, "last");
+            }
+            return retVal;
+        }
+    });
+});

+ 4 - 0
esp/src/eclwatch/css/hpcc.css

@@ -269,6 +269,10 @@ hr.dashedLine {
     text-align: right !important;
 }
 
+.centerInCell {
+    text-align: center !important; /*overwrite the default grid cell text-align */
+}
+
 .flat .hpccCentered { 
     text-align: center; 
 }

BIN
esp/src/eclwatch/img/base.gif


BIN
esp/src/eclwatch/img/information.png


+ 5 - 0
esp/src/eclwatch/nls/hpcc.js

@@ -53,6 +53,7 @@ define({root:
     ArchivedOnly: "Archived Only",
     ArchivedWarning: "Warning: please specify a small date range. If not, it may take some time to retrieve the workunits and the browser may be timed out.",
     Attach: "Attach",
+    AuditLogs: "Audit Log",
     BinaryInstalls: "Binary Installs",
     Attribute: "Attribute",
     AttributesAreRequired: "Attributes are required",
@@ -99,6 +100,7 @@ define({root:
     ComplexityWarning: "More than {threshold} activities ({activityCount}) - suppress initial display?",
     CompressedFileSize: "Compressed File Size",
     Component: "Component",
+    ComponentLogs: "Component Log",
     Compress: "Compress",
     Compressed: "Compressed",
     ComputerUpTime: "Computer Up Time",
@@ -319,6 +321,7 @@ define({root:
     IncludeSlaveLogs: "Include slave logs",
     Index: "Index",
     Info: "Info",
+    Informational: "Informational",
     InfoDialog: "Info Dialog",
     InheritedPermissions: "Inherited permission:",
     Inputs: "Inputs",
@@ -800,6 +803,8 @@ define({root:
     title_PreflightResults: "Preflight Results",
     title_SearchResults: "Search Results",
     title_SourceFiles: "",
+    title_SystemServers: "System Servers",
+    title_SystemServersLegacy: "System Servers (legacy)",
     title_TargetClusters: "Target Clusters",
     title_Topology: "Topology",
     title_TpThorStatus: "Thor Status",

+ 1 - 1
esp/src/eclwatch/templates/HPCCPlatformOpsWidget.html

@@ -12,7 +12,7 @@
             </div>
             <div id="${id}_ClusterProcessesQuery" title="${i18n.ClusterProcesses}" style="padding: 0px; border:0px; border-color:none; overflow: hidden" data-dojo-props="delayWidget: 'ClusterProcessesQueryWidget'" data-dojo-type="DelayLoadWidget">
             </div>
-            <div id="${id}_SystemServers" title="${i18n.SystemServers}" style="padding: 0px; border:0px; border-color:none; overflow: hidden" data-dojo-type="dijit.layout.ContentPane">
+            <div id="${id}_SystemServersQuery" title="${i18n.SystemServers}" style="padding: 0px; border:0px; border-color:none; overflow: hidden" data-dojo-props="delayWidget: 'SystemServersQueryWidget'" data-dojo-type="DelayLoadWidget">
             </div>
             <div id="${id}_Permissions" title="${i18n.Security}" data-dojo-type="UserQueryWidget">
             </div>

+ 51 - 42
esp/src/src/ESPPreflight.ts

@@ -23,63 +23,72 @@ var SystemServersStore = declare([ESPRequest.Store], {
     },
     preProcessRow: function (row) {
         lang.mixin(row, {
-            Platform: this.getOS(row.OS),
-            calculatedID: row.Name,
-            Name: row.Name,
-            type: "parentcomponent",
-            Component: row.Type,
-            Configuration: true
+            Name: row.parent,
+            childName: row.Name,
+            hpcc_id: row.parent + "_" + row.Name
         });
     },
+
     preProcessResponse: function (response, request) {
-        var tempArr = [];
+        var results = [];
         for (var key in response.ServiceList) {
             for (var i in response.ServiceList[key]) {
-                response.ServiceList[key][i].map(function(item){
-                    tempArr.push(item);
-                });
+                if (key !== "TpEclServers") {
+                    response.ServiceList[key][i].map(function(item){
+                        var cleanKey = key.replace('Tp', '');
+                        results.push(item);
+                        lang.mixin(item, {
+                            parent: cleanKey
+                        });
+                    });
+                }
             }
         }
-        return tempArr;
+        response.ServiceList = results;
     },
-    
+
     mayHaveChildren: function (item) {
-        return item.TpMachines;
-    },
-    getChildren: function (parent, options) {
-        var store = Observable(new ClusterProcessesList({
-            parent: parent
-        }));
-        return store.query({
-            Type: this.getMachineType(parent.Type),
-            Parent: parent,
-            Cluster: parent.Name,
-            LogDirectory: parent.LogDirectory,
-            Path: parent.Path,
-            Directory: parent.Directory
-        });
+        return item.TpMachines
     },
 
-    getMachineType: function (type) {
-        switch (type) {
-            case "RoxieCluster":
-                return "ROXIEMACHINES"
-            case "ThorCluster":
-                return "THORMACHINES"
+    getMachineIP: function (item) {
+        if (item.TpMachines) {
+            return item.TpMachines.TpMachine[0].Netaddress
+        } else {
+            return ""
         }
     },
 
-    getOS: function (int) {
-        switch (int) {
-            case 0:
-                return "Windows"
-            case 1:
-                return "Solaris"
-            case 2:
-                return "Linux"
-            default:
-                return "Linux"
+    getMachinePort: function (port) {
+        if (port > 0) {
+            return ":" + port
         }
+        return ""
+    },
+
+    getChildren: function (parent, options) {
+        var children = [];
+        var context = this;
+
+        arrayUtil.forEach(parent.TpMachines.TpMachine, function (item, idx) {
+            children.push({
+                hpcc_id: parent.childName + "_" + item.Name + "_" + idx,
+                Parent: parent,
+                Name: parent.childName,
+                Computer: item.Name,
+                Netaddress: item.Netaddress,
+                NetaddressWithPort: item.Netaddress + context.getMachinePort(item.Port),
+                OS: item.OS,
+                Directory: item.Directory,
+                Type: item.Type,
+                AuditLog: parent.AuditLogDirectory,
+                Log: parent.LogDirectory,
+                ChildQueue: parent.Queue,
+                Informational: item.Type,
+                Component: "SystemServers"
+            });
+        });
+        return QueryResults(children);
     }
 });
 

+ 3 - 0
esp/src/src/Utility.ts

@@ -659,6 +659,9 @@ export function resolve(hpccWidget, callback) {
         case "SourceFilesWidget":
             require(["hpcc/SourceFilesWidget"], doLoad);
             break;
+        case "SystemServersQueryWidget":
+            require(["hpcc/SystemServersQueryWidget"], doLoad);
+            break;
         case "TargetClustersQueryWidget":
             require(["hpcc/TargetClustersQueryWidget"], doLoad);
             break;