本文整理汇总了Java中org.apache.cassandra.utils.FBUtilities.nowInSeconds方法的典型用法代码示例。如果您正苦于以下问题:Java FBUtilities.nowInSeconds方法的具体用法?Java FBUtilities.nowInSeconds怎么用?Java FBUtilities.nowInSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.utils.FBUtilities
的用法示例。
在下文中一共展示了FBUtilities.nowInSeconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UpdateParameters
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
public UpdateParameters(CFMetaData metadata,
PartitionColumns updatedColumns,
QueryOptions options,
long timestamp,
int ttl,
Map<DecoratedKey, Partition> prefetchedRows)
throws InvalidRequestException
{
this.metadata = metadata;
this.updatedColumns = updatedColumns;
this.options = options;
this.nowInSec = FBUtilities.nowInSeconds();
this.timestamp = timestamp;
this.ttl = ttl;
this.deletionTime = new DeletionTime(timestamp, nowInSec);
this.prefetchedRows = prefetchedRows;
// We use MIN_VALUE internally to mean the absence of of timestamp (in Selection, in sstable stats, ...), so exclude
// it to avoid potential confusion.
if (timestamp == Long.MIN_VALUE)
throw new InvalidRequestException(String.format("Out of bound timestamp, must be in [%d, %d]", Long.MIN_VALUE + 1, Long.MAX_VALUE));
}
示例2: iterator
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
public Iterator<Row> iterator()
{
return new AbstractIterator<Row>()
{
private Iterator<List<ByteBuffer>> currentPage;
protected Row computeNext()
{
int nowInSec = FBUtilities.nowInSeconds();
while (currentPage == null || !currentPage.hasNext())
{
if (pager.isExhausted())
return endOfData();
try (ReadOrderGroup orderGroup = pager.startOrderGroup(); PartitionIterator iter = pager.fetchPageInternal(pageSize, orderGroup))
{
currentPage = select.process(iter, nowInSec).rows.iterator();
}
}
return new Row(metadata, currentPage.next());
}
};
}
示例3: mergeComplexDeletionSupersededByRowDeletion
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Test
public void mergeComplexDeletionSupersededByRowDeletion()
{
int now1 = FBUtilities.nowInSeconds();
Row.Builder existingBuilder = createBuilder(c1, now1, null, null, null);
int now2 = now1 + 1;
Row.Builder updateBuilder = createBuilder(c1, now2, null, BB1, BB1);
int now3 = now2 + 1;
Row.Deletion expectedDeletion = new Row.Deletion(new DeletionTime(secondToTs(now3), now3), false);
updateBuilder.addRowDeletion(expectedDeletion);
RowBuilder builder = new RowBuilder();
Rows.merge(existingBuilder.build(), updateBuilder.build(), builder, now3 + 1);
Assert.assertEquals(expectedDeletion, builder.deletionTime);
Assert.assertEquals(Collections.emptyList(), builder.complexDeletions);
Assert.assertEquals(Collections.emptyList(), builder.cells);
}
示例4: testTrackTimesRangeTombstoneWithData
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Test
public void testTrackTimesRangeTombstoneWithData() throws ExecutionException, InterruptedException
{
Keyspace ks = Keyspace.open(KSNAME);
ColumnFamilyStore cfs = ks.getColumnFamilyStore(CFNAME);
cfs.truncateBlocking();
String key = "rt_times";
UpdateBuilder.create(cfs.metadata, key).withTimestamp(999).newRow(5).add("val", 5).apply();
key = "rt_times2";
int nowInSec = FBUtilities.nowInSeconds();
new Mutation(PartitionUpdate.fullPartitionDelete(cfs.metadata, Util.dk(key), 1000, nowInSec)).apply();
cfs.forceBlockingFlush();
cfs.forceBlockingFlush();
SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
assertTimes(sstable.getSSTableMetadata(), 999, 1000, Integer.MAX_VALUE);
cfs.forceMajorCompaction();
sstable = cfs.getLiveSSTables().iterator().next();
assertTimes(sstable.getSSTableMetadata(), 999, 1000, Integer.MAX_VALUE);
}
示例5: writeHintsForUndeliveredEndpoints
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
private void writeHintsForUndeliveredEndpoints(int startFrom, Set<InetAddress> hintedNodes)
{
int gcgs = gcgs(mutations);
// expired
if (TimeUnit.MILLISECONDS.toSeconds(writtenAt) + gcgs <= FBUtilities.nowInSeconds())
return;
for (int i = startFrom; i < replayHandlers.size(); i++)
{
ReplayWriteResponseHandler<Mutation> handler = replayHandlers.get(i);
Mutation undeliveredMutation = mutations.get(i);
if (handler != null)
{
hintedNodes.addAll(handler.undelivered);
HintsService.instance.write(transform(handler.undelivered, StorageService.instance::getHostIdForEndpoint),
Hint.create(undeliveredMutation, writtenAt));
}
}
}
示例6: mergeIterators
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
public UnfilteredRowIterator mergeIterators(List<UnfilteredRowIterator> us, boolean iterations)
{
int now = FBUtilities.nowInSeconds();
if (iterations)
{
UnfilteredRowIterator mi = us.get(0);
int i;
for (i = 1; i + 2 <= ITERATORS; i += 2)
mi = UnfilteredRowIterators.merge(ImmutableList.of(mi, us.get(i), us.get(i+1)), now);
if (i + 1 <= ITERATORS)
mi = UnfilteredRowIterators.merge(ImmutableList.of(mi, us.get(i)), now);
return mi;
}
else
{
return UnfilteredRowIterators.merge(us, now);
}
}
示例7: testTrackTimesPartitionTombstoneWithData
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Test
public void testTrackTimesPartitionTombstoneWithData() throws ExecutionException, InterruptedException
{
Keyspace ks = Keyspace.open(KSNAME);
ColumnFamilyStore cfs = ks.getColumnFamilyStore(CFNAME);
cfs.truncateBlocking();
String key = "rt_times";
UpdateBuilder.create(cfs.metadata, key).withTimestamp(999).newRow(5).add("val", 5).apply();
key = "rt_times2";
int nowInSec = FBUtilities.nowInSeconds();
new Mutation(PartitionUpdate.fullPartitionDelete(cfs.metadata, Util.dk(key), 1000, nowInSec)).apply();
cfs.forceBlockingFlush();
SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
assertTimes(sstable.getSSTableMetadata(), 999, 1000, Integer.MAX_VALUE);
cfs.forceMajorCompaction();
sstable = cfs.getLiveSSTables().iterator().next();
assertTimes(sstable.getSSTableMetadata(), 999, 1000, Integer.MAX_VALUE);
}
示例8: RowUpdater
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
private RowUpdater(AtomicBTreePartition updating, MemtableAllocator allocator, OpOrder.Group writeOp, UpdateTransaction indexer)
{
this.updating = updating;
this.allocator = allocator;
this.writeOp = writeOp;
this.indexer = indexer;
this.nowInSec = FBUtilities.nowInSeconds();
}
示例9: testCanonicalView
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Test
public void testCanonicalView() throws Exception
{
Keyspace keyspace = Keyspace.open(KEYSPACE);
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
truncate(cfs);
SSTableReader s = writeFile(cfs, 1000);
cfs.addSSTable(s);
Set<SSTableReader> sstables = Sets.newHashSet(s);
assertEquals(1, sstables.size());
boolean checked = false;
try (ISSTableScanner scanner = sstables.iterator().next().getScanner();
CompactionController controller = new CompactionController(cfs, sstables, 0);
LifecycleTransaction txn = cfs.getTracker().tryModify(sstables, OperationType.UNKNOWN);
SSTableRewriter writer = new SSTableRewriter(txn, 1000, false, 10000000, false);
CompactionIterator ci = new CompactionIterator(OperationType.COMPACTION, Collections.singletonList(scanner), controller, FBUtilities.nowInSeconds(), UUIDGen.getTimeUUID())
)
{
writer.switchWriter(getWriter(cfs, sstables.iterator().next().descriptor.directory, txn));
while (ci.hasNext())
{
writer.append(ci.next());
if (!checked && writer.currentWriter().getFilePointer() > 15000000)
{
checked = true;
ColumnFamilyStore.ViewFragment viewFragment = cfs.select(View.selectFunction(SSTableSet.CANONICAL));
// canonical view should have only one SSTable which is not opened early.
assertEquals(1, viewFragment.sstables.size());
SSTableReader sstable = viewFragment.sstables.get(0);
assertEquals(s.descriptor, sstable.descriptor);
assertTrue("Found early opened SSTable in canonical view: " + sstable.getFilename(), sstable.openReason != SSTableReader.OpenReason.EARLY);
}
}
}
truncateCF();
validateCFS(cfs);
}
示例10: convertLegacyHint
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
private static Hint convertLegacyHint(UntypedResultSet.Row row)
{
Mutation mutation = deserializeLegacyMutation(row);
if (mutation == null)
return null;
long creationTime = row.getLong("write_time"); // milliseconds, not micros, for the hints table
int expirationTime = FBUtilities.nowInSeconds() + row.getInt("ttl");
int originalGCGS = expirationTime - (int) TimeUnit.MILLISECONDS.toSeconds(creationTime);
int gcgs = Math.min(originalGCGS, mutation.smallestGCGS());
return Hint.create(mutation, creationTime, gcgs);
}
示例11: collectStats
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Test
public void collectStats()
{
int now = FBUtilities.nowInSeconds();
long ts = secondToTs(now);
Row.Builder builder = BTreeRow.unsortedBuilder(now);
builder.newRow(c1);
LivenessInfo liveness = LivenessInfo.create(kcvm, ts, now);
builder.addPrimaryKeyLivenessInfo(liveness);
DeletionTime complexDeletion = new DeletionTime(ts-1, now);
builder.addComplexDeletion(m, complexDeletion);
List<Cell> expectedCells = Lists.newArrayList(BufferCell.live(kcvm, v, ts, BB1),
BufferCell.live(kcvm, m, ts, BB1, CellPath.create(BB1)),
BufferCell.live(kcvm, m, ts, BB2, CellPath.create(BB2)));
expectedCells.forEach(builder::addCell);
// We need to use ts-1 so the deletion doesn't shadow what we've created
Row.Deletion rowDeletion = new Row.Deletion(new DeletionTime(ts-1, now), false);
builder.addRowDeletion(rowDeletion);
StatsCollector collector = new StatsCollector();
Rows.collectStats(builder.build(), collector);
Assert.assertEquals(Lists.newArrayList(liveness), collector.liveness);
Assert.assertEquals(Sets.newHashSet(rowDeletion.time(), complexDeletion), Sets.newHashSet(collector.deletions));
Assert.assertEquals(Sets.newHashSet(expectedCells), Sets.newHashSet(collector.cells));
Assert.assertEquals(2, collector.columnCount);
Assert.assertFalse(collector.hasLegacyCounterShards);
}
示例12: RowUpdater
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
private RowUpdater(AtomicBTreePartition updating, MemtableAllocator allocator, OpOrder.Group writeOp, UpdateTransaction indexer)
{
this.updating = updating;
this.allocator = allocator;
this.writeOp = writeOp;
this.indexer = indexer;
this.nowInSec = FBUtilities.nowInSeconds();
this.reclaimer = allocator.reclaimer();
}
示例13: testIndexHelper
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Test
public void testIndexHelper()
{
DeletionTime deletionInfo = new DeletionTime(FBUtilities.timestampMicros(), FBUtilities.nowInSeconds());
List<IndexInfo> indexes = new ArrayList<>();
indexes.add(new IndexInfo(cn(0L), cn(5L), 0, 0, deletionInfo));
indexes.add(new IndexInfo(cn(10L), cn(15L), 0, 0, deletionInfo));
indexes.add(new IndexInfo(cn(20L), cn(25L), 0, 0, deletionInfo));
assertEquals(0, IndexHelper.indexFor(cn(-1L), indexes, comp, false, -1));
assertEquals(0, IndexHelper.indexFor(cn(5L), indexes, comp, false, -1));
assertEquals(1, IndexHelper.indexFor(cn(12L), indexes, comp, false, -1));
assertEquals(2, IndexHelper.indexFor(cn(17L), indexes, comp, false, -1));
assertEquals(3, IndexHelper.indexFor(cn(100L), indexes, comp, false, -1));
assertEquals(3, IndexHelper.indexFor(cn(100L), indexes, comp, false, 0));
assertEquals(3, IndexHelper.indexFor(cn(100L), indexes, comp, false, 1));
assertEquals(3, IndexHelper.indexFor(cn(100L), indexes, comp, false, 2));
assertEquals(3, IndexHelper.indexFor(cn(100L), indexes, comp, false, 3));
assertEquals(-1, IndexHelper.indexFor(cn(-1L), indexes, comp, true, -1));
assertEquals(0, IndexHelper.indexFor(cn(5L), indexes, comp, true, 3));
assertEquals(0, IndexHelper.indexFor(cn(5L), indexes, comp, true, 2));
assertEquals(1, IndexHelper.indexFor(cn(17L), indexes, comp, true, 3));
assertEquals(2, IndexHelper.indexFor(cn(100L), indexes, comp, true, 3));
assertEquals(2, IndexHelper.indexFor(cn(100L), indexes, comp, true, 4));
assertEquals(1, IndexHelper.indexFor(cn(12L), indexes, comp, true, 3));
assertEquals(1, IndexHelper.indexFor(cn(12L), indexes, comp, true, 2));
assertEquals(1, IndexHelper.indexFor(cn(100L), indexes, comp, true, 1));
assertEquals(2, IndexHelper.indexFor(cn(100L), indexes, comp, true, 2));
}
示例14: readTypeTimestamp
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
private static long readTypeTimestamp(String keyspaceName, String typeName)
{
ColumnFamilyStore store = org.apache.cassandra.db.Keyspace.open(SystemKeyspace.NAME)
.getColumnFamilyStore(SystemKeyspace.LEGACY_USERTYPES);
ClusteringComparator comparator = store.metadata.comparator;
Slices slices = Slices.with(comparator, Slice.make(comparator, typeName));
int nowInSec = FBUtilities.nowInSeconds();
DecoratedKey key = store.metadata.decorateKey(AsciiType.instance.fromString(keyspaceName));
SinglePartitionReadCommand command = SinglePartitionReadCommand.create(store.metadata, nowInSec, key, slices);
try (OpOrder.Group op = store.readOrdering.start();
RowIterator partition = UnfilteredRowIterators.filter(command.queryMemtableAndDisk(store, op), nowInSec))
{
long timestamp;
do {
Row row = partition.next();
timestamp = row.primaryKeyLivenessInfo().timestamp();
if (row.primaryKeyLivenessInfo().isEmpty() && nonPersistent) {
// I don't think this is a scylla bug per se, but apparently we
// generate sstables slightly different from origin, thus though we get the
// data, the pk liveness/timestamp is not set. But returning NO_TIMESTAMP
// here will lead to all mutations generated being empty (deletion deletes).
// Work around this (only in tool/non-persistent mode) by saying "now"
timestamp = FBUtilities.timestampMicros();
break;
}
} while (partition.hasNext());
return timestamp;
}
}
示例15: merge
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Test
public void merge()
{
int now1 = FBUtilities.nowInSeconds();
Row.Builder existingBuilder = createBuilder(c1, now1, BB1, BB1, BB1);
int now2 = now1 + 1;
long ts2 = secondToTs(now2);
Cell expectedVCell = BufferCell.live(kcvm, v, ts2, BB2);
Cell expectedMCell = BufferCell.live(kcvm, m, ts2, BB2, CellPath.create(BB1));
DeletionTime expectedComplexDeletionTime = new DeletionTime(ts2 - 1, now2);
Row.Builder updateBuilder = createBuilder(c1, now2, null, null, null);
updateBuilder.addCell(expectedVCell);
updateBuilder.addComplexDeletion(m, expectedComplexDeletionTime);
updateBuilder.addCell(expectedMCell);
RowBuilder builder = new RowBuilder();
long td = Rows.merge(existingBuilder.build(), updateBuilder.build(), builder, now2 + 1);
Assert.assertEquals(c1, builder.clustering);
Assert.assertEquals(LivenessInfo.create(kcvm, ts2, now2), builder.livenessInfo);
Assert.assertEquals(Lists.newArrayList(Pair.create(m, new DeletionTime(ts2-1, now2))), builder.complexDeletions);
Assert.assertEquals(2, builder.cells.size());
Assert.assertEquals(Lists.newArrayList(expectedVCell, expectedMCell), Lists.newArrayList(builder.cells));
Assert.assertEquals(ts2 - secondToTs(now1), td);
}