Search in sources :

Example 1 with DbIndex

use of com.emc.storageos.db.client.impl.DbIndex in project coprhd-controller by CoprHD.

the class AggregationIndexTimeUUIDMigration method removeTimeUUIDIndexedFields.

private void removeTimeUUIDIndexedFields(Class<? extends DataObject> clazz) throws Exception {
    DataObjectType doType = TypeMap.getDoType(clazz);
    Collection<ColumnField> fields = doType.getColumnFields();
    Map<String, ColumnField> uuidFields = new HashMap<>();
    for (ColumnField field : fields) {
        DbIndex index = field.getIndex();
        if (index != null && index instanceof AggregateDbIndex) {
            uuidFields.put(field.getName(), field);
        }
    }
    // true: ignore exception while accessing db
    getInternalDbClient().resetFields(clazz, uuidFields, true);
}
Also used : HashMap(java.util.HashMap) ColumnField(com.emc.storageos.db.client.impl.ColumnField) DataObjectType(com.emc.storageos.db.client.impl.DataObjectType) AggregateDbIndex(com.emc.storageos.db.client.impl.AggregateDbIndex) DbIndex(com.emc.storageos.db.client.impl.DbIndex) AggregateDbIndex(com.emc.storageos.db.client.impl.AggregateDbIndex)

Example 2 with DbIndex

use of com.emc.storageos.db.client.impl.DbIndex in project coprhd-controller by CoprHD.

the class DbIndexTest method verify.

@Override
public void verify(Class<? extends DataObject> clazz, URI id, DbClient client) {
    // Get meta data about the object, field and index we're going to test
    DataObjectType doType = TypeMap.getDoType(clazz);
    ColumnField field = doType.getColumnField(fieldName);
    if (field == null) {
        throw new NullPointerException(String.format("Cannot find field %s from class %s", fieldName, clazz.getSimpleName()));
    }
    DbIndex index = field.getIndex();
    // Load object first
    DataObject obj = (DataObject) client.queryObject(clazz, id);
    // Get current value of indexed field
    Object val = null;
    try {
        val = field.getPropertyDescriptor().getReadMethod().invoke(obj);
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Assert.fail("Cannot get field value");
    }
    boolean indexByKey = field.getPropertyDescriptor().getReadMethod().getAnnotation(IndexByKey.class) != null;
    // See which type the index is, and call corresponding verification functions
    if (index instanceof AltIdDbIndex) {
        verifyAltIdDbIndex(obj, field, val, indexByKey, client);
    } else if (index instanceof RelationDbIndex) {
        verifyRelationDbIndex(obj, field, val, indexByKey, client);
    } else if (index instanceof NamedRelationDbIndex) {
        verifyNamedRelationDbIndex(obj, field, val, indexByKey, client);
    } else if (index instanceof PrefixDbIndex) {
        verifyPrefixDbIndex(obj, field, val, indexByKey, client);
    } else if (index instanceof DecommissionedDbIndex) {
        verifyDecommissionedDbIndex(obj, field, val, indexByKey, client);
    } else if (index instanceof PermissionsDbIndex) {
        verifyPermissionsDbIndex(obj, field, val, indexByKey, client);
    } else if (index instanceof ScopedLabelDbIndex) {
        verifyScopedLabelDbIndex(obj, field, val, indexByKey, client);
    } else {
        System.out.printf("Unsupported index type %s%n", index.getClass().getSimpleName());
    }
}
Also used : AltIdDbIndex(com.emc.storageos.db.client.impl.AltIdDbIndex) PrefixDbIndex(com.emc.storageos.db.client.impl.PrefixDbIndex) DecommissionedDbIndex(com.emc.storageos.db.client.impl.DecommissionedDbIndex) ColumnField(com.emc.storageos.db.client.impl.ColumnField) ScopedLabelDbIndex(com.emc.storageos.db.client.impl.ScopedLabelDbIndex) NamedRelationDbIndex(com.emc.storageos.db.client.impl.NamedRelationDbIndex) AltIdDbIndex(com.emc.storageos.db.client.impl.AltIdDbIndex) RelationDbIndex(com.emc.storageos.db.client.impl.RelationDbIndex) PrefixDbIndex(com.emc.storageos.db.client.impl.PrefixDbIndex) DbIndex(com.emc.storageos.db.client.impl.DbIndex) DecommissionedDbIndex(com.emc.storageos.db.client.impl.DecommissionedDbIndex) PermissionsDbIndex(com.emc.storageos.db.client.impl.PermissionsDbIndex) InvocationTargetException(java.lang.reflect.InvocationTargetException) ScopedLabelDbIndex(com.emc.storageos.db.client.impl.ScopedLabelDbIndex) JsonObject(com.google.gson.JsonObject) PermissionsDbIndex(com.emc.storageos.db.client.impl.PermissionsDbIndex) DataObjectType(com.emc.storageos.db.client.impl.DataObjectType) NamedRelationDbIndex(com.emc.storageos.db.client.impl.NamedRelationDbIndex) NamedRelationDbIndex(com.emc.storageos.db.client.impl.NamedRelationDbIndex) RelationDbIndex(com.emc.storageos.db.client.impl.RelationDbIndex)

Aggregations

ColumnField (com.emc.storageos.db.client.impl.ColumnField)2 DataObjectType (com.emc.storageos.db.client.impl.DataObjectType)2 DbIndex (com.emc.storageos.db.client.impl.DbIndex)2 AggregateDbIndex (com.emc.storageos.db.client.impl.AggregateDbIndex)1 AltIdDbIndex (com.emc.storageos.db.client.impl.AltIdDbIndex)1 DecommissionedDbIndex (com.emc.storageos.db.client.impl.DecommissionedDbIndex)1 NamedRelationDbIndex (com.emc.storageos.db.client.impl.NamedRelationDbIndex)1 PermissionsDbIndex (com.emc.storageos.db.client.impl.PermissionsDbIndex)1 PrefixDbIndex (com.emc.storageos.db.client.impl.PrefixDbIndex)1 RelationDbIndex (com.emc.storageos.db.client.impl.RelationDbIndex)1 ScopedLabelDbIndex (com.emc.storageos.db.client.impl.ScopedLabelDbIndex)1 JsonObject (com.google.gson.JsonObject)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1