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