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);
}
}
}
}
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);
}
}
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);
}
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;
}
Aggregations