Skip to content

Commit

Permalink
idk
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sikina committed Jan 5, 2024
1 parent fb6ece9 commit 358df56
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,23 +272,21 @@ public Response writeQueryResult(
.status(400, "The write endpoint only writes time series dataframes. Fix result type.")
.build();
}
// query IDs within HPDS are a different concept that query IDs in PIC-SURE
// Generally, equivalent queries with different PIC-SURE query IDs will have the SAME
// HPDS query ID.
queryDecorator.setId(query);

String hpdsQueryID;
try {
String status = convertToQueryStatus(queryService.runQuery(query)).getResourceStatus();
while ("RUNNING".equalsIgnoreCase(status) || "PENDING".equalsIgnoreCase(status)) {
QueryStatus queryStatus = convertToQueryStatus(queryService.runQuery(query));
String status = queryStatus.getResourceStatus();
hpdsQueryID = queryStatus.getResourceResultId();
while ("RUNNING".equalsIgnoreCase(status) || "PENDING".equalsIgnoreCase(status)) {
Thread.sleep(10000); // Yea, this is not restful. Sorry.
status = convertToQueryStatus(queryService.getStatusFor(query.getId())).getResourceStatus();
status = convertToQueryStatus(queryService.getStatusFor(hpdsQueryID)).getResourceStatus();
}
} catch (ClassNotFoundException | IOException | InterruptedException e) {
log.warn("Error waiting for response", e);
return Response.serverError().build();
}

AsyncResult result = queryService.getResultFor(query.getId());
AsyncResult result = queryService.getResultFor(hpdsQueryID);
// the queryResult has this DIY retry logic that blocks a system thread.
// I'm not going to do that here. If the service can't find it, you get a 404.
// Retry it client side.
Expand Down

0 comments on commit 358df56

Please sign in to comment.