예제 #1
0
파일: OutputCsv.java 프로젝트: araqne/logdb
  private void close() {
    if (flushInterval != null && tickService != null) {
      tickService.removeTimer(flushTimer);
    }

    if (!usePartition) {
      try {
        writer.close();
        if (tmpPath != null) {
          mover.move(tmpPath, pathToken);
        }
      } catch (Throwable t) {
        logger.error("araqne logdb: file move failed", t);
      }
    } else {
      for (PartitionOutput output : outputs.values()) output.close();
    }
  }
예제 #2
0
파일: OutputCsv.java 프로젝트: araqne/logdb
  private void writeLog(Row m) throws IOException {
    LineWriter writer = this.writer;
    if (usePartition) {
      List<String> key = new ArrayList<String>(holders.size());
      Date date = m.getDate();
      for (PartitionPlaceholder holder : holders) key.add(holder.getKey(date));

      PartitionOutput output = outputs.get(key);
      if (output == null) {
        output = new PartitionOutput(writerFactory, pathToken, tmpPath, date, encoding, overwrite);
        outputs.put(key, output);

        if (logger.isDebugEnabled())
          logger.debug(
              "araqne logdb: new partition found key [{}] tmpPath [{}] filePath [{}] date [{}]",
              new Object[] {key, tmpPath, pathToken, date});
      }

      writer = output.getWriter();
    }

    writer.write(m);
  }