public long put( K key, long value ) { synchronized( mutex ) { return m.put( key, value ); } } public long remove( Object key ) {
/** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code>Long</code> value * @return the previous value associated with <tt>key</tt>, * or Integer(0) if none was found. */ public Long put( K key, Long value ) { if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) ); return wrapValue( _map.put( key, unwrapValue( value ) ) ); }
i.setTags(tags); }); recentlyRequestedWorkers.put(graphId, System.currentTimeMillis()); LOG.info("Requesting {} workers", nWorkers);
@Override public long put( K key, long value ) { synchronized( mutex ) { return m.put( key, value ); } } @Override
public long put( K key, long value ) { synchronized( mutex ) { return m.put( key, value ); } } public long remove( Object key ) {
public long put( K key, long value ) { synchronized( mutex ) { return m.put( key, value ); } } public long remove( Object key ) {
public long put( K key, long value ) { synchronized( mutex ) { return m.put( key, value ); } } public long remove( Object key ) {
/** * Adds the counts from the provided {@code Counter} to the current counts, * adding new elements as needed. */ public void add(Counter<? extends T> counter) { for (Map.Entry<? extends T,Integer> e : counter) { T t = e.getKey(); Long cur = counts.get(t); counts.put(t, (cur == null) ? e.getValue() : cur + e.getValue()); } }
/** * Counts the object, increasing its total count by 1. */ public long count(T obj) { long count = counts.get(obj); count++; counts.put(obj, count); sum++; return count; }
/** * Adds the counts from the provided {@code Counter} to the current counts, * adding new elements as needed. */ public void add(BigCounter<? extends T> counter) { for (Map.Entry<? extends T,Long> e : counter) { T t = e.getKey(); Long cur = counts.get(t); counts.put(t, (cur == null) ? e.getValue() : cur + e.getValue()); } }
public static long getGCTimeDiff(final List<GarbageCollectorMXBean> gcBeans, final TObjectLongMap lastValues) { long gcTime = 0; for (GarbageCollectorMXBean gcBean : gcBeans) { long prevVal = lastValues.get(gcBean); long currVal = gcBean.getCollectionTime(); gcTime += currVal - prevVal; lastValues.put(gcBean, currVal); } return gcTime; }
/** * Counts the object, increasing its total count by the specified positive amount. * * @param count a positive value for the number of times the object occurred * * @throws IllegalArgumentException if {@code count} is not a positive value. */ public long count(T obj, long count) { if (count < 1) throw new IllegalArgumentException("Count must be positive: " + count); long oldCount = counts.get(obj); long newCount = count + oldCount; counts.put(obj, newCount); sum += count; return newCount; }
public static synchronized long getId(@Nonnull final MeasurementsInfo info) { long id = INFO2ID.get(info); if (id <= 0) { id = idSeq++; INFO2ID.put(info, id); ID2INFO.put(id, info); } return id; }
/** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code>Long</code> value * @return the previous value associated with <tt>key</tt>, * or Integer(0) if none was found. */ public Long put( K key, Long value ) { if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) ); return wrapValue( _map.put( key, unwrapValue( value ) ) ); }
/** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code>Long</code> value * @return the previous value associated with <tt>key</tt>, * or Integer(0) if none was found. */ public Long put( K key, Long value ) { if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) ); return wrapValue( _map.put( key, unwrapValue( value ) ) ); }
/** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code>Long</code> value * @return the previous value associated with <tt>key</tt>, * or Integer(0) if none was found. */ public Long put( K key, Long value ) { if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) ); return wrapValue( _map.put( key, unwrapValue( value ) ) ); }
/** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code>Long</code> value * @return the previous value associated with <tt>key</tt>, * or Integer(0) if none was found. */ @Override public Long put( K key, Long value ) { if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) ); return wrapValue( _map.put( key, unwrapValue( value ) ) ); }
private void update_(TimeSeriesCollection tsc) { timestamps.add(tsc.getTimestamp()); tsc.getTSValues().stream() .forEach(tsv -> { data.compute(tsv.getGroup(), (grp, tsvChain) -> { if (tsvChain == null) tsvChain = new TsvChain(tsc.getTimestamp(), tsv); else tsvChain.add(tsc.getTimestamp(), tsv); return tsvChain; }); activeGroups.put(tsv.getGroup(), tsc.getTimestamp().getMillis()); }); }
public void persist(final boolean warn) throws IOException { long currentTime = System.currentTimeMillis(); if (currentTime > lastRun) { lastRun = currentTime; for (MeasurementAccumulator m : ScalableMeasurementRecorderSource.this.getEntitiesMeasurementsAndReset().values()) { final MeasurementsInfo info = m.getInfo(); long tableId; synchronized (tableIds) { tableId = tableIds.get(info); if (tableId == 0) { tableId = database.alocateMeasurements(info, sampleTimeMillis); tableIds.put(info, tableId); } } final long[] data = m.getThenReset(); if (data != null) { database.saveMeasurements(tableId, currentTime, data); } } } else if (warn) { LOG.warn("Last measurement recording for {} was at {} current run is {}, something is wrong", processor.getInfo(), lastRun, currentTime); } } }
@Override public long alocateMeasurements(final MeasurementsInfo measurement, final int sampleTimeMillis) throws IOException { IOException ex = null; synchronized (idToIds) { long id = infoToId.get(measurement); if (id <= 0) { long[] ids = new long[stores.length]; int i = 0; for (MeasurementStore store : stores) { try { ids[i++] = store.alocateMeasurements(measurement, sampleTimeMillis); } catch (IOException e) { if (ex != null) { Throwables.suppressLimited(e, ex); } ex = e; } } if (ex != null) { throw ex; } id = idSeq++; infoToId.put(measurement, id); idToIds.put(id, ids); } return id; } }