Esempio n. 1
0
  public static void main(final String[] args) {

    final ClientRunner clientRunner =
        new ClientRunner(args) {
          @Override
          public void runClient(final String[] args) throws Exception {

            final Parameters parameters = new Parameters();
            parameters.parse(args, TilePairClient.class);

            File toFile = new File(parameters.toJson).getAbsoluteFile();
            if (!toFile.exists()) {
              toFile = toFile.getParentFile();
            }

            if (!toFile.canWrite()) {
              throw new IllegalArgumentException("cannot write to " + toFile.getAbsolutePath());
            }

            LOG.info("runClient: entry, parameters={}", parameters);

            final TilePairClient client = new TilePairClient(parameters);

            // TODO: consider splitting up into multiple pair files for large z ranges

            final List<OrderedCanvasIdPair> neighborPairs = client.getSortedNeighborPairs();
            final RenderableCanvasIdPairs renderableCanvasIdPairs =
                new RenderableCanvasIdPairs(client.getRenderParametersUrlTemplate(), neighborPairs);
            FileUtil.saveJsonFile(parameters.toJson, renderableCanvasIdPairs);
          }
        };
    clientRunner.run();
  }
Esempio n. 2
0
 /**
  * Submit a task
  *
  * @param taskRunner
  */
 public void submitTaskRunner(DbTaskRunner taskRunner) {
   if (isRunning || !Configuration.configuration.isShutdown()) {
     if (threadPoolExecutor.getActiveCount() > Configuration.configuration.getRUNNER_THREAD()) {
       // too many current active threads
       taskRunner.changeUpdatedInfo(UpdatedInfo.TOSUBMIT);
       taskRunner.forceSaveStatus();
       return;
     }
     logger.debug("Will run {}", taskRunner);
     ClientRunner runner = new ClientRunner(networkTransaction, taskRunner, null);
     if (taskRunner.isSendThrough()
         && (taskRunner.isRescheduledTransfer() || taskRunner.isPreTaskStarting())) {
       runner.setSendThroughMode();
       taskRunner.checkThroughMode();
     }
     runner.setDaemon(true);
     // create the client, connect and run
     threadPoolExecutor.execute(runner);
     runner = null;
   }
 }