Search in sources :

Example 1 with TimeSeriesIndexColumnName

use of com.emc.storageos.db.client.impl.TimeSeriesIndexColumnName in project coprhd-controller by CoprHD.

the class DbConsistencyCheckerHelperTest method testTimeSeriesAlternateId.

@Test
public void testTimeSeriesAlternateId() throws Exception {
    DbConsistencyCheckerHelperMock mockHelper = new DbConsistencyCheckerHelperMock((DbClientImpl) getDbClient());
    Order order = new Order();
    order.setId(URIUtil.createId(Order.class));
    order.setLabel("order2");
    order.setTenant("tenant");
    order.setIndexed(true);
    getDbClient().createObject(order);
    Keyspace keyspace = ((DbClientImpl) getDbClient()).getLocalContext().getKeyspace();
    ColumnFamily<String, TimeSeriesIndexColumnName> indexCF = 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, 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) TimeSeriesIndexColumnName(com.emc.storageos.db.client.impl.TimeSeriesIndexColumnName) ClassNameTimeSeriesIndexColumnName(com.emc.storageos.db.client.impl.ClassNameTimeSeriesIndexColumnName) ColumnFamily(com.netflix.astyanax.model.ColumnFamily) Test(org.junit.Test)

Example 2 with TimeSeriesIndexColumnName

use of com.emc.storageos.db.client.impl.TimeSeriesIndexColumnName 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

ClassNameTimeSeriesIndexColumnName (com.emc.storageos.db.client.impl.ClassNameTimeSeriesIndexColumnName)2 CompositeColumnName (com.emc.storageos.db.client.impl.CompositeColumnName)2 CheckResult (com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.CheckResult)2 IndexAndCf (com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.IndexAndCf)2 TimeSeriesIndexColumnName (com.emc.storageos.db.client.impl.TimeSeriesIndexColumnName)2 Order (com.emc.storageos.db.client.model.uimodels.Order)2 Keyspace (com.netflix.astyanax.Keyspace)2 ColumnFamily (com.netflix.astyanax.model.ColumnFamily)2 Test (org.junit.Test)2