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; }
/** * Create DbClient to embedded DB * * @return */ protected static DbClient createDbClient() { ENCRYPTION_PROVIDER.setCoordinator(ModelTestSuite.getCoordinator()); DbClientContext localCtx = new DbClientContext(); localCtx.setClusterName("Test"); localCtx.setKeyspaceName("Test"); DbClientImpl dbClient = new DbClientImpl(); dbClient.setCoordinatorClient(ModelTestSuite.getCoordinator()); dbClient.setEncryptionProvider(ENCRYPTION_PROVIDER); dbClient.setBypassMigrationLock(true); dbClient.setDbVersionInfo(ModelTestSuite.getDbVersionInfo()); dbClient.setLocalContext(localCtx); VdcUtil.setDbClient(dbClient); dbClient.start(); return dbClient; }