public static void incCounter(Counter counter) { if (counter != null) { counter.inc(); } }
@Override public void onBarrierError(String version, Throwable t) { LOG.error("Encountered error while attaining consensus on JobModel version " + version); metrics.barrierError.inc(); stop(); } }
/** * Updates the MetricsRegistery of this operator * @param startProcessing = begin processing of the message * @param endProcessing = end of processing */ private void updateMetrics(Instant startProcessing, Instant endProcessing) { queryInputEvents.inc(); processingTime.update(Duration.between(startProcessing, endProcessing).toMillis()); }
public void incNumEvents(SystemStreamPartition systemStreamPartition) { if (!numEventsCounterMap.containsKey(systemStreamPartition)) { registerSystemStreamPartition(systemStreamPartition); } numEventsCounterMap.get(systemStreamPartition).inc(); }
/** * update metrics given a message * @param message the input message * @return the same message */ @Override public SamzaSqlRelMessage apply(SamzaSqlRelMessage message) { inputEvents.inc(); message.getSamzaSqlRelMsgMetadata().operatorBeginProcessingInstant = Instant.now().toString(); return message; }
public void connect() throws ZkInterruptedException { boolean isConnected = zkClient.waitUntilConnected(connectionTimeoutMs, TimeUnit.MILLISECONDS); if (!isConnected) { metrics.zkConnectionError.inc(); throw new RuntimeException("Unable to connect to Zookeeper within connectionTimeout " + connectionTimeoutMs + "ms. Shutting down!"); } }
@Override public void onBarrierError(String version, Throwable t) { LOG.error("Encountered error while attaining consensus on JobModel version " + version); metrics.barrierError.inc(); stop(); } }
public void connect() throws ZkInterruptedException { boolean isConnected = zkClient.waitUntilConnected(connectionTimeoutMs, TimeUnit.MILLISECONDS); if (!isConnected) { metrics.zkConnectionError.inc(); throw new RuntimeException("Unable to connect to Zookeeper within connectionTimeout " + connectionTimeoutMs + "ms. Shutting down!"); } }
public void connect() throws ZkInterruptedException { boolean isConnected = zkClient.waitUntilConnected(connectionTimeoutMs, TimeUnit.MILLISECONDS); if (!isConnected) { metrics.zkConnectionError.inc(); throw new RuntimeException("Unable to connect to Zookeeper within connectionTimeout " + connectionTimeoutMs + "ms. Shutting down!"); } }
public void updateMetrics(String stream, Record record) { eventReadRates.get(stream).inc(); aggEventReadRate.inc(); long recordSize = record.getData().array().length + record.getPartitionKey().length(); eventByteReadRates.get(stream).inc(recordSize); aggEventByteReadRate.inc(recordSize); long latencyMs = Duration.between(Instant.now(), record.getApproximateArrivalTimestamp().toInstant()).toMillis(); readLatencies.get(stream).update(latencyMs); aggReadLatency.update(latencyMs); } }
@Override public synchronized void flush() { writeMetrics.numFlushes.inc(); long startNs = System.nanoTime(); Preconditions.checkNotNull(rwTable, "Cannot flush a read-only table: " + rdTable); rwTable.flush(); writeMetrics.flushNs.update(System.nanoTime() - startNs); }
@Override public Map<K, V> getAll(List<K> keys) { readMetrics.numGetAlls.inc(); long startNs = System.nanoTime(); Map<K, V> result = kvStore.getAll(keys); readMetrics.getAllNs.update(System.nanoTime() - startNs); return result; }
@Override public void handleSessionEstablishmentError(Throwable error) { // this means we cannot connect to zookeeper to establish a session zkSessionMetrics.zkSessionErrors.inc(); LOG.info("handleSessionEstablishmentError received for processor=" + processorId, error); debounceTimer.scheduleAfterDebounceTime(ZK_SESSION_ERROR, 0, () -> stop()); } }
/** * {@inheritDoc} */ @Override public Map<K, V> getAll(List<K> keys) { readMetrics.numGetAlls.inc(); try { return getAllAsync(keys).get(); } catch (Exception e) { throw new SamzaException(e); } }
/** * read the jobmodel version from ZK * @return jobmodel version as a string */ public String getJobModelVersion() { String jobModelVersion = zkClient.readData(keyBuilder.getJobModelVersionPath(), true); metrics.reads.inc(); return jobModelVersion; }
/** * read the jobmodel version from ZK * @return jobmodel version as a string */ public String getJobModelVersion() { String jobModelVersion = zkClient.readData(keyBuilder.getJobModelVersionPath(), true); metrics.reads.inc(); return jobModelVersion; }
/** * subscribe for changes of JobModel version * @param dataListener describe this */ public void subscribeToJobModelVersionChange(GenerationAwareZkDataListener dataListener) { LOG.info(" subscribing for jm version change at:" + keyBuilder.getJobModelVersionPath()); zkClient.subscribeDataChanges(keyBuilder.getJobModelVersionPath(), dataListener); metrics.subscriptions.inc(); }
/** * subscribe to the changes in the list of processors in ZK * @param listener - will be called when a processor is added or removed. */ public void subscribeToProcessorChange(IZkChildListener listener) { LOG.info("Subscribing for child change at:" + keyBuilder.getProcessorsPath()); zkClient.subscribeChildChanges(keyBuilder.getProcessorsPath(), listener); metrics.subscriptions.inc(); }
@Override public void onBarrierCreated(String version) { // Start the timer for rebalancing startTime = System.nanoTime(); metrics.barrierCreation.inc(); if (leaderElector.amILeader()) { debounceTimer.scheduleAfterDebounceTime(barrierAction, (new ZkConfig(config)).getZkBarrierTimeoutMs(), () -> barrier.expire(version)); } }
@Override public void onBarrierCreated(String version) { // Start the timer for rebalancing startTime = System.nanoTime(); metrics.barrierCreation.inc(); if (leaderElector.amILeader()) { debounceTimer.scheduleAfterDebounceTime(barrierAction, (new ZkConfig(config)).getZkBarrierTimeoutMs(), () -> barrier.expire(version)); } }