Search in sources :

Example 11 with DbClientImpl

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

the class TestDBClientUtils method newDBClient.

public static DbClientImpl newDBClient() throws Exception {
    ZkConnection zkConnection = new ZkConnection();
    zkConnection.setServer(Lists.newArrayList(new URI("coordinator://localhost:2181")));
    zkConnection.build();
    DualInetAddress dualInetAddress = DualInetAddress.fromAddresses("127.0.0.1", "::1");
    Map<String, DualInetAddress> addresses = Maps.newHashMap();
    addresses.put("localhost", dualInetAddress);
    CoordinatorClientInetAddressMap map = new CoordinatorClientInetAddressMap();
    map.setNodeId("standalone");
    map.setDualInetAddress(dualInetAddress);
    map.setControllerNodeIPLookupMap(addresses);
    CoordinatorClientImpl coordinatorClient = new CoordinatorClientImpl();
    coordinatorClient.setZkConnection(zkConnection);
    coordinatorClient.setInetAddessLookupMap(map);
    coordinatorClient.start();
    DbClientContext localContext = new DbClientContext();
    localContext.setKeyspaceName("StorageOS");
    localContext.setClusterName("StorageOs");
    DbClientContext geoContext = new DbClientContext();
    geoContext.setKeyspaceName("GeoStorageOs");
    geoContext.setClusterName("GeoStorageOs");
    DbVersionInfo versionInfo = new DbVersionInfo();
    versionInfo.setSchemaVersion("2.0");
    DbClientImpl client = new DbClientImpl();
    client.setDbVersionInfo(versionInfo);
    client.setLocalContext(localContext);
    client.setGeoContext(geoContext);
    client.setCoordinatorClient(coordinatorClient);
    client.setLocalContext(new DbClientContext());
    client.start();
    VdcUtil.setDbClient(client);
    return client;
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl) DbClientContext(com.emc.storageos.db.client.impl.DbClientContext) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) DbVersionInfo(com.emc.storageos.coordinator.client.model.DbVersionInfo)

Example 12 with DbClientImpl

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

the class GeoDbSvcStartupTest method getDbClient.

protected static DbClient getDbClient() throws URISyntaxException, IOException {
    if (dbClient == null) {
        dbClient = new DbClientImpl();
        CoordinatorClient coordinator = runner.getCoordinator();
        dbClient.setCoordinatorClient(coordinator);
        DbVersionInfo dbVersionInfo = new DbVersionInfo();
        dbVersionInfo.setSchemaVersion(DbSvcRunner.SVC_VERSION);
        dbClient.setDbVersionInfo(dbVersionInfo);
        dbClient.setBypassMigrationLock(true);
        EncryptionProviderImpl encryptionProvider = new EncryptionProviderImpl();
        encryptionProvider.setCoordinator(coordinator);
        dbClient.setEncryptionProvider(encryptionProvider);
        EncryptionProviderImpl geoEncryptionProvider = new EncryptionProviderImpl();
        geoEncryptionProvider.setCoordinator(coordinator);
        geoEncryptionProvider.setEncryptId("geoid");
        dbClient.setGeoEncryptionProvider(geoEncryptionProvider);
        DbClientContext geoCtx = new DbClientContext();
        geoCtx.setClusterName("GeoStorageOS");
        geoCtx.setKeyspaceName("GeoStorageOS");
        dbClient.setGeoContext(geoCtx);
        dbClient.start();
    }
    return dbClient;
}
Also used : DbClientContext(com.emc.storageos.db.client.impl.DbClientContext) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) EncryptionProviderImpl(com.emc.storageos.db.client.impl.EncryptionProviderImpl) DbVersionInfo(com.emc.storageos.coordinator.client.model.DbVersionInfo)

Example 13 with DbClientImpl

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

the class OrderService method exportOrders.

private void exportOrders(List<URI> tids, String orderIDsStr, long startTime, long endTime, OutputStream outputStream, OrderJobStatus status) {
    PrintStream out = new PrintStream(outputStream);
    out.println("ORDER DETAILS");
    out.println("-------------");
    List<URI> orderIDs = toIDs(SearchConstants.ORDER_IDS, orderIDsStr);
    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);
    }
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) PrintStream(java.io.PrintStream) TimeSeriesConstraint(com.emc.storageos.db.client.constraint.TimeSeriesConstraint) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) URI(java.net.URI) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) InvalidParameterException(java.security.InvalidParameterException) WebApplicationException(javax.ws.rs.WebApplicationException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 14 with DbClientImpl

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

the class BourneDbClient method getOrderCount.

@Override
public long getOrderCount(String userId, String fieldName, long startTime, long endTime) {
    LOG.debug("getOrderCount(userId={} cf={}, startTime={}, endTime={})", new Object[] { userId, fieldName, startTime, endTime });
    TimeSeriesConstraint constraint = TimeSeriesConstraint.Factory.getOrdersByUser(userId, startTime, endTime);
    DbClientImpl dbclient = (DbClientImpl) getDbClient();
    constraint.setKeyspace(dbclient.getKeyspace(Order.class));
    try {
        return constraint.count();
    } catch (ConnectionException e) {
        throw new DataAccessException(e);
    }
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) TimeSeriesConstraint(com.emc.storageos.db.client.constraint.TimeSeriesConstraint) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException)

Example 15 with DbClientImpl

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

the class BourneDbClient method getOrderCount.

@Override
public Map<String, Long> getOrderCount(List<URI> tids, String fieldName, long startTime, long endTime) {
    LOG.debug("getOrderCount(tids={} cf={}, startTime={}, endTime={})", new Object[] { tids, fieldName, startTime, endTime });
    Map<String, Long> counts = new HashMap();
    for (URI tid : tids) {
        TimeSeriesConstraint constraint = TimeSeriesConstraint.Factory.getOrders(tid, startTime, endTime);
        DbClientImpl dbclient = (DbClientImpl) getDbClient();
        constraint.setKeyspace(dbclient.getKeyspace(Order.class));
        try {
            counts.put(tid.toString(), constraint.count());
        } catch (ConnectionException e) {
            throw new DataAccessException(e);
        }
    }
    return counts;
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) HashMap(java.util.HashMap) TimeSeriesConstraint(com.emc.storageos.db.client.constraint.TimeSeriesConstraint) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) URI(java.net.URI) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException)

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