.setCf_defs(new LinkedList<CfDef>()) // cannot be null but can be empty .setStrategy_class(storageConfig.get(REPLICATION_STRATEGY)) .setStrategy_options(strategyOptions);
.setStrategy_class("org.apache.cassandra.locator.SimpleStrategy") .setStrategy_options(strategyOptions) .setCf_defs(cfs);
private static void updateExistingKeyspace(CassandraClientPool clientPool, CassandraKeyValueServiceConfig config) throws TException { clientPool.runWithRetry((FunctionCheckedException<CassandraClient, Void, TException>) client -> { KsDef originalKsDef = client.describe_keyspace(config.getKeyspaceOrThrow()); // there was an existing keyspace // check and make sure it's definition is up to date with our config KsDef modifiedKsDef = originalKsDef.deepCopy(); checkAndSetReplicationFactor( client, modifiedKsDef, config); if (!modifiedKsDef.equals(originalKsDef)) { // Can't call system_update_keyspace to update replication factor if CfDefs are set modifiedKsDef.setCf_defs(ImmutableList.of()); client.system_update_keyspace(modifiedKsDef); CassandraKeyValueServices.waitForSchemaVersions(config, client, "after updating the existing keyspace"); } return null; }); }
private void changeReplicationFactor(int replicationFactor) throws TException { clientPool.run((FunctionCheckedException<CassandraClient, Void, TException>) client -> { KsDef originalKsDef = client.describe_keyspace(CASSANDRA.getConfig().getKeyspaceOrThrow()); KsDef modifiedKsDef = originalKsDef.deepCopy(); modifiedKsDef.setStrategy_class(CassandraConstants.NETWORK_STRATEGY); modifiedKsDef.setStrategy_options(ImmutableMap.of("dc1", Integer.toString(replicationFactor))); modifiedKsDef.setCf_defs(ImmutableList.of()); client.system_update_keyspace(modifiedKsDef); return null; }); }
public ThriftKeyspaceDefinitionImpl() { ks_def = new KsDef(); ks_def.setCf_defs(new ArrayList<CfDef>()); }
public ThriftKeyspaceDefinitionImpl() { ks_def = new KsDef(); ks_def.setCf_defs(new ArrayList<CfDef>()); }
public OperationResult<SchemaChangeResult> internalCreateKeyspace(final KsDef ksDef) throws ConnectionException { if (ksDef.getCf_defs() == null) ksDef.setCf_defs(Lists.<CfDef>newArrayList()); return executeDdlOperation( new AbstractOperationImpl<SchemaChangeResult>( tracerFactory.newTracer(CassandraOperationType.ADD_KEYSPACE)) { @Override public SchemaChangeResult internalExecute(Client client, ConnectionContext context) throws Exception { precheckSchemaAgreement(client); return new SchemaChangeResponseImpl().setSchemaId(client.system_add_keyspace(ksDef)); } }, RunOnce.get()); }
protected void initializeKeyspaceDefinitions() throws NoSuchFieldException, InstantiationException, IllegalAccessException, ClassNotFoundException, NotFoundException { for (Map.Entry<Class<?>, ClassMetadata<?>> entry : classMetadataMap.entrySet()) { ClassMetadata classMetadata = entry.getValue(); String keysPace = classMetadata.getKeySpace(); KsDef ksDef = keyspaceDefinitions.get(keysPace); if (ksDef == null) { ksDef = new KsDef(); ksDef.setName(keysPace); if (replicaReplacementStrategyClass == null) { strategyOptions.put("replication_factor", String.valueOf(replicationFactor)); replicaReplacementStrategyClass = SimpleStrategy.class; } ksDef.setStrategy_class(replicaReplacementStrategyClass.getName()); ksDef.setStrategy_options(strategyOptions); ksDef.setCf_defs(new ArrayList<CfDef>()); keyspaceDefinitions.put(keysPace, ksDef); } List<CfDef> columnFamilyDefinitions = ksDef.getCf_defs(); columnFamilyDefinitions.add(classMetadata.getColumnFamilyDefinition()); } }
@Override public OperationResult<SchemaChangeResult> createKeyspace(final Properties props) throws ConnectionException { final KsDef def; try { def = ThriftUtils.getThriftObjectFromProperties(KsDef.class, props); if (def.getCf_defs() == null) { def.setCf_defs(Lists.<CfDef>newArrayList()); } } catch (Exception e) { throw new BadRequestException("Error converting properties to KsDef", e); } return internalCreateKeyspace(def); }
@Override public OperationResult<SchemaChangeResult> updateKeyspace(final Properties props) throws ConnectionException { final KsDef def; try { def = ThriftUtils.getThriftObjectFromProperties(KsDef.class, props); if (def.getCf_defs() == null) { def.setCf_defs(Lists.<CfDef>newArrayList()); } } catch (Exception e) { throw new BadRequestException("Error converting properties to KsDef", e); } return internalUpdateKeyspace(def); }
@Override public OperationResult<SchemaChangeResult> updateKeyspace(final Properties props) throws ConnectionException { final KsDef def; try { def = ThriftUtils.getThriftObjectFromProperties(KsDef.class, props); if (def.getCf_defs() == null) { def.setCf_defs(Lists.<CfDef>newArrayList()); } } catch (Exception e) { throw new BadRequestException("Error converting properties to KsDef", e); } return internalUpdateKeyspace(def); }
@Override public OperationResult<SchemaChangeResult> createKeyspace(final Properties props) throws ConnectionException { final KsDef def; try { def = ThriftUtils.getThriftObjectFromProperties(KsDef.class, props); if (def.getCf_defs() == null) { def.setCf_defs(Lists.<CfDef>newArrayList()); } } catch (Exception e) { throw new BadRequestException("Error converting properties to KsDef", e); } return internalCreateKeyspace(def); }
@Override public KeyspaceDefinition addColumnFamily(ColumnFamilyDefinition cfDef) { if (ks_def.getCf_defs() == null) { ks_def.setCf_defs(new ArrayList<CfDef>()); } CfDef thriftCfDef = ((ThriftColumnFamilyDefinitionImpl) cfDef).getThriftColumnFamilyDefinition(); thriftCfDef.setColumn_type("Standard"); thriftCfDef.setKeyspace(ks_def.getName()); ks_def.getCf_defs().add(thriftCfDef); return this; }
@Override public KeyspaceDefinition addColumnFamily(ColumnFamilyDefinition cfDef) { if (ks_def.getCf_defs() == null) { ks_def.setCf_defs(new ArrayList<CfDef>()); } CfDef thriftCfDef = ((ThriftColumnFamilyDefinitionImpl) cfDef).getThriftColumnFamilyDefinition(); thriftCfDef.setColumn_type("Standard"); thriftCfDef.setKeyspace(ks_def.getName()); ks_def.getCf_defs().add(thriftCfDef); return this; }
public OperationResult<SchemaChangeResult> internalCreateKeyspace(final KsDef ksDef) throws ConnectionException { if (ksDef.getCf_defs() == null) ksDef.setCf_defs(Lists.<CfDef>newArrayList()); return executeDdlOperation( new AbstractOperationImpl<SchemaChangeResult>( tracerFactory.newTracer(CassandraOperationType.ADD_KEYSPACE)) { @Override public SchemaChangeResult internalExecute(Client client, ConnectionContext context) throws Exception { precheckSchemaAgreement(client); return new SchemaChangeResponseImpl().setSchemaId(client.system_add_keyspace(ksDef)); } }, RunOnce.get()); }
ksDef.setCf_defs(DEFAULT_KS_CF_DEFS);
ksDef.setCf_defs(DEFAULT_KS_CF_DEFS);
private static void updateExistingKeyspace(CassandraClientPool clientPool, CassandraKeyValueServiceConfig config) throws TException { clientPool.runWithRetry((FunctionCheckedException<CassandraClient, Void, TException>) client -> { KsDef originalKsDef = client.describe_keyspace(config.getKeyspaceOrThrow()); // there was an existing keyspace // check and make sure it's definition is up to date with our config KsDef modifiedKsDef = originalKsDef.deepCopy(); checkAndSetReplicationFactor( client, modifiedKsDef, config); if (!modifiedKsDef.equals(originalKsDef)) { // Can't call system_update_keyspace to update replication factor if CfDefs are set modifiedKsDef.setCf_defs(ImmutableList.of()); client.system_update_keyspace(modifiedKsDef); CassandraKeyValueServices.waitForSchemaVersions(config, client, "after updating the existing keyspace"); } return null; }); }
.setCf_defs(new LinkedList<CfDef>()) // cannot be null but can be empty .setStrategy_class(storageConfig.get(REPLICATION_STRATEGY)) .setStrategy_options(strategyOptions);
.setCf_defs(new LinkedList<CfDef>()) // cannot be null but can be empty .setStrategy_class(storageConfig.get(REPLICATION_STRATEGY)) .setStrategy_options(strategyOptions);