Search in sources :

Example 1 with SchemaRecord

use of com.emc.storageos.db.client.model.SchemaRecord in project coprhd-controller by CoprHD.

the class MigrationHandlerImpl method getPersistedSchema.

private DbSchemas getPersistedSchema(String version) {
    SchemaRecord record = dbClient.querySchemaRecord(version);
    if (record == null) {
        return null;
    }
    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new StringReader(record.getSchema()));
        return DbSchemaChecker.unmarshalSchemas(version, reader);
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (Exception e) {
                log.error("Fail to close buffer reader", e);
            }
        }
    }
}
Also used : SchemaRecord(com.emc.storageos.db.client.model.SchemaRecord) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) FatalCoordinatorException(com.emc.storageos.coordinator.exceptions.FatalCoordinatorException) FatalDatabaseException(com.emc.storageos.db.exceptions.FatalDatabaseException)

Example 2 with SchemaRecord

use of com.emc.storageos.db.client.model.SchemaRecord in project coprhd-controller by CoprHD.

the class DBClient method dumpSchema.

/**
 * Read the schema record from db and dump it into a specified file
 *
 * @param schemaVersion
 * @param dumpFilename
 */
public void dumpSchema(String schemaVersion, String dumpFilename) {
    SchemaRecord schemaRecord = _dbClient.querySchemaRecord(schemaVersion);
    if (schemaRecord == null) {
        System.err.println("No such schema version: " + schemaVersion);
        return;
    }
    try (BufferedWriter writer = new BufferedWriter(new FileWriter(dumpFilename));
        BufferedReader reader = new BufferedReader(new StringReader(schemaRecord.getSchema()))) {
        DbSchemas dbSchemas = DbSchemaChecker.unmarshalSchemas(schemaVersion, reader);
        writer.write(DbSchemaChecker.marshalSchemas(dbSchemas, schemaVersion));
        System.out.println("Db Schema version " + schemaVersion + " successfully" + " dumped to file " + dumpFilename);
    } catch (IOException e) {
        System.err.println("Caught IOException: " + e);
        log.error("Caught IOException: ", e);
    }
}
Also used : SchemaRecord(com.emc.storageos.db.client.model.SchemaRecord) DbCheckerFileWriter(com.emc.storageos.db.client.impl.DbCheckerFileWriter) FileWriter(java.io.FileWriter) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) DbSchemas(com.emc.storageos.db.common.schema.DbSchemas) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 3 with SchemaRecord

use of com.emc.storageos.db.client.model.SchemaRecord in project coprhd-controller by CoprHD.

the class MigrationHandlerImpl method persistSchema.

private void persistSchema(String version, String schema) {
    SchemaRecord record = new SchemaRecord();
    record.setVersion(version);
    record.setSchema(schema);
    dbClient.persistSchemaRecord(record);
}
Also used : SchemaRecord(com.emc.storageos.db.client.model.SchemaRecord)

Example 4 with SchemaRecord

use of com.emc.storageos.db.client.model.SchemaRecord in project coprhd-controller by CoprHD.

the class SchemaRecordType method deserialize.

public SchemaRecord deserialize(Row<String, String> row) {
    if (row == null) {
        return null;
    }
    ColumnList<String> columnList = row.getColumns();
    if (columnList == null || columnList.isEmpty()) {
        return null;
    }
    Column<String> column = columnList.getColumnByName(SCHEMA_COLUMN_NAME);
    SchemaRecord record = new SchemaRecord();
    record.setVersion(row.getKey());
    record.setSchema(column.getStringValue());
    return record;
}
Also used : SchemaRecord(com.emc.storageos.db.client.model.SchemaRecord)

Aggregations

SchemaRecord (com.emc.storageos.db.client.model.SchemaRecord)4 BufferedReader (java.io.BufferedReader)2 StringReader (java.io.StringReader)2 FatalCoordinatorException (com.emc.storageos.coordinator.exceptions.FatalCoordinatorException)1 DbCheckerFileWriter (com.emc.storageos.db.client.impl.DbCheckerFileWriter)1 DbSchemas (com.emc.storageos.db.common.schema.DbSchemas)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 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1