Search in sources :

Example 11 with CoordinatorClientInetAddressMap

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

the class BackupOps method getMyDownloadingZKPath.

private String getMyDownloadingZKPath() {
    String downloadersPath = getDownloadOwnerPath();
    CoordinatorClientImpl client = (CoordinatorClientImpl) coordinatorClient;
    CoordinatorClientInetAddressMap addrMap = client.getInetAddessLookupMap();
    String myNodeId = addrMap.getNodeId();
    return downloadersPath + "/" + myNodeId;
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)

Example 12 with CoordinatorClientInetAddressMap

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

the class DbServiceImpl method isStaleConfiguration.

private boolean isStaleConfiguration(Configuration config) {
    String delimiter = "-";
    String configId = config.getId();
    // Bypasses item of "global" and folders of "version", just check db configurations.
    if (configId == null || configId.equals(Constants.GLOBAL_ID) || !configId.contains(delimiter)) {
        return false;
    }
    if (_serviceInfo.getId().endsWith(Constants.STANDALONE_ID)) {
        if (!configId.equals(_serviceInfo.getId())) {
            return true;
        }
    } else {
        CoordinatorClientInetAddressMap nodeMap = _coordinator.getInetAddessLookupMap();
        int nodeCount = nodeMap.getControllerNodeIPLookupMap().size();
        String nodeIndex = configId.split(delimiter)[1];
        if (Constants.STANDALONE_ID.equalsIgnoreCase(nodeIndex) || Integer.parseInt(nodeIndex) > nodeCount) {
            return true;
        }
    }
    return false;
}
Also used : CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)

Example 13 with CoordinatorClientInetAddressMap

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

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

the class SeedProviderImpl method getSeeds.

/**
 *  We select seeds based on the following rules -
 *  For DR standby sites, use all nodes in active site as seeds
 *  For DR active site, use local nodes as seeds. The rule to select local seed is
 *    - first boot node(AUTOBOOT = false) uses itself as seed nodes so that it could boot and initialize schema
 *    - subsquent node(AUTOBOOT = true) uses other successfully booted(JOINED = true) nodes as seeds
 */
@Override
public List<InetAddress> getSeeds() {
    try {
        CoordinatorClientInetAddressMap nodeMap = _client.getInetAddessLookupMap();
        List<Configuration> configs = _client.queryAllConfiguration(_client.getSiteId(), Constants.DB_CONFIG);
        List<InetAddress> seeds = new ArrayList<>();
        // If we are upgrading from pre-2.5 releases, dbconfig exists in zk global area
        List<Configuration> leftoverConfig = _client.queryAllConfiguration(Constants.DB_CONFIG);
        configs.addAll(leftoverConfig);
        // Add extra seeds - seeds from remote sites
        for (String seed : extraSeeds) {
            if (StringUtils.isNotEmpty(seed)) {
                seeds.add(InetAddress.getByName(seed));
            }
        }
        for (int i = 0; i < configs.size(); i++) {
            Configuration config = configs.get(i);
            // Bypasses item of "global" and folders of "version", just check db configurations.
            if (config.getId() == null || config.getId().equals(Constants.GLOBAL_ID)) {
                continue;
            }
            String nodeId = config.getConfig(DbConfigConstants.NODE_ID);
            if (!Boolean.parseBoolean(config.getConfig(DbConfigConstants.AUTOBOOT)) || (!config.getId().equals(_id) && Boolean.parseBoolean(config.getConfig(DbConfigConstants.JOINED)))) {
                // all non autobootstrap nodes + other nodes are used as seeds
                InetAddress ip = null;
                if (nodeMap != null) {
                    String ipAddress = nodeMap.getConnectableInternalAddress(nodeId);
                    _logger.debug("ip[" + i + "]: " + ipAddress);
                    ip = InetAddress.getByName(ipAddress);
                } else {
                    ip = InetAddress.getByName(nodeId);
                }
                seeds.add(ip);
                _logger.info("Seed {}", ip);
            }
        }
        _logger.info("Seeds list {}", StringUtils.join(seeds.toArray(), ","));
        return seeds;
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) ArrayList(java.util.ArrayList) InetAddress(java.net.InetAddress)

Example 15 with CoordinatorClientInetAddressMap

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

the class TestCoordinatorService method createInetAddressLookup.

private CoordinatorClientInetAddressMap createInetAddressLookup() throws Exception {
    CoordinatorClientInetAddressMap lookup = new CoordinatorClientInetAddressMap();
    lookup.setNodeId("localhost");
    lookup.setDualInetAddress(DualInetAddress.fromAddress("127.0.0.1"));
    Map<String, DualInetAddress> addressMap = new HashMap<>();
    addressMap.put(lookup.getNodeId(), lookup.getDualInetAddress());
    lookup.setControllerNodeIPLookupMap(addressMap);
    return lookup;
}
Also used : HashMap(java.util.HashMap) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress)

Aggregations

CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)22 DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)13 ZkConnection (com.emc.storageos.coordinator.common.impl.ZkConnection)9 ArrayList (java.util.ArrayList)9 URI (java.net.URI)8 HashMap (java.util.HashMap)7 FileInputStream (java.io.FileInputStream)6 CoordinatorClientImpl (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl)5 Properties (java.util.Properties)5 Before (org.junit.Before)5 DbVersionInfo (com.emc.storageos.coordinator.client.model.DbVersionInfo)4 KeyCertificateAlgorithmValuesHolder (com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder)4 KeyCertificatePairGenerator (com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator)3 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)3 DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)2 Configuration (com.emc.storageos.coordinator.common.Configuration)2 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)2 ServiceImpl (com.emc.storageos.coordinator.common.impl.ServiceImpl)2 DbClientContext (com.emc.storageos.db.client.impl.DbClientContext)2 DbClientImpl (com.emc.storageos.db.client.impl.DbClientImpl)2