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;
}
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;
}
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);
}
}
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);
}
}
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;
}
Aggregations