Search in sources :

Example 1 with CoordinatorClientImpl

use of com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl in project coprhd-controller by CoprHD.

the class DbServiceImpl method start.

@Override
public void start() throws IOException {
    if (_log.isInfoEnabled()) {
        _log.info("Starting DB service...");
    }
    // Suppress Sonar violation of Lazy initialization of static fields should be synchronized
    // start() method will be only called one time when startup dbsvc, so it's safe to ignore sonar violation
    // NOSONAR ("squid:S2444")
    instance = this;
    if (backCompatPreYoda) {
        _log.info("Pre-yoda back compatible flag detected. Initialize local keystore/truststore for Cassandra native encryption");
        initKeystoreAndTruststore();
        _schemaUtil.setBackCompatPreYoda(true);
    }
    System.setProperty("cassandra.config", _config);
    System.setProperty("cassandra.config.loader", CassandraConfigLoader.class.getName());
    // Set to false to clear all gossip state for the node on restart.
    // 
    // We encounter a weird Cassandra grossip issue(COP-19246) - some nodes are missing from gossip
    // when rebooting the entire cluster simultaneously. Critical Gossip fields(ApplicationState.STATUS, ApplicationState.TOKENS)
    // are not synchronized during handshaking. It looks like some problem caused by incorrect gossip version/generation
    // at system local table. So add this option to cleanup local gossip state during reboot
    // 
    // Make sure add-vdc/add-standby passed when you would remove this option in the future.
    // 
    // We need make sure majority local nodes are added as seed nodes. Otherwise cassandra may not see other nodes if it loses
    // connection to other sites
    System.setProperty("cassandra.load_ring_state", "false");
    // See https://docs.datastax.com/en/cassandra/2.0/cassandra/operations/ops_add_dc_to_cluster_t.html
    if (_schemaUtil.isStandby()) {
        System.setProperty("cassandra.auto_bootstrap", "false");
    }
    InterProcessLock lock = null;
    Configuration config = null;
    StartupMode mode = null;
    try {
        // we use this lock to discourage more than one node bootstrapping / joining at the same time
        // Cassandra can handle this but it's generally not recommended to make changes to schema concurrently
        lock = getLock(getSchemaLockName());
        config = checkConfiguration();
        checkGlobalConfiguration();
        checkVersionedConfiguration();
        removeStaleConfiguration();
        mode = checkStartupMode(config);
        _log.info("Current startup mode is {}", mode);
        // Check if service is allowed to get started by querying db offline info to avoid bringing back stale data.
        // Skipping hibernate mode for node recovery procedure to recover the overdue node.
        int nodeCount = ((CoordinatorClientImpl) _coordinator).getNodeCount();
        if (nodeCount != 1 && mode.type != StartupMode.StartupModeType.HIBERNATE_MODE) {
            checkDBOfflineInfo(_coordinator, _serviceInfo.getName(), dbDir, true);
        }
        // this call causes instantiation of a seed provider instance, so the check*Configuration
        // calls must be preceed it
        removeCassandraSavedCaches();
        mode.onPreStart();
        if (_jmxServer != null) {
            _jmxServer.start();
            System.setProperty("com.sun.management.jmxremote.port", Integer.toString(_jmxServer.getPort()));
        }
        _service = new CassandraDaemon();
        _service.init(null);
        _service.start();
        cassandraInitialized = true;
        mode.onPostStart();
    } catch (Exception e) {
        if (mode != null && mode.type == StartupMode.StartupModeType.HIBERNATE_MODE) {
            printRecoveryWorkAround(e);
        }
        _log.error("e=", e);
        throw new IllegalStateException(e);
    } finally {
        if (lock != null) {
            try {
                lock.release();
            } catch (Exception ignore) {
                _log.debug("lock release failed");
            }
        }
    }
    if (config.getConfig(DbConfigConstants.JOINED) == null) {
        config.setConfig(DbConfigConstants.JOINED, Boolean.TRUE.toString());
        _coordinator.persistServiceConfiguration(_coordinator.getSiteId(), config);
    }
    _statusChecker.waitForAllNodesJoined();
    _svcBeacon.start();
    if (backCompatPreYoda) {
        _log.info("Enable duplicated beacon in global area during pre-yoda upgrade");
        startDupBeacon();
    }
    setDbInitializedFlag();
    setDbConfigInitDone();
    _dbClient.start();
    if (_schemaUtil.isStandby()) {
        String localDataRevision = getLocalDataRevision();
        if (localDataRevision != null) {
            _schemaUtil.checkDataRevision(localDataRevision);
        }
    }
    // Setup the vdc information, so that login enabled before migration
    if (!isGeoDbsvc()) {
        _schemaUtil.checkAndSetupBootStrapInfo(_dbClient);
    }
    dbMgr.init();
    if (_handler.run()) {
        // Setup the bootstrap info root tenant, if root tenant migrated from local db, then skip it
        if (isGeoDbsvc()) {
            _schemaUtil.checkAndSetupBootStrapInfo(_dbClient);
        } else {
            _schemaUtil.checkAndInitStorageSystemTypes(_dbClient);
        }
        startBackgroundTasks();
        _log.info("DB service started");
    } else {
        _log.error("DB migration failed. Skipping starting background tasks.");
    }
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl) Configuration(com.emc.storageos.coordinator.common.Configuration) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) IOException(java.io.IOException) CassandraDaemon(org.apache.cassandra.service.CassandraDaemon)

