Beispiel #1
0
  // For new user created keyspaces (through CQL)
  public static KSMetaData newKeyspace(
      String name, String strategyName, Map<String, String> options) throws ConfigurationException {
    Class<? extends AbstractReplicationStrategy> cls =
        AbstractReplicationStrategy.getClass(strategyName);
    if (cls.equals(LocalStrategy.class))
      throw new ConfigurationException(
          "Unable to use given strategy class: LocalStrategy is reserved for internal use.");

    return new KSMetaData(name, cls, options, true, Collections.<CFMetaData>emptyList());
  }
Beispiel #2
0
 /**
  * Deserialize only Keyspace attributes without nested ColumnFamilies
  *
  * @param row Keyspace attributes in serialized form
  * @return deserialized keyspace without cf_defs
  * @throws IOException if deserialization failed
  */
 public static KSMetaData fromSchema(Row row, Iterable<CFMetaData> cfms) throws IOException {
   UntypedResultSet.Row result =
       QueryProcessor.resultify("SELECT * FROM system.schema_keyspaces", row).one();
   try {
     return new KSMetaData(
         result.getString("name"),
         AbstractReplicationStrategy.getClass(result.getString("strategy_class")),
         fromJsonMap(result.getString("strategy_options")),
         result.getBoolean("durable_writes"),
         cfms);
   } catch (ConfigurationException e) {
     throw new RuntimeException(e);
   }
 }
Beispiel #3
0
  public static KSMetaData fromThrift(KsDef ksd, CFMetaData... cfDefs)
      throws ConfigurationException {
    Class<? extends AbstractReplicationStrategy> cls =
        AbstractReplicationStrategy.getClass(ksd.strategy_class);
    if (cls.equals(LocalStrategy.class))
      throw new ConfigurationException(
          "Unable to use given strategy class: LocalStrategy is reserved for internal use.");

    return new KSMetaData(
        ksd.name,
        cls,
        ksd.strategy_options == null
            ? Collections.<String, String>emptyMap()
            : ksd.strategy_options,
        ksd.durable_writes,
        Arrays.asList(cfDefs));
  }