Skip to content

Commit

Permalink
update blob parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Jan 7, 2024
1 parent 3f9237b commit 290f6d1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
FROM maven:3.8.3-openjdk-8

# Install nodejs for log processing
ENV NVM_DIR /usr/local/nvm
RUN mkdir -p $NVM_DIR
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
ENV NODE_VERSION v20
RUN /bin/bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm use --delete-prefix $NODE_VERSION"
ARG NODE_VERSION=20.10.0
RUN curl https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz | tar -xz -C /usr/local --strip-components 1

WORKDIR /usr/src/parser
ADD . /usr/src/parser
Expand Down
6 changes: 4 additions & 2 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash

#curl localhost:5600 --data-binary "@/datadrive/odota-parser/7355186741_1742953546.dem"
curl localhost:5600 --data-binary "@/datadrive/odota-parser/7437280975_580771917.dem"
#curl localhost:5600 --data-binary "@/datadrive/odota-parser/7437280975_580771917.dem"

#curl localhost:5600/blob?replay_url=http://replay152.valve.net/570/7503212404_1277518156.dem.bz2
curl localhost:5600/blob?replay_url=http://replay152.valve.net/570/7503212404_1277518156.dem.bz2
16 changes: 11 additions & 5 deletions src/main/java/opendota/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,18 @@ public void handle(HttpExchange t) throws IOException {
try {
Map<String, String> query = splitQuery(t.getRequestURI());
URL replayUrl = new URL(query.get("replay_url"));
Runtime run = Runtime.getRuntime();
String[] cmd = new String[]{"bash","-c", String.format("curl --max-time 90 --fail -L %s | %s | curl -X POST -T - localhost:5600 | node processors/createParsedDataBlob.mjs", replayUrl, replayUrl.toString().endsWith(".bz2") ? "bunzip2" : "cat")};

String cmd = String.format("curl --max-time 90 --fail -L %s | %s | curl -X POST --data-binary @- localhost:5600 | node processors/createParsedDataBlob.mjs",
replayUrl,
replayUrl.toString().endsWith(".bz2") ? "bunzip2" : "cat"
);
System.err.println(cmd);
// Download, unzip, parse, aggregate
Process proc = run.exec(cmd);

Process proc = new ProcessBuilder(new String[] {"bash", "-c", cmd})
.start();

// Write error to console (uncomment for debugging but this causes the process not to exit)
// copy(proc.getErrorStream(), System.err);

// Write output to response
copy(proc.getInputStream(), os);
}
Expand Down

0 comments on commit 290f6d1

Please sign in to comment.