private void advanceCounter(long nextCount) { long deltaCount = nextCount - lastCount; if (deltaCount > 0) { counter.add(deltaCount); lastCount = nextCount; } }
private void advanceCounter() { double last = lastBytes; double next = last + averageBytesPerRecord; long delta = (long) (next - last); if (delta >= 0L) { counter.add(delta); } lastBytes = next; }
@Override public int read() throws IOException { int read = target.read(); if (read > 0) { counter.add(1); } return read; }
@Override public void write(byte[] b) throws IOException { stream.write(b); counter.add(b.length); }
@Override public int read(byte[] b) throws IOException { int read = target.read(b); if (read > 0) { counter.add(read); } return read; }
@Override public void write(byte[] b, int off, int len) throws IOException { stream.write(b, off, len); counter.add(len); }
@Override public int read(byte[] b, int off, int len) throws IOException { int read = target.read(b, off, len); if (read > 0) { counter.add(read); } return read; }
@Override public void write(int b) throws IOException { stream.write(b); counter.add(1); }
void keepAlive() { if (interval <= 0) { return; } try { while (true) { if (LOG.isDebugEnabled() && counters.isEmpty() == false) { LOG.debug(MessageFormat.format( "Heartbeat by HearbeatKeeper: {1}counter(s) ({0})", //$NON-NLS-1$ Thread.currentThread().getName(), counters.size())); } for (Counter counter : counters) { counter.add(0); } Thread.sleep(interval); } } catch (InterruptedException e) { LOG.info(MessageFormat.format( "Direct I/O KeepAlive Thread is going to shut down: {1}counter(s) ({0})", Thread.currentThread().getName(), counters.size())); } }
/** * Registers a counter into this keeper. * @param counter target counter * @throws IllegalArgumentException if some parameters were {@code null} */ public void register(Counter counter) { if (counter == null) { throw new IllegalArgumentException("counter must not be null"); //$NON-NLS-1$ } counter.add(0); counters.add(counter); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Registered counter: {2} ({0}@{1})", //$NON-NLS-1$ daemon.getName(), daemon.getState(), counter)); } synchronized (daemon) { if (daemon.getState() == State.NEW) { if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Starting Heartbeat Keeper: {0})", daemon.getName())); } daemon.start(); } } }
private static void moveSerial( Counter counter, FileSystem fromFs, FileSystem toFs, Path source, Path target, List<Path> list, boolean fromLocal) throws IOException { Set<Path> directoryCreated = new HashSet<>(); for (Path path : list) { Path sourceFile = new Path(source, path); Path targetFile = new Path(target, path); if (LOG.isTraceEnabled()) { FileStatus stat = fromFs.getFileStatus(sourceFile); LOG.trace(MessageFormat.format( "Moving file (from={0}, to={1}, size={2})", //$NON-NLS-1$ sourceFile, targetFile, stat.getLen())); } prepareTarget(toFs, targetFile, directoryCreated); counter.add(1); moveFile(toFs, sourceFile, targetFile, fromLocal); counter.add(1); } }
@Override public void write(T model) throws IOException { Writer writer = prepare(); writer.addRow(model); // not sure counter.add(1); }
@Override public void write(T model) throws IOException { ParquetWriter<T> writer = prepareWriter(); writer.write(model); // not sure counter.add(1); }
private static void moveParallel( Counter counter, FileSystem fromFs, FileSystem toFs, Path source, Path target, List<Path> list, boolean fromLocal, ExecutorService executor) throws IOException, InterruptedException { prepareParallel(counter, toFs, target, list, executor); parallel(executor, list.stream() .map(path -> (Callable<?>) () -> { Path sourceFile = new Path(source, path); Path targetFile = new Path(target, path); if (LOG.isTraceEnabled()) { FileStatus stat = fromFs.getFileStatus(sourceFile); LOG.trace(MessageFormat.format( "moving file (from={0}, to={1}, size={2})", //$NON-NLS-1$ sourceFile, targetFile, stat.getLen())); } moveFile(toFs, sourceFile, targetFile, fromLocal); counter.add(1); return null; }) .collect(Collectors.toList())); }
@Override public void write(T model) throws IOException { copyFromModel(model, keyBuffer, valueBuffer); writer.append(keyBuffer, valueBuffer); long nextPosition = writer.getLength(); counter.add(nextPosition - lastPosition); lastPosition = nextPosition; }
containerPath)).initCause(e); context.getCounter().add(1);
containerPath)).initCause(e); context.getCounter().add(1);
containerPath)).initCause(e); context.getCounter().add(1);
counter.add(1); ResourceInfo resource = new ResourceInfo( profile.getId(),
@Override public boolean readTo(T model) throws IOException { if (next == false) { return false; } long current = reader.getPosition(); @SuppressWarnings("unchecked") K key = (K) reader.next(keyBuffer); if (key == null || (current >= end && reader.syncSeen())) { next = false; return false; } else { reader.getCurrentValue(valueBuffer); SequenceFileFormat.this.copyToModel(keyBuffer, valueBuffer, model); long nextPosition = reader.getPosition(); counter.add(nextPosition - lastPosition); lastPosition = nextPosition; return true; } }