Search in sources :

Example 6 with IndexAndCf

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;
}
Also used : IndexAndCf(com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.IndexAndCf) ArrayList(java.util.ArrayList) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with IndexAndCf

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());
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) CompositeColumnName(com.emc.storageos.db.client.impl.CompositeColumnName) Keyspace(com.netflix.astyanax.Keyspace) CheckResult(com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.CheckResult) IndexAndCf(com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.IndexAndCf) ClassNameTimeSeriesIndexColumnName(com.emc.storageos.db.client.impl.ClassNameTimeSeriesIndexColumnName) ColumnFamily(com.netflix.astyanax.model.ColumnFamily) Test(org.junit.Test)

Example 8 with IndexAndCf

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());
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) CompositeColumnName(com.emc.storageos.db.client.impl.CompositeColumnName) ClassNameTimeSeriesIndexColumnName(com.emc.storageos.db.client.impl.ClassNameTimeSeriesIndexColumnName) ColumnFamily(com.netflix.astyanax.model.ColumnFamily) Keyspace(com.netflix.astyanax.Keyspace) CheckResult(com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.CheckResult) IndexAndCf(com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.IndexAndCf) TimeSeriesIndexColumnName(com.emc.storageos.db.client.impl.TimeSeriesIndexColumnName) ClassNameTimeSeriesIndexColumnName(com.emc.storageos.db.client.impl.ClassNameTimeSeriesIndexColumnName) Test(org.junit.Test)

Aggregations

IndexAndCf (com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.IndexAndCf)8 CheckResult (com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.CheckResult)6 ClassNameTimeSeriesIndexColumnName (com.emc.storageos.db.client.impl.ClassNameTimeSeriesIndexColumnName)4 CompositeColumnName (com.emc.storageos.db.client.impl.CompositeColumnName)4 Keyspace (com.netflix.astyanax.Keyspace)4 ColumnFamily (com.netflix.astyanax.model.ColumnFamily)4 Test (org.junit.Test)4 TimeSeriesIndexColumnName (com.emc.storageos.db.client.impl.TimeSeriesIndexColumnName)3 Order (com.emc.storageos.db.client.model.uimodels.Order)3 DbConsistencyStatus (com.emc.storageos.coordinator.client.model.DbConsistencyStatus)1 CompositeIndexColumnName (com.emc.storageos.db.client.impl.CompositeIndexColumnName)1 DataObjectType (com.emc.storageos.db.client.impl.DataObjectType)1 DbClientImpl (com.emc.storageos.db.client.impl.DbClientImpl)1 DbConsistencyCheckerHelper (com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper)1 IndexColumnName (com.emc.storageos.db.client.impl.IndexColumnName)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)1 MutationBatch (com.netflix.astyanax.MutationBatch)1 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)1 ArrayList (java.util.ArrayList)1