Search in sources :

Example 6 with DbVersionInfo

use of com.emc.storageos.coordinator.client.model.DbVersionInfo in project coprhd-controller by CoprHD.

the class DbServiceTestBase method startDb.

/**
 * Start embedded DB
 */
protected void startDb(String schemaVersion, String extraModelsPkg) throws Exception {
    List<String> packages = new ArrayList<String>();
    packages.add("com.emc.storageos.db.client.model");
    if (extraModelsPkg != null) {
        packages.add(extraModelsPkg);
    }
    String[] pkgsArray = packages.toArray(new String[packages.size()]);
    ServiceImpl service = new ServiceImpl();
    service.setName("dbsvc");
    service.setVersion(schemaVersion);
    service.setEndpoint(URI.create("thrift://localhost:9160"));
    service.setId("db-standalone");
    DataObjectScanner scanner = new DataObjectScanner();
    scanner.setPackages(pkgsArray);
    scanner.init();
    dbVersionInfo = new DbVersionInfo();
    dbVersionInfo.setSchemaVersion(schemaVersion);
    coordinator.setDbVersionInfo(dbVersionInfo);
    DbServiceStatusChecker statusChecker = new DbServiceStatusChecker();
    statusChecker.setCoordinator(coordinator);
    statusChecker.setClusterNodeCount(1);
    statusChecker.setDbVersionInfo(dbVersionInfo);
    statusChecker.setServiceName(service.getName());
    CoordinatorClientInetAddressMap coordinatorMap = new CoordinatorClientInetAddressMap();
    coordinatorMap.setNodeId("localhost");
    coordinatorMap.setDualInetAddress(DualInetAddress.fromAddress("127.0.0.1"));
    Map<String, DualInetAddress> addressLookupMap = new HashMap<String, DualInetAddress>();
    addressLookupMap.put(coordinatorMap.getNodeId(), coordinatorMap.getDualInetAddress());
    coordinatorMap.setControllerNodeIPLookupMap(addressLookupMap);
    coordinatorMap.setCoordinatorClient(coordinator);
    coordinator.setInetAddessLookupMap(coordinatorMap);
    SchemaUtil util = new SchemaUtil();
    util.setKeyspaceName("Test");
    util.setClusterName("Test");
    util.setDataObjectScanner(scanner);
    util.setService(service);
    util.setStatusChecker(statusChecker);
    util.setCoordinator(coordinator);
    util.setVdcShortId("vdc1");
    util.setClientContext(createLocalContext());
    List<String> vdcHosts = new ArrayList();
    vdcHosts.add("127.0.0.1");
    util.setVdcNodeList(vdcHosts);
    util.setDbCommonInfo(new java.util.Properties());
    dbsvc = new InternalDbService();
    dbsvc.setConfig("db-test.yaml");
    dbsvc.setSchemaUtil(util);
    dbsvc.setCoordinator(coordinator);
    dbsvc.setStatusChecker(statusChecker);
    dbsvc.setService(service);
    dbsvc.setDbDir(".");
    JmxServerWrapper jmx = new JmxServerWrapper();
    jmx.setEnabled(false);
    dbsvc.setJmxServerWrapper(jmx);
    dbClient = getDbClientBase();
    dbsvc.setDbClient(dbClient);
    PasswordUtils passwordUtils = new PasswordUtils();
    passwordUtils.setCoordinator(coordinator);
    EncryptionProviderImpl provider = new EncryptionProviderImpl();
    provider.setCoordinator(coordinator);
    provider.start();
    passwordUtils.setEncryptionProvider(provider);
    passwordUtils.setDbClient(dbClient);
    util.setPasswordUtils(passwordUtils);
    StubBeaconImpl beacon = new StubBeaconImpl(service);
    dbsvc.setBeacon(beacon);
    MigrationHandlerImpl handler = new MigrationHandlerImpl();
    handler.setPackages(pkgsArray);
    handler.setService(service);
    handler.setStatusChecker(statusChecker);
    handler.setCoordinator(coordinator);
    handler.setDbClient(dbClient);
    handler.setSchemaUtil(util);
    dbsvc.setMigrationHandler(handler);
    dbsvc.setDisableScheduledDbRepair(true);
    dbsvc.start();
}
Also used : DataObjectScanner(com.emc.storageos.db.common.DataObjectScanner) InternalDbService(com.emc.storageos.db.server.upgrade.util.InternalDbService) HashMap(java.util.HashMap) ServiceImpl(com.emc.storageos.coordinator.common.impl.ServiceImpl) MigrationHandlerImpl(com.emc.storageos.db.server.impl.MigrationHandlerImpl) ArrayList(java.util.ArrayList) DbServiceStatusChecker(com.emc.storageos.db.common.DbServiceStatusChecker) PasswordUtils(com.emc.storageos.security.password.PasswordUtils) EncryptionProviderImpl(com.emc.storageos.db.client.impl.EncryptionProviderImpl) DbVersionInfo(com.emc.storageos.coordinator.client.model.DbVersionInfo) SchemaUtil(com.emc.storageos.db.server.impl.SchemaUtil) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) StubBeaconImpl(com.emc.storageos.db.server.util.StubBeaconImpl) JmxServerWrapper(com.emc.storageos.services.util.JmxServerWrapper) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress)

Example 7 with DbVersionInfo

