本文整理汇总了Java中org.apache.cassandra.service.MigrationManager.announceColumnFamilyUpdate方法的典型用法代码示例。如果您正苦于以下问题:Java MigrationManager.announceColumnFamilyUpdate方法的具体用法?Java MigrationManager.announceColumnFamilyUpdate怎么用?Java MigrationManager.announceColumnFamilyUpdate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.service.MigrationManager
的用法示例。
在下文中一共展示了MigrationManager.announceColumnFamilyUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTriggerToCf
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addTriggerToCf() throws Exception
{
CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
KSMetaData ksm = KSMetaData.newKeyspace(ksName,
SimpleStrategy.class,
Collections.singletonMap("replication_factor", "1"),
true,
Collections.singletonList(cfm1));
MigrationManager.announceNewKeyspace(ksm);
CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName).copy();
TriggerDefinition td = TriggerDefinition.create(triggerName, triggerClass);
cfm2.addTriggerDefinition(td);
MigrationManager.announceColumnFamilyUpdate(cfm2, false);
CFMetaData cfm3 = Schema.instance.getCFMetaData(ksName, cfName);
assertFalse(cfm3.getTriggers().isEmpty());
assertEquals(1, cfm3.getTriggers().size());
assertEquals(td, cfm3.getTriggers().get(triggerName));
}
示例2: removeTriggerFromCf
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void removeTriggerFromCf() throws Exception
{
TriggerDefinition td = TriggerDefinition.create(triggerName, triggerClass);
CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
cfm1.addTriggerDefinition(td);
KSMetaData ksm = KSMetaData.newKeyspace(ksName,
SimpleStrategy.class,
Collections.singletonMap("replication_factor", "1"),
true,
Collections.singletonList(cfm1));
MigrationManager.announceNewKeyspace(ksm);
CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName).copy();
cfm2.removeTrigger(triggerName);
MigrationManager.announceColumnFamilyUpdate(cfm2, false);
CFMetaData cfm3 = Schema.instance.getCFMetaData(ksName, cfName).copy();
assertTrue(cfm3.getTriggers().isEmpty());
}
示例3: announceMigration
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public void announceMigration() throws InvalidRequestException, ConfigurationException
{
logger.debug("Updating column {} definition for index {}", columnName, indexName);
CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).clone();
ColumnDefinition cd = cfm.getColumnDefinition(columnName.key);
if (cd.getIndexType() != null && ifNotExists)
return;
if (isCustom)
cd.setIndexType(IndexType.CUSTOM, Collections.singletonMap(SecondaryIndex.CUSTOM_INDEX_OPTION_NAME, indexClass));
else if (cfm.getCfDef().isComposite)
cd.setIndexType(IndexType.COMPOSITES, Collections.<String, String>emptyMap());
else
cd.setIndexType(IndexType.KEYS, Collections.<String, String>emptyMap());
cd.setIndexName(indexName);
cfm.addDefaultIndexNames();
MigrationManager.announceColumnFamilyUpdate(cfm, false);
}
示例4: announceMigration
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws ConfigurationException, InvalidRequestException
{
CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).copy();
Triggers triggers = cfm.getTriggers();
if (triggers.get(triggerName).isPresent())
{
if (ifNotExists)
return null;
else
throw new InvalidRequestException(String.format("Trigger %s already exists", triggerName));
}
cfm.triggers(triggers.with(TriggerMetadata.create(triggerName, triggerClass)));
logger.info("Adding trigger with name {} and class {}", triggerName, triggerClass);
MigrationManager.announceColumnFamilyUpdate(cfm, isLocalOnly);
return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily());
}
示例5: announceMigration
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public Event.SchemaChange announceMigration(boolean isLocalOnly) throws ConfigurationException, InvalidRequestException
{
CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).copy();
Triggers triggers = cfm.getTriggers();
if (!triggers.get(triggerName).isPresent())
{
if (ifExists)
return null;
else
throw new InvalidRequestException(String.format("Trigger %s was not found", triggerName));
}
logger.info("Dropping trigger with name {}", triggerName);
cfm.triggers(triggers.without(triggerName));
MigrationManager.announceColumnFamilyUpdate(cfm, isLocalOnly);
return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily());
}
示例6: addTriggerToCf
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void addTriggerToCf() throws Exception
{
CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
KeyspaceMetadata ksm = KeyspaceMetadata.create(ksName, KeyspaceParams.simple(1), Tables.of(cfm1));
MigrationManager.announceNewKeyspace(ksm);
CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName).copy();
TriggerMetadata td = TriggerMetadata.create(triggerName, triggerClass);
cfm2.triggers(cfm2.getTriggers().with(td));
MigrationManager.announceColumnFamilyUpdate(cfm2);
CFMetaData cfm3 = Schema.instance.getCFMetaData(ksName, cfName);
assertFalse(cfm3.getTriggers().isEmpty());
assertEquals(1, cfm3.getTriggers().size());
assertEquals(td, cfm3.getTriggers().get(triggerName).get());
}
示例7: removeTriggerFromCf
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void removeTriggerFromCf() throws Exception
{
TriggerMetadata td = TriggerMetadata.create(triggerName, triggerClass);
CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName);
cfm1.triggers(cfm1.getTriggers().with(td));
KeyspaceMetadata ksm = KeyspaceMetadata.create(ksName, KeyspaceParams.simple(1), Tables.of(cfm1));
MigrationManager.announceNewKeyspace(ksm);
CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName).copy();
cfm2.triggers(cfm2.getTriggers().without(triggerName));
MigrationManager.announceColumnFamilyUpdate(cfm2);
CFMetaData cfm3 = Schema.instance.getCFMetaData(ksName, cfName).copy();
assertTrue(cfm3.getTriggers().isEmpty());
}
示例8: announceMigration
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public boolean announceMigration(boolean isLocalOnly) throws ConfigurationException, InvalidRequestException
{
CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).copy();
TriggerDefinition triggerDefinition = TriggerDefinition.create(triggerName, triggerClass);
if (!ifNotExists || !cfm.containsTriggerDefinition(triggerDefinition))
{
cfm.addTriggerDefinition(triggerDefinition);
logger.info("Adding trigger with name {} and class {}", triggerName, triggerClass);
MigrationManager.announceColumnFamilyUpdate(cfm, false, isLocalOnly);
return true;
}
return false;
}
示例9: testDropIndex
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
@Test
public void testDropIndex() throws ConfigurationException
{
// persist keyspace definition in the system keyspace
SchemaKeyspace.makeCreateKeyspaceMutation(Schema.instance.getKSMetaData(KEYSPACE6), FBUtilities.timestampMicros()).applyUnsafe();
ColumnFamilyStore cfs = Keyspace.open(KEYSPACE6).getColumnFamilyStore(TABLE1i);
String indexName = "birthdate_key_index";
// insert some data. save the sstable descriptor so we can make sure it's marked for delete after the drop
QueryProcessor.executeInternal(String.format(
"INSERT INTO %s.%s (key, c1, birthdate, notbirthdate) VALUES (?, ?, ?, ?)",
KEYSPACE6,
TABLE1i),
"key0", "col0", 1L, 1L);
cfs.forceBlockingFlush();
ColumnFamilyStore indexCfs = cfs.indexManager.getIndexByName(indexName)
.getBackingTable()
.orElseThrow(throwAssert("Cannot access index cfs"));
Descriptor desc = indexCfs.getLiveSSTables().iterator().next().descriptor;
// drop the index
CFMetaData meta = cfs.metadata.copy();
IndexMetadata existing = cfs.metadata.getIndexes()
.get(indexName)
.orElseThrow(throwAssert("Index not found"));
meta.indexes(meta.getIndexes().without(existing.name));
MigrationManager.announceColumnFamilyUpdate(meta);
// check
assertTrue(cfs.indexManager.listIndexes().isEmpty());
LifecycleTransaction.waitForDeletions();
assertFalse(new File(desc.filenameFor(Component.DATA)).exists());
}
示例10: announceMigration
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public boolean announceMigration(boolean isLocalOnly) throws ConfigurationException, InvalidRequestException
{
CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).copy();
if (cfm.removeTrigger(triggerName))
{
logger.info("Dropping trigger with name {}", triggerName);
MigrationManager.announceColumnFamilyUpdate(cfm, false, isLocalOnly);
return true;
}
if (!ifExists)
throw new InvalidRequestException(String.format("Trigger %s was not found", triggerName));
return false;
}
示例11: announceMigration
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public boolean announceMigration(boolean isLocalOnly) throws InvalidRequestException, ConfigurationException
{
CFMetaData cfm = findIndexedCF();
if (cfm == null)
return false;
CFMetaData updatedCfm = updateCFMetadata(cfm);
indexedCF = updatedCfm.cfName;
MigrationManager.announceColumnFamilyUpdate(updatedCfm, false, isLocalOnly);
return true;
}
示例12: system_update_column_family
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public String system_update_column_family(CfDef cf_def)
throws InvalidRequestException, SchemaDisagreementException, TException
{
logger.debug("update_column_family");
try
{
if (cf_def.keyspace == null || cf_def.name == null)
throw new InvalidRequestException("Keyspace and CF name must be set.");
state().hasColumnFamilyAccess(cf_def.keyspace, cf_def.name, Permission.ALTER);
CFMetaData oldCfm = Schema.instance.getCFMetaData(cf_def.keyspace, cf_def.name);
if (oldCfm == null)
throw new InvalidRequestException("Could not find column family definition to modify.");
if (!oldCfm.isThriftCompatible())
throw new InvalidRequestException("Cannot modify CQL3 table " + oldCfm.cfName + " as it may break the schema. You should use cqlsh to modify CQL3 tables instead.");
CFMetaData cfm = CFMetaData.fromThriftForUpdate(cf_def, oldCfm);
CFMetaData.validateCompactionOptions(cfm.compactionStrategyClass, cfm.compactionStrategyOptions);
cfm.addDefaultIndexNames();
if (!oldCfm.getTriggers().equals(cfm.getTriggers()))
state().ensureIsSuper("Only superusers are allowed to add or remove triggers.");
MigrationManager.announceColumnFamilyUpdate(cfm, true);
return Schema.instance.getVersion().toString();
}
catch (RequestValidationException e)
{
throw ThriftConversion.toThrift(e);
}
}
示例13: announceMigration
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public void announceMigration() throws ConfigurationException
{
CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).clone();
cfm.addTriggerDefinition(TriggerDefinition.create(triggerName, triggerClass));
logger.info("Adding trigger with name {} and class {}", triggerName, triggerClass);
MigrationManager.announceColumnFamilyUpdate(cfm, false);
}
示例14: announceMigration
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public void announceMigration() throws ConfigurationException
{
CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).clone();
if (!cfm.removeTrigger(triggerName))
throw new ConfigurationException(String.format("Trigger %s was not found", triggerName));
logger.info("Dropping trigger with name {}", triggerName);
MigrationManager.announceColumnFamilyUpdate(cfm, false);
}
示例15: announceMigration
import org.apache.cassandra.service.MigrationManager; //导入方法依赖的package包/类
public void announceMigration() throws InvalidRequestException, ConfigurationException
{
CFMetaData cfm = findIndexedCF();
if (cfm == null)
return;
CFMetaData updatedCfm = updateCFMetadata(cfm);
MigrationManager.announceColumnFamilyUpdate(updatedCfm, false);
}