Esempio n. 1
0
  /**
   * Read schema from system table and calculate MD5 digest of every row, resulting digest will be
   * converted into UUID which would act as content-based version of the schema.
   */
  public void updateVersion() {
    try {
      MessageDigest versionDigest = MessageDigest.getInstance("MD5");

      for (Row row : SystemTable.serializedSchema()) {
        if (invalidSchemaRow(row) || ignoredSchemaRow(row)) continue;

        row.cf.updateDigest(versionDigest);
      }

      version = UUID.nameUUIDFromBytes(versionDigest.digest());
      SystemTable.updateSchemaVersion(version);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
Esempio n. 2
0
  public RowMutation dropFromSchema(long timestamp) {
    RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, SystemTable.getSchemaKSKey(name));
    rm.delete(new QueryPath(SystemTable.SCHEMA_KEYSPACES_CF), timestamp);
    rm.delete(new QueryPath(SystemTable.SCHEMA_COLUMNFAMILIES_CF), timestamp);
    rm.delete(new QueryPath(SystemTable.SCHEMA_COLUMNS_CF), timestamp);

    return rm;
  }
Esempio n. 3
0
  public KSMetaData reloadAttributes() throws IOException {
    Row ksDefRow = SystemTable.readSchemaRow(name);

    if (ksDefRow.cf == null)
      throw new IOException(
          String.format(
              "%s not found in the schema definitions table (%s).",
              name, SystemTable.SCHEMA_KEYSPACES_CF));

    return fromSchema(ksDefRow, Collections.<CFMetaData>emptyList());
  }
Esempio n. 4
0
  public RowMutation toSchema(long timestamp) {
    RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, SystemTable.getSchemaKSKey(name));
    ColumnFamily cf = rm.addOrGet(SystemTable.SCHEMA_KEYSPACES_CF);

    cf.addColumn(Column.create(name, timestamp, "name"));
    cf.addColumn(Column.create(durableWrites, timestamp, "durable_writes"));
    cf.addColumn(Column.create(strategyClass.getName(), timestamp, "strategy_class"));
    cf.addColumn(Column.create(json(strategyOptions), timestamp, "strategy_options"));

    for (CFMetaData cfm : cfMetaData.values()) cfm.toSchema(rm, timestamp);

    return rm;
  }