private KSMetaData makeNewKeyspaceDefinition(KSMetaData ksm) {
   List<CFMetaData> newCfs = new ArrayList<CFMetaData>(ksm.cfMetaData().values());
   newCfs.add(cfm);
   return new KSMetaData(
       ksm.name,
       ksm.strategyClass,
       ksm.strategyOptions,
       newCfs.toArray(new CFMetaData[newCfs.size()]));
 }
  public AddColumnFamily(CFMetaData cfm) throws ConfigurationException, IOException {
    super(
        UUIDGen.makeType1UUIDFromHost(GossipUtilities.getLocalAddress()),
        NodeDescriptor.getDefsVersion());
    this.cfm = cfm;
    KSMetaData ksm = NodeDescriptor.getTableDefinition(cfm.ksName);

    if (ksm == null) throw new ConfigurationException("No such keyspace: " + cfm.ksName);
    else if (ksm.cfMetaData().containsKey(cfm.cfName))
      throw new ConfigurationException(
          String.format("%s already exists in keyspace %s", cfm.cfName, cfm.ksName));
    else if (!Migration.isLegalName(cfm.cfName))
      throw new ConfigurationException("Invalid column family name: " + cfm.cfName);
    for (Map.Entry<ByteBuffer, ColumnDefinition> entry : cfm.getColumn_metadata().entrySet()) {
      String indexName = entry.getValue().getIndexName();
      if (indexName != null && !Migration.isLegalName(indexName))
        throw new ConfigurationException("Invalid index name: " + indexName);
    }

    // clone ksm but include the new cf def.
    KSMetaData newKsm = makeNewKeyspaceDefinition(ksm);

    rm = Migration.makeDefinitionMutation(newKsm, null, newVersion);
  }