summaryrefslogtreecommitdiffstats
path: root/jack-server
diff options
context:
space:
mode:
authorJean-Philippe Lesot <jplesot@google.com>2015-04-01 14:40:08 +0200
committerJean-Philippe Lesot <jplesot@google.com>2015-04-01 14:40:08 +0200
commit98efb7bb82b1a2a3c5ada01c7b2265ecf408db82 (patch)
tree02dbc72446bf43d4a6bc70c0c357e0978bc51a68 /jack-server
parent8d3de6f6064425abbd66232fbf51d91838e5ab65 (diff)
downloadtoolchain_jack-98efb7bb82b1a2a3c5ada01c7b2265ecf408db82.tar.gz
toolchain_jack-98efb7bb82b1a2a3c5ada01c7b2265ecf408db82.tar.bz2
toolchain_jack-98efb7bb82b1a2a3c5ada01c7b2265ecf408db82.zip
Rework finally in Jack simple server, add a retry counter in script
Change-Id: Id9a8a08e27d923a347cc18fb2b861c1963f3f858
Diffstat (limited to 'jack-server')
-rw-r--r--jack-server/src/com/android/jack/server/JackSimpleServer.java130
1 files changed, 65 insertions, 65 deletions
diff --git a/jack-server/src/com/android/jack/server/JackSimpleServer.java b/jack-server/src/com/android/jack/server/JackSimpleServer.java
index baca0d1c..fa2184ce 100644
--- a/jack-server/src/com/android/jack/server/JackSimpleServer.java
+++ b/jack-server/src/com/android/jack/server/JackSimpleServer.java
@@ -87,7 +87,6 @@ import javax.annotation.Nonnull;
* Server controlling the number of Jack compilations that are executed simultaneously.
*/
public class JackSimpleServer {
-
static {
// It seems that loggers must be created from parents to children to have the loggers
// correctly initialized. Thus load the initial configuration that define specific level
@@ -97,7 +96,6 @@ public class JackSimpleServer {
LoggerFactory.loadLoggerConfiguration(JackSimpleServer.class, "/initial.logging.properties");
}
-
@Nonnull
private static Logger logger = Logger.getLogger(JackSimpleServer.class.getName());
@@ -305,8 +303,8 @@ public class JackSimpleServer {
if (currentLocal == 0) {
cancelTimer();
}
+
currentLocal++;
- logger.log(Level.INFO, "Number of concurrent compilations: " + currentLocal);
if (currentLocal > maxLocal) {
maxLocal = currentLocal;
}
@@ -330,79 +328,81 @@ public class JackSimpleServer {
return;
}
- logger.log(Level.INFO, "Open standard output '" + command[CMD_IDX_OUT] + "'");
- try {
- out = new FifoStreamFile(command[CMD_IDX_OUT]).getPrintStream(10000);
- } catch (IOException | TimeoutException e) {
- logger.log(Level.SEVERE, e.getMessage());
- response.setStatus(Status.BAD_REQUEST);
- return;
- }
-
- logger.log(Level.INFO, "Open standard error '" + command[CMD_IDX_ERR] + "'");
- try {
- err = new FifoStreamFile(command[CMD_IDX_ERR]).getPrintStream(10000);
- } catch (IOException | TimeoutException e) {
- logger.log(Level.SEVERE, e.getMessage());
- response.setStatus(Status.BAD_REQUEST);
- return;
- }
-
- logger.log(Level.INFO, "Parse command line");
- TokenIterator args = new TokenIterator(new NoLocation(), "@" + command[CMD_IDX_CLI]);
- args.allowFileReferenceInFile();
- if (!args.hasNext()) {
- logger.log(Level.SEVERE, "Cli format error");
- response.setStatus(Status.BAD_REQUEST);
- return;
- }
-
- String workingDir;
try {
- workingDir = args.next();
- } catch (IOException e) {
- logger.log(Level.SEVERE, "Cli format error");
- response.setStatus(Status.BAD_REQUEST);
- return;
- }
+ logger.log(Level.INFO, "Open standard output '" + command[CMD_IDX_OUT] + "'");
+ try {
+ out = new FifoStreamFile(command[CMD_IDX_OUT]).getPrintStream(10000);
+ } catch (IOException | TimeoutException e) {
+ logger.log(Level.SEVERE, e.getMessage());
+ response.setStatus(Status.BAD_REQUEST);
+ return;
+ }
- int code = -1;
- long start = System.currentTimeMillis();
- try {
- logger.log(Level.INFO, "Run Compilation #" + id);
- start = System.currentTimeMillis();
- code = service.run(out, err, new File(workingDir), args);
- } finally {
- long stop = System.currentTimeMillis();
- logger.log(Level.INFO, "Compilation #" + id + " return exit code " + code);
- logger.log(Level.INFO, "Compilation #" + id + " run in " + (stop - start) + " ms");
+ logger.log(Level.INFO, "Open standard error '" + command[CMD_IDX_ERR] + "'");
+ try {
+ err = new FifoStreamFile(command[CMD_IDX_ERR]).getPrintStream(10000);
+ } catch (IOException | TimeoutException e) {
+ logger.log(Level.SEVERE, e.getMessage());
+ response.setStatus(Status.BAD_REQUEST);
+ return;
+ }
- response.setStatus(Status.OK);
+ logger.log(Level.INFO, "Parse command line");
+ TokenIterator args = new TokenIterator(new NoLocation(), "@" + command[CMD_IDX_CLI]);
+ args.allowFileReferenceInFile();
+ if (!args.hasNext()) {
+ logger.log(Level.SEVERE, "Cli format error");
+ response.setStatus(Status.BAD_REQUEST);
+ return;
+ }
- PrintStream printer;
+ String workingDir;
try {
- printer = response.getPrintStream();
- printer.println(code);
- printer.close();
+ workingDir = args.next();
} catch (IOException e) {
- logger.log(Level.SEVERE, "Problem to send exit code for compilation #" + id);
+ logger.log(Level.SEVERE, "Cli format error");
response.setStatus(Status.BAD_REQUEST);
return;
}
- }
- } finally {
- if (out != null) {
- out.close();
- } else {
- unblock(command[CMD_IDX_OUT]);
- }
- if (err != null) {
- err.close();
- } else {
- unblock(command[CMD_IDX_ERR]);
- }
+ int code = -1;
+ long start = System.currentTimeMillis();
+ try {
+ logger.log(Level.INFO, "Run Compilation #" + id);
+ start = System.currentTimeMillis();
+ code = service.run(out, err, new File(workingDir), args);
+ } finally {
+ long stop = System.currentTimeMillis();
+ logger.log(Level.INFO, "Compilation #" + id + " return exit code " + code);
+ logger.log(Level.INFO, "Compilation #" + id + " run in " + (stop - start) + " ms");
+
+ response.setStatus(Status.OK);
+
+ PrintStream printer;
+ try {
+ printer = response.getPrintStream();
+ printer.println(code);
+ printer.close();
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, "Problem to send exit code for compilation #" + id);
+ response.setStatus(Status.BAD_REQUEST);
+ return;
+ }
+ }
+ } finally {
+ if (out != null) {
+ out.close();
+ } else {
+ unblock(command[CMD_IDX_OUT]);
+ }
+ if (err != null) {
+ err.close();
+ } else {
+ unblock(command[CMD_IDX_ERR]);
+ }
+ }
+ } finally {
lock.lock();
try {
currentLocal--;