mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-16 17:25:58 +00:00
Always schedule memory call (#1231)
* Always schedule memory call * Memory heart beat issue-fix Co-authored-by: kcheekuri <kcheekuri@microsoft.com>
This commit is contained in:
parent
0a51e24b94
commit
7a809cd2bc
@ -19,6 +19,7 @@ export class NotebookContainerClient {
|
|||||||
private isResettingWorkspace: boolean;
|
private isResettingWorkspace: boolean;
|
||||||
private phoenixClient: PhoenixClient;
|
private phoenixClient: PhoenixClient;
|
||||||
private retryOptions: promiseRetry.Options;
|
private retryOptions: promiseRetry.Options;
|
||||||
|
private scheduleTimerId: NodeJS.Timeout;
|
||||||
|
|
||||||
constructor(private onConnectionLost: () => void) {
|
constructor(private onConnectionLost: () => void) {
|
||||||
this.phoenixClient = new PhoenixClient();
|
this.phoenixClient = new PhoenixClient();
|
||||||
@ -27,34 +28,34 @@ export class NotebookContainerClient {
|
|||||||
maxTimeout: Notebook.retryAttemptDelayMs,
|
maxTimeout: Notebook.retryAttemptDelayMs,
|
||||||
minTimeout: Notebook.retryAttemptDelayMs,
|
minTimeout: Notebook.retryAttemptDelayMs,
|
||||||
};
|
};
|
||||||
const notebookServerInfo = useNotebook.getState().notebookServerInfo;
|
|
||||||
if (notebookServerInfo?.notebookServerEndpoint) {
|
this.initHeartbeat(Constants.Notebook.heartbeatDelayMs);
|
||||||
this.scheduleHeartbeat(Constants.Notebook.heartbeatDelayMs);
|
|
||||||
} else {
|
|
||||||
const unsub = useNotebook.subscribe(
|
|
||||||
(newServerInfo: DataModels.NotebookWorkspaceConnectionInfo) => {
|
|
||||||
if (newServerInfo?.notebookServerEndpoint) {
|
|
||||||
this.scheduleHeartbeat(Constants.Notebook.heartbeatDelayMs);
|
|
||||||
}
|
|
||||||
unsub();
|
|
||||||
},
|
|
||||||
(state) => state.notebookServerInfo
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private initHeartbeat(delayMs: number): void {
|
||||||
* Heartbeat: each ping schedules another ping
|
this.scheduleHeartbeat(delayMs);
|
||||||
*/
|
|
||||||
private scheduleHeartbeat(delayMs: number): void {
|
useNotebook.subscribe(
|
||||||
setTimeout(async () => {
|
() => this.scheduleHeartbeat(delayMs),
|
||||||
const memoryUsageInfo = await this.getMemoryUsage();
|
(state) => state.notebookServerInfo
|
||||||
useNotebook.getState().setMemoryUsageInfo(memoryUsageInfo);
|
);
|
||||||
const notebookServerInfo = useNotebook.getState().notebookServerInfo;
|
}
|
||||||
if (notebookServerInfo?.notebookServerEndpoint) {
|
|
||||||
this.scheduleHeartbeat(Constants.Notebook.heartbeatDelayMs);
|
private scheduleHeartbeat(delayMs: number) {
|
||||||
}
|
if (this.scheduleTimerId) {
|
||||||
}, delayMs);
|
clearInterval(this.scheduleTimerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const notebookServerInfo = useNotebook.getState().notebookServerInfo;
|
||||||
|
if (notebookServerInfo?.notebookServerEndpoint) {
|
||||||
|
this.scheduleTimerId = setInterval(async () => {
|
||||||
|
const notebookServerInfo = useNotebook.getState().notebookServerInfo;
|
||||||
|
if (notebookServerInfo?.notebookServerEndpoint) {
|
||||||
|
const memoryUsageInfo = await this.getMemoryUsage();
|
||||||
|
useNotebook.getState().setMemoryUsageInfo(memoryUsageInfo);
|
||||||
|
}
|
||||||
|
}, delayMs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getMemoryUsage(): Promise<DataModels.MemoryUsageInfo> {
|
public async getMemoryUsage(): Promise<DataModels.MemoryUsageInfo> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user