本文整理汇总了Java中org.apache.cassandra.db.ColumnFamilyStore类的典型用法代码示例。如果您正苦于以下问题:Java ColumnFamilyStore类的具体用法?Java ColumnFamilyStore怎么用?Java ColumnFamilyStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColumnFamilyStore类属于org.apache.cassandra.db包,在下文中一共展示了ColumnFamilyStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStore
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
private ColumnFamilyStore getStore(String ksName, String cfName) {
// Start by validating keyspace name
if (Schema.instance.getKSMetaData(ksName) == null) {
System.err.println(String.format("Reference to nonexistent keyspace: %s!", ksName));
System.exit(1);
}
Keyspace keyspace = Keyspace.open(ksName);
// Make it works for indexes too - find parent cf if necessary
String baseName = cfName;
if (cfName.contains(".")) {
String[] parts = cfName.split("\\.", 2);
baseName = parts[0];
}
// IllegalArgumentException will be thrown here if ks/cf pair does not exist
try {
return keyspace.getColumnFamilyStore(baseName);
} catch (Throwable t) {
System.err.println(String.format(
"The provided column family is not part of this cassandra keyspace: keyspace = %s, column family = %s",
ksName, cfName));
System.exit(1);
}
return null;
}
示例2: getColumnFamily
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
public ColumnFamilyProxy getColumnFamily(String ksName, String cfName, String snapshotName, Collection<String> filter) {
ColumnFamilyStore cfStore = getStore(ksName, cfName);
try {
CFMetaData metaData = Schema.instance.getCFMetaData(ksName, cfName);
return new ColumnFamilyBackend(
metaData.getKeyValidator(),
metaData.params.compaction.klass().equals(org.apache.cassandra.db.compaction.DateTieredCompactionStrategy.class),
cfStore,
snapshotName,
filter);
} catch (Throwable t) {
System.err.println(String.format("Error retrieving snapshot for %s.%s", ksName, cfName));
System.exit(1);
}
return null;
}
示例3: getColumnFamily
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
public ColumnFamilyProxy getColumnFamily(String ksName, String cfName, String snapshotName, Collection<String> filter) {
ColumnFamilyStore cfStore = getStore(ksName, cfName);
try {
CFMetaData metaData = Schema.instance.getCFMetaData(ksName, cfName);
return new ColumnFamilyBackend(
metaData.getKeyValidator(),
cfStore.getCompactionStrategyClass().equals("org.apache.cassandra.db.compaction.DateTieredCompactionStrategy"),
cfStore,
snapshotName,
filter);
} catch (Throwable t) {
System.err.println(String.format("Error retrieving snapshot for %s.%s", ksName, cfName));
System.exit(1);
}
return null;
}
示例4: getColumnFamily
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
public ColumnFamilyProxy getColumnFamily(String ksName, String cfName, String snapshotName, Collection<String> filter) {
ColumnFamilyStore cfStore = getStore(ksName, cfName);
try {
CFMetaData metaData = Schema.instance.getCFMetaData(ksName, cfName);
return new ColumnFamilyBackend(
metaData.getKeyValidator(),
cfStore.getCompactionStrategyClass().equals("org.apache.cassandra.db.compaction.DateTieredCompactionStrategy"),
cfStore,
snapshotName,
filter);
} catch (Throwable t) {
System.err.println(String.format("Error retrieving snapshot for %s.%s", ksName, cfName));
System.exit(1);
}
return null;
}
示例5: checkRegistrations
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
private boolean checkRegistrations(ObjectName name) {
if (name != null && server.isRegistered(name)) {
return false;
}
boolean result = false;
try {
String type = name != null ? name.getKeyProperty("type") : null;
if (type == null || tables.matcher(type).matches()) {
result |= ColumnFamilyStore.checkRegistration(client, server);
}
if (type == null || StreamingMetrics.TYPE_NAME.equals(type)) {
result |= StreamingMetrics.checkRegistration(client, server);
}
} catch (MalformedObjectNameException | UnknownHostException e) {
// TODO: log
}
return result;
}
示例6: testConversionsInverses
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
@Test
public void testConversionsInverses() throws Exception
{
for (String keyspaceName : Schema.instance.getNonSystemKeyspaces())
{
for (ColumnFamilyStore cfs : Keyspace.open(keyspaceName).getColumnFamilyStores())
{
CFMetaData cfm = cfs.metadata;
if (!cfm.isThriftCompatible())
continue;
checkInverses(cfm);
// Testing with compression to catch #3558
CFMetaData withCompression = cfm.copy();
withCompression.compression(CompressionParams.snappy(32768));
checkInverses(withCompression);
}
}
}
示例7: takeColumnFamilySnapshot
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
/**
* Takes the snapshot of a specific column family. A snapshot name must be specified.
*
* @param keyspaceName the keyspace which holds the specified column family
* @param columnFamilyName the column family to snapshot
* @param tag the tag given to the snapshot; may not be null or empty
*/
public void takeColumnFamilySnapshot(String keyspaceName, String columnFamilyName, String tag) throws IOException
{
if (keyspaceName == null)
throw new IOException("You must supply a keyspace name");
if (operationMode.equals(Mode.JOINING))
throw new IOException("Cannot snapshot until bootstrap completes");
if (columnFamilyName == null)
throw new IOException("You must supply a column family name");
if (columnFamilyName.contains("."))
throw new IllegalArgumentException("Cannot take a snapshot of a secondary index by itself. Run snapshot on the column family that owns the index.");
if (tag == null || tag.equals(""))
throw new IOException("You must supply a snapshot name.");
Keyspace keyspace = getValidKeyspace(keyspaceName);
ColumnFamilyStore columnFamilyStore = keyspace.getColumnFamilyStore(columnFamilyName);
if (columnFamilyStore.snapshotExists(tag))
throw new IOException("Snapshot " + tag + " already exists.");
columnFamilyStore.snapshot(tag);
}
示例8: getMemtableAllocatorPool
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
public static MemtablePool getMemtableAllocatorPool()
{
long heapLimit = ((long) conf.memtable_heap_space_in_mb) << 20;
long offHeapLimit = ((long) conf.memtable_offheap_space_in_mb) << 20;
switch (conf.memtable_allocation_type)
{
case unslabbed_heap_buffers:
return new HeapPool(heapLimit, conf.memtable_cleanup_threshold, new ColumnFamilyStore.FlushLargestColumnFamily());
case heap_buffers:
return new SlabPool(heapLimit, 0, conf.memtable_cleanup_threshold, new ColumnFamilyStore.FlushLargestColumnFamily());
case offheap_buffers:
if (!FileUtils.isCleanerAvailable())
{
throw new IllegalStateException("Could not free direct byte buffer: offheap_buffers is not a safe memtable_allocation_type without this ability, please adjust your config. This feature is only guaranteed to work on an Oracle JVM. Refusing to start.");
}
return new SlabPool(heapLimit, offHeapLimit, conf.memtable_cleanup_threshold, new ColumnFamilyStore.FlushLargestColumnFamily());
case offheap_objects:
throw new ConfigurationException("offheap_objects are not available in 3.0. They should be re-introduced in a future release, see https://issues.apache.org/jira/browse/CASSANDRA-9472 for details");
// return new NativePool(heapLimit, offHeapLimit, conf.memtable_cleanup_threshold, new ColumnFamilyStore.FlushLargestColumnFamily());
default:
throw new AssertionError();
}
}
示例9: getSplits
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
/**
* @return list of Token ranges (_not_ keys!) together with estimated key count,
* breaking up the data this node is responsible for into pieces of roughly keysPerSplit
*/
public List<Pair<Range<Token>, Long>> getSplits(String keyspaceName, String cfName, Range<Token> range, int keysPerSplit)
{
Keyspace t = Keyspace.open(keyspaceName);
ColumnFamilyStore cfs = t.getColumnFamilyStore(cfName);
List<DecoratedKey> keys = keySamples(Collections.singleton(cfs), range);
long totalRowCountEstimate = cfs.estimatedKeysForRange(range);
// splitCount should be much smaller than number of key samples, to avoid huge sampling error
int minSamplesPerSplit = 4;
int maxSplitCount = keys.size() / minSamplesPerSplit + 1;
int splitCount = Math.max(1, Math.min(maxSplitCount, (int)(totalRowCountEstimate / keysPerSplit)));
List<Token> tokens = keysToTokens(range, keys);
return getSplits(tokens, splitCount, cfs);
}
示例10: complete
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
private void complete()
{
if (!SSTableReader.acquireReferences(sstables))
throw new AssertionError("We shouldn't fail acquiring a reference on a sstable that has just been transferred");
try
{
Pair<String, String> kscf = Schema.instance.getCF(cfId);
ColumnFamilyStore cfs = Keyspace.open(kscf.left).getColumnFamilyStore(kscf.right);
// add sstables and build secondary indexes
cfs.addSSTables(sstables);
cfs.indexManager.maybeBuildSecondaryIndexes(sstables, cfs.indexManager.allIndexesNames());
}
finally
{
SSTableReader.releaseReferences(sstables);
}
session.taskCompleted(this);
}
示例11: testAbortOnlyNew
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
@Test
public void testAbortOnlyNew() throws Throwable
{
ColumnFamilyStore cfs = MockSchema.newCFS(KEYSPACE);
File dataFolder = new Directories(cfs.metadata).getDirectoryForNewSSTables();
SSTableReader sstable = sstable(dataFolder, cfs, 0, 128);
LogTransaction log = new LogTransaction(OperationType.COMPACTION);
assertNotNull(log);
log.trackNew(sstable);
log.abort();
sstable.selfRef().release();
assertFiles(dataFolder.getPath(), new HashSet<>());
}
示例12: testGetScannerForNoIntersectingRanges
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
/** see CASSANDRA-5407 */
@Test
public void testGetScannerForNoIntersectingRanges()
{
Keyspace keyspace = Keyspace.open("Keyspace1");
ColumnFamilyStore store = keyspace.getColumnFamilyStore("Standard1");
ByteBuffer key = ByteBufferUtil.bytes(String.valueOf("k1"));
Mutation rm = new Mutation("Keyspace1", key);
rm.add("Standard1", cellname("xyz"), ByteBufferUtil.bytes("abc"), 0);
rm.apply();
store.forceBlockingFlush();
boolean foundScanner = false;
for (SSTableReader s : store.getSSTables())
{
ISSTableScanner scanner = s.getScanner(new Range<Token>(t(0), t(1), s.partitioner), null);
scanner.next(); // throws exception pre 5407
foundScanner = true;
}
assertTrue(foundScanner);
}
示例13: LeveledManifest
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
LeveledManifest(ColumnFamilyStore cfs, int maxSSTableSizeInMB, SizeTieredCompactionStrategyOptions options)
{
this.cfs = cfs;
this.maxSSTableSizeInBytes = maxSSTableSizeInMB * 1024 * 1024;
this.options = options;
// allocate enough generations for a PB of data, with a 1-MB sstable size. (Note that if maxSSTableSize is
// updated, we will still have sstables of the older, potentially smaller size. So don't make this
// dependent on maxSSTableSize.)
int n = (int) Math.log10(1000 * 1000 * 1000);
generations = new List[n];
lastCompactedKeys = new RowPosition[n];
for (int i = 0; i < generations.length; i++)
{
generations[i] = new ArrayList<>();
lastCompactedKeys[i] = cfs.partitioner.getMinimumToken().minKeyBound();
}
compactionCounter = new int[n];
}
示例14: testSnapshotAddSSTables
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
@Test
public void testSnapshotAddSSTables() throws ExecutionException, InterruptedException
{
ColumnFamilyStore store = prepareColumnFamilyStore();
UUID prsId = UUID.randomUUID();
Set<SSTableReader> original = Sets.newHashSet(store.select(View.select(SSTableSet.CANONICAL, (s) -> !s.isRepaired())).sstables);
ActiveRepairService.instance.registerParentRepairSession(prsId, FBUtilities.getBroadcastAddress(), Collections.singletonList(store), Collections.singleton(new Range<>(store.getPartitioner().getMinimumToken(), store.getPartitioner().getMinimumToken())), true, System.currentTimeMillis(), true);
ActiveRepairService.instance.getParentRepairSession(prsId).maybeSnapshot(store.metadata.cfId, prsId);
UUID prsId2 = UUID.randomUUID();
ActiveRepairService.instance.registerParentRepairSession(prsId2, FBUtilities.getBroadcastAddress(), Collections.singletonList(store), Collections.singleton(new Range<>(store.getPartitioner().getMinimumToken(), store.getPartitioner().getMinimumToken())), true, System.currentTimeMillis(), true);
createSSTables(store, 2);
ActiveRepairService.instance.getParentRepairSession(prsId).maybeSnapshot(store.metadata.cfId, prsId);
try (Refs<SSTableReader> refs = ActiveRepairService.instance.getParentRepairSession(prsId).getActiveRepairedSSTableRefsForAntiCompaction(store.metadata.cfId, prsId))
{
assertEquals(original, Sets.newHashSet(refs.iterator()));
}
store.forceMajorCompaction();
// after a major compaction the original sstables will be gone and we will have no sstables to anticompact:
try (Refs<SSTableReader> refs = ActiveRepairService.instance.getParentRepairSession(prsId).getActiveRepairedSSTableRefsForAntiCompaction(store.metadata.cfId, prsId))
{
assertEquals(0, refs.size());
}
}
示例15: addNewKS
import org.apache.cassandra.db.ColumnFamilyStore; //导入依赖的package包/类
@Test
public void addNewKS() throws ConfigurationException
{
CFMetaData cfm = addTestTable("newkeyspace1", "newstandard1", "A new cf for a new ks");
KeyspaceMetadata newKs = KeyspaceMetadata.create(cfm.ksName, KeyspaceParams.simple(5), Tables.of(cfm));
MigrationManager.announceNewKeyspace(newKs);
assertNotNull(Schema.instance.getKSMetaData(cfm.ksName));
assertEquals(Schema.instance.getKSMetaData(cfm.ksName), newKs);
// test reads and writes.
QueryProcessor.executeInternal("INSERT INTO newkeyspace1.newstandard1 (key, col, val) VALUES (?, ?, ?)",
"key0", "col0", "val0");
ColumnFamilyStore store = Keyspace.open(cfm.ksName).getColumnFamilyStore(cfm.cfName);
assertNotNull(store);
store.forceBlockingFlush();
UntypedResultSet rows = QueryProcessor.executeInternal("SELECT * FROM newkeyspace1.newstandard1");
assertRows(rows, row("key0", "col0", "val0"));
}