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