/** * Compares this object to the specified object. The result is <code>true</code> if and only if the argument * is not <code>null</code> and is a <code>MutableLong</code> object that contains the same <code>long</code> * value as this object. * * @param obj the object to compare with, null returns false * @return <code>true</code> if the objects are the same; <code>false</code> otherwise. */ public boolean equals(Object obj) { if (obj instanceof MutableLong) { return value == ((MutableLong) obj).longValue(); } return false; }
public CommBufferSizeStats() { commReadBufferSizeBytes = new MutableLong(0); commWriteBufferSizeBytes = new MutableLong(0); }
/** * Sets the value from any Number instance. * * @param value the value to set, not null * @throws NullPointerException if the object is null * @throws ClassCastException if the type is not a {@link Number} */ public void setValue(Object value) { setValue(((Number) value).longValue()); }
/** * Transfers the counters in partitioning. * * @param target target counter * @param source removed counter */ protected void addCounters(BasicCounters<MutableLong> target, BasicCounters<MutableLong> source) { for (Enum<ReaderCounterKeys> key : ReaderCounterKeys.values()) { MutableLong tcounter = target.getCounter(key); if (tcounter == null) { tcounter = new MutableLong(); target.setCounter(key, tcounter); } MutableLong scounter = source.getCounter(key); if (scounter != null) { tcounter.add(scounter.longValue()); } } }
.setMasterKey(ByteString.copyFrom(masterKey)).build(); ledgerIndex.set(ledgerId, ledgerData); MutableLong numberOfEntries = new MutableLong(); lep.getEntries((entryId, location) -> { entryLocationIndex.addLocation(batch, ledgerId, entryId, location); numberOfEntries.increment(); return true; }); batch.close(); return numberOfEntries.longValue();
public void endWindow() { Map<String, Object> summary = new HashMap<String, Object>(); double avg; if (txnsInLastSecond.longValue() == 0) { avg = 0; } else { avg = amtInLastSecond.doubleValue() / txnsInLastSecond.longValue(); } summary.put("totalTxns", totalTxns); summary.put("txnsInLastSecond", txnsInLastSecond); summary.put("amtInLastSecond", amtFormatter.format(amtInLastSecond)); summary.put("avgAmtInLastSecond", amtFormatter.format(avg)); summaryTxnOutputPort.emit(summary); txnsInLastSecond.setValue(0); amtInLastSecond.setValue(0); }
MutableLong size = new MutableLong(); Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { size.add(attrs.size()); } }
private void incrementCounter(K counter) { emitted++; MutableLong ml = counters.get(counter); if (ml == null) { if (counters.size() >= maxCounters) { // no need to store this counter in the map and get() it... just use instance variable tooMany++; } else { // we have never seen this key before, check if its too long if (encoder.apply(counter).length() >= maxCounterKeyLen) { tooLong++; } else { counters.put(copier.apply(counter), new MutableLong(1)); } } } else { // using mutable long allows calling put() to be avoided ml.increment(); } }
private void convertMutations(TabletServerMutations<QCMutation> mutations, Map<Long,CMK> cmidToCm, MutableLong cmid, Map<TKeyExtent,List<TConditionalMutation>> tmutations, CompressedIterators compressedIters) { for (Entry<KeyExtent,List<QCMutation>> entry : mutations.getMutations().entrySet()) { TKeyExtent tke = entry.getKey().toThrift(); ArrayList<TConditionalMutation> tcondMutaions = new ArrayList<>(); List<QCMutation> condMutations = entry.getValue(); for (QCMutation cm : condMutations) { TMutation tm = cm.toThrift(); List<TCondition> conditions = convertConditions(cm, compressedIters); cmidToCm.put(cmid.longValue(), new CMK(entry.getKey(), cm)); TConditionalMutation tcm = new TConditionalMutation(conditions, tm, cmid.longValue()); cmid.increment(); tcondMutaions.add(tcm); } tmutations.put(tke, tcondMutaions); } }
private long updateTimestamps() { MutableLong ts = new MutableLong(Long.MAX_VALUE); for (Attribute<?> attribute : getAttributes()) { mergeTimestamps(attribute, ts); } return ts.longValue(); }
public void incrementKeysSeen(long keys) { keysSeen.add(keys); }
MutableLong globalNumberOfFailures = tempFileCounters.getCounter(FileCounters.GLOBAL_NUMBER_OF_FAILURES); MutableLong globalNumberOfRetries = tempFileCounters.getCounter(FileCounters.GLOBAL_NUMBER_OF_RETRIES); totalLocalProcessedFiles.setValue(0); pendingFiles.setValue(0); totalLocalNumberOfFailures.setValue(0); totalLocalNumberOfRetries.setValue(0); totalLocalProcessedFiles.add(basicFileCounters.getCounter(FileCounters.LOCAL_PROCESSED_FILES)); pendingFiles.add(basicFileCounters.getCounter(FileCounters.PENDING_FILES)); totalLocalNumberOfFailures.add(basicFileCounters.getCounter(FileCounters.LOCAL_NUMBER_OF_FAILURES)); totalLocalNumberOfRetries.add(basicFileCounters.getCounter(FileCounters.LOCAL_NUMBER_OF_RETRIES)); globalProcessedFiles.add(totalLocalProcessedFiles); globalProcessedFiles.subtract(pendingFiles); globalNumberOfFailures.add(totalLocalNumberOfFailures); globalNumberOfRetries.add(totalLocalNumberOfRetries);
totalPendingFiles.addAll(oper.pendingFiles); currentFiles.addAll(unfinishedFiles); tempGlobalNumberOfRetries.add(oper.localNumberOfRetries); tempGlobalNumberOfFailures.add(oper.localNumberOfFailures); if (oper.currentFile != null) { currentFiles.add(new FailedFile(oper.currentFile, oper.offset)); oper.localNumberOfFailures.setValue(0); oper.globalNumberOfRetries = tempGlobalNumberOfFailures; oper.localNumberOfRetries.setValue(0);
/** * Read the block data and emit records based on reader context * * @param blockMetadata * block * @throws IOException */ protected void readBlock(BlockMetadata blockMetadata) throws IOException { readerContext.initialize(stream, blockMetadata, consecutiveBlock); ReaderContext.Entity entity; while ((entity = readerContext.next()) != null) { counters.getCounter(ReaderCounterKeys.BYTES).add(entity.getUsedBytes()); byte[] record = entity.getRecord(); if (record != null) { counters.getCounter(ReaderCounterKeys.RECORDS).increment(); records.emit(record); } } }
@Override public void endWindow() { if (currentWindowId > windowDataManager.getLargestCompletedWindow()) { try { windowDataManager.save(currentWindowRecoveryState, currentWindowId); } catch (IOException e) { throw new RuntimeException("saving recovery", e); } } currentWindowRecoveryState.clear(); if (context != null) { pendingFileCount.setValue(pendingFiles.size() + failedFiles.size() + unfinishedFiles.size()); if (currentFile != null) { pendingFileCount.increment(); } context.setCounters(fileCounters); } }
/** * Helper method for handling IOExceptions. * @param e The caught IOException. */ private void failureHandling(Exception e) { localNumberOfFailures.increment(); if (maxRetryCount <= 0) { throw new RuntimeException(e); } LOG.error("FS reader error", e); addToFailedList(); }
/** * Transfers the counters in partitioning. * * @param target * target counter * @param source * removed counter */ protected void addCounters(BasicCounters<MutableLong> target, BasicCounters<MutableLong> source) { for (Enum<BlockWriter.Counters> key : BlockWriter.Counters.values()) { MutableLong tcounter = target.getCounter(key); if (tcounter == null) { tcounter = new MutableLong(); target.setCounter(key, tcounter); } MutableLong scounter = source.getCounter(key); if (scounter != null) { tcounter.add(scounter.longValue()); } } }
long checkedLedgers = 0; long checkedPages = 0; final MutableLong checkedEntries = new MutableLong(0); final MutableLong pageRetries = new MutableLong(0); NavigableMap<Long, Boolean> bkActiveLedgersSnapshot = activeLedgers.snapshot(); final List<DetectedInconsistency> errors = new ArrayList<>(); checkedEntries.increment(); } catch (EntryLogger.EntryLookupException e) { if (version != lep.getVersion()) { pageRetries.increment(); if (lep.isDeleted()) { LOG.debug("localConsistencyCheck: ledger {} deleted", ledger); checkedLedgers, checkedPages, checkedEntries.longValue(), pageRetries.longValue(), errors.size());