Search in sources :

Example 6 with DbClientImpl

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

the class Cassandraforplugin method returnDBClient.

public static DbClient returnDBClient() throws IOException {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/dbutils-conf.xml");
    DbClientImpl dbClient = (DbClientImpl) ctx.getBean("dbclient");
    dbClient.setClusterName("StorageOS");
    dbClient.setKeyspaceName("StorageOS");
    dbClient.start();
    return dbClient;
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl)

Example 7 with DbClientImpl

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

the class SMICommunicationInterfaceTest method testVNXBlockPlugin.

// Need to start coordinator & DB service, before running this test
@Test
public void testVNXBlockPlugin() {
    try {
        final SMICommunicationInterface _smiplugin = (SMICommunicationInterface) _context.getBean("block");
        Map<String, Object> map1 = new ConcurrentHashMap<String, Object>();
        Set<String> idset = new HashSet<String>();
        idset.add("SYMMETRIX+000194900404+VOLUME+00000");
        map1.put("000194900404-block-Volumes", idset);
        _smiplugin.injectCache(map1);
        _smiplugin.injectDBClient(new DbClientImpl());
        _smiplugin.scan(createAccessProfile());
    // sleeptest(_smiplugin);
    } catch (Exception e) {
        _LOGGER.error(e.getMessage(), e);
    }
}
Also used : DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) SMICommunicationInterface(com.emc.storageos.volumecontroller.impl.plugins.SMICommunicationInterface) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with DbClientImpl

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

the class RowMutationTest method insertRecordAndIndexColumnWithError.

@Test
public void insertRecordAndIndexColumnWithError() throws ConnectionException {
    String rowKey = URIUtil.createId(Volume.class).toString();
    String volumeLabel = "volume label";
    // insert data object
    ColumnListMutation<CompositeColumnName> columnList = rowMutator.getRecordColumnList(volumeCF, rowKey);
    columnList.putColumn(new CompositeColumnName("allocatedCapacity"), 20);
    columnList.putColumn(new CompositeColumnName("label"), volumeLabel);
    // insert related index
    rowMutator.getIndexColumnList(indexCF, "vo").putColumn(new IndexColumnName("Volume", volumeLabel, volumeLabel, rowKey, rowMutator.getTimeUUID()), "");
    // insert error column
    ColumnListMutation<CompositeColumnName> no_columnList = rowMutator.getRecordColumnList(noExistCF, rowKey);
    no_columnList.putColumn(new CompositeColumnName("test"), 20);
    try {
        rowMutator.execute();
        Assert.fail();
    } catch (Exception e) {
    // expected exception
    }
    // no volume should be created
    Volume volume = (Volume) this.getDbClient().queryObject(URI.create(rowKey));
    Assert.assertNull(volume);
    // no index should be created
    CqlStatement statement = ((DbClientImpl) this.getDbClient()).getLocalContext().getKeyspace().prepareCqlStatement();
    String cql = String.format("select * from \"LabelPrefixIndex\" where key='%s' and column1='Volume' and column2='%s' and column3='%s' and column4='%s'", "vo", volumeLabel, volumeLabel, rowKey);
    CqlStatementResult result = statement.withCql(cql).execute().getResult();
    Rows<String, IndexColumnName> rows = result.getRows(indexCF);
    Assert.assertEquals(rows.size(), 0);
}
Also used : CompositeColumnName(com.emc.storageos.db.client.impl.CompositeColumnName) Volume(com.emc.storageos.db.client.model.Volume) IndexColumnName(com.emc.storageos.db.client.impl.IndexColumnName) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) CqlStatement(com.netflix.astyanax.cql.CqlStatement) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) CqlStatementResult(com.netflix.astyanax.cql.CqlStatementResult) Test(org.junit.Test)

Example 9 with DbClientImpl

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

the class DbConsistencyCheckerHelperTest method setUp.

