Search in sources :

Example 1 with NoInactiveIndex

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

the class DbClientImpl method removeObject.

@Override
public void removeObject(DataObject... object) {
    tracer.newTracer("write");
    Map<Class<? extends DataObject>, List<DataObject>> typeObjMap = new HashMap<Class<? extends DataObject>, List<DataObject>>();
    for (DataObject obj : object) {
        List<DataObject> objTypeList = typeObjMap.get(obj.getClass());
        if (objTypeList == null) {
            objTypeList = new ArrayList<>();
            typeObjMap.put(obj.getClass(), objTypeList);
        }
        objTypeList.add(obj);
    }
    for (Entry<Class<? extends DataObject>, List<DataObject>> entry : typeObjMap.entrySet()) {
        if (entry.getKey().getAnnotation(NoInactiveIndex.class) == null) {
            _log.debug("Model class {} has no NoInactiveIndex. Call markForDeletion() to delete", entry.getKey());
            markForDeletion(entry.getValue());
        } else {
            List<DataObject> dbObjList = entry.getValue();
            removeObject(entry.getKey(), dbObjList.toArray(new DataObject[dbObjList.size()]));
        }
    }
}
Also used : PropertyListDataObject(com.emc.storageos.db.client.model.PropertyListDataObject) DataObject(com.emc.storageos.db.client.model.DataObject) NoInactiveIndex(com.emc.storageos.db.client.model.NoInactiveIndex) ColumnList(com.netflix.astyanax.model.ColumnList) QueryResultList(com.emc.storageos.db.client.constraint.QueryResultList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 2 with NoInactiveIndex

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

the class DbClientImpl method queryByType.

/**
 * @param clazz object type
 * @param activeOnly if true, gets only active object ids. NOTE: For classes marked with NoInactiveIndex, there could be 2 cases:
 *            a. The class does not use .inactive field at all, which means all object instances with .inactive == null
 *            b. The class does make use of .inactive field, just don't want to put it into Decommissioned index
 *            When querying type A classes, you can only specify activeOnly == false, otherwise you get nothing
 *            When querying type B classes, you can specify activeOnly freely as normal classes
 * @param <T>
 * @return
 * @throws DatabaseException
 */
@Override
public <T extends DataObject> List<URI> queryByType(Class<T> clazz, boolean activeOnly) {
    tracer.newTracer("read");
    if (clazz.getAnnotation(NoInactiveIndex.class) != null) {
        // A class not indexed by Decommissioned CF, we can only scan entire CF for it
        return scanByType(clazz, activeOnly ? false : null, null, Integer.MAX_VALUE);
    }
    DataObjectType doType = TypeMap.getDoType(clazz);
    if (doType == null) {
        throw new IllegalArgumentException();
    }
    URIQueryResultList result = new URIQueryResultList();
    DecommissionedConstraint constraint;
    if (activeOnly) {
        constraint = DecommissionedConstraint.Factory.getAllObjectsConstraint(clazz, false);
    } else {
        constraint = DecommissionedConstraint.Factory.getAllObjectsConstraint(clazz, null);
    }
    constraint.setKeyspace(getKeyspace(clazz));
    constraint.execute(result);
    return result;
}
Also used : NoInactiveIndex(com.emc.storageos.db.client.model.NoInactiveIndex) DecommissionedConstraint(com.emc.storageos.db.client.constraint.DecommissionedConstraint) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 NoInactiveIndex (com.emc.storageos.db.client.model.NoInactiveIndex)2 DecommissionedConstraint (com.emc.storageos.db.client.constraint.DecommissionedConstraint)1 QueryResultList (com.emc.storageos.db.client.constraint.QueryResultList)1 DataObject (com.emc.storageos.db.client.model.DataObject)1 PropertyListDataObject (com.emc.storageos.db.client.model.PropertyListDataObject)1 ColumnList (com.netflix.astyanax.model.ColumnList)1