/** * The mean time to execute removes. * * @return the time in milliseconds */ @Override public float getAverageRemoveTime() { if (cacheRemoveTimeTakenNanos.longValue() == 0 || getCacheGets() == 0) { return 0; } return (cacheRemoveTimeTakenNanos.longValue() / getCacheGets()) / NANOSECONDS_IN_A_MICROSECOND; }
/** longValue returns current value. */ public void testLongValue() { AtomicLong ai = new AtomicLong(); for (int i = -12; i < 6; ++i) { ai.set(i); assertEquals((long) i, ai.longValue()); } }
@Override public void output(Collection<Metric> metrics) { if (!eventRegistered.getAndSet(true)) { EventBusManager.createRegistrationPoint() .subscribe( WriteToStorageEvent.class, w -> { MetricStorage storage = w.storageToWriteTo().getSubStorageCalled("cassandra"); storage.store("metrics-to-cassandra", metricCount.longValue()); }); EvilManagerHack.subscribe(this.cluster); } if (metrics.size() == 0) { return; } Map<RetentionTable, BatchStatement> stms = LazyMap.<RetentionTable, BatchStatement>lazyMap( new HashMap<>(), () -> new BatchStatement()); for (Metric metric : metrics) { insertMetricIntoBatch(metric, stms); } KeyspaceMetadata metadata = cluster.getMetadata().getKeyspace(keyspace); for (RetentionTable table : stms.keySet()) { createTableIfNecessary(table, metadata); } for (BatchStatement batch : stms.values()) { session.execute(batch); } metricCount.addAndGet(metrics.size()); }
private boolean checkCommit(final ClientSession session) throws Exception { if (perfParams.isSessionTransacted()) { if (count.longValue() % perfParams.getBatchSize() == 0) { session.commit(); return true; } } return false; }
private int addThread() { boolean set; int n; do { long l = bits.longValue(); long next = (l + 1) | l; n = Long.numberOfTrailingZeros(l + 1); set = bits.compareAndSet(l, next); } while (!set); return n; }
public static long balanceSumF(Account ac1, Account ac2) { final AtomicLong result = new AtomicLong(); lockBothAndRun( ac1, ac2, new Runnable() { public void run() { result.addAndGet(ac1.balance); result.addAndGet(ac2.balance); } }); return result.longValue(); }
private void updateCounters(final long increment) { final long newValue = bytesRead.addAndGet(increment); final long nextBound = firstPercentBound.longValue(); if ((newValue > nextBound) && (nextBound != 0L)) { final int percentage = Math.min(100, (int) Math.floor(100 * newValue / contentLength)); percentRead.set(percentage); // to next percentage value firstPercentBound.set((1 + percentRead.get()) * contentLength / 100); if (callback != null) { callback.updateProgress(percentage); callback.publishP(percentage); } } }
public void onMessage(final ClientMessage message) { try { if (warmingUp) { boolean committed = checkCommit(session); if (count.incrementAndGet() == perfParams.getNoOfWarmupMessages()) { PerfBase.log.info("warmed up after receiving " + count.longValue() + " msgs"); if (!committed) { checkCommit(session); } warmingUp = false; } return; } if (!started) { started = true; // reset count to take stats count.set(0); start = System.currentTimeMillis(); } message.acknowledge(); long currentCount = count.incrementAndGet(); boolean committed = checkCommit(session); if (currentCount == perfParams.getNoOfMessagesToSend()) { if (!committed) { checkCommit(session); } countDownLatch.countDown(); } if (currentCount % modulo == 0) { double duration = (1.0 * System.currentTimeMillis() - start) / 1000; PerfBase.log.info( String.format("received %6d messages in %2.2fs", currentCount, duration)); } } catch (Exception e) { e.printStackTrace(); } }
/** @return the number of hits */ @Override public long getCacheHits() { return cacheHits.longValue(); }
public long getStartTimeMillis() { return startupTimestamp.longValue(); }
/** @return the number of evictions from the cache */ @Override public long getCacheEvictions() { return cacheEvictions.longValue(); }
public final long getBytesOut() { return _deliveredBytes.longValue(); }
/** @return the number of misses */ @Override public long getCacheMisses() { return cacheMisses.longValue(); }
/** * The total number of removals from the cache. This does not include evictions, where the cache * itself initiates the removal to make space. * * <p>A replace invcludes a put and remove. * * @return the number of hits */ @Override public long getCacheRemovals() { return cacheRemovals.longValue(); }
long age() { return System.currentTimeMillis() - timestamp.longValue(); }
public long getLastIoTime() { return _lastIoTime.longValue(); }
public final long getMessagesOut() { return _deliveredCount.longValue(); }
/** * Get the number of bytes read since creation or since last resetBytesRead() call. * * @return The number of bytes read * @see MonitoredBufferedInputStream#resetBytesRead */ public long getBytesRead() { return bytesRead.longValue(); }
/** * Returns the last value generated. * * @return the raw value */ public long getLastValue() { return counter.longValue(); }
public long getDataLength() { return dataLength.longValue(); }
public long getConnectTime() { return connectTime.longValue(); }
public long getUsed() { return used.longValue(); }
private void sendCount(CountRequest countRequest) { getContext().sender().tell(new CountResponse(count.longValue()), getContext().self()); }