예제 #1
0
  @Override
  protected void validateOrCreateTableForCounter(boolean forceColumnFamilyCreation) {
    if (tableMetas.containsKey(CQL_COUNTER_TABLE)) {
      validator.validateAchillesCounter();
    } else {
      if (forceColumnFamilyCreation) {
        CQLTableBuilder builder = CQLTableBuilder.createTable(CQL_COUNTER_TABLE);
        builder.addColumn(CQL_COUNTER_FQCN, String.class);
        builder.addColumn(CQL_COUNTER_PRIMARY_KEY, String.class);
        builder.addColumn(CQL_COUNTER_PROPERTY_NAME, String.class);
        builder.addColumn(CQL_COUNTER_VALUE, Counter.class);
        builder.addPrimaryKeys(
            Arrays.asList(CQL_COUNTER_FQCN, CQL_COUNTER_PRIMARY_KEY, CQL_COUNTER_PROPERTY_NAME));

        builder.addComment("Create default Achilles counter table '" + CQL_COUNTER_TABLE + "'");

        session.execute(builder.generateDDLScript());
      } else {
        throw new AchillesInvalidTableException(
            "The required generic table '" + CQL_COUNTER_TABLE + "' does not exist");
      }
    }
  }