use of com.emc.storageos.coordinator.client.model.DbVersionInfo in project coprhd-controller by CoprHD.

the class LazyLoadTests method setup.

@BeforeClass
public static void setup() throws IOException {
    sourceVersion = new DbVersionInfo();
    sourceVersion.setSchemaVersion("1.1");
    _dataDir = new File(dataDir);
    if (_dataDir.exists() && _dataDir.isDirectory()) {
        cleanDirectory(_dataDir);
    }
    _dataDir.mkdir();
    DataObjectScanner scanner = new DataObjectScanner();
    scanner.setPackages("com.emc.storageos.db.modelclient.model");
    scanner.init();
    // setting migration status to failed is a workaround for getting into
    // an endless loop of trying to run migration; if it's set to failed, we
    // simply by-pass migration; the other side affect is we don't start any
    // of the dbsvc background tasks, but we don't need them for this test
    setMigrationStatus(MigrationStatus.FAILED);
    startDb(sourceVersion.getSchemaVersion(), sourceVersion.getSchemaVersion(), null, scanner, false);
}
Also used : DataObjectScanner(com.emc.storageos.db.common.DataObjectScanner) File(java.io.File) DbVersionInfo(com.emc.storageos.coordinator.client.model.DbVersionInfo) BeforeClass(org.junit.BeforeClass)

Example 8 with DbVersionInfo

use of com.emc.storageos.coordinator.client.model.DbVersionInfo in project coprhd-controller by CoprHD.

the class DbClientImpl method setupContext.

protected void setupContext(DbClientContext ctx, String dbSvcName) {
    if (keyspaceName != null) {
        ctx.setKeyspaceName(keyspaceName);
    }
    if (clusterName != null) {
        ctx.setClusterName(clusterName);
    }
    // wait for schema init
    DbServiceStatusChecker statusChecker = new DbServiceStatusChecker();
    statusChecker.setCoordinator(_coordinator);
    statusChecker.setVersion(_dbVersionInfo.getSchemaVersion());
    statusChecker.setServiceName(dbSvcName);
    DbVersionInfo versionInfo = new DbVersionInfo();
    versionInfo.setSchemaVersion(_dbVersionInfo.getSchemaVersion());
    statusChecker.setDbVersionInfo(versionInfo);
    _coordinator.setDbVersionInfo(versionInfo);
    if (_bypassMigrationLock) {
        statusChecker.waitForAnyNodeInitDone();
    } else {
        statusChecker.waitForMigrationDone();
    }
    HostSupplierImpl hostSupplier = new HostSupplierImpl();
    hostSupplier.setDbClientVersion(_dbVersionInfo.getSchemaVersion());
    hostSupplier.setCoordinatorClient(_coordinator);
    hostSupplier.setDbSvcName(dbSvcName);
    ctx.init(hostSupplier);
}
Also used : DbServiceStatusChecker(com.emc.storageos.db.common.DbServiceStatusChecker) DbVersionInfo(com.emc.storageos.coordinator.client.model.DbVersionInfo)

Example 9 with DbVersionInfo

use of com.emc.storageos.coordinator.client.model.DbVersionInfo in project coprhd-controller by CoprHD.

the class DbsvcGeoTestBase method setup.

@BeforeClass
public static void setup() {
    _dbVersionInfo = new DbVersionInfo();
    _dbVersionInfo.setSchemaVersion(DbSvcRunner.SVC_VERSION);
    geoRunner = new DbSvcRunner(DbSvcRunner.GEODBSVC_CONFIG, Constants.GEODBSVC_NAME);
    geoRunner.startCoordinator();
    geoRunner.start();
    localRunner = new DbSvcRunner(DbSvcRunner.DBSVC_CONFIG, Constants.DBSVC_NAME);
    localRunner.start();
    // geoRunner.waitUntilStarted(100);
    try {
        configDbClient();
    } catch (Exception e) {
        log.error("Error configuring dbclient", e);
        return;
    }
}
Also used : DbVersionInfo(com.emc.storageos.coordinator.client.model.DbVersionInfo) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) IOException(java.io.IOException) BeforeClass(org.junit.BeforeClass)

Aggregations

DbVersionInfo (com.emc.storageos.coordinator.client.model.DbVersionInfo)9 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)4 DataObjectScanner (com.emc.storageos.db.common.DataObjectScanner)4 ArrayList (java.util.ArrayList)4 DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)3 DbClientContext (com.emc.storageos.db.client.impl.DbClientContext)3 DbServiceStatusChecker (com.emc.storageos.db.common.DbServiceStatusChecker)3 CoordinatorClientImpl (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl)2 ServiceImpl (com.emc.storageos.coordinator.common.impl.ServiceImpl)2 ZkConnection (com.emc.storageos.coordinator.common.impl.ZkConnection)2 DbClientImpl (com.emc.storageos.db.client.impl.DbClientImpl)2 EncryptionProviderImpl (com.emc.storageos.db.client.impl.EncryptionProviderImpl)2 StubBeaconImpl (com.emc.storageos.db.server.util.StubBeaconImpl)2 PasswordUtils (com.emc.storageos.security.password.PasswordUtils)2 JmxServerWrapper (com.emc.storageos.services.util.JmxServerWrapper)2 File (java.io.File)2 URI (java.net.URI)2 BeforeClass (org.junit.BeforeClass)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)1