Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion deploy/java-library/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ candidates=$(docker exec "$neo2" cypher-shell -u neo4j -p fixturepass -d graph.d
RETURN kind + " " + e.stId + " " + e.dbId + " " + replace(e.speciesName, " ", "_")
ORDER BY kind, e.dbId' | tail -n +2 | tr -d '"')
events=$(while read -r kind id dbid species; do
grep -q ">$dbid</bp:id>" "$bci/fixture/expected/$species.owl" && echo "$kind $id $dbid $species"
# The event's own database-id xref, whose comment ends with its id: not any
# numeric id (a PubMed id) that happens to match. An if, not &&: under
# pipefail a last candidate not in its file would end the script silently.
if grep -q "&amp;ID=$dbid</bp:comment>" "$bci/fixture/expected/$species.owl"; then
echo "$kind $id $dbid $species"
fi
done <<<"$candidates" | sort -u -k1,1 | cut -d' ' -f2-)
[ "$(printf '%s\n' "$events" | wc -l)" -eq 5 ] || { echo "Expected one event of each of five kinds in the fixture's files, got: $events" >&2; exit 1; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public DiagramUnavailable(String message, Throwable cause) {
}

private static final Logger logger = LoggerFactory.getLogger(ExportFiles.class);
private static final java.util.regex.Pattern OLD_WORK =
java.util.regex.Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}");

private final String kind;
private final String extension;
Expand All @@ -100,8 +102,16 @@ public ExportFiles(String kind, String extension, Graph graph, Converter convert
this.diagrams = diagrams;
this.cache = cache;
this.conversions = conversions;
// Work in progress when the service last stopped, which nothing will finish
// Work in progress when the service last stopped, which nothing will finish: this export's, and any left
// in the layout before exports had a folder each (cache/tmp/{uuid})
delete(work());
try (DirectoryStream<Path> left = Files.newDirectoryStream(cache.resolve("tmp"))) {
for (Path old : left) {
if (OLD_WORK.matcher(old.getFileName().toString()).matches()) delete(old);
}
} catch (IOException e) {
// No tmp folder yet, or none readable: nothing to clear
}
}

private Path work() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ public Optional<ExportFiles.Event> event(String stId) {
};
}

/** The conversions at once, across every export: two, within the heap (spec 015 T069). */
/**
* The conversions at once, across every export: two, within the heap (spec 015 T069). Fair, so a request
* waiting for a place is not overtaken by later ones of the other export.
*/
@Bean
public Semaphore conversions() {
return new Semaphore(2);
return new Semaphore(2, true);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ void workLeftByAStoppedServiceIsRemoved() throws Exception {
assertTrue(Files.exists(others));
}

@Test
void workLeftInTheLayoutBeforeExportsHadFoldersIsRemoved() throws Exception {
Path old = Files.createDirectories(cache.resolve("tmp/0f8fad5b-d9cb-469f-a165-70867728950e"));
Files.writeString(old.resolve("R-HSA-2.sbml"), "<sbml");
Path others = Files.createDirectories(cache.resolve("tmp/biopax"));
sbml(converter, diagrams);
assertFalse(Files.exists(old));
assertTrue(Files.exists(others));
}

@Test
void aNewReleaseIsNeverAnsweredFromTheOldOnesFiles() throws Exception {
ExportFiles files = sbml(converter, diagrams);
Expand Down
4 changes: 3 additions & 1 deletion tools/content-node/exporters-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ async function exportEvent(raw: string): Promise<ExportEvent | null> {
* deep pool, so a burst of exports cannot starve the queries the pages need,
* and from each other, so one export cannot take the other's places here. The
* service converts two at once across both (spec 015 T069), for its heap: a
* BioPAX file may wait there behind two SBML ones, within the headers' time.
* BioPAX file may wait there behind two SBML ones, and past the headers' time
* at the worst (T069 measured 300–310 s): the reader then gets the 503 below,
* and the service, finishing, keeps the file for the next request.
*/
const SBML_SHARE = deepShare(2);
const BIOPAX_SHARE = deepShare(2);
Expand Down
Loading