Example 2 with CoordinatorClientImpl

use of com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl 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 3 with CoordinatorClientImpl

use of com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl in project coprhd-controller by CoprHD.

the class CoordinatorClientInetAddressMapTest method connectClient.

/**
 * Connects to test coordinator
 *
 * @return connected client
 * @throws Exception
 */
protected static CoordinatorClient connectClient() throws Exception {
    CoordinatorClientImpl client = new CoordinatorClientImpl();
    client.setZkConnection(createConnection(10 * 1000));
    return client;
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl)

Example 4 with CoordinatorClientImpl

use of com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl in project coprhd-controller by CoprHD.

the class CoordinatorTestBase method connectClient.

/**
 * Connects to test coordinator
 *
 * @return connected client
 * @throws Exception
 */
protected static CoordinatorClient connectClient() throws Exception {
    CoordinatorClientImpl client = new CoordinatorClientImpl();
    client.setZkConnection(createConnection(10 * 1000));
    client.setInetAddessLookupMap(createLocalInetAddressLookupMap());
    client.setVdcShortId("vdc1");
    client.start();
    return client;
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl)

Example 5 with CoordinatorClientImpl

use of com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl in project coprhd-controller by CoprHD.

the class CoordinatorTestBase method connectClient.

protected static CoordinatorClient connectClient(List<URI> server) throws Exception {
    CoordinatorClientImpl client = new CoordinatorClientImpl();
    ZkConnection conn = new ZkConnection();
    conn.setServer(server);
    conn.setTimeoutMs(10 * 1000);
    System.out.println("Connecting with coordinator service...");
    conn.build();
    System.out.println("Connecting with coordinator service.");
    client.setZkConnection(conn);
    client.start();
    return client;
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection)

Aggregations

CoordinatorClientImpl (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl)18 ZkConnection (com.emc.storageos.coordinator.common.impl.ZkConnection)6 URI (java.net.URI)6 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)5 DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)4 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)3 ArrayList (java.util.ArrayList)3 DbVersionInfo (com.emc.storageos.coordinator.client.model.DbVersionInfo)2 Service (com.emc.storageos.coordinator.common.Service)2 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)2 IOException (java.io.IOException)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 StubCoordinatorClientImpl (com.emc.sa.model.mock.StubCoordinatorClientImpl)1 Site (com.emc.storageos.coordinator.client.model.Site)1 Configuration (com.emc.storageos.coordinator.common.Configuration)1 DbClientContext (com.emc.storageos.db.client.impl.DbClientContext)1 DbClientImpl (com.emc.storageos.db.client.impl.DbClientImpl)1 BackupException (com.emc.storageos.management.backup.exceptions.BackupException)1 RetryableBackupException (com.emc.storageos.management.backup.exceptions.RetryableBackupException)1 FileInputStream (java.io.FileInputStream)1