use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method terminateAnyRestoreSessionsForVolume.
/**
* Look up any snapshot objects associated with the give volume. For each, can to terminate
* any existing restore sessions.
*
* @param storage [in] - StorageSystem object representing the array
* @param volume [in] - Volume to use for lookup
* @param taskCompleter [in] - TaskCompleter used for updating status of operation
* @throws Exception
*/
private void terminateAnyRestoreSessionsForVolume(StorageSystem storage, BlockObject volume, TaskCompleter taskCompleter) throws Exception {
if (storage.checkIfVmax3()) {
terminateAnyRestoreSessions(storage, null, volume.getId(), taskCompleter);
return;
}
NamedElementQueryResultList snapshots = new NamedElementQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(volume.getId()), snapshots);
for (NamedElementQueryResultList.NamedElement ne : snapshots) {
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, ne.getId());
if (snapshot != null && !snapshot.getInactive()) {
CIMObjectPath syncObjectPath = _cimPath.getSyncObject(storage, snapshot);
if (_helper.checkExists(storage, syncObjectPath, false, false) != null) {
terminateAnyRestoreSessions(storage, volume, snapshot.getId(), taskCompleter);
}
}
}
}
use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList in project coprhd-controller by CoprHD.
the class TaskUtils method findResourceTaskIds.
public static List<NamedURI> findResourceTaskIds(DbClient dbClient, URI resourceId) {
NamedElementQueryResultList results = new NamedElementQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getResourceTaskConstraint(resourceId), results);
List<NamedURI> uris = Lists.newArrayList();
Iterator<NamedElementQueryResultList.NamedElement> it = results.iterator();
while (it.hasNext()) {
NamedElementQueryResultList.NamedElement element = it.next();
uris.add(new NamedURI(element.getId(), element.getName()));
}
return uris;
}
use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList in project coprhd-controller by CoprHD.
the class DbIndexTest method verifyPermissionsDbIndex.
private void verifyPermissionsDbIndex(DataObject obj, ColumnField field, Object val, boolean indexByKey, DbClient client) {
switch(field.getType()) {
case TrackingSetMap:
for (String key : ((AbstractChangeTrackingSetMap<String>) val).keySet()) {
ContainmentPermissionsConstraintImpl constraint = new ContainmentPermissionsConstraintImpl(key, field, obj.getClass());
NamedElementQueryResultList results = new NamedElementQueryResultList();
client.queryByConstraint(constraint, results);
HashSet<String> setFromIndex = new HashSet<String>();
for (NamedElementQueryResultList.NamedElement elem : results) {
if (elem.getId().equals(obj.getId())) {
setFromIndex.add(elem.getName());
}
}
AbstractChangeTrackingSet<String> values = ((AbstractChangeTrackingSetMap<String>) val).get(key);
assertTrue("The value set from index is not same as what is currently in object", setFromIndex.equals(values));
}
break;
case Id:
case NamedURI:
case NestedObject:
case Primitive:
case TrackingMap:
case TrackingSet:
default:
throw new IllegalArgumentException(String.format("Field type %s is not supported by PermissionsDbIndex", field.getType().toString()));
}
}
use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList in project coprhd-controller by CoprHD.
the class ModelClientImpl method queryNamedElementsByConstraint.
protected List<NamedElement> queryNamedElementsByConstraint(Constraint constraint) {
NamedElementQueryResultList queryResults = new NamedElementQueryResultList();
dbClient.queryByConstraint(constraint, queryResults);
return queryResults;
}
use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList in project coprhd-controller by CoprHD.
the class OrderService method exportOrders.
private void exportOrders(List<URI> tids, long startTime, long endTime, OutputStream outputStream, OrderJobStatus status) {
PrintStream out = new PrintStream(outputStream);
out.println("ORDER DETAILS");
out.println("-------------");
List<URI> orderIDs = status.getOrderIDs();
if (!orderIDs.isEmpty()) {
dumpOrders(out, orderIDs, status);
} else {
long completed = 0;
long failed = 0;
for (URI tid : tids) {
TimeSeriesConstraint constraint = TimeSeriesConstraint.Factory.getOrders(tid, startTime, endTime);
DbClientImpl dbclient = (DbClientImpl) _dbClient;
constraint.setKeyspace(dbclient.getKeyspace(Order.class));
NamedElementQueryResultList ids = new NamedElementQueryResultList();
_dbClient.queryByConstraint(constraint, ids);
for (NamedElementQueryResultList.NamedElement namedID : ids) {
URI id = namedID.getId();
try {
dumpOrder(out, id, status);
completed++;
} catch (Exception e) {
failed++;
}
}
}
status.setTotal(completed + failed);
}
try {
saveJobInfo(status);
} catch (Exception e) {
log.error("Failed to save job info status={} e=", status, e);
}
}
Aggregations