/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
@Override public void read(final DataInput dis, final MutableLong x) throws IOException { byte b = dis.readByte(); long t = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = dis.readByte(); t |= (b & 0x7FL) << shift; } x.setValue(t); } }, new MutableLong());
public void success() { waitTime.get().setValue(0); } public void failure() {
public void success() { waitTime.get().setValue(0); } public void failure() {
protected void resetExpirationTimeSuggestion() { expirationTimeSuggestion.setValue(System.currentTimeMillis() + getMaxInactiveIntervalMillis()); }
private void processTuple(KeyValPair<MerchantKey, String> tuple, Integer count) { MerchantKey key = tuple.getKey(); Map<String, BankIdNumData> map = bankIdNumCountMap.get(key); if (map == null) { map = new HashMap<String, BankIdNumData>(); bankIdNumCountMap.put(key, map); } String bankIdNum = tuple.getValue(); BankIdNumData bankIdNumData = map.get(bankIdNum); if (bankIdNumData == null) { bankIdNumData = new BankIdNumData(); bankIdNumData.bankIdNum = bankIdNum; map.put(bankIdNum, bankIdNumData); } bankIdNumData.count.setValue(count); if (key.userGenerated) { bankIdNumData.userGenerated = true; } }
public void failure() { long current = waitTime.get().intValue(); if(current == 0) { current=minTime; } else if(current < maxTime) { current = (long) (current * rate); } waitTime.get().setValue(Math.min(current, maxTime)); }
public void failure() { long current = waitTime.get().intValue(); if(current == 0) { current=minTime; } else if(current < maxTime) { current = (long) (current * rate); } waitTime.get().setValue(Math.min(current, maxTime)); }
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); }
@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); } }
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);
@Override public void setup(OperatorContext context) { operatorId = context.getId(); globalProcessedFileCount.setValue(processedFiles.size()); LOG.debug("Setup processed file count: {}", globalProcessedFileCount); this.context = context; try { filePath = new Path(directory); configuration = new Configuration(); fs = getFSInstance(); } catch (IOException ex) { failureHandling(ex); } fileCounters.setCounter(FileCounters.GLOBAL_PROCESSED_FILES, globalProcessedFileCount); fileCounters.setCounter(FileCounters.LOCAL_PROCESSED_FILES, localProcessedFileCount); fileCounters.setCounter(FileCounters.GLOBAL_NUMBER_OF_FAILURES, globalNumberOfFailures); fileCounters.setCounter(FileCounters.LOCAL_NUMBER_OF_FAILURES, localNumberOfFailures); fileCounters.setCounter(FileCounters.GLOBAL_NUMBER_OF_RETRIES, globalNumberOfRetries); fileCounters.setCounter(FileCounters.LOCAL_NUMBER_OF_RETRIES, localNumberOfRetries); fileCounters.setCounter(FileCounters.PENDING_FILES, pendingFileCount); windowDataManager.setup(context); if (context.getValue(OperatorContext.ACTIVATION_WINDOW_ID) < windowDataManager.getLargestCompletedWindow()) { //reset current file and offset in case of replay currentFile = null; offset = 0; } }
private Option<E> readAndCheck(long address, MutableLong nextElementStart) throws IOException { if (address+4 > memory.length()) { throw new ConsistencyException("not enough bytes in file"); } final int length = memory.getInt(address); if (length < 0) { return Option.none(); } if (address+8 > memory.length()) { throw new ConsistencyException("not enough bytes in file"); } if (address+8+length > memory.length()) { throw new ConsistencyException("not enough bytes in file"); } final int checksum = memory.getInt(address+4); MemoryDataInput in = new MemoryDataInput(memory); in.seek(address+8); CRC32 crc32 = new CRC32(); crc32.update(CRC_SEED); byte[] bytes = new byte[length]; in.readFully(bytes); crc32.update(bytes); if ((int)crc32.getValue() != checksum) { throw new ConsistencyException("checksum for record does not match: expected "+checksum+" actual "+(int)crc32.getValue()); } E ret = serializer.read(ByteStreams.newDataInput(bytes)); if (nextElementStart != null) nextElementStart.setValue(address+8+length); return Option.some(ret); }
private Option<E> readAndCheck(long address, MutableLong nextElementStart) throws IOException { if (address+4 > memory.length()) { throw new ConsistencyException("not enough bytes in file"); } final int length = memory.getInt(address); if (length < 0) { return Option.none(); } if (address+8 > memory.length()) { throw new ConsistencyException("not enough bytes in file"); } if (address+8+length > memory.length()) { throw new ConsistencyException("not enough bytes in file"); } final int checksum = memory.getInt(address+4); MemoryDataInput in = new MemoryDataInput(memory); in.seek(address+8); CRC32 crc32 = new CRC32(); crc32.update(CRC_SEED); byte[] bytes = new byte[length]; in.readFully(bytes); crc32.update(bytes); if ((int)crc32.getValue() != checksum) { throw new ConsistencyException("checksum for record does not match: expected "+checksum+" actual "+(int)crc32.getValue()); } E ret = serializer.read(ByteStreams.newDataInput(bytes)); if (nextElementStart != null) nextElementStart.setValue(address+8+length); return Option.some(ret); }