Skip to content

Commit

Permalink
Adding internal endpoint to enable manual cleanup on codespace-level
Browse files Browse the repository at this point in the history
  • Loading branch information
lassetyr committed Feb 6, 2025
1 parent 5bbd58e commit 5e02da3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ public void flushDataFromSubscription(String subscriptionId) {
}
}

protected void flushDataFromCodespace(String codespaceId, String dataType) {
ExecutorService executor = Executors.newSingleThreadExecutor();
if (codespaceId != null && dataType != null) {
executor.execute(() -> flushData(codespaceId, dataType));
}
}

public JSONObject getSituationMetadataAsJson(String codespaceId) {
Collection<PtSituationElement> allSituations = situations.getAll(codespaceId);
JSONArray situations = new JSONArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public void configure() throws Exception {
.put("").to(OPERATION_ROUTE)
.get("/locks").to("direct:locks")
.get("/prepare-shutdown").to("direct:prepare-shutdown")
.delete("/flush-dataset").to("direct:flush.data.from.codespace")
.delete("/unmapped/{datasetId}").to("direct:clear-unmapped")
;

Expand Down Expand Up @@ -323,6 +324,17 @@ public void configure() throws Exception {
.to("direct:internal.flush.data.from.subscription")
;


//Return subscription status
from("direct:flush.data.from.codespace")
.log("Triggered deletion of all data of type ${header.dataType} from codespace ${header.codespaceId}")
.process(p -> {
String codespaceId = p.getIn().getHeader("codespaceId", String.class);
String dataType = p.getIn().getHeader("dataType", String.class);
helper.flushDataFromCodespace(codespaceId, dataType);
})
;

//Return subscription status
from("direct:validate.all.subscriptions")
.process(basicAuthProcessor)
Expand Down

0 comments on commit 5e02da3

Please sign in to comment.