org.apache.cassandra.config.KSMetaData Java Examples
The following examples show how to use
org.apache.cassandra.config.KSMetaData.
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: 986499_AddColumnFamily_0_s.java From coming with MIT License | 6 votes |
public AddColumnFamily(CFMetaData cfm) throws ConfigurationException, IOException { super(UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress()), DatabaseDescriptor.getDefsVersion()); this.cfm = cfm; KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); if (ksm == null) throw new ConfigurationException("Keyspace does not already exist."); else if (ksm.cfMetaData().containsKey(cfm.cfName)) throw new ConfigurationException("CF is already defined in that keyspace."); else if (!Migration.isLegalName(cfm.cfName)) throw new ConfigurationException("Invalid column family name: " + cfm.cfName); KSMetaData newKsm = makeNewKeyspaceDefinition(ksm); rm = Migration.makeDefinitionMutation(newKsm, null, newVersion); }
Example #2
Source File: CassandraRunner.java From staash with Apache License 2.0 | 6 votes |
private void maybeCreateKeyspace(RequiresKeyspace rk, RequiresColumnFamily rcf) { logger.debug("RequiresKeyspace annotation has keyspace name: {}", rk.ksName()); List<CFMetaData> cfs = extractColumnFamily(rcf); try { MigrationManager .announceNewKeyspace(KSMetaData.newKeyspace(rk.ksName(), rk.strategy(), KSMetaData.optsWithRF(rk.replication()), false, cfs)); } catch (AlreadyExistsException aee) { logger.info("using existing Keyspace for " + rk.ksName()); if ( cfs.size() > 0 ) { maybeTruncateSafely(rcf); } } catch (Exception ex) { throw new RuntimeException("Failure creating keyspace for " + rk.ksName(),ex); } }
Example #3
Source File: TriggersSchemaTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@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()); }
Example #4
Source File: TriggersSchemaTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@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)); }
Example #5
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 #6
Source File: TriggersSchemaTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Test public void newKsContainsCfWithTrigger() 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); assertFalse(cfm2.getTriggers().isEmpty()); assertEquals(1, cfm2.getTriggers().size()); assertEquals(td, cfm2.getTriggers().get(triggerName)); }
Example #7
Source File: OldNetworkTopologyStrategyTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
/** * 2 same rack endpoints * 1 same datacenter, different rack endpoints * 1 external datacenter * * @throws UnknownHostException */ @Test public void testBigIntegerEndpointsC() throws UnknownHostException { RackInferringSnitch endpointSnitch = new RackInferringSnitch(); AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tmd, endpointSnitch, KSMetaData.optsWithRF(1)); addEndpoint("0", "5", "254.0.0.1"); addEndpoint("10", "15", "254.0.0.2"); addEndpoint("20", "25", "254.0.1.3"); addEndpoint("30", "35", "254.1.0.4"); expectedResults.put("5", buildResult("254.0.0.2", "254.0.1.3", "254.1.0.4")); expectedResults.put("15", buildResult("254.0.1.3", "254.1.0.4", "254.0.0.1")); expectedResults.put("25", buildResult("254.1.0.4", "254.0.0.1", "254.0.0.2")); expectedResults.put("35", buildResult("254.0.0.1", "254.0.1.3", "254.1.0.4")); testGetEndpoints(strategy, keyTokens.toArray(new Token[0])); }
Example #8
Source File: OldNetworkTopologyStrategyTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
/** * 3 same rack endpoints * 1 external datacenter * * @throws UnknownHostException */ @Test public void testBigIntegerEndpointsB() throws UnknownHostException { RackInferringSnitch endpointSnitch = new RackInferringSnitch(); AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tmd, endpointSnitch, KSMetaData.optsWithRF(1)); addEndpoint("0", "5", "254.0.0.1"); addEndpoint("10", "15", "254.0.0.2"); addEndpoint("20", "25", "254.1.0.3"); addEndpoint("30", "35", "254.0.0.4"); expectedResults.put("5", buildResult("254.0.0.2", "254.1.0.3", "254.0.0.4")); expectedResults.put("15", buildResult("254.1.0.3", "254.0.0.4", "254.0.0.1")); expectedResults.put("25", buildResult("254.0.0.4", "254.1.0.3", "254.0.0.1")); expectedResults.put("35", buildResult("254.0.0.1", "254.1.0.3", "254.0.0.2")); testGetEndpoints(strategy, keyTokens.toArray(new Token[0])); }
Example #9
Source File: OldNetworkTopologyStrategyTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
/** * 4 same rack endpoints * * @throws UnknownHostException */ @Test public void testBigIntegerEndpointsA() throws UnknownHostException { RackInferringSnitch endpointSnitch = new RackInferringSnitch(); AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tmd, endpointSnitch, KSMetaData.optsWithRF(1)); addEndpoint("0", "5", "254.0.0.1"); addEndpoint("10", "15", "254.0.0.2"); addEndpoint("20", "25", "254.0.0.3"); addEndpoint("30", "35", "254.0.0.4"); expectedResults.put("5", buildResult("254.0.0.2", "254.0.0.3", "254.0.0.4")); expectedResults.put("15", buildResult("254.0.0.3", "254.0.0.4", "254.0.0.1")); expectedResults.put("25", buildResult("254.0.0.4", "254.0.0.1", "254.0.0.2")); expectedResults.put("35", buildResult("254.0.0.1", "254.0.0.2", "254.0.0.3")); testGetEndpoints(strategy, keyTokens.toArray(new Token[0])); }
Example #10
Source File: CassandraServer.java From stratio-cassandra with Apache License 2.0 | 6 votes |
/** update an existing keyspace, but do not allow column family modifications. * @throws SchemaDisagreementException */ public String system_update_keyspace(KsDef ks_def) throws InvalidRequestException, SchemaDisagreementException, TException { logger.debug("update_keyspace"); try { ThriftValidation.validateKeyspaceNotSystem(ks_def.name); state().hasKeyspaceAccess(ks_def.name, Permission.ALTER); ThriftValidation.validateKeyspace(ks_def.name); if (ks_def.getCf_defs() != null && ks_def.getCf_defs().size() > 0) throw new InvalidRequestException("Keyspace update must not contain any column family definitions."); MigrationManager.announceKeyspaceUpdate(KSMetaData.fromThrift(ks_def)); return Schema.instance.getVersion().toString(); } catch (RequestValidationException e) { throw ThriftConversion.toThrift(e); } }
Example #11
Source File: DefsTables.java From stratio-cassandra with Apache License 2.0 | 6 votes |
/** * Load keyspace definitions for the system keyspace (system.SCHEMA_KEYSPACES_CF) * * @return Collection of found keyspace definitions */ public static Collection<KSMetaData> loadFromKeyspace() { List<Row> serializedSchema = SystemKeyspace.serializedSchema(SystemKeyspace.SCHEMA_KEYSPACES_CF); List<KSMetaData> keyspaces = new ArrayList<>(serializedSchema.size()); for (Row row : serializedSchema) { if (Schema.invalidSchemaRow(row) || Schema.ignoredSchemaRow(row)) continue; keyspaces.add(KSMetaData.fromSchema(row, serializedColumnFamilies(row.key), serializedUserTypes(row.key))); } return keyspaces; }
Example #12
Source File: SystemKeyspace.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public static void finishStartup() { setupVersion(); migrateIndexInterval(); migrateCachingOption(); // add entries to system schema columnfamilies for the hardcoded system definitions KSMetaData ksmd = Schema.instance.getKSMetaData(Keyspace.SYSTEM_KS); // delete old, possibly obsolete entries in schema columnfamilies for (String cfname : Arrays.asList(SystemKeyspace.SCHEMA_KEYSPACES_CF, SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF, SystemKeyspace.SCHEMA_COLUMNS_CF, SystemKeyspace.SCHEMA_TRIGGERS_CF, SystemKeyspace.SCHEMA_USER_TYPES_CF)) executeOnceInternal(String.format("DELETE FROM system.%s WHERE keyspace_name = ?", cfname), ksmd.name); // (+1 to timestamp to make sure we don't get shadowed by the tombstones we just added) ksmd.toSchema(FBUtilities.timestampMicros() + 1).apply(); }
Example #13
Source File: StorageService.java From stratio-cassandra with Apache License 2.0 | 6 votes |
private boolean hasSameReplication(List<String> list) { if (list.isEmpty()) return false; for (int i = 0; i < list.size() -1; i++) { KSMetaData ksm1 = Schema.instance.getKSMetaData(list.get(i)); KSMetaData ksm2 = Schema.instance.getKSMetaData(list.get(i + 1)); if (!ksm1.strategyClass.equals(ksm2.strategyClass) || !Iterators.elementsEqual(ksm1.strategyOptions.entrySet().iterator(), ksm2.strategyOptions.entrySet().iterator())) return false; } return true; }
Example #14
Source File: DropIndexStatement.java From stratio-cassandra with Apache License 2.0 | 6 votes |
private CFMetaData findIndexedCF() throws InvalidRequestException { KSMetaData ksm = Schema.instance.getKSMetaData(keyspace()); if (ksm == null) throw new KeyspaceNotDefinedException("Keyspace " + keyspace() + " does not exist"); for (CFMetaData cfm : ksm.cfMetaData().values()) { if (findIndexedColumn(cfm) != null) return cfm; } if (ifExists) return null; else throw new InvalidRequestException("Index '" + indexName + "' could not be found in any of the tables of keyspace '" + keyspace() + '\''); }
Example #15
Source File: AlterKeyspaceStatement.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public void validate(ClientState state) throws RequestValidationException { KSMetaData ksm = Schema.instance.getKSMetaData(name); if (ksm == null) throw new InvalidRequestException("Unknown keyspace " + name); if (ksm.name.equalsIgnoreCase(Keyspace.SYSTEM_KS)) throw new InvalidRequestException("Cannot alter system keyspace"); attrs.validate(); if (attrs.getReplicationStrategyClass() == null && !attrs.getReplicationOptions().isEmpty()) { throw new ConfigurationException("Missing replication strategy class"); } else if (attrs.getReplicationStrategyClass() != null) { // The strategy is validated through KSMetaData.validate() in announceKeyspaceUpdate below. // However, for backward compatibility with thrift, this doesn't validate unexpected options yet, // so doing proper validation here. AbstractReplicationStrategy.validateReplicationStrategy(name, AbstractReplicationStrategy.getClass(attrs.getReplicationStrategyClass()), StorageService.instance.getTokenMetadata(), DatabaseDescriptor.getEndpointSnitch(), attrs.getReplicationOptions()); } }
Example #16
Source File: 986499_AddColumnFamily_0_t.java From coming with MIT License | 6 votes |
public void applyModels() throws IOException { KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); ksm = makeNewKeyspaceDefinition(ksm); try { CFMetaData.map(cfm); } catch (ConfigurationException ex) { throw new IOException(ex); } Table.open(cfm.tableName); DatabaseDescriptor.setTableDefinition(ksm, newVersion); CFMetaData.fixMaxId(); if (!clientMode) Table.open(ksm.name).initCf(cfm.cfId, cfm.cfName); if (!clientMode) CommitLog.instance().forceNewSegment(); }
Example #17
Source File: 986499_AddColumnFamily_0_t.java From coming with MIT License | 6 votes |
public AddColumnFamily(CFMetaData cfm) throws ConfigurationException, IOException { super(UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress()), DatabaseDescriptor.getDefsVersion()); this.cfm = cfm; KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); if (ksm == null) throw new ConfigurationException("Keyspace does not already exist."); else if (ksm.cfMetaData().containsKey(cfm.cfName)) throw new ConfigurationException("CF is already defined in that keyspace."); else if (!Migration.isLegalName(cfm.cfName)) throw new ConfigurationException("Invalid column family name: " + cfm.cfName); KSMetaData newKsm = makeNewKeyspaceDefinition(ksm); rm = Migration.makeDefinitionMutation(newKsm, null, newVersion); }
Example #18
Source File: CassandraEmbeddedStoreManager.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
@Override public void clearStorage() throws BackendException { openStores.clear(); try { KSMetaData ksMetaData = Schema.instance.getKSMetaData(keySpaceName); // Not a big deal if Keyspace doesn't not exist (dropped manually by user or tests). // This is called on per test setup basis to make sure that previous test cleaned // everything up, so first invocation would always fail as Keyspace doesn't yet exist. if (ksMetaData == null) return; for (String cfName : ksMetaData.cfMetaData().keySet()) StorageService.instance.truncate(keySpaceName, cfName); } catch (Exception e) { throw new PermanentBackendException(e); } }
Example #19
Source File: 986499_AddColumnFamily_0_s.java From coming with MIT License | 6 votes |
public void applyModels() throws IOException { KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); ksm = makeNewKeyspaceDefinition(ksm); try { CFMetaData.map(cfm); } catch (ConfigurationException ex) { throw new IOException(ex); } Table.open(cfm.tableName); // make sure it's init-ed w/ the old definitions first, since we're going to call initCf on the new one manually DatabaseDescriptor.setTableDefinition(ksm, newVersion); if (!clientMode) Table.open(ksm.name).initCf(cfm.cfId, cfm.cfName); if (!clientMode) CommitLog.instance().forceNewSegment(); }
Example #20
Source File: 986499_AddColumnFamily_0_t.java From coming with MIT License | 6 votes |
public AddColumnFamily(CFMetaData cfm) throws ConfigurationException, IOException { super(UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress()), DatabaseDescriptor.getDefsVersion()); this.cfm = cfm; KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); if (ksm == null) throw new ConfigurationException("Keyspace does not already exist."); else if (ksm.cfMetaData().containsKey(cfm.cfName)) throw new ConfigurationException("CF is already defined in that keyspace."); else if (!Migration.isLegalName(cfm.cfName)) throw new ConfigurationException("Invalid column family name: " + cfm.cfName); KSMetaData newKsm = makeNewKeyspaceDefinition(ksm); rm = Migration.makeDefinitionMutation(newKsm, null, newVersion); }
Example #21
Source File: 986499_AddColumnFamily_0_t.java From coming with MIT License | 6 votes |
public void applyModels() throws IOException { KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); ksm = makeNewKeyspaceDefinition(ksm); try { CFMetaData.map(cfm); } catch (ConfigurationException ex) { throw new IOException(ex); } Table.open(cfm.tableName); // make sure it's init-ed w/ the old definitions first, since we're going to call initCf on the new one manually DatabaseDescriptor.setTableDefinition(ksm, newVersion); // these definitions could have come from somewhere else. CFMetaData.fixMaxId(); if (!clientMode) Table.open(ksm.name).initCf(cfm.cfId, cfm.cfName); if (!clientMode) CommitLog.instance().forceNewSegment(); }
Example #22
Source File: 986499_AddColumnFamily_0_s.java From coming with MIT License | 6 votes |
public AddColumnFamily(CFMetaData cfm) throws ConfigurationException, IOException { super(UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress()), DatabaseDescriptor.getDefsVersion()); this.cfm = cfm; KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); if (ksm == null) throw new ConfigurationException("Keyspace does not already exist."); else if (ksm.cfMetaData().containsKey(cfm.cfName)) throw new ConfigurationException("CF is already defined in that keyspace."); else if (!Migration.isLegalName(cfm.cfName)) throw new ConfigurationException("Invalid column family name: " + cfm.cfName); KSMetaData newKsm = makeNewKeyspaceDefinition(ksm); rm = Migration.makeDefinitionMutation(newKsm, null, newVersion); }
Example #23
Source File: 986499_AddColumnFamily_0_s.java From coming with MIT License | 6 votes |
public void applyModels() throws IOException { KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); ksm = makeNewKeyspaceDefinition(ksm); try { CFMetaData.map(cfm); } catch (ConfigurationException ex) { throw new IOException(ex); } Table.open(cfm.tableName); DatabaseDescriptor.setTableDefinition(ksm, newVersion); if (!clientMode) Table.open(ksm.name).initCf(cfm.cfId, cfm.cfName); if (!clientMode) CommitLog.instance().forceNewSegment(); }
Example #24
Source File: 986499_AddColumnFamily_0_t.java From coming with MIT License | 6 votes |
public void applyModels() throws IOException { KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); ksm = makeNewKeyspaceDefinition(ksm); try { CFMetaData.map(cfm); } catch (ConfigurationException ex) { throw new IOException(ex); } Table.open(cfm.tableName); DatabaseDescriptor.setTableDefinition(ksm, newVersion); CFMetaData.fixMaxId(); if (!clientMode) Table.open(ksm.name).initCf(cfm.cfId, cfm.cfName); if (!clientMode) CommitLog.instance().forceNewSegment(); }
Example #25
Source File: 986499_AddColumnFamily_0_t.java From coming with MIT License | 6 votes |
public AddColumnFamily(CFMetaData cfm) throws ConfigurationException, IOException { super(UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress()), DatabaseDescriptor.getDefsVersion()); this.cfm = cfm; KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); if (ksm == null) throw new ConfigurationException("Keyspace does not already exist."); else if (ksm.cfMetaData().containsKey(cfm.cfName)) throw new ConfigurationException("CF is already defined in that keyspace."); else if (!Migration.isLegalName(cfm.cfName)) throw new ConfigurationException("Invalid column family name: " + cfm.cfName); KSMetaData newKsm = makeNewKeyspaceDefinition(ksm); rm = Migration.makeDefinitionMutation(newKsm, null, newVersion); }
Example #26
Source File: 986499_AddColumnFamily_0_s.java From coming with MIT License | 6 votes |
public AddColumnFamily(CFMetaData cfm) throws ConfigurationException, IOException { super(UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress()), DatabaseDescriptor.getDefsVersion()); this.cfm = cfm; KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); if (ksm == null) throw new ConfigurationException("Keyspace does not already exist."); else if (ksm.cfMetaData().containsKey(cfm.cfName)) throw new ConfigurationException("CF is already defined in that keyspace."); else if (!Migration.isLegalName(cfm.cfName)) throw new ConfigurationException("Invalid column family name: " + cfm.cfName); KSMetaData newKsm = makeNewKeyspaceDefinition(ksm); rm = Migration.makeDefinitionMutation(newKsm, null, newVersion); }
Example #27
Source File: CassandraServer.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public KsDef describe_keyspace(String keyspaceName) throws NotFoundException, InvalidRequestException { validateLogin(); KSMetaData ksm = Schema.instance.getKSMetaData(keyspaceName); if (ksm == null) throw new NotFoundException(); return ksm.toThrift(); }
Example #28
Source File: SampleTest.java From staash with Apache License 2.0 | 5 votes |
@Test @Ignore public void mytest2() { System.out.println("Hello World!"); for (String ks :Schema.instance.getTables()) { KSMetaData ksm = Schema.instance.getKSMetaData(ks); Map<String, CFMetaData> cfm = ksm.cfMetaData(); } }
Example #29
Source File: CQL3Type.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public CQL3Type prepare(String keyspace) throws InvalidRequestException { if (name.hasKeyspace()) { // The provided keyspace is the one of the current statement this is part of. If it's different from the keyspace of // the UTName, we reject since we want to limit user types to their own keyspace (see #6643) if (!keyspace.equals(name.getKeyspace())) throw new InvalidRequestException(String.format("Statement on keyspace %s cannot refer to a user type in keyspace %s; " + "user types can only be used in the keyspace they are defined in", keyspace, name.getKeyspace())); } else { name.setKeyspace(keyspace); } KSMetaData ksm = Schema.instance.getKSMetaData(name.getKeyspace()); if (ksm == null) throw new InvalidRequestException("Unknown keyspace " + name.getKeyspace()); UserType type = ksm.userTypes.getType(name.getUserTypeName()); if (type == null) throw new InvalidRequestException("Unknown type " + name); if (!frozen) throw new InvalidRequestException("Non-frozen User-Defined types are not supported, please use frozen<>"); return new UserDefined(name.toString(), type); }
Example #30
Source File: LeaveAndBootstrapTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
private AbstractReplicationStrategy getStrategy(String keyspaceName, TokenMetadata tmd) { KSMetaData ksmd = Schema.instance.getKSMetaData(keyspaceName); return AbstractReplicationStrategy.createReplicationStrategy( keyspaceName, ksmd.strategyClass, tmd, new SimpleSnitch(), ksmd.strategyOptions); }