Search in sources :

Example 1 with InternalDbClient

use of com.emc.storageos.db.client.upgrade.InternalDbClient in project coprhd-controller by CoprHD.

the class NetworkVarrayIndexMigration method process.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.db.client.upgrade.BaseCustomMigrationCallback#process()
     */
@Override
public void process() throws MigrationCallbackException {
    InternalDbClient internalDbClient;
    if (InternalDbClient.class.isAssignableFrom(dbClient.getClass())) {
        internalDbClient = (InternalDbClient) dbClient;
    } else {
        throw new IllegalStateException("Migration callback " + name + " needs InternalDbClient");
    }
    MigrateIndexHelper.migrateRemovedIndex(internalDbClient, Network.class, "assignedVirtualArrays", "RelationIndex", "RelationIndex");
    MigrateIndexHelper.migrateRemovedIndex(internalDbClient, Network.class, "connectedVirtualArrays", "RelationIndex", "RelationIndex");
    MigrateIndexHelper.migrateAddedIndex(internalDbClient, Network.class, "assignedVirtualArrays", "RelationIndex");
    MigrateIndexHelper.migrateAddedIndex(internalDbClient, Network.class, "connectedVirtualArrays", "RelationIndex");
}
Also used : InternalDbClient(com.emc.storageos.db.client.upgrade.InternalDbClient)

Example 2 with InternalDbClient

use of com.emc.storageos.db.client.upgrade.InternalDbClient in project coprhd-controller by CoprHD.

the class FieldValueTimeUUIDPair method handleDataObjectClass.

public void handleDataObjectClass(Class<? extends DataObject> clazz) throws Exception {
    log.info("proccess model class {}", clazz);
    InternalDbClient dbClient = (InternalDbClient) getDbClient();
    DataObjectType doType = TypeMap.getDoType(clazz);
    Keyspace keyspace = dbClient.getLocalContext().getKeyspace();
    ColumnFamilyQuery<String, CompositeColumnName> query = keyspace.prepareQuery(doType.getCF());
    OperationResult<Rows<String, CompositeColumnName>> result = query.getAllRows().setRowLimit(100).execute();
    int totalCount = 0;
    List<Row<String, CompositeColumnName>> rows = new ArrayList<Row<String, CompositeColumnName>>();
    for (Row<String, CompositeColumnName> objRow : result.getResult()) {
        boolean inactiveObject = false;
        totalCount++;
        for (Column<CompositeColumnName> column : objRow.getColumns()) {
            if (DataObject.INACTIVE_FIELD_NAME.equals(column.getName().getOne()) && column.getBooleanValue()) {
                inactiveObject = true;
                break;
            }
        }
        if (inactiveObject) {
            continue;
        }
        rows.add(objRow);
        if (rows.size() > REBUILD_INDEX_BATCH_SIZE) {
            try {
                executor.submit(new RebuildIndexTask(doType, rows, keyspace));
                rows = new ArrayList<Row<String, CompositeColumnName>>();
            } catch (Exception e) {
                log.warn("Failed to submit rebuild index task, this may be caused by thread pool is full, try in next round", e);
            }
        }
    }
    executor.submit(new RebuildIndexTask(doType, rows, keyspace));
    log.info("Total data object count is {} for model {}", totalCount, clazz.getName());
    return;
}
Also used : CompositeColumnName(com.emc.storageos.db.client.impl.CompositeColumnName) InternalDbClient(com.emc.storageos.db.client.upgrade.InternalDbClient) ArrayList(java.util.ArrayList) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Keyspace(com.netflix.astyanax.Keyspace) Row(com.netflix.astyanax.model.Row) DataObjectType(com.emc.storageos.db.client.impl.DataObjectType) Rows(com.netflix.astyanax.model.Rows)

Example 3 with InternalDbClient

use of com.emc.storageos.db.client.upgrade.InternalDbClient in project coprhd-controller by CoprHD.

the class StoragePortNetworkIndexMigration method process.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.db.client.upgrade.BaseCustomMigrationCallback#process()
     */
@Override
public void process() throws MigrationCallbackException {
    InternalDbClient internalDbClient;
    if (InternalDbClient.class.isAssignableFrom(dbClient.getClass())) {
        internalDbClient = (InternalDbClient) dbClient;
    } else {
        throw new IllegalStateException("Migration callback " + name + " needs InternalDbClient");
    }
    MigrateIndexHelper.migrateRemovedIndex(internalDbClient, StoragePort.class, "network", "AlternateId", "AltIdIndex");
    MigrateIndexHelper.migrateAddedIndex(internalDbClient, StoragePort.class, "network", "AltIdIndex");
}
Also used : InternalDbClient(com.emc.storageos.db.client.upgrade.InternalDbClient)

Example 4 with InternalDbClient

use of com.emc.storageos.db.client.upgrade.InternalDbClient in project coprhd-controller by CoprHD.

the class AggregationIndexTimeUUIDMigration method removeOldAggregationIndex.

private void removeOldAggregationIndex() {
    InternalDbClient internalDbClient = getInternalDbClient();
    internalDbClient.rebuildCf("AggregatedIndex");
}
Also used : InternalDbClient(com.emc.storageos.db.client.upgrade.InternalDbClient)

Example 5 with InternalDbClient

use of com.emc.storageos.db.client.upgrade.InternalDbClient in project coprhd-controller by CoprHD.

the class VirtualPoolVarrayIndexFix method process.

/* (non-Javadoc)
     * @see com.emc.storageos.db.client.upgrade.BaseCustomMigrationCallback#process()
     */
@Override
public void process() throws MigrationCallbackException {
    log.info("Fix virtual arrays index for all vpools");
    InternalDbClient internalDbClient;
    if (InternalDbClient.class.isAssignableFrom(dbClient.getClass())) {
        internalDbClient = (InternalDbClient) dbClient;
    } else {
        throw new IllegalStateException("Migration callback " + name + " needs InternalDbClient");
    }
    // removes the entries from RelationIndex (old) index table
    MigrateIndexHelper.migrateRemovedIndex(internalDbClient, VirtualPool.class, "protectionVarraySettings", "RelationIndex", "RelationIndex");
    // adds entries to the new index table (framework knows the new index table)
    MigrateIndexHelper.migrateAddedIndex(internalDbClient, VirtualPool.class, "protectionVarraySettings", "RelationIndex");
}
Also used : InternalDbClient(com.emc.storageos.db.client.upgrade.InternalDbClient)

Aggregations

InternalDbClient (com.emc.storageos.db.client.upgrade.InternalDbClient)7 AggregatedConstraint (com.emc.storageos.db.client.constraint.AggregatedConstraint)1 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 Constraint (com.emc.storageos.db.client.constraint.Constraint)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 ContainmentPermissionsConstraint (com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint)1 ContainmentPrefixConstraint (com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint)1 PrefixConstraint (com.emc.storageos.db.client.constraint.PrefixConstraint)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 CompositeColumnName (com.emc.storageos.db.client.impl.CompositeColumnName)1 DataObjectType (com.emc.storageos.db.client.impl.DataObjectType)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 Volume (com.emc.storageos.db.client.model.Volume)1 MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)1 Keyspace (com.netflix.astyanax.Keyspace)1 Row (com.netflix.astyanax.model.Row)1 Rows (com.netflix.astyanax.model.Rows)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1