本文整理汇总了Java中org.apache.cassandra.io.sstable.SSTableDeletingTask类的典型用法代码示例。如果您正苦于以下问题:Java SSTableDeletingTask类的具体用法?Java SSTableDeletingTask怎么用?Java SSTableDeletingTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SSTableDeletingTask类属于org.apache.cassandra.io.sstable包,在下文中一共展示了SSTableDeletingTask类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDirectoryForCompactedSSTables
import org.apache.cassandra.io.sstable.SSTableDeletingTask; //导入依赖的package包/类
public File getDirectoryForCompactedSSTables()
{
File path = getCompactionLocationAsFile();
// Requesting GC has a chance to free space only if we're using mmap and a non SUN jvm
if (path == null
&& (DatabaseDescriptor.getDiskAccessMode() == Config.DiskAccessMode.mmap || DatabaseDescriptor.getIndexAccessMode() == Config.DiskAccessMode.mmap)
&& !FileUtils.isCleanerAvailable())
{
logger.info("Forcing GC to free up disk space. Upgrade to the Oracle JVM to avoid this");
StorageService.instance.requestGC();
// retry after GCing has forced unmap of compacted SSTables so they can be deleted
// Note: GCInspector will do this already, but only sun JVM supports GCInspector so far
SSTableDeletingTask.rescheduleFailedTasks();
Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);
path = getCompactionLocationAsFile();
}
return path;
}
示例2: testDropIndex
import org.apache.cassandra.io.sstable.SSTableDeletingTask; //导入依赖的package包/类
@Test
public void testDropIndex() throws ConfigurationException
{
// persist keyspace definition in the system keyspace
Schema.instance.getKSMetaData(KEYSPACE6).toSchema(System.currentTimeMillis()).applyUnsafe();
ColumnFamilyStore cfs = Keyspace.open(KEYSPACE6).getColumnFamilyStore("Indexed1");
// insert some data. save the sstable descriptor so we can make sure it's marked for delete after the drop
Mutation rm = new Mutation(KEYSPACE6, ByteBufferUtil.bytes("k1"));
rm.add("Indexed1", cellname("notbirthdate"), ByteBufferUtil.bytes(1L), 0);
rm.add("Indexed1", cellname("birthdate"), ByteBufferUtil.bytes(1L), 0);
rm.applyUnsafe();
cfs.forceBlockingFlush();
ColumnFamilyStore indexedCfs = cfs.indexManager.getIndexForColumn(ByteBufferUtil.bytes("birthdate")).getIndexCfs();
Descriptor desc = indexedCfs.getSSTables().iterator().next().descriptor;
// drop the index
CFMetaData meta = cfs.metadata.copy();
ColumnDefinition cdOld = meta.regularColumns().iterator().next();
ColumnDefinition cdNew = ColumnDefinition.regularDef(meta, cdOld.name.bytes, cdOld.type, null);
meta.addOrReplaceColumnDefinition(cdNew);
MigrationManager.announceColumnFamilyUpdate(meta, false);
// check
Assert.assertTrue(cfs.indexManager.getIndexes().isEmpty());
SSTableDeletingTask.waitForDeletions();
Assert.assertFalse(new File(desc.filenameFor(Component.DATA)).exists());
}
示例3: testDropIndex
import org.apache.cassandra.io.sstable.SSTableDeletingTask; //导入依赖的package包/类
@Test
public void testDropIndex() throws ConfigurationException
{
// persist keyspace definition in the system keyspace
Schema.instance.getKSMetaData("Keyspace6").toSchema(System.currentTimeMillis()).apply();
ColumnFamilyStore cfs = Keyspace.open("Keyspace6").getColumnFamilyStore("Indexed1");
// insert some data. save the sstable descriptor so we can make sure it's marked for delete after the drop
Mutation rm = new Mutation("Keyspace6", ByteBufferUtil.bytes("k1"));
rm.add("Indexed1", cellname("notbirthdate"), ByteBufferUtil.bytes(1L), 0);
rm.add("Indexed1", cellname("birthdate"), ByteBufferUtil.bytes(1L), 0);
rm.apply();
cfs.forceBlockingFlush();
ColumnFamilyStore indexedCfs = cfs.indexManager.getIndexForColumn(ByteBufferUtil.bytes("birthdate")).getIndexCfs();
Descriptor desc = indexedCfs.getSSTables().iterator().next().descriptor;
// drop the index
CFMetaData meta = cfs.metadata.copy();
ColumnDefinition cdOld = meta.regularColumns().iterator().next();
ColumnDefinition cdNew = ColumnDefinition.regularDef(meta, cdOld.name.bytes, cdOld.type, null);
meta.addOrReplaceColumnDefinition(cdNew);
MigrationManager.announceColumnFamilyUpdate(meta, false);
// check
Assert.assertTrue(cfs.indexManager.getIndexes().isEmpty());
SSTableDeletingTask.waitForDeletions();
Assert.assertFalse(new File(desc.filenameFor(Component.DATA)).exists());
}
示例4: rescheduleFailedDeletions
import org.apache.cassandra.io.sstable.SSTableDeletingTask; //导入依赖的package包/类
public void rescheduleFailedDeletions()
{
SSTableDeletingTask.rescheduleFailedTasks();
}
示例5: handleNotification
import org.apache.cassandra.io.sstable.SSTableDeletingTask; //导入依赖的package包/类
public void handleNotification(Notification notification, Object handback)
{
String type = notification.getType();
if (type.equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION))
{
// retrieve the garbage collection notification information
CompositeData cd = (CompositeData) notification.getUserData();
GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from(cd);
long duration = info.getGcInfo().getDuration();
StringBuilder sb = new StringBuilder();
sb.append(info.getGcName()).append(" GC in ").append(duration).append("ms. ");
long bytes = 0;
List<String> keys = new ArrayList<>(info.getGcInfo().getMemoryUsageBeforeGc().keySet());
Collections.sort(keys);
for (String key : keys)
{
MemoryUsage before = info.getGcInfo().getMemoryUsageBeforeGc().get(key);
MemoryUsage after = info.getGcInfo().getMemoryUsageAfterGc().get(key);
if (after != null && after.getUsed() != before.getUsed())
{
sb.append(key).append(": ").append(before.getUsed());
sb.append(" -> ");
sb.append(after.getUsed());
if (!key.equals(keys.get(keys.size() - 1)))
sb.append("; ");
bytes += before.getUsed() - after.getUsed();
}
}
while (true)
{
State prev = state.get();
if (state.compareAndSet(prev, new State(duration, bytes, prev)))
break;
}
String st = sb.toString();
if (duration > MIN_LOG_DURATION)
logger.info(st);
else if (logger.isDebugEnabled())
logger.debug(st);
if (duration > MIN_LOG_DURATION_TPSTATS)
StatusLogger.log();
// if we just finished a full collection and we're still using a lot of memory, try to reduce the pressure
if (info.getGcName().equals("ConcurrentMarkSweep"))
SSTableDeletingTask.rescheduleFailedTasks();
}
}
示例6: logGCResults
import org.apache.cassandra.io.sstable.SSTableDeletingTask; //导入依赖的package包/类
private void logGCResults()
{
for (GarbageCollectorMXBean gc : beans)
{
Long previousTotal = gctimes.get(gc.getName());
Long total = gc.getCollectionTime();
if (previousTotal == null)
previousTotal = 0L;
if (previousTotal.equals(total))
continue;
gctimes.put(gc.getName(), total);
Long duration = total - previousTotal; // may be zero for a really fast collection
Long previousCount = gccounts.get(gc.getName());
Long count = gc.getCollectionCount();
if (previousCount == null)
previousCount = 0L;
if (count.equals(previousCount))
continue;
gccounts.put(gc.getName(), count);
MemoryUsage mu = membean.getHeapMemoryUsage();
long memoryUsed = mu.getUsed();
long memoryMax = mu.getMax();
String st = String.format("GC for %s: %s ms for %s collections, %s used; max is %s",
gc.getName(), duration, count - previousCount, memoryUsed, memoryMax);
org.apache.cassandra.db.compaction.CompactionTask.MyLogWriter("AcaZoo " +st);
long durationPerCollection = duration / (count - previousCount);
if (durationPerCollection > MIN_DURATION)
logger.info(st);
else if (logger.isDebugEnabled())
logger.debug(st);
if (durationPerCollection > MIN_DURATION_TPSTATS)
StatusLogger.log();
// if we just finished a full collection and we're still using a lot of memory, try to reduce the pressure
if (gc.getName().equals("ConcurrentMarkSweep"))
SSTableDeletingTask.rescheduleFailedTasks();
}
}
示例7: logGCResults
import org.apache.cassandra.io.sstable.SSTableDeletingTask; //导入依赖的package包/类
private void logGCResults()
{
for (GarbageCollectorMXBean gc : beans)
{
Long previousTotal = gctimes.get(gc.getName());
Long total = gc.getCollectionTime();
if (previousTotal == null)
previousTotal = 0L;
if (previousTotal.equals(total))
continue;
gctimes.put(gc.getName(), total);
Long duration = total - previousTotal; // may be zero for a really fast collection
Long previousCount = gccounts.get(gc.getName());
Long count = gc.getCollectionCount();
if (previousCount == null)
previousCount = 0L;
if (count.equals(previousCount))
continue;
gccounts.put(gc.getName(), count);
MemoryUsage mu = membean.getHeapMemoryUsage();
long memoryUsed = mu.getUsed();
long memoryMax = mu.getMax();
String st = String.format("GC for %s: %s ms for %s collections, %s used; max is %s",
gc.getName(), duration, count - previousCount, memoryUsed, memoryMax);
long durationPerCollection = duration / (count - previousCount);
if (durationPerCollection > MIN_DURATION)
logger.info(st);
else if (logger.isDebugEnabled())
logger.debug(st);
if (durationPerCollection > MIN_DURATION_TPSTATS)
StatusLogger.log();
// if we just finished a full collection and we're still using a lot of memory, try to reduce the pressure
if (gc.getName().equals("ConcurrentMarkSweep"))
{
SSTableDeletingTask.rescheduleFailedTasks();
double usage = (double) memoryUsed / memoryMax;
if (memoryUsed > DatabaseDescriptor.getReduceCacheSizesAt() * memoryMax && !cacheSizesReduced)
{
cacheSizesReduced = true;
logger.warn("Heap is " + usage + " full. You may need to reduce memtable and/or cache sizes. Cassandra is now reducing cache sizes to free up memory. Adjust reduce_cache_sizes_at threshold in cassandra.yaml if you don't want Cassandra to do this automatically");
CacheService.instance.reduceCacheSizes();
}
if (memoryUsed > DatabaseDescriptor.getFlushLargestMemtablesAt() * memoryMax)
{
logger.warn("Heap is " + usage + " full. You may need to reduce memtable and/or cache sizes. Cassandra will now flush up to the two largest memtables to free up memory. Adjust flush_largest_memtables_at threshold in cassandra.yaml if you don't want Cassandra to do this automatically");
StorageService.instance.flushLargestMemtables();
}
}
}
}
示例8: logGCResults
import org.apache.cassandra.io.sstable.SSTableDeletingTask; //导入依赖的package包/类
private void logGCResults()
{
for (GarbageCollectorMXBean gc : beans)
{
Long previousTotal = gctimes.get(gc.getName());
Long total = gc.getCollectionTime();
if (previousTotal == null)
previousTotal = 0L;
if (previousTotal.equals(total))
continue;
gctimes.put(gc.getName(), total);
Long duration = total - previousTotal; // may be zero for a really fast collection
Long previousCount = gccounts.get(gc.getName());
Long count = gc.getCollectionCount();
if (previousCount == null)
previousCount = 0L;
if (count.equals(previousCount))
continue;
gccounts.put(gc.getName(), count);
MemoryUsage mu = membean.getHeapMemoryUsage();
long memoryUsed = mu.getUsed();
long memoryMax = mu.getMax();
String st = String.format("GC for %s: %s ms for %s collections, %s used; max is %s",
gc.getName(), duration, count - previousCount, memoryUsed, memoryMax);
long durationPerCollection = duration / (count - previousCount);
if (durationPerCollection > MIN_DURATION)
logger.info(st);
else if (logger.isDebugEnabled())
logger.debug(st);
if (durationPerCollection > MIN_DURATION_TPSTATS)
StatusLogger.log();
// if we just finished a full collection and we're still using a lot of memory, try to reduce the pressure
if (gc.getName().equals("ConcurrentMarkSweep"))
SSTableDeletingTask.rescheduleFailedTasks();
}
}