Search in sources :

Example 6 with DbSchemas

use of com.emc.storageos.db.common.schema.DbSchemas 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));
}
Also used : DbSchema(com.emc.storageos.db.common.schema.DbSchema) ArrayList(java.util.ArrayList) DbSchemasDiff(com.emc.storageos.db.common.diff.DbSchemasDiff) DbSchemas(com.emc.storageos.db.common.schema.DbSchemas)

Example 7 with DbSchemas

use of com.emc.storageos.db.common.schema.DbSchemas in project coprhd-controller by CoprHD.

the class DbSchemaChecker method unmarshalSchemas.

public static DbSchemas unmarshalSchemas(final String version, final Reader reader) {
    DbSchemas schemas = null;
    try {
        JAXBContext jc = JAXBContext.newInstance(DbSchemas.class);
        Unmarshaller um = jc.createUnmarshaller();
        schemas = (DbSchemas) um.unmarshal(reader);
        log.info("{} drop unused schema if exists", version);
        removeUnusedSchemaIfExists(schemas, DbSchemaInterceptorImpl.getIgnoreCfList());
        if (DbSchemaFilter.needDoFilterFor(version)) {
            log.info("filter out the garbage fileds for {}", version);
            DbSchemaFilter.doFilter(schemas);
        }
    } catch (JAXBException e) {
        log.error("Failed to unmarshal DbSchemas:", e);
    }
    return schemas;
}
Also used : JAXBException(javax.xml.bind.JAXBException) DbSchemas(com.emc.storageos.db.common.schema.DbSchemas) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Aggregations

DbSchemas (com.emc.storageos.db.common.schema.DbSchemas)7 DbSchemasDiff (com.emc.storageos.db.common.diff.DbSchemasDiff)3 BufferedReader (java.io.BufferedReader)2 BufferedWriter (java.io.BufferedWriter)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 JAXBContext (javax.xml.bind.JAXBContext)2 Unmarshaller (javax.xml.bind.Unmarshaller)2 MigrationStatus (com.emc.storageos.coordinator.client.model.MigrationStatus)1 FatalCoordinatorException (com.emc.storageos.coordinator.exceptions.FatalCoordinatorException)1 DbCheckerFileWriter (com.emc.storageos.db.client.impl.DbCheckerFileWriter)1 SchemaRecord (com.emc.storageos.db.client.model.SchemaRecord)1 DataObjectSchema (com.emc.storageos.db.common.schema.DataObjectSchema)1 DbSchema (com.emc.storageos.db.common.schema.DbSchema)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 FatalDatabaseException (com.emc.storageos.db.exceptions.FatalDatabaseException)1 MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)1 File (java.io.File)1 FileReader (java.io.FileReader)1