@Before
public void setUp() throws Exception {
    Map<Long, String> timeStampVersionMap = new TreeMap<Long, String>();
    timeStampVersionMap.put(TIME_STAMP_2_4_1, "2.4.1");
    timeStampVersionMap.put(TIME_STAMP_3_0, "3.0");
    timeStampVersionMap.put(TIME_STAMP_3_5, "3.5");
    timeStampVersionMap.put(TIME_STAMP_3_6, "3.6");
    helper = new DbConsistencyCheckerHelper((DbClientImpl) getDbClient()) {

        @Override
        protected Map<Long, String> querySchemaVersions() {
            return timeStampVersionMap;
        }
    };
}
Also used : DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) DbConsistencyCheckerHelper(com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper) TreeMap(java.util.TreeMap) TypeMap(com.emc.storageos.db.client.impl.TypeMap) Map(java.util.Map) TreeMap(java.util.TreeMap) Before(org.junit.Before)

Example 10 with DbClientImpl

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

the class DbConsistencyCheckerHelperTest method testIsIndexExists.

@Test
public void testIsIndexExists() throws Exception {
    FileShare testData = new FileShare();
    testData.setId(URIUtil.createId(FileShare.class));
    testData.setPath("path1");
    testData.setMountPath("mountPath1");
    getDbClient().createObject(testData);
    ColumnFamily<String, IndexColumnName> indexCF = new ColumnFamily<String, IndexColumnName>("AltIdIndex", StringSerializer.get(), IndexColumnNameSerializer.get());
    Keyspace keyspace = ((DbClientImpl) getDbClient()).getLocalContext().getKeyspace();
    CompositeRangeBuilder builder = IndexColumnNameSerializer.get().buildRange();
    builder.withPrefix("FileShare").greaterThanEquals(testData.getId().toString()).lessThanEquals(testData.getId().toString());
    Rows<String, IndexColumnName> result = keyspace.prepareQuery(indexCF).getAllRows().withColumnRange(builder).execute().getResult();
    for (Row<String, IndexColumnName> row : result) {
        System.out.println(row.getColumns().getColumnByIndex(0).getName());
        assertTrue(helper.isIndexExists(keyspace, indexCF, row.getKey(), row.getColumns().getColumnByIndex(0).getName()));
    }
    ((DbClientImpl) getDbClient()).internalRemoveObjects(testData);
    for (Row<String, IndexColumnName> row : result) {
        assertFalse(helper.isIndexExists(keyspace, indexCF, row.getKey(), row.getColumns().getColumnByIndex(0).getName()));
    }
}
Also used : CompositeIndexColumnName(com.emc.storageos.db.client.impl.CompositeIndexColumnName) TimeSeriesIndexColumnName(com.emc.storageos.db.client.impl.TimeSeriesIndexColumnName) ClassNameTimeSeriesIndexColumnName(com.emc.storageos.db.client.impl.ClassNameTimeSeriesIndexColumnName) IndexColumnName(com.emc.storageos.db.client.impl.IndexColumnName) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) Keyspace(com.netflix.astyanax.Keyspace) CompositeRangeBuilder(com.netflix.astyanax.serializers.CompositeRangeBuilder) FileShare(com.emc.storageos.db.client.model.FileShare) ColumnFamily(com.netflix.astyanax.model.ColumnFamily) Test(org.junit.Test)

Aggregations

DbClientImpl (com.emc.storageos.db.client.impl.DbClientImpl)27 Test (org.junit.Test)11 URI (java.net.URI)9 IndexColumnName (com.emc.storageos.db.client.impl.IndexColumnName)6 CompositeColumnName (com.emc.storageos.db.client.impl.CompositeColumnName)5 Order (com.emc.storageos.db.client.model.uimodels.Order)5 TimeSeriesConstraint (com.emc.storageos.db.client.constraint.TimeSeriesConstraint)4 DataObjectType (com.emc.storageos.db.client.impl.DataObjectType)4 Volume (com.emc.storageos.db.client.model.Volume)4 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)4 MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)4 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)4 ClassNameTimeSeriesIndexColumnName (com.emc.storageos.db.client.impl.ClassNameTimeSeriesIndexColumnName)3 DbClientContext (com.emc.storageos.db.client.impl.DbClientContext)3 DbConsistencyCheckerHelper (com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper)3 GlobalLockImpl (com.emc.storageos.db.client.impl.GlobalLockImpl)3 FileShare (com.emc.storageos.db.client.model.FileShare)3 ColumnFamily (com.netflix.astyanax.model.ColumnFamily)3 DbVersionInfo (com.emc.storageos.coordinator.client.model.DbVersionInfo)2 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)2