Java Code Examples for org.apache.cassandra.service.MigrationManager#announceNewColumnFamily()
The following examples show how to use
org.apache.cassandra.service.MigrationManager#announceNewColumnFamily() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CassandraServer.java From stratio-cassandra with Apache License 2.0 | 6 votes |
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); } }
Example 2
Source File: TriggersSchemaTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@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)); }
Example 3
Source File: CreateTableStatement.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public boolean announceMigration(boolean isLocalOnly) throws RequestValidationException { try { MigrationManager.announceNewColumnFamily(getCFMetaData(), isLocalOnly); return true; } catch (AlreadyExistsException e) { if (ifNotExists) return false; throw e; } }
Example 4
Source File: DefsTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@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) { } }