本文整理汇总了Java中org.apache.cassandra.service.MigrationManager.announceNewColumnFamily方法的典型用法代码示例。如果您正苦于以下问题:Java MigrationManager.announceNewColumnFamily方法的具体用法?Java MigrationManager.announceNewColumnFamily怎么用?Java MigrationManager.announceNewColumnFamily使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.service.MigrationManager
的用法示例。
在下文中一共展示了MigrationManager.announceNewColumnFamily方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: system_add_column_family
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public String system_add_column_family(CfDef cf_def)
throws InvalidRequestException, SchemaDisagreementException, TException
{
logger.debug("add_column_family");
try
{
ClientState cState = state();
String keyspace = cState.getKeyspace();
cState.hasKeyspaceAccess(keyspace, Permission.CREATE);
cf_def.unsetId(); // explicitly ignore any id set by client (Hector likes to set zero)
CFMetaData cfm = CFMetaData.fromThrift(cf_def);
CFMetaData.validateCompactionOptions(cfm.compactionStrategyClass, cfm.compactionStrategyOptions);
cfm.addDefaultIndexNames();
if (!cfm.getTriggers().isEmpty())
state().ensureIsSuper("Only superusers are allowed to add triggers.");
MigrationManager.announceNewColumnFamily(cfm);
return Schema.instance.getVersion().toString();
}
catch (RequestValidationException e)
{
throw ThriftConversion.toThrift(e);
}
}
示例2: addNewCfWithTriggerToKs
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addNewCfWithTriggerToKs() throws Exception
{
KSMetaData ksm = KSMetaData.newKeyspace(ksName,
SimpleStrategy.class,
Collections.singletonMap("replication_factor", "1"),
true,
Collections.EMPTY_LIST);
MigrationManager.announceNewKeyspace(ksm);
CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
TriggerDefinition td = TriggerDefinition.create(triggerName, triggerClass);
cfm1.addTriggerDefinition(td);
MigrationManager.announceNewColumnFamily(cfm1);
CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName);
assertFalse(cfm2.getTriggers().isEmpty());
assertEquals(1, cfm2.getTriggers().size());
assertEquals(td, cfm2.getTriggers().get(triggerName));
}
示例3: addNewCfWithTriggerToKs
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addNewCfWithTriggerToKs() throws Exception
{
KeyspaceMetadata ksm = KeyspaceMetadata.create(ksName, KeyspaceParams.simple(1));
MigrationManager.announceNewKeyspace(ksm);
CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
TriggerMetadata td = TriggerMetadata.create(triggerName, triggerClass);
cfm1.triggers(cfm1.getTriggers().with(td));
MigrationManager.announceNewColumnFamily(cfm1);
CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName);
assertFalse(cfm2.getTriggers().isEmpty());
assertEquals(1, cfm2.getTriggers().size());
assertEquals(td, cfm2.getTriggers().get(triggerName).get());
}
示例4: system_add_column_family
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public String system_add_column_family(CfDef cf_def)
throws InvalidRequestException, SchemaDisagreementException, TException
{
logger.debug("add_column_family");
try
{
ClientState cState = state();
String keyspace = cState.getKeyspace();
cState.hasKeyspaceAccess(keyspace, Permission.CREATE);
cf_def.unsetId(); // explicitly ignore any id set by client (Hector likes to set zero)
CFMetaData cfm = CFMetaData.fromThrift(cf_def);
CFMetaData.validateCompactionOptions(cfm.compactionStrategyClass, cfm.compactionStrategyOptions, false);
cfm.addDefaultIndexNames();
MigrationManager.announceNewColumnFamily(cfm);
return Schema.instance.getVersion().toString();
}
catch (RequestValidationException e)
{
throw ThriftConversion.toThrift(e);
}
}
示例5: announceMigration
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public boolean announceMigration(boolean isLocalOnly) throws RequestValidationException
{
try
{
MigrationManager.announceNewColumnFamily(getCFMetaData(), isLocalOnly);
return true;
}
catch (AlreadyExistsException e)
{
if (ifNotExists)
return false;
throw e;
}
}
示例6: addNewCfToBogusKeyspace
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addNewCfToBogusKeyspace()
{
CFMetaData newCf = addTestCF("MadeUpKeyspace", "NewCF", "new cf");
try
{
MigrationManager.announceNewColumnFamily(newCf);
throw new AssertionError("You shouldn't be able to do anything to a keyspace that doesn't exist.");
}
catch (ConfigurationException expected)
{
}
}
示例7: announceMigration
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public void announceMigration() throws RequestValidationException
{
try
{
MigrationManager.announceNewColumnFamily(getCFMetaData());
}
catch (AlreadyExistsException e)
{
if (!ifNotExists)
throw e;
}
}
示例8: addNewCfToBogusKeyspace
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addNewCfToBogusKeyspace() throws InterruptedException
{
CFMetaData newCf = addTestCF("MadeUpKeyspace", "NewCF", "new cf");
try
{
MigrationManager.announceNewColumnFamily(newCf);
throw new AssertionError("You shouldn't be able to do anything to a keyspace that doesn't exist.");
}
catch (ConfigurationException expected)
{
}
}
示例9: announceMigration
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws RequestValidationException
{
try
{
MigrationManager.announceNewColumnFamily(getCFMetaData(), isLocalOnly);
return new Event.SchemaChange(Event.SchemaChange.Change.CREATED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily());
}
catch (AlreadyExistsException e)
{
if (ifNotExists)
return null;
throw e;
}
}
示例10: addNewCfToBogusKeyspace
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addNewCfToBogusKeyspace()
{
CFMetaData newCf = addTestTable("MadeUpKeyspace", "NewCF", "new cf");
try
{
MigrationManager.announceNewColumnFamily(newCf);
throw new AssertionError("You shouldn't be able to do anything to a keyspace that doesn't exist.");
}
catch (ConfigurationException expected)
{
}
}
示例11: addNewTable
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addNewTable() throws ConfigurationException
{
final String ksName = KEYSPACE1;
final String tableName = "anewtable";
KeyspaceMetadata original = Schema.instance.getKSMetaData(ksName);
CFMetaData cfm = addTestTable(original.name, tableName, "A New Table");
assertFalse(Schema.instance.getKSMetaData(ksName).tables.get(cfm.cfName).isPresent());
MigrationManager.announceNewColumnFamily(cfm);
assertTrue(Schema.instance.getKSMetaData(ksName).tables.get(cfm.cfName).isPresent());
assertEquals(cfm, Schema.instance.getKSMetaData(ksName).tables.get(cfm.cfName).get());
// now read and write to it.
QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (key, col, val) VALUES (?, ?, ?)",
ksName, tableName),
"key0", "col0", "val0");
// flush to exercise more than just hitting the memtable
ColumnFamilyStore cfs = Keyspace.open(ksName).getColumnFamilyStore(tableName);
assertNotNull(cfs);
cfs.forceBlockingFlush();
// and make sure we get out what we put in
UntypedResultSet rows = QueryProcessor.executeInternal(String.format("SELECT * FROM %s.%s", ksName, tableName));
assertRows(rows, row("key0", "col0", "val0"));
}
示例12: createEmptyKsAddNewCf
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void createEmptyKsAddNewCf() throws ConfigurationException
{
assertNull(Schema.instance.getKSMetaData(EMPTY_KEYSPACE));
KeyspaceMetadata newKs = KeyspaceMetadata.create(EMPTY_KEYSPACE, KeyspaceParams.simple(5));
MigrationManager.announceNewKeyspace(newKs);
assertNotNull(Schema.instance.getKSMetaData(EMPTY_KEYSPACE));
String tableName = "added_later";
CFMetaData newCf = addTestTable(EMPTY_KEYSPACE, tableName, "A new CF to add to an empty KS");
//should not exist until apply
assertFalse(Schema.instance.getKSMetaData(newKs.name).tables.get(newCf.cfName).isPresent());
//add the new CF to the empty space
MigrationManager.announceNewColumnFamily(newCf);
assertTrue(Schema.instance.getKSMetaData(newKs.name).tables.get(newCf.cfName).isPresent());
assertEquals(Schema.instance.getKSMetaData(newKs.name).tables.get(newCf.cfName).get(), newCf);
// now read and write to it.
QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (key, col, val) VALUES (?, ?, ?)",
EMPTY_KEYSPACE, tableName),
"key0", "col0", "val0");
ColumnFamilyStore cfs = Keyspace.open(newKs.name).getColumnFamilyStore(newCf.cfName);
assertNotNull(cfs);
cfs.forceBlockingFlush();
UntypedResultSet rows = QueryProcessor.executeInternal(String.format("SELECT * FROM %s.%s", EMPTY_KEYSPACE, tableName));
assertRows(rows, row("key0", "col0", "val0"));
}
示例13: addNewCfWithNullComment
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addNewCfWithNullComment() throws ConfigurationException
{
final String ks = "Keyspace1";
final String cf = "BrandNewCfWithNull";
KSMetaData original = Schema.instance.getKSMetaData(ks);
CFMetaData newCf = addTestCF(original.name, cf, null);
Assert.assertFalse(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName));
MigrationManager.announceNewColumnFamily(newCf);
Assert.assertTrue(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName));
Assert.assertEquals(newCf, Schema.instance.getKSMetaData(ks).cfMetaData().get(newCf.cfName));
}
示例14: addNewCF
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addNewCF() throws ConfigurationException
{
final String ks = "Keyspace1";
final String cf = "BrandNewCf";
KSMetaData original = Schema.instance.getKSMetaData(ks);
CFMetaData newCf = addTestCF(original.name, cf, "A New Column Family");
Assert.assertFalse(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName));
MigrationManager.announceNewColumnFamily(newCf);
Assert.assertTrue(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName));
Assert.assertEquals(newCf, Schema.instance.getKSMetaData(ks).cfMetaData().get(newCf.cfName));
// now read and write to it.
CellName col0 = cellname("col0");
DecoratedKey dk = Util.dk("key0");
Mutation rm = new Mutation(ks, dk.key);
rm.add(cf, col0, ByteBufferUtil.bytes("value0"), 1L);
rm.apply();
ColumnFamilyStore store = Keyspace.open(ks).getColumnFamilyStore(cf);
Assert.assertNotNull(store);
store.forceBlockingFlush();
ColumnFamily cfam = store.getColumnFamily(Util.namesQueryFilter(store, dk, col0));
Assert.assertNotNull(cfam.getColumn(col0));
Cell col = cfam.getColumn(col0);
Assert.assertEquals(ByteBufferUtil.bytes("value0"), col.value());
}
示例15: addNewCF
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addNewCF() throws ConfigurationException
{
final String ks = KEYSPACE1;
final String cf = "BrandNewCf";
KSMetaData original = Schema.instance.getKSMetaData(ks);
CFMetaData newCf = addTestCF(original.name, cf, "A New Table");
Assert.assertFalse(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName));
MigrationManager.announceNewColumnFamily(newCf);
Assert.assertTrue(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName));
Assert.assertEquals(newCf, Schema.instance.getKSMetaData(ks).cfMetaData().get(newCf.cfName));
// now read and write to it.
CellName col0 = cellname("col0");
DecoratedKey dk = Util.dk("key0");
Mutation rm = new Mutation(ks, dk.getKey());
rm.add(cf, col0, ByteBufferUtil.bytes("value0"), 1L);
rm.applyUnsafe();
ColumnFamilyStore store = Keyspace.open(ks).getColumnFamilyStore(cf);
Assert.assertNotNull(store);
store.forceBlockingFlush();
ColumnFamily cfam = store.getColumnFamily(Util.namesQueryFilter(store, dk, col0));
Assert.assertNotNull(cfam.getColumn(col0));
Cell col = cfam.getColumn(col0);
Assert.assertEquals(ByteBufferUtil.bytes("value0"), col.value());
}