本文整理汇总了Java中org.apache.cassandra.io.sstable.SSTable类的典型用法代码示例。如果您正苦于以下问题:Java SSTable类的具体用法?Java SSTable怎么用?Java SSTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SSTable类属于org.apache.cassandra.io.sstable包,在下文中一共展示了SSTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compact
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
@VisibleForTesting
protected synchronized void compact()
{
ArrayList<Descriptor> descriptors = new ArrayList<>();
for (SSTable sstable : hintStore.getDataTracker().getUncompactingSSTables())
descriptors.add(sstable.descriptor);
if (descriptors.isEmpty())
return;
try
{
CompactionManager.instance.submitUserDefined(hintStore, descriptors, (int) (System.currentTimeMillis() / 1000)).get();
}
catch (InterruptedException | ExecutionException e)
{
throw new RuntimeException(e);
}
}
示例2: cleanup
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
public void cleanup()
{
List<String> files = readLockfile(lockfile);
for (String file : files)
{
try
{
Descriptor desc = Descriptor.fromFilename(file, true);
SSTable.delete(desc, SSTable.componentsFor(desc));
}
catch (Exception e)
{
JVMStabilityInspector.inspectThrowable(e);
logger.warn("failed to delete a potentially stale sstable {}", file);
}
}
}
示例3: getColumnStats
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
public ColumnStats getColumnStats()
{
long minTimestampSeen = deletionInfo().isLive() ? Long.MAX_VALUE : deletionInfo().minTimestamp();
long maxTimestampSeen = deletionInfo().maxTimestamp();
StreamingHistogram tombstones = new StreamingHistogram(SSTable.TOMBSTONE_HISTOGRAM_BIN_SIZE);
int maxLocalDeletionTime = Integer.MIN_VALUE;
List<ByteBuffer> minColumnNamesSeen = Collections.emptyList();
List<ByteBuffer> maxColumnNamesSeen = Collections.emptyList();
for (Column column : this)
{
minTimestampSeen = Math.min(minTimestampSeen, column.minTimestamp());
maxTimestampSeen = Math.max(maxTimestampSeen, column.maxTimestamp());
maxLocalDeletionTime = Math.max(maxLocalDeletionTime, column.getLocalDeletionTime());
int deletionTime = column.getLocalDeletionTime();
if (deletionTime < Integer.MAX_VALUE)
tombstones.update(deletionTime);
minColumnNamesSeen = ColumnNameHelper.minComponents(minColumnNamesSeen, column.name, metadata.comparator);
maxColumnNamesSeen = ColumnNameHelper.maxComponents(maxColumnNamesSeen, column.name, metadata.comparator);
}
return new ColumnStats(getColumnCount(), minTimestampSeen, maxTimestampSeen, maxLocalDeletionTime, tombstones, minColumnNamesSeen, maxColumnNamesSeen);
}
示例4: close
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
public void close()
{
FileUtils.closeQuietly(writer);
byte[] bytes = digest.digest();
if (bytes == null)
return;
SequentialWriter out = SequentialWriter.open(new File(descriptor.filenameFor(SSTable.COMPONENT_DIGEST)), true);
// Writting output compatible with sha1sum
Descriptor newdesc = descriptor.asTemporary(false);
String[] tmp = newdesc.filenameFor(SSTable.COMPONENT_DATA).split(Pattern.quote(File.separator));
String dataFileName = tmp[tmp.length - 1];
try
{
out.write(String.format("%s %s", Hex.bytesToHex(bytes), dataFileName).getBytes());
}
catch (ClosedChannelException e)
{
throw new AssertionError(); // can't happen.
}
finally
{
FileUtils.closeQuietly(out);
}
}
示例5: run
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
public void run()
{
SystemKeyspace.clearSSTableReadMeter(desc.ksname, desc.cfname, desc.generation);
try
{
// If we can't successfully delete the DATA component, set the task to be retried later: see TransactionTidier
File datafile = new File(desc.filenameFor(Component.DATA));
delete(datafile);
// let the remainder be cleaned up by delete
SSTable.delete(desc, SSTable.discoverComponentsFor(desc));
}
catch (Throwable t)
{
logger.error("Failed deletion for {}, we'll retry after GC and on server restart", desc);
failedDeletions.add(this);
return;
}
if (tracker != null && tracker.cfstore != null && !wasNew)
tracker.cfstore.metric.totalDiskSpaceUsed.dec(sizeOnDisk);
// release the referent to the parent so that the all transaction files can be released
parentRef.release();
}
示例6: cleanup
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
public void cleanup()
{
List<String> files = readLockfile(lockfile);
for (String file : files)
{
try
{
Descriptor desc = Descriptor.fromFilename(file, true);
SSTable.delete(desc, SSTable.componentsFor(desc));
}
catch (Exception e)
{
logger.warn("failed to delete a potentially stale sstable {}", file);
}
}
}
示例7: getColumnStats
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
public ColumnStats getColumnStats()
{
long minTimestampSeen = deletionInfo().isLive() ? Long.MAX_VALUE : deletionInfo().minTimestamp();
long maxTimestampSeen = deletionInfo().maxTimestamp();
StreamingHistogram tombstones = new StreamingHistogram(SSTable.TOMBSTONE_HISTOGRAM_BIN_SIZE);
for (IColumn column : columns)
{
minTimestampSeen = Math.min(minTimestampSeen, column.minTimestamp());
maxTimestampSeen = Math.max(maxTimestampSeen, column.maxTimestamp());
int deletionTime = column.getLocalDeletionTime();
if (deletionTime < Integer.MAX_VALUE)
tombstones.update(deletionTime);
}
return new ColumnStats(getColumnCount(), minTimestampSeen, maxTimestampSeen, tombstones);
}
示例8: repairOverlappingSSTables
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
public synchronized void repairOverlappingSSTables(int level)
{
SSTableReader previous = null;
Collections.sort(generations[level], SSTable.sstableComparator);
List<SSTableReader> outOfOrderSSTables = new ArrayList<SSTableReader>();
for (SSTableReader current : generations[level])
{
if (previous != null && current.first.compareTo(previous.last) <= 0)
{
logger.error(String.format("At level %d, %s [%s, %s] overlaps %s [%s, %s]. This is caused by a bug in Cassandra 1.1.0 .. 1.1.3. Sending back to L0. If you have not yet run scrub, you should do so since you may also have rows out-of-order within an sstable",
level, previous, previous.first, previous.last, current, current.first, current.last));
outOfOrderSSTables.add(current);
}
else
{
previous = current;
}
}
if (!outOfOrderSSTables.isEmpty())
{
for (SSTableReader sstable : outOfOrderSSTables)
sendBackToL0(sstable);
serialize();
}
}
示例9: getColumnStats
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
public ColumnStats getColumnStats()
{
long minTimestampSeen = deletionInfo().isLive() ? Long.MAX_VALUE : deletionInfo().minTimestamp();
long maxTimestampSeen = deletionInfo().maxTimestamp();
StreamingHistogram tombstones = new StreamingHistogram(SSTable.TOMBSTONE_HISTOGRAM_BIN_SIZE);
int maxLocalDeletionTime = Integer.MIN_VALUE;
List<ByteBuffer> minColumnNamesSeen = Collections.emptyList();
List<ByteBuffer> maxColumnNamesSeen = Collections.emptyList();
for (Cell cell : this)
{
minTimestampSeen = Math.min(minTimestampSeen, cell.minTimestamp());
maxTimestampSeen = Math.max(maxTimestampSeen, cell.maxTimestamp());
maxLocalDeletionTime = Math.max(maxLocalDeletionTime, cell.getLocalDeletionTime());
int deletionTime = cell.getLocalDeletionTime();
if (deletionTime < Integer.MAX_VALUE)
tombstones.update(deletionTime);
minColumnNamesSeen = ColumnNameHelper.minComponents(minColumnNamesSeen, cell.name, metadata.comparator);
maxColumnNamesSeen = ColumnNameHelper.maxComponents(maxColumnNamesSeen, cell.name, metadata.comparator);
}
return new ColumnStats(getColumnCount(), minTimestampSeen, maxTimestampSeen, maxLocalDeletionTime, tombstones, minColumnNamesSeen, maxColumnNamesSeen);
}
示例10: getReplayPosition
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
/**
* Convenience method to compute the replay position for a group of SSTables.
* @param sstables
* @return the most recent (highest) replay position
*/
public static ReplayPosition getReplayPosition(Iterable<? extends SSTable> sstables)
{
if (Iterables.isEmpty(sstables))
return NONE;
Function<SSTable, ReplayPosition> f = new Function<SSTable, ReplayPosition>()
{
public ReplayPosition apply(SSTable sstable)
{
return sstable.replayPosition;
}
};
Ordering<ReplayPosition> ordering = Ordering.from(ReplayPosition.comparator);
return ordering.max(Iterables.transform(sstables, f));
}
示例11: makeSSTable
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
private static SSTable makeSSTable()
{
Table t = Table.open("Keyspace1");
for (int i = 0; i < 100; i++)
{
RowMutation rm = new RowMutation(t.name, ByteBufferUtil.bytes(Long.toString(System.nanoTime())));
rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("cola")), ByteBufferUtil.bytes("value"), 0);
try
{
rm.apply();
}
catch (IOException ex)
{
throw new RuntimeException(ex);
}
}
try
{
t.getColumnFamilyStore("Standard1").forceBlockingFlush();
return t.getColumnFamilyStore("Standard1").getSSTables().iterator().next();
}
catch (Exception any)
{
throw new RuntimeException(any);
}
}
示例12: run
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
public void run()
{
logger.info("SSTableTidier is running..");
//if (tracker != null && !tracker.isDummy())
// SystemKeyspace.clearSSTableReadMeter(desc.ksname, desc.cfname, desc.generation);
try
{
// If we can't successfully delete the DATA component, set the task to be retried later: see TransactionTidier
File datafile = new File(desc.filenameFor(Component.DATA));
if (datafile.exists())
delete(datafile);
else if (!wasNew)
logger.error("SSTableTidier ran with no existing data file for an sstable that was not new");
// let the remainder be cleaned up by delete
SSTable.delete(desc, SSTable.discoverComponentsFor(desc));
}
catch (Throwable t)
{
logger.error("Failed deletion for {}, we'll retry after GC and on server restart", desc);
failedDeletions.add(this);
return;
}
//if (tracker != null && tracker.cfstore != null && !wasNew)
// tracker.cfstore.metric.totalDiskSpaceUsed.dec(sizeOnDisk);
// release the referent to the parent so that the all transaction files can be released
parentRef.release();
}
示例13: doPrepare
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
protected void doPrepare()
{
iwriter.prepareToCommit();
// write sstable statistics
dataFile.prepareToCommit();
writeMetadata(descriptor, finalizeMetadata());
// save the table of components
SSTable.appendTOC(descriptor, components);
//if (openResult)
// finalReader = openFinal(SSTableReader.OpenReason.NORMAL);
}
示例14: compact
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
@VisibleForTesting
protected Future<?> compact()
{
hintStore.forceBlockingFlush();
ArrayList<Descriptor> descriptors = new ArrayList<Descriptor>();
for (SSTable sstable : hintStore.getSSTables())
descriptors.add(sstable.descriptor);
return CompactionManager.instance.submitUserDefined(hintStore, descriptors, (int) (System.currentTimeMillis() / 1000));
}
示例15: makeRecord
import org.apache.cassandra.io.sstable.SSTable; //导入依赖的package包/类
private LogRecord makeRecord(Type type, SSTable table)
{
assert type == Type.ADD || type == Type.REMOVE;
File folder = table.descriptor.directory;
replicas.maybeCreateReplica(folder, getFileName(folder), records);
return LogRecord.make(type, table);
}