use of com.emc.storageos.db.common.schema.DbSchema in project coprhd-controller by CoprHD.
the class DbSchemasDiff method removeIgnoredSchemas.
private void removeIgnoredSchemas(List<DbSchema> schemas, String[] ignoredPkgs) {
Iterator<DbSchema> iterator = schemas.iterator();
boolean found = false;
while (iterator.hasNext()) {
DbSchema schema = iterator.next();
found = false;
for (String pkg : ignoredPkgs) {
if (schema.getType().startsWith(pkg)) {
found = true;
break;
}
}
if (found) {
// remove the schema that should not be checked
iterator.remove();
}
}
}
use of com.emc.storageos.db.common.schema.DbSchema in project coprhd-controller by CoprHD.
the class DbSchemaCheckerTest method testGeoNewAnnotationOnExistingField.
@Test
public void testGeoNewAnnotationOnExistingField() {
DbSchema srcGeoSchema = new DataObjectSchema(GeoClassUT.class);
srcSchemas.addSchema(srcGeoSchema);
tgtSchema = new DataObjectSchema(GeoNewAnnotationOnExistingField.class);
tgtSchema.setType(srcSchema.getType());
tgtSchemas.addSchema(tgtSchema);
tgtSchemas.addSchema(srcSchema);
DbSchemasDiff diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
// Adding index on existing field of Geo object is not allowed
Assert.assertFalse(diff.isUpgradable());
Assert.assertTrue(diff.isChanged());
}
use of com.emc.storageos.db.common.schema.DbSchema in project coprhd-controller by CoprHD.
the class MigrationHandlerImpl method dumpChanges.
/**
* Dump schema changes we are processing to the log
*
* @param diff
*/
public void dumpChanges(DbSchemasDiff diff) {
log.info("Start dumping changes");
for (AnnotationValue newValue : diff.getNewAnnotationValues()) {
log.info("new annotation value for class {}, field {}," + " annotation type {}: {}={}", new Object[] { newValue.getCfClass().getSimpleName(), newValue.getFieldName(), newValue.getAnnoClass().getSimpleName(), newValue.getName(), newValue.getValue() });
}
for (FieldInfo newField : diff.getNewFields()) {
log.info("new field for class {}: {}", newField.getCfClass().getSimpleName(), newField.getName());
}
for (AnnotationType newAnno : diff.getNewClassAnnotations()) {
log.info("new class annotation for class {}: {}", newAnno.getCfClass().getSimpleName(), newAnno.getType());
}
for (AnnotationType newAnno : diff.getNewFieldAnnotations()) {
log.info("new field annotation for class {}, field {}: {}", new Object[] { newAnno.getCfClass().getSimpleName(), newAnno.getFieldName(), newAnno.getType() });
}
for (DbSchema schema : diff.getNewClasses()) {
log.info("new CF: {}", schema.getType());
}
log.info("Finish dumping changes");
}
use of com.emc.storageos.db.common.schema.DbSchema in project coprhd-controller by CoprHD.
the class DbSchemaChecker method genGeoDiffs.
/**
* Filter out all the non-geo db schemas from the spec and generate a diff
* Note that some CFs might have been migrated from local db to geo db
* So we need to grab a latest list of geo schemas from the current schema first.
*
* @param spec the db schema spec generated from the baseline file
* @param geoSchemas the latest list of geo schemas from the current DbSchemas object
* @return
*/
private static DbSchemasDiff genGeoDiffs(DbSchemas spec, List<DbSchema> geoSchemas) {
// prepare a list of geo schema names
List<String> geoSchemaNames = new ArrayList<>();
for (DbSchema geoSchema : geoSchemas) {
geoSchemaNames.add(geoSchema.getName());
}
List<DbSchema> specSchemaList = new ArrayList<>();
for (DbSchema schema : spec.getSchemas()) {
if (geoSchemaNames.contains(schema.getName())) {
specSchemaList.add(schema);
}
}
return new DbSchemasDiff(new DbSchemas(specSchemaList), new DbSchemas(geoSchemas));
}
use of com.emc.storageos.db.common.schema.DbSchema 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