private static void checkRfsMatchConfig(KsDef ks, CassandraKeyValueServiceConfig config, Set<String> dcs, Map<String, String> strategyOptions) { for (String datacenter : dcs) { if (Integer.parseInt(strategyOptions.get(datacenter)) != config.replicationFactor()) { throw new UnsupportedOperationException("Your current Cassandra keyspace (" + ks.getName() + ") has a replication factor not matching your Atlas Cassandra configuration." + " Change them to match, but be mindful of what steps you'll need to" + " take to correctly repair or cleanup existing data in your cluster."); } } } }
cassandra_client.set_keyspace(ksDef.getName()); for (TableInfo tableInfo : tableInfos)
@Override public String getName() { return ks_def.getName(); }
@Override public String getName() { return ks_def.getName(); }
CassandraCli.executeCqlQuery("USE \"CompositeCassandra\"", ksDef.getName()); .executeCqlQuery( "CREATE TABLE \"CompositeUserAssociation\" (\"userId\" varchar,\"tweetId\" int,\"timeLineId\" uuid, \"tweetBody\" varchar, \"tweetDate\" timestamp, \"userInfo_id\" varchar, PRIMARY KEY (\"userId\", \"tweetId\",\"timeLineId\"))", ksDef.getName());
private static void checkRfsMatchConfig(KsDef ks, CassandraKeyValueServiceConfig config, Set<String> dcs, Map<String, String> strategyOptions) { for (String datacenter : dcs) { if (Integer.parseInt(strategyOptions.get(datacenter)) != config.replicationFactor()) { throw new UnsupportedOperationException("Your current Cassandra keyspace (" + ks.getName() + ") has a replication factor not matching your Atlas Cassandra configuration." + " Change them to match, but be mindful of what steps you'll need to" + " take to correctly repair or cleanup existing data in your cluster."); } } } }
/** * Get a list of all known keyspaces. This method can be used with any DB connection. * * @param dbConn Database connection to use. * @return List of all known keyspaces, empty if none. */ public Collection<String> getKeyspaces(DBConn dbConn) { List<String> result = new ArrayList<>(); try { for (KsDef ksDef : dbConn.getClientSession().describe_keyspaces()) { result.add(ksDef.getName()); } } catch (Exception e) { String errMsg = "Failed to get keyspace description"; m_logger.error(errMsg, e); throw new RuntimeException(errMsg, e); } return result; } // getKeyspaces
/** * Get a list of all known keyspaces. This method can be used with any DB connection. * * @param dbConn Database connection to use. * @return List of all known keyspaces, empty if none. */ public static Collection<String> getKeyspaces(DBConn dbConn) { List<String> result = new ArrayList<>(); try { for (KsDef ksDef : dbConn.getClientSession().describe_keyspaces()) { result.add(ksDef.getName()); } } catch (Exception e) { String errMsg = "Failed to get keyspace description"; m_logger.error(errMsg, e); throw new RuntimeException(errMsg, e); } return result; } // getKeyspaces
/** * is specific per set of keyspace definitions. */ public ColumnDecoder(List<KsDef> defs) { for (KsDef ks : defs) for (CfDef cf : ks.getCf_defs()) metadata.put(String.format("%s.%s", ks.getName(), cf.getName()), new CFamMeta(cf)); }
public synchronized void refresh(Cassandra.Iface connection) throws TException, InvalidRequestException { // Obtain a set of available keyspaces List<KsDef> ks = connection.describe_keyspaces(); String keyspace = null; for (KsDef k : ks) { if (!"system".equalsIgnoreCase(k.getName())) { keyspace = k.getName(); break; } } if(keyspace==null) { // cannot get a ring without a keyspace return; } // Get a token range for the keyspace List<TokenRange> ranges = connection.describe_ring(keyspace); Set<String> addresses = new HashSet<String>(); // Cycle all of the token ranges adding the endpoint addresses to a // set, so that duplicates are discarded for (TokenRange range : ranges) { addresses.addAll(range.getEndpoints()); } this.hosts = hostArrayToMap(addresses.toArray(new String[] {})); }
/** * check for Tables method check the existence of schema and table. * * @param tableInfos * list of TableInfos and ksDef object of KsDef * @param ksDef * the ks def * @throws TException * @throws InvalidRequestException */ private void onValidateTables(List<TableInfo> tableInfos, KsDef ksDef) throws Exception { cassandra_client.set_keyspace(ksDef.getName()); for (TableInfo tableInfo : tableInfos) { onValidateTable(ksDef, tableInfo); } }
public Object getFieldValue(_Fields field) { switch (field) { case NAME: return getName(); case STRATEGY_CLASS: return getStrategy_class(); case STRATEGY_OPTIONS: return getStrategy_options(); case REPLICATION_FACTOR: return Integer.valueOf(getReplication_factor()); case CF_DEFS: return getCf_defs(); case DURABLE_WRITES: return Boolean.valueOf(isDurable_writes()); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case NAME: return getName(); case STRATEGY_CLASS: return getStrategy_class(); case STRATEGY_OPTIONS: return getStrategy_options(); case REPLICATION_FACTOR: return Integer.valueOf(getReplication_factor()); case CF_DEFS: return getCf_defs(); case DURABLE_WRITES: return Boolean.valueOf(isDurable_writes()); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case NAME: return getName(); case STRATEGY_CLASS: return getStrategy_class(); case STRATEGY_OPTIONS: return getStrategy_options(); case REPLICATION_FACTOR: return Integer.valueOf(getReplication_factor()); case CF_DEFS: return getCf_defs(); case DURABLE_WRITES: return Boolean.valueOf(isDurable_writes()); } throw new IllegalStateException(); }
@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; }
private void describeColumnFamily(KsDef ks_def, CfDef cf_def, NodeProbe probe) ColumnFamilyStoreMBean cfMBean = (probe == null) ? null : probe.getCfsProxy(ks_def.getName(), cf_def.getName());
if (!cf.getKeyspace().equals(ks_def.getName()))
if (!cf.getKeyspace().equals(ks_def.getName()))
if (!cf.getKeyspace().equals(ks_def.getName()))