use of com.emc.storageos.db.client.model.DbKeyspace in project coprhd-controller by CoprHD.
the class CollectionChangeTracker method isUpgradable.
public boolean isUpgradable() {
boolean returnVal = true;
if (!removedList.isEmpty()) {
for (T schema : removedList) {
// CustomMigrationCallback can be removed
if (clazz.equals(AnnotationType.class)) {
AnnotationType at = (AnnotationType) schema;
// type associated with it. Do string comparison instead.
if (CustomMigrationCallback.class.getCanonicalName().equals(at.getType())) {
log.info("CustomMigrationCallback {} has been removed", at.describe());
continue;
} else if (EnumType.class.getCanonicalName().equals(at.getType())) {
log.info("EnumType {} has been removed", at.describe());
continue;
}
if (at.canBeIgnore()) {
continue;
}
}
log.warn("An unsupported schema change has been made. {} has been removed.", schema.describe());
returnVal = false;
}
}
if (!duplicateList.isEmpty()) {
for (T schema : duplicateList) {
log.warn("An unsupported schema change has been made. Duplicate {} has been added", schema.describe());
}
returnVal = false;
}
for (S diff : diffs) {
if (!diff.isUpgradable()) {
returnVal = false;
}
}
if (clazz.equals(AnnotationType.class)) {
for (T element : newList) {
AnnotationType at = (AnnotationType) element;
Class cfClass = at.getCfClass();
// refuse adding any annotation (including index) on existing field
if (cfClass.isAnnotationPresent(DbKeyspace.class)) {
DbKeyspace keyspaceType = (DbKeyspace) cfClass.getAnnotation(DbKeyspace.class);
if (DbKeyspace.Keyspaces.GLOBAL.equals(keyspaceType.value())) {
log.warn("An unsupported geo schema change has been made. {} has been added", at.describe());
returnVal = false;
break;
}
}
// check UpgradeAllowed annotation for new annotations
if (!CustomMigrationCallback.class.isAssignableFrom(at.getAnnoClass()) && !at.getAnnoClass().isAnnotationPresent(UpgradeAllowed.class)) {
log.warn("An unsupported schema change has been made. {} has been added", at.describe());
returnVal = false;
break;
}
}
}
return returnVal;
}
use of com.emc.storageos.db.client.model.DbKeyspace in project coprhd-controller by CoprHD.
the class GeoDbMigrationCallback method process.
@Override
public void process() throws MigrationCallbackException {
if (cfClass == null || annotation == null) {
// this callback has not been set up; skip it.
throw DatabaseException.fatals.failedDuringUpgrade("Unexpected state: callback not setup", null);
}
if (!annotation.annotationType().equals(DbKeyspace.class)) {
throw DatabaseException.fatals.failedDuringUpgrade("Unexpected annotation: only support" + " @DbKeyspace", null);
}
String cfName = cfClass.getCanonicalName();
if (!DataObject.class.isAssignableFrom(cfClass)) {
throw DatabaseException.fatals.failedDuringUpgrade("Unexpected CF type: " + cfName, null);
}
// No need to do anything if the DbKeyspace is set to LOCAL
DbKeyspace keyspace = (DbKeyspace) cfClass.getAnnotation(annotation.annotationType());
if (keyspace.value().equals(DbKeyspace.Keyspaces.LOCAL)) {
log.info("No need to do anything for CF {}", cfName);
return;
}
log.info("Copying db records for class: {} from local db into geodb", cfName);
try {
getInternalDbClient().migrateToGeoDb(cfClass);
} catch (Exception e) {
log.error("GeoDbMigrationCallback migration failed", e);
throw DatabaseException.fatals.failedDuringUpgrade("db schema migration error: failed" + "to migrate CF " + cfName + " into geodb", e);
}
log.info("migrate on global resource {} finished", cfClass.getSimpleName());
}
use of com.emc.storageos.db.client.model.DbKeyspace in project coprhd-controller by CoprHD.
the class DbSchemaScanner method processClass.
@Override
protected void processClass(Class clazz) {
DbSchema schema = null;
if (DataObject.class.isAssignableFrom(clazz)) {
if (_scannerInterceptor != null && _scannerInterceptor.isClassIgnored(clazz.getSimpleName())) {
log.info("{} is ignored in schema due to interceptor", clazz.getSimpleName());
return;
}
schema = new DataObjectSchema(clazz, _scannerInterceptor);
if (clazz.isAnnotationPresent(DbKeyspace.class)) {
DbKeyspace anno = (DbKeyspace) clazz.getAnnotation(DbKeyspace.class);
if (DbKeyspace.Keyspaces.GLOBAL.equals(anno.value())) {
geoSchemas.add(schema);
}
}
} else if (TimeSeries.class.isAssignableFrom(clazz)) {
schema = new TimeSeriesSchema(clazz);
} else if (TimeSeriesSerializer.DataPoint.class.isAssignableFrom(clazz)) {
schema = new DataPointSchema(clazz);
} else {
return;
}
schemas.addSchema(schema);
}
Aggregations