use of com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.IndexAndCf in project coprhd-controller by CoprHD.
the class DbConsistencyChecker method resumeFromWorkingPoint.
private Collection resumeFromWorkingPoint(CheckType checkType, String workingPoint) {
Collection sortedCfs;
if (checkType == CheckType.INDEX_OBJECTS) {
Collection<IndexAndCf> idxCfs = helper.getAllIndices().values();
sortedCfs = sortIndexCfs(idxCfs);
} else {
// Currently, other cases are related to DataObjectType
Collection<DataObjectType> allDoTypes = TypeMap.getAllDoTypes();
sortedCfs = sortDataObjectCfs(allDoTypes);
}
if (toConsole || workingPoint == null) {
return sortedCfs;
}
boolean found = false;
List resumeCfs = new ArrayList<>();
for (Object cfEntry : sortedCfs) {
String cfWorkingPoint;
if (checkType == CheckType.INDEX_OBJECTS) {
IndexAndCf idxCf = (IndexAndCf) cfEntry;
cfWorkingPoint = idxCf.generateKey();
} else {
DataObjectType dataCf = (DataObjectType) cfEntry;
cfWorkingPoint = dataCf.getCF().getName();
}
if (workingPoint.equals(cfWorkingPoint)) {
found = true;
}
if (found) {
resumeCfs.add(cfEntry);
}
}
return found ? resumeCfs : sortedCfs;
}
use of com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.IndexAndCf in project coprhd-controller by CoprHD.
the class DbConsistencyCheckerHelperTest method testClassNameTimeSeriesIndex.
@Test
public void testClassNameTimeSeriesIndex() throws Exception {
DbConsistencyCheckerHelperMock mockHelper = new DbConsistencyCheckerHelperMock((DbClientImpl) getDbClient());
Order order = new Order();
order.setId(URIUtil.createId(Order.class));
order.setLabel("order1");
order.setSubmittedByUserId("root");
getDbClient().createObject(order);
Keyspace keyspace = ((DbClientImpl) getDbClient()).getLocalContext().getKeyspace();
ColumnFamily<String, ClassNameTimeSeriesIndexColumnName> indexCF = new ColumnFamily<String, ClassNameTimeSeriesIndexColumnName>("UserToOrdersByTimeStamp", StringSerializer.get(), ClassNameTimeSeriesSerializer.get());
ColumnFamily<String, CompositeColumnName> cf = new ColumnFamily<String, CompositeColumnName>("Order", StringSerializer.get(), CompositeColumnNameSerializer.get());
IndexAndCf indexAndCf = new IndexAndCf(ClassNameTimeSeriesDBIndex.class, indexCF, keyspace);
CheckResult checkResult = new CheckResult();
mockHelper.checkIndexingCF(indexAndCf, false, checkResult);
assertEquals(0, checkResult.getTotal());
keyspace.prepareQuery(cf).withCql(String.format("delete from \"Order\" where key='%s'", order.getId())).execute();
checkResult = new CheckResult();
mockHelper.checkIndexingCF(indexAndCf, false, checkResult);
assertEquals(1, checkResult.getTotal());
keyspace.prepareQuery(indexCF).withCql(mockHelper.getCleanIndexCQL()).execute();
checkResult = new CheckResult();
mockHelper.checkIndexingCF(indexAndCf, false, checkResult);
assertEquals(0, checkResult.getTotal());
}
use of com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.IndexAndCf in project coprhd-controller by CoprHD.
the class DbConsistencyCheckerHelperTest method testCFIndexForOrder.
@Test
public void testCFIndexForOrder() throws Exception {
DbConsistencyCheckerHelperMock mockHelper = new DbConsistencyCheckerHelperMock((DbClientImpl) getDbClient());
Order order = new Order();
order.setId(URIUtil.createId(Order.class));
order.setLabel("order2");
order.setSubmittedByUserId("Tom");
order.setTenant("urn:storageos:TenantOrg:128e0354-c26e-438b-b1e6-1a6ceaa9b380:global");
order.setIndexed(true);
getDbClient().createObject(order);
Keyspace keyspace = ((DbClientImpl) getDbClient()).getLocalContext().getKeyspace();
ColumnFamily<String, ClassNameTimeSeriesIndexColumnName> userToOrdersByTimeStampCF = new ColumnFamily<String, ClassNameTimeSeriesIndexColumnName>("UserToOrdersByTimeStamp", StringSerializer.get(), ClassNameTimeSeriesSerializer.get());
ColumnFamily<String, TimeSeriesIndexColumnName> allOrdersByTimeStampCF = new ColumnFamily<String, TimeSeriesIndexColumnName>("AllOrdersByTimeStamp", StringSerializer.get(), TimeSeriesColumnNameSerializer.get());
ColumnFamily<String, CompositeColumnName> cf = new ColumnFamily<String, CompositeColumnName>("Order", StringSerializer.get(), CompositeColumnNameSerializer.get());
IndexAndCf indexAndCf = new IndexAndCf(TimeSeriesDbIndex.class, userToOrdersByTimeStampCF, keyspace);
CheckResult checkResult = new CheckResult();
mockHelper.checkCFIndices(TypeMap.getDoType(Order.class), true, checkResult);
assertEquals(0, checkResult.getTotal());
keyspace.prepareQuery(userToOrdersByTimeStampCF).withCql(String.format("delete from \"UserToOrdersByTimeStamp\" where key='%s'", order.getSubmittedByUserId())).execute();
keyspace.prepareQuery(userToOrdersByTimeStampCF).withCql(String.format("delete from \"AllOrdersByTimeStamp\" where key='%s'", order.getTenant())).execute();
checkResult = new CheckResult();
mockHelper.checkCFIndices(TypeMap.getDoType(Order.class), true, checkResult);
assertEquals(2, checkResult.getTotal());
}
Aggregations