Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/candidate-9.0.x' into candidate-…
Browse files Browse the repository at this point in the history
…9.2.x
  • Loading branch information
GordonSmith committed Dec 14, 2023
2 parents 547610b + d0d0321 commit 96875ce
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 74 deletions.
39 changes: 7 additions & 32 deletions esp/src/eclwatch/stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ define([

"src/Utility",
"src/Session",
"src/KeyValStore",
"src/BuildInfo",
"hpcc/LockDialogWidget",

"dojox/html/entities",
Expand All @@ -22,46 +20,23 @@ define([
"css!hpcc/css/hpcc.css"

], function (fx, dom, domStyle, ioQuery, ready, lang, arrayUtil, topic,
Utility, Session, KeyValStore, BuildInfo, LockDialogWidget,
Utility, Session, LockDialogWidget,
entities, Toaster) {

Session.initSession();

const params = ioQuery.queryToObject(dojo.doc.location.search.substr((dojo.doc.location.search.substr(0, 1) === "?" ? 1 : 0)));
const hpccWidget = params.Widget ? params.Widget : "HPCCPlatformWidget";

Session.fetchModernMode().then(modernMode => {
if (modernMode === String(true) && hpccWidget !== "IFrameWidget") {
switch (hpccWidget) {
case "WUDetailsWidget":
window.location.replace(`/esp/files/index.html#/workunits/${params.Wuid}`);
break;
case "GraphsWUWidget":
window.location.replace(`/esp/files/index.html#/workunits/${params.Wuid}/metrics`);
break;
case "TopologyWidget":
case "DiskUsageWidget":
case "TargetClustersQueryWidget":
case "ClusterProcessesQueryWidget":
case "SystemServersQueryWidget":
case "LogWidget":
loadUI();
break;
default:
window.location.replace("/esp/files/index.html");
}
} else {
loadUI();
Session.needsRedirectV5().then(redirected => {
if (!redirected) {
ready(function () {
parseUrl();
initUI();
});
}
});

function loadUI() {
ready(function () {
parseUrl();
initUI();
});
}

function startLoading(targetNode) {
domStyle.set(dom.byId("loadingOverlay"), "display", "block");
domStyle.set(dom.byId("loadingOverlay"), "opacity", "255");
Expand Down
74 changes: 38 additions & 36 deletions esp/src/src-react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as ReactDOM from "react-dom";
import { initializeIcons } from "@fluentui/react";
import { scopedLogger } from "@hpcc-js/util";
import { cookieKeyValStore } from "src/KeyValStore";
import { fetchModernMode } from "src/Session";
import { needsRedirectV9 } from "src/Session";
import { ECLWatchLogger } from "./hooks/logging";
import { replaceUrl } from "./util/history";

Expand Down Expand Up @@ -32,41 +32,43 @@ dojoConfig.urlInfo = {
};
dojoConfig.disableLegacyHashing = true;

fetchModernMode().then(async modernMode => {
if (modernMode === String(false)) {
window.location.replace("/esp/files/stub.htm");
needsRedirectV9().then(async redirected => {
if (!redirected) {
loadUI();
}
});

async function loadUI() {
const authTypeResp = await fetch("/esp/getauthtype");
const authType = await authTypeResp?.text() ?? "None";
const userStore = cookieKeyValStore();
const userSession = await userStore.getAll();
if (authType.indexOf("None") < 0 && (userSession["ESPSessionState"] === "false" || userSession["ECLWatchUser"] === "false" || (!userSession["Status"] || userSession["Status"] === "Locked"))) {
if (window.location.hash.indexOf("login") < 0) {
replaceUrl("/login");
}
import("./components/forms/Login").then(_ => {
try {
ReactDOM.render(
<_.Login />,
document.getElementById("placeholder")
);
document.getElementById("loadingOverlay").remove();
} catch (e) {
logger.error(e);
}
});
} else {
const authTypeResp = await fetch("/esp/getauthtype");
const authType = await authTypeResp?.text() ?? "None";
const userStore = cookieKeyValStore();
const userSession = await userStore.getAll();
if (authType.indexOf("None") < 0 && (userSession["ESPSessionState"] === "false" || userSession["ECLWatchUser"] === "false" || (!userSession["Status"] || userSession["Status"] === "Locked"))) {
if (window.location.hash.indexOf("login") < 0) {
replaceUrl("/login");
import("./components/Frame").then(_ => {
try {
ReactDOM.render(
<_.Frame />,
document.getElementById("placeholder")
);
document.getElementById("loadingOverlay").remove();
} catch (e) {
logger.error(e);
}
import("./components/forms/Login").then(_ => {
try {
ReactDOM.render(
<_.Login />,
document.getElementById("placeholder")
);
document.getElementById("loadingOverlay").remove();
} catch (e) {
logger.error(e);
}
});
} else {
import("./components/Frame").then(_ => {
try {
ReactDOM.render(
<_.Frame />,
document.getElementById("placeholder")
);
document.getElementById("loadingOverlay").remove();
} catch (e) {
logger.error(e);
}
});
}
});
}
});
}
57 changes: 57 additions & 0 deletions esp/src/src/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { format as d3Format } from "@hpcc-js/common";
import { SMCService } from "@hpcc-js/comms";
import { cookieKeyValStore, sessionKeyValStore, userKeyValStore } from "src/KeyValStore";
import { singletonDebounce } from "../src-react/util/throttle";
import { parseSearch } from "../src-react/util/history";
import { ModernMode } from "./BuildInfo";
import * as ESPUtil from "./ESPUtil";
import { scopedLogger } from "@hpcc-js/util";
Expand Down Expand Up @@ -34,6 +35,62 @@ export async function fetchModernMode(): Promise<string> {
});
}

const isV5DirectURL = () => !!parseSearch(window.location.search)?.["Widget"];
const isV9DirectURL = () => window.location.hash && window.location.hash.indexOf("#/stub/") !== 0;

export async function needsRedirectV5(): Promise<boolean> {
if (isV9DirectURL()) {
window.location.replace(`/esp/files/index.html${window.location.hash}`);
return true;
}
if (isV5DirectURL()) {
return false;
}

const v9Mode = await fetchModernMode() === String(true);
if (v9Mode) {
const params = parseSearch(window.location.search);
if (params?.["hpccWidget"] !== "IFrameWidget") {
switch (params?.["hpccWidget"]) {
case "WUDetailsWidget":
window.location.replace(`/esp/files/index.html#/workunits/${params.Wuid}`);
break;
case "GraphsWUWidget":
window.location.replace(`/esp/files/index.html#/workunits/${params.Wuid}/metrics`);
break;
case "TopologyWidget":
case "DiskUsageWidget":
case "TargetClustersQueryWidget":
case "ClusterProcessesQueryWidget":
case "SystemServersQueryWidget":
case "LogWidget":
return false;
default:
window.location.replace("/esp/files/index.html");
}
return true;
}
}
return false;
}

export async function needsRedirectV9(): Promise<boolean> {
if (isV5DirectURL()) {
window.location.replace(`/esp/files/stub.htm${window.location.search}`);
return true;
}
if (isV9DirectURL()) {
return false;
}

const v5Mode = await fetchModernMode() === String(false);
if (v5Mode) {
window.location.replace(`/esp/files/stub.htm${window.location.search}`);
return true;
}
return false;
}

const smc = new SMCService({ baseUrl: "" });

export type BuildInfo = { [key: string]: string };
Expand Down
29 changes: 23 additions & 6 deletions roxie/udplib/udptrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,20 @@ class UdpReceiverEntry : public IUdpReceiverEntry
activeFlowSequence = seq;
return seq;
}

bool hasDataToSend() const
{
return (packetsQueued.load(std::memory_order_relaxed) || (resendList && resendList->numActive()));
}

void setRequestExpiryTime(unsigned newExpiryTime)
{
//requestExpiryTime 0 should only be used if there is no data to send. Ensure it is non zero otherwise.
if (newExpiryTime == 0)
newExpiryTime == 1;
requestExpiryTime.store(newExpiryTime);
}

void sendStart(unsigned packets)
{
UdpRequestToSendMsg msg;
Expand Down Expand Up @@ -326,7 +335,7 @@ class UdpReceiverEntry : public IUdpReceiverEntry
msg.cmd = flowType::request_to_send;
msg.packets = 0;
msg.flowSeq = nextFlowSequence();
requestExpiryTime = msTick() + udpFlowAckTimeout;
setRequestExpiryTime(msTick() + udpFlowAckTimeout);
block.leave();
sendRequest(msg, false);
}
Expand All @@ -339,7 +348,7 @@ class UdpReceiverEntry : public IUdpReceiverEntry

//The flow event is sent on the data socket, so it needs to wait for all the data to be sent before being received
//therefore use the updDataSendTimeout instead of udpFlowAckTimeout
requestExpiryTime = msTick() + updDataSendTimeout;
setRequestExpiryTime(msTick() + updDataSendTimeout);
block.leave();
sendRequest(msg, true);
}
Expand Down Expand Up @@ -367,7 +376,7 @@ class UdpReceiverEntry : public IUdpReceiverEntry
msg.sendSeq = nextSendSequence;
msg.flowSeq = nextFlowSequence();
msg.sourceNode = sourceIP;
requestExpiryTime = msTick() + udpFlowAckTimeout;
setRequestExpiryTime(msTick() + udpFlowAckTimeout);
block.leave();
sendRequest(msg, false);
}
Expand All @@ -394,6 +403,11 @@ class UdpReceiverEntry : public IUdpReceiverEntry
CLeavableCriticalBlock block(activeCrit);
if (maxRequestDeadTimeouts && (timeouts >= maxRequestDeadTimeouts))
{
int timeExpired = msTick()-requestExpiryTime;
StringBuffer s;
EXCLOG(MCoperatorError,"ERROR: UdpSender: too many timeouts - aborting sends. Timed out %i times (flow=%u, max=%i, timeout=%u, expiryTime=%u[%u] ack(%u)) waiting ok_to_send for %u packets from node=%s",
timeouts.load(), activeFlowSequence.load(), maxRequestDeadTimeouts, udpFlowAckTimeout, requestExpiryTime.load(), timeExpired, (int)hadAcknowledgement, packetsQueued.load(), ip.getIpText(s).str());

abort();
return;
}
Expand All @@ -405,7 +419,7 @@ class UdpReceiverEntry : public IUdpReceiverEntry
msg.sendSeq = nextSendSequence;
msg.flowSeq = activeFlowSequence;
msg.sourceNode = sourceIP;
requestExpiryTime = msTick() + udpFlowAckTimeout;
setRequestExpiryTime(msTick() + udpFlowAckTimeout);
block.leave();
sendRequest(msg, false);
}
Expand All @@ -430,7 +444,7 @@ class UdpReceiverEntry : public IUdpReceiverEntry
hadAcknowledgement = true;
CriticalBlock b(activeCrit);
if (requestExpiryTime)
requestExpiryTime = msTick() + udpRequestTimeout; // set a timeout in case an ok_to_send message goes missing
setRequestExpiryTime(msTick() + udpRequestTimeout); // set a timeout in case an ok_to_send message goes missing
}

#ifdef TEST_DROPPED_PACKETS
Expand Down Expand Up @@ -655,8 +669,11 @@ class UdpReceiverEntry : public IUdpReceiverEntry
DBGLOG("UdpSender: abort sending queued data to node=%s", ip.getIpText(s).str());
}
timeouts = 0;
requestExpiryTime = 0;
removeData(nullptr, nullptr);

CriticalBlock block(activeCrit);
if (packetsQueued == 0)
requestExpiryTime = 0;
}

inline void pushData(unsigned queue, DataBuffer *buffer)
Expand Down

0 comments on commit 96875ce

Please sign in to comment.