}
// load column family definitions
List<Element> elements = keyspace.getChildren();
for (Element element: elements) {
BasicColumnFamilyDefinition cfDef = new BasicColumnFamilyDefinition();
String familyName = element.getAttributeValue(NAME_ATTRIBUTE);
if (familyName == null) {
LOG.error("Error locating column family name attribute!");
continue;
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Located column family: '" + familyName + "'" );
}
}
String gcgrace_scs = element.getAttributeValue(GCGRACE_SECONDS_ATTRIBUTE);
if (gcgrace_scs == null) {
LOG.warn("Error locating gc_grace_seconds attribute for '" + familyName + "' column family");
LOG.warn("Using default set to: " + DEFAULT_GCGRACE_SECONDS);
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Located gc_grace_seconds: '" + gcgrace_scs + "'" );
}
}
String superAttribute = element.getAttributeValue(SUPER_ATTRIBUTE);
if (superAttribute != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Located super column family");
}
this.superFamilies.add(familyName);
if (LOG.isDebugEnabled()) {
LOG.debug("Added super column family: '" + familyName + "'");
}
cfDef.setColumnType(ColumnType.SUPER);
cfDef.setSubComparatorType(ComparatorType.BYTESTYPE);
}
cfDef.setKeyspaceName(this.keyspaceName);
cfDef.setName(familyName);
cfDef.setComparatorType(ComparatorType.BYTESTYPE);
cfDef.setDefaultValidationClass(ComparatorType.BYTESTYPE.getClassName());
cfDef.setGcGraceSeconds(gcgrace_scs!=null?Integer.parseInt(gcgrace_scs):DEFAULT_GCGRACE_SECONDS);
this.columnFamilyDefinitions.put(familyName, cfDef);
}
// load column definitions
elements = mapping.getChildren();
for (Element element: elements) {
String fieldName = element.getAttributeValue(NAME_ATTRIBUTE);
String familyName = element.getAttributeValue(FAMILY_ATTRIBUTE);
String columnName = element.getAttributeValue(COLUMN_ATTRIBUTE);
String ttlValue = element.getAttributeValue(COLUMNS_TTL_ATTRIBUTE);
if (fieldName == null) {
LOG.error("Field name is not declared.");
continue;
}
if (familyName == null) {
LOG.error("Family name is not declared for \"" + fieldName + "\" field.");
continue;
}
if (columnName == null) {
LOG.warn("Column name (qualifier) is not declared for \"" + fieldName + "\" field.");
columnName = fieldName;
}
if (ttlValue == null) {
LOG.warn("TTL value is not defined for \"" + fieldName + "\" field. \n Using default value: " + DEFAULT_COLUMNS_TTL);
}
BasicColumnFamilyDefinition columnFamilyDefinition = this.columnFamilyDefinitions.get(familyName);
if (columnFamilyDefinition == null) {
LOG.warn("Family " + familyName + " was not declared in the keyspace.");
}
this.familyMap.put(fieldName, familyName);