// 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 gc_grace_seconds default value which is: " + DEFAULT_GCGRACE_SECONDS
+ " and is viable ONLY FOR A SINGLE NODE CLUSTER");
LOG.warn("please update the gora-cassandra-mapping.xml file to avoid seeing this warning");
} 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(Integer.parseInt( gcgrace_scs!=null?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);