Skip to content

Commit

Permalink
Call TSP endpoint to close an experiment when closing it in the UI
Browse files Browse the repository at this point in the history
With this it's possible to close an experiment on the server. Upon
reception of the command the server can dispose allocated resources
hence the client doesn't need them anymore.

This change follows the TSP update provided by:
eclipse-cdt-cloud/trace-server-protocol#95

Fixes #1024

Signed-off-by: Bernd Hufmann <[email protected]>
  • Loading branch information
bhufmann committed Nov 2, 2023
1 parent 7495999 commit f7e6c49
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/base/src/experiment-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ export class ExperimentManager {
return undefined;
}

/**
* Close the given experiment from the server
* @param experimentUUID experiment UUID
*/
async closeExperiment(experimentUUID: string): Promise<void> {
const experimentToDelete = this.fOpenExperiments.get(experimentUUID);
if (experimentToDelete) {
await this.fTspClient.closeExperiment(experimentUUID);

Check failure on line 131 in packages/base/src/experiment-manager.ts

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest, 16.x)

Property 'closeExperiment' does not exist on type 'ITspClient'.
}
}

/**
* Delete the given experiment from the server
* @param experimentUUID experiment UUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ export class TheiaRpcTspProxy implements ITspClient {
return this.toTspClientResponse<Experiment>(await this.tspClient.updateExperiment(expUUID, parameters));
}

/**
* Close an experiment
* @param expUUID Experiment UUID to close
* @returns The closed experiment
*/
public async closeExperiment(expUUID: string): Promise<TspClientResponse<Experiment>> {
return this.toTspClientResponse<Experiment>(await this.tspClient.closeExperiment(expUUID));
}

/**
* Delete an experiment on the server
* @param expUUID Experiment UUID to delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ export class TraceExplorerOpenedTracesWidget extends ReactWidget {

public closeExperiment(traceUUID: string): void {
signalManager().fireCloseTraceViewerTabSignal(traceUUID);
this._experimentManager.closeExperiment(traceUUID);
}

public deleteExperiment(traceUUID: string): void {
this._experimentManager.deleteExperiment(traceUUID);
this.closeExperiment(traceUUID);
this._experimentManager.deleteExperiment(traceUUID);
}

render(): React.ReactNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ export class TraceViewerWidget extends ReactWidget implements StatefulWidget {
super.onCloseRequest(msg);
if (this.openedExperiment) {
signalManager().fireExperimentClosedSignal(this.openedExperiment);
this.experimentManager.closeExperiment(this.openedExperiment.UUID);
}
}

Expand Down

0 comments on commit f7e6c49

Please sign in to comment.