本文整理汇总了Java中org.github.jamm.MemoryMeter类的典型用法代码示例。如果您正苦于以下问题:Java MemoryMeter类的具体用法?Java MemoryMeter怎么用?Java MemoryMeter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MemoryMeter类属于org.github.jamm包,在下文中一共展示了MemoryMeter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Memtable
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
public Memtable(ColumnFamilyStore cfs)
{
this.cfs = cfs;
this.initialComparator = cfs.metadata.comparator;
this.cfs.scheduleFlush();
Callable<Set<Object>> provider = new Callable<Set<Object>>()
{
public Set<Object> call() throws Exception
{
// avoid counting this once for each row
Set<Object> set = Collections.newSetFromMap(new IdentityHashMap<Object, Boolean>());
set.add(Memtable.this.cfs.metadata);
return set;
}
};
meter = new MemoryMeter().omitSharedBufferOverhead().withTrackerProvider(provider);
}
示例2: updateLiveRatio
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
public void updateLiveRatio() throws RuntimeException
{
if (!MemoryMeter.isInitialized())
{
// hack for openjdk. we log a warning about this in the startup script too.
logger.warn("MemoryMeter uninitialized (jamm not specified as java agent); assuming liveRatio of {}. "
+ " Usually this means cassandra-env.sh disabled jamm because you are using a buggy JRE; "
+ " upgrade to the Sun JRE instead", cfs.liveRatio);
return;
}
if (!meteringInProgress.add(cfs))
{
logger.debug("Metering already pending or active for {}; skipping liveRatio update", cfs);
return;
}
meterExecutor.submit(new MeteringRunnable(cfs));
}
示例3: Memtable
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
public Memtable(ColumnFamilyStore cfs)
{
this.cfs = cfs;
this.creationTime = System.currentTimeMillis();
this.initialComparator = cfs.metadata.comparator;
Callable<Set<Object>> provider = new Callable<Set<Object>>()
{
public Set<Object> call() throws Exception
{
// avoid counting this once for each row
Set<Object> set = Collections.newSetFromMap(new IdentityHashMap<Object, Boolean>());
set.add(Memtable.this.cfs.metadata);
return set;
}
};
meter = new MemoryMeter().omitSharedBufferOverhead().withTrackerProvider(provider);
}
示例4: updateLiveRatio
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
public void updateLiveRatio() throws RuntimeException
{
if (!MemoryMeter.isInitialized())
{
// hack for openjdk. we log a warning about this in the startup script too.
logger.error("MemoryMeter uninitialized (jamm not specified as java agent); assuming liveRatio of {}. "
+ " Usually this means cassandra-env.sh disabled jamm because you are using a buggy JRE; "
+ " upgrade to the Sun JRE instead", cfs.liveRatio);
return;
}
if (!meteringInProgress.add(cfs))
{
logger.debug("Metering already pending or active for {}; skipping liveRatio update", cfs);
return;
}
meterExecutor.submit(new MeteringRunnable(cfs));
}
示例5: getSessionMemorySize
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
/**
* HttpSession 객체에 대한 메모리 점유 사이즈를 계산
*
* @param session
* @return
*/
private long getSessionMemorySize(HttpSession session) {
if( statsEnabled == false )
return 0;
else if( khanSessionConfig.isEnableMemoryStatistics() == false )
return 0;
if( memoryStatError )
return 0;
// TODO : agent를 설정하지 않을 경우를 체크해야 함
long memorySize = 0;
try {
MemoryMeter meter = new MemoryMeter();
memorySize += meter.measureDeep(getSessionAttributes(session.getId()));
} catch (Exception e) {
log.error("Session memory size calculation error");
memoryStatError = true;
}
return memorySize;
}
示例6: IndexMemtable
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
public IndexMemtable(final SSTableAttachedSecondaryIndex backend)
{
this.indexes = new NonBlockingHashMap<>();
this.backend = backend;
this.meter = new MemoryMeter().omitSharedBufferOverhead().withTrackerProvider(new Callable<Set<Object>>()
{
public Set<Object> call() throws Exception
{
// avoid counting this once for each row
Set<Object> set = Collections.newSetFromMap(new IdentityHashMap<Object, Boolean>());
set.add(backend.getBaseCfs().metadata);
return set;
}
});
}
示例7: maybeMeasureMemory
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
public void maybeMeasureMemory() throws IOException {
final String memPath = bc.getMemoryMeasurementPath();
if (memPath != null) {
final MemoryMeter meter = new MemoryMeter();
final long memoryB = meter.measureDeep(adapter.engine());
final double memoryMB = memoryB / Math.pow(10, 6);
final String line = String.join(",",
Arrays.asList(bc.getToolName(), bc.getQueryVariant(), bc.getFileName(), String.format("%.02f", memoryMB))) + "\n";
FileUtils.write(new File(memPath), line, Charset.defaultCharset(), true);
}
}
示例8: measureForPreparedCache
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
public long measureForPreparedCache(MemoryMeter meter)
{
return meter.measure(this)
+ meter.measureDeep(attrs)
+ meter.measureDeep(processedKeys)
+ meter.measureDeep(columnOperations)
+ (columnConditions == null ? 0 : meter.measureDeep(columnConditions))
+ (staticConditions == null ? 0 : meter.measureDeep(staticConditions));
}
示例9: measureForPreparedCache
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
@Override
public long measureForPreparedCache(MemoryMeter meter) {
return meter.measure(this)
+ meter.measureDeep(startwclause)
+ meter.measureDeep(paths)
+ meter.measureDeep(allKeyRestrictions)
+ meter.measureDeep(allColumnRestrictions)
+ meter.measureDeep(restrictedColumns);
/*
+ meter.measureDeep(metadataRestrictions)
+ (sliceRestriction == null ? 0 : meter.measureDeep(sliceRestriction))
+ (orderingIndexes == null ? 0 : meter.measureDeep(orderingIndexes));
*/
}
示例10: measureForPreparedCache
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
public long measureForPreparedCache(MemoryMeter meter)
{
long size = meter.measure(this)
+ meter.measureDeep(type)
+ meter.measure(statements)
+ meter.measureDeep(attrs);
for (ModificationStatement stmt : statements)
size += stmt.measureForPreparedCache(meter);
return size;
}
示例11: measureForPreparedCache
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
public long measureForPreparedCache(MemoryMeter meter)
{
return meter.measure(this)
+ meter.measureDeep(parameters)
+ meter.measureDeep(selection)
+ (limit == null ? 0 : meter.measureDeep(limit))
+ meter.measureDeep(keyRestrictions)
+ meter.measureDeep(columnRestrictions)
+ meter.measureDeep(metadataRestrictions)
+ meter.measureDeep(restrictedColumns)
+ (sliceRestriction == null ? 0 : meter.measureDeep(sliceRestriction))
+ (orderingIndexes == null ? 0 : meter.measureDeep(orderingIndexes));
}
示例12: initKeyCache
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
/**
* We can use Weighers.singleton() because Long can't be leaking memory
* @return auto saving cache object
*/
private AutoSavingCache<KeyCacheKey, RowIndexEntry> initKeyCache()
{
logger.info("Initializing key cache with capacity of {} MBs.", DatabaseDescriptor.getKeyCacheSizeInMB());
long keyCacheInMemoryCapacity = DatabaseDescriptor.getKeyCacheSizeInMB() * 1024 * 1024;
// as values are constant size we can use singleton weigher
// where 48 = 40 bytes (average size of the key) + 8 bytes (size of value)
ICache<KeyCacheKey, RowIndexEntry> kc;
if (MemoryMeter.isInitialized())
{
kc = ConcurrentLinkedHashCache.create(keyCacheInMemoryCapacity);
}
else
{
logger.warn("MemoryMeter uninitialized (jamm not specified as java agent); KeyCache size in JVM Heap will not be calculated accurately. " +
"Usually this means cassandra-env.sh disabled jamm because you are using a buggy JRE; upgrade to the Sun JRE instead");
/* We don't know the overhead size because memory meter is not enabled. */
EntryWeigher<KeyCacheKey, RowIndexEntry> weigher = new EntryWeigher<KeyCacheKey, RowIndexEntry>()
{
public int weightOf(KeyCacheKey key, RowIndexEntry entry)
{
return key.key.length + entry.serializedSize();
}
};
kc = ConcurrentLinkedHashCache.create(keyCacheInMemoryCapacity, weigher);
}
AutoSavingCache<KeyCacheKey, RowIndexEntry> keyCache = new AutoSavingCache<KeyCacheKey, RowIndexEntry>(kc, CacheType.KEY_CACHE, new KeyCacheSerializer());
int keyCacheKeysToSave = DatabaseDescriptor.getKeyCacheKeysToSave();
logger.info("Scheduling key cache save to each {} seconds (going to save {} keys).",
DatabaseDescriptor.getKeyCacheSavePeriod(),
keyCacheKeysToSave == Integer.MAX_VALUE ? "all" : keyCacheKeysToSave);
keyCache.scheduleSaving(DatabaseDescriptor.getKeyCacheSavePeriod(), keyCacheKeysToSave);
return keyCache;
}
示例13: setKeyCacheCapacityInMB
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
public void setKeyCacheCapacityInMB(long capacity)
{
if (capacity < 0)
throw new RuntimeException("capacity should not be negative.");
long weightedCapacity = capacity * 1024 * 1024;
keyCache.setCapacity(MemoryMeter.isInitialized() ? weightedCapacity : (weightedCapacity / 48));
}
示例14: measure
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
private static long measure(Object key)
{
if (!MemoryMeter.isInitialized())
return 1;
return key instanceof MeasurableForPreparedCache
? ((MeasurableForPreparedCache)key).measureForPreparedCache(meter)
: meter.measureDeep(key);
}
示例15: measureForPreparedCache
import org.github.jamm.MemoryMeter; //导入依赖的package包/类
public long measureForPreparedCache(MemoryMeter meter)
{
long size = meter.measure(this) + meter.measure(statements) + meter.measureDeep(attrs);
for (ModificationStatement stmt : statements)
size += stmt.measureForPreparedCache(meter);
return size;
}