use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class DisasterRecoveryServiceTest method testPrecheckForStandbyAttach_PrimarySite_EmptyPrimaryID.
@Test
public void testPrecheckForStandbyAttach_PrimarySite_EmptyPrimaryID() throws Exception {
doReturn(ClusterInfo.ClusterState.STABLE).when(coordinator).getControlNodesState();
Configuration config = new ConfigurationImpl();
doReturn(config).when(coordinator).queryConfiguration(Constants.CONFIG_DR_ACTIVE_KIND, Constants.CONFIG_DR_ACTIVE_ID);
doReturn(primarySite).when(drUtil).getLocalSite();
doReturn(primarySite).when(drUtil).getActiveSite();
drService.precheckForStandbyAdd(standby, mockViPRCoreClient(null));
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class DbServiceImpl method checkConfiguration.
/**
* Checks and registers db configuration information,
* this is one time when cluster is coming up for the first time
*/
private Configuration checkConfiguration() {
String configKind = _coordinator.getDbConfigPath(_serviceInfo.getName());
Configuration config = _coordinator.queryConfiguration(_coordinator.getSiteId(), configKind, _serviceInfo.getId());
if (config == null) {
// check if it is upgraded from previous version to yoda - configuration may be stored in
// zk global area /config. Since SeedProvider still need access that, so we remove the config
// from global in migration callback after migration is done.
config = _coordinator.queryConfiguration(configKind, _serviceInfo.getId());
if (config != null) {
_log.info("Upgrade from pre-yoda release, move dbconfig to new location");
_coordinator.persistServiceConfiguration(_coordinator.getSiteId(), config);
return config;
}
// this is a new node
// 1. register its configuration with coordinator
// 2. assume autobootstrap configuration
// this means that when a node is added, it take 1/2 of biggest token rage and
// copies its data over
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setId(_serviceInfo.getId());
cfg.setKind(configKind);
cfg.setConfig(DbConfigConstants.NODE_ID, _coordinator.getInetAddessLookupMap().getNodeId());
cfg.setConfig(DbConfigConstants.AUTOBOOT, Boolean.TRUE.toString());
// check other existing db nodes
List<Configuration> configs = _coordinator.queryAllConfiguration(_coordinator.getSiteId(), configKind);
if (configs.isEmpty()) {
// we are the first node - turn off autobootstrap
cfg.setConfig(DbConfigConstants.AUTOBOOT, Boolean.FALSE.toString());
}
// persist configuration
_coordinator.persistServiceConfiguration(_coordinator.getSiteId(), cfg);
config = cfg;
}
return config;
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class SchemaUtil method setMigrationStatus.
void setMigrationStatus(MigrationStatus status) {
Configuration config = _coordinator.queryConfiguration(_coordinator.getSiteId(), getDbConfigPath(), Constants.GLOBAL_ID);
_log.debug("setMigrationStatus: target version \"{}\" status {}", _coordinator.getTargetDbSchemaVersion(), status.name());
if (config == null) {
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setKind(getDbConfigPath());
cfg.setId(Constants.GLOBAL_ID);
config = cfg;
}
config.setConfig(Constants.MIGRATION_STATUS, status.name());
_coordinator.persistServiceConfiguration(_coordinator.getSiteId(), config);
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class DbsvcTestBase method startDb.
/**
* Start embedded DB
*/
protected static void startDb(String currentVersion, String targetVersion, String extraModelsPkg, DataObjectScanner scanner, boolean createMockHandler) throws IOException {
sourceVersion = new DbVersionInfo();
sourceVersion.setSchemaVersion(currentVersion);
DbVersionInfo targetVersionInfo = new DbVersionInfo();
targetVersionInfo.setSchemaVersion(targetVersion);
List<String> packages = new ArrayList<String>();
packages.add("com.emc.storageos.db.client.model");
packages.add("com.emc.sa.model");
if (extraModelsPkg != null) {
packages.add(extraModelsPkg);
}
String[] pkgsArray = packages.toArray(new String[packages.size()]);
service = new ServiceImpl();
service.setName("dbsvc");
service.setVersion(targetVersion);
service.setEndpoint(URI.create("thrift://localhost:9160"));
service.setId("db-standalone");
StubBeaconImpl beacon = new StubBeaconImpl(service);
if (scanner == null) {
scanner = new DataObjectScanner();
scanner.setPackages(pkgsArray);
scanner.init();
}
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("nodeaddrmap-var.xml");
CoordinatorClientInetAddressMap inetAddressMap = (CoordinatorClientInetAddressMap) ctx.getBean("inetAddessLookupMap");
if (inetAddressMap == null) {
_log.error("CoordinatorClientInetAddressMap is not initialized. Node address lookup will fail.");
}
_coordinator.setInetAddessLookupMap(inetAddressMap);
_coordinator.setDbVersionInfo(sourceVersion);
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setKind(Constants.DB_CONFIG);
cfg.setId(Constants.GLOBAL_ID);
cfg.setConfig(Constants.SCHEMA_VERSION, currentVersion);
_coordinator.persistServiceConfiguration(cfg);
statusChecker = new DbServiceStatusChecker();
statusChecker.setCoordinator(_coordinator);
statusChecker.setClusterNodeCount(1);
statusChecker.setDbVersionInfo(sourceVersion);
statusChecker.setServiceName(service.getName());
SecretKey key = null;
try {
KeyGenerator keyGenerator = null;
keyGenerator = KeyGenerator.getInstance("HmacSHA256");
key = keyGenerator.generateKey();
} catch (NoSuchAlgorithmException e) {
fail("generate key fail");
}
schemaUtil = new MockSchemaUtil();
schemaUtil.setKeyspaceName("Test");
schemaUtil.setClusterName("Test");
schemaUtil.setDataObjectScanner(scanner);
schemaUtil.setService(service);
schemaUtil.setStatusChecker(statusChecker);
schemaUtil.setCoordinator(_coordinator);
schemaUtil.setVdcShortId("datacenter1");
schemaUtil.setDrUtil(new DrUtil(_coordinator));
DbClientContext dbctx = new MockDbClientContext();
dbctx.setClusterName("Test");
dbctx.setKeyspaceName("Test");
schemaUtil.setClientContext(dbctx);
Properties props = new Properties();
props.put(DbClientImpl.DB_STAT_OPTIMIZE_DISK_SPACE, "false");
schemaUtil.setDbCommonInfo(props);
List<String> vdcHosts = new ArrayList();
vdcHosts.add("127.0.0.1");
schemaUtil.setVdcNodeList(vdcHosts);
schemaUtil.setDbCommonInfo(new java.util.Properties());
JmxServerWrapper jmx = new JmxServerWrapper();
if (_startJmx) {
jmx.setEnabled(true);
jmx.setServiceUrl("service:jmx:rmi://localhost:%d/jndi/rmi://%s:%d/jmxrmi");
jmx.setHost("127.0.0.1");
jmx.setPort(7199);
jmx.setExportPort(7200);
} else {
jmx.setEnabled(false);
}
_encryptionProvider.setCoordinator(_coordinator);
_dbClient = getDbClientBase();
_dbClient.setDbVersionInfo(targetVersionInfo);
PasswordUtils passwordUtils = new PasswordUtils();
passwordUtils.setCoordinator(_coordinator);
passwordUtils.setEncryptionProvider(_encryptionProvider);
passwordUtils.setDbClient(_dbClient);
schemaUtil.setPasswordUtils(passwordUtils);
DependencyChecker localDependencyChecker = new DependencyChecker(_dbClient, scanner);
_geoDependencyChecker = new GeoDependencyChecker(_dbClient, _coordinator, localDependencyChecker);
_dbsvc = new TestMockDbServiceImpl();
_dbsvc.setConfig("db-test.yaml");
_dbsvc.setSchemaUtil(schemaUtil);
_dbsvc.setCoordinator(_coordinator);
_dbsvc.setStatusChecker(statusChecker);
_dbsvc.setService(service);
_dbsvc.setJmxServerWrapper(jmx);
_dbsvc.setDbClient(_dbClient);
_dbsvc.setBeacon(beacon);
_dbsvc.setDbDir(dataDir);
_dbsvc.setDisableScheduledDbRepair(true);
_dbsvc.setMigrationHandler(getMigrationHandler(createMockHandler, pkgsArray));
_dbsvc.setDbMgr(new MockDbManager());
_dbsvc.start();
isDbStarted = true;
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class VdcConfigMigration method migrateVdcConfigToZk.
/**
* We store vdc ip addresses in local db(VirtualDataCenter CF) in pre-yoda. Since yoda, we move it
* to zookeeper. We move all vdcs config to zk
*/
private void migrateVdcConfigToZk() {
List<URI> vdcIds = dbClient.queryByType(VirtualDataCenter.class, true);
for (URI vdcId : vdcIds) {
VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, vdcId);
if (vdc.getLocal()) {
continue;
}
// Insert vdc info
ConfigurationImpl vdcConfig = new ConfigurationImpl();
vdcConfig.setKind(Site.CONFIG_KIND);
vdcConfig.setId(vdc.getShortId());
coordinatorClient.persistServiceConfiguration(vdcConfig);
// insert DR active site info to ZK
Site site = new Site();
// TODO - we have no way to know site uuid in remote vdc during upgrade
// no harm for now. We don't care site uuid in remote vdc at all
site.setUuid(UUID.randomUUID().toString());
site.setName("Default Active Site");
site.setVdcShortId(vdc.getShortId());
site.setSiteShortId(Constants.CONFIG_DR_FIRST_SITE_SHORT_ID);
site.setHostIPv4AddressMap(vdc.getHostIPv4AddressesMap());
site.setHostIPv6AddressMap(vdc.getHostIPv6AddressesMap());
site.setState(SiteState.ACTIVE);
site.setCreationTime(System.currentTimeMillis());
site.setVip(vdc.getApiEndpoint());
site.setNodeCount(vdc.getHostCount());
coordinatorClient.persistServiceConfiguration(site.toConfiguration());
// update Site version in ZK
SiteInfo siteInfo = new SiteInfo(System.currentTimeMillis(), SiteInfo.NONE);
coordinatorClient.setTargetInfo(siteInfo);
}
log.info("Migrated vdc config from db to zk");
}
Aggregations