use of javax.naming.ConfigurationException in project cosmic by MissionCriticalCloud.
the class NiciraNvpResource method configure.
@Override
public boolean configure(final String ignoredName, final Map<String, Object> params) throws ConfigurationException {
name = (String) params.get("name");
if (name == null) {
throw new ConfigurationException("Unable to find name");
}
guid = (String) params.get("guid");
if (guid == null) {
throw new ConfigurationException("Unable to find the guid");
}
zoneId = (String) params.get("zoneId");
if (zoneId == null) {
throw new ConfigurationException("Unable to find zone");
}
final String ips = (String) params.get("ip");
if (ips == null) {
throw new ConfigurationException("Unable to find IPs");
}
final String adminuser = (String) params.get("adminuser");
if (adminuser == null) {
throw new ConfigurationException("Unable to find admin username");
}
final String adminpass = (String) params.get("adminpass");
if (adminpass == null) {
throw new ConfigurationException("Unable to find admin password");
}
niciraNvpUtilities = NiciraNvpUtilities.getInstance();
retryUtility = CommandRetryUtility.getInstance();
retryUtility.setServerResource(this);
try {
for (String ip : ips.split(",")) {
niciraNvpApis.add(createNiciraNvpApi(ip, adminuser, adminpass));
}
} catch (final CosmicRESTException e) {
throw new ConfigurationException("Could not create a Nicira Nvp API client: " + e.getMessage());
}
return true;
}
use of javax.naming.ConfigurationException in project cosmic by MissionCriticalCloud.
the class VirtualNetworkApplianceManagerImpl method configure.
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("RouterMonitor"));
_checkExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("RouterStatusMonitor"));
_networkStatsUpdateExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("NetworkStatsUpdater"));
VirtualMachine.State.getStateMachine().registerListener(this);
final Map<String, String> configs = _configDao.getConfiguration("AgentManager", params);
_routerRamSize = NumbersUtil.parseInt(configs.get("router.ram.size"), DEFAULT_ROUTER_VM_RAMSIZE);
_routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
final String guestOSString = configs.get("network.dhcp.nondefaultnetwork.setgateway.guestos");
if (guestOSString != null) {
final String[] guestOSList = guestOSString.split(",");
for (final String os : guestOSList) {
_guestOSNeedGatewayOnNonDefaultNetwork.add(os);
}
}
String value = configs.get("start.retry");
_retry = NumbersUtil.parseInt(value, 2);
value = configs.get("router.stats.interval");
_routerStatsInterval = NumbersUtil.parseInt(value, 300);
value = configs.get("router.check.interval");
_routerCheckInterval = NumbersUtil.parseInt(value, 30);
value = configs.get("router.check.poolsize");
_rvrStatusUpdatePoolSize = NumbersUtil.parseInt(value, 10);
/*
* We assume that one thread can handle 20 requests in 1 minute in
* normal situation, so here we give the queue size up to 50 minutes.
* It's mostly for buffer, since each time CheckRouterTask running, it
* would add all the redundant networks in the queue immediately
*/
_vrUpdateQueue = new LinkedBlockingQueue<>(_rvrStatusUpdatePoolSize * 1000);
_rvrStatusUpdateExecutor = Executors.newFixedThreadPool(_rvrStatusUpdatePoolSize, new NamedThreadFactory("RedundantRouterStatusMonitor"));
String instance = configs.get("instance.name");
if (instance == null) {
instance = "DEFAULT";
}
NetworkHelperImpl.setVMInstanceName(instance);
final String rpValue = configs.get("network.disable.rpfilter");
if (rpValue != null && rpValue.equalsIgnoreCase("true")) {
_disableRpFilter = true;
}
_dnsBasicZoneUpdates = String.valueOf(_configDao.getValue(Config.DnsBasicZoneUpdates.key()));
s_logger.info("Router configurations: " + "ramsize=" + _routerRamSize);
_agentMgr.registerForHostEvents(new SshKeysDistriMonitor(_agentMgr, _hostDao, _configDao), true, false, false);
final List<ServiceOfferingVO> offerings = _serviceOfferingDao.createSystemServiceOfferings("System Offering For Software Router", ServiceOffering.routerDefaultOffUniqueName, 1, _routerRamSize, null, null, true, null, ProvisioningType.THIN, true, null, true, VirtualMachine.Type.DomainRouter, true);
final List<ServiceOfferingVO> SecondaryOfferings = _serviceOfferingDao.createSystemServiceOfferings("System Offering For Secundary Software Router", ServiceOffering.routerDefaultSecondaryOffUniqueName, 1, _routerRamSize, null, null, true, null, ProvisioningType.THIN, true, null, true, VirtualMachine.Type.DomainRouter, true);
// this can sometimes happen, if DB is manually or programmatically manipulated
if (offerings == null || offerings.size() < 2) {
final String msg = "Data integrity problem : System Offering For Software router VM has been removed?";
s_logger.error(msg);
throw new ConfigurationException(msg);
}
NetworkHelperImpl.setSystemAccount(_accountMgr.getSystemAccount());
final String aggregationRange = configs.get("usage.stats.job.aggregation.range");
_usageAggregationRange = NumbersUtil.parseInt(aggregationRange, 1440);
_usageTimeZone = configs.get("usage.aggregation.timezone");
if (_usageTimeZone == null) {
_usageTimeZone = "GMT";
}
_agentMgr.registerForHostEvents(this, true, false, false);
s_logger.info("DomainRouterManager is configured.");
return true;
}
use of javax.naming.ConfigurationException in project cosmic by MissionCriticalCloud.
the class SecondaryStorageManagerImpl method configure.
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
logger.info("Start configuring secondary storage vm manager : " + name);
final Map<String, String> configs = _configDao.getConfiguration("management-server", params);
_secStorageVmMtuSize = NumbersUtil.parseInt(configs.get("secstorage.vm.mtu.size"), DEFAULT_SS_VM_MTUSIZE);
final String useServiceVM = _configDao.getValue("secondary.storage.vm");
boolean _useServiceVM = false;
if ("true".equalsIgnoreCase(useServiceVM)) {
_useServiceVM = true;
}
final String sslcopy = _configDao.getValue("secstorage.encrypt.copy");
if ("true".equalsIgnoreCase(sslcopy)) {
_useSSlCopy = true;
}
// default to HTTP in case of missing domain
final String ssvmUrlDomain = _configDao.getValue("secstorage.ssl.cert.domain");
if (_useSSlCopy && (ssvmUrlDomain == null || ssvmUrlDomain.isEmpty())) {
logger.warn("Empty secondary storage url domain, explicitly disabling SSL");
_useSSlCopy = false;
}
_allowedInternalSites = _configDao.getValue("secstorage.allowed.internal.sites");
_allowedExternalCidrs = _configDao.getValue("secstorage.allowed.external.cidrs");
String value = configs.get("secstorage.capacityscan.interval");
final long _capacityScanInterval = NumbersUtil.parseLong(value, DEFAULT_CAPACITY_SCAN_INTERVAL);
_instance = configs.get("instance.name");
if (_instance == null) {
_instance = "DEFAULT";
}
final Map<String, String> agentMgrConfigs = _configDao.getConfiguration("AgentManager", params);
value = agentMgrConfigs.get("port");
_mgmtPort = NumbersUtil.parseInt(value, 8250);
final SecondaryStorageListener _listener = new SecondaryStorageListener(this);
_agentMgr.registerForHostEvents(_listener, true, false, true);
_itMgr.registerGuru(VirtualMachine.Type.SecondaryStorageVm, this);
// check if there is a default service offering configured
final String ssvmSrvcOffIdStr = configs.get(Config.SecondaryStorageServiceOffering.key());
if (ssvmSrvcOffIdStr != null) {
_serviceOffering = _offeringDao.findByUuid(ssvmSrvcOffIdStr);
if (_serviceOffering == null) {
try {
_serviceOffering = _offeringDao.findById(Long.parseLong(ssvmSrvcOffIdStr));
} catch (final NumberFormatException e) {
logger.debug("The system service offering specified by global config is not id, but uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm", e);
}
}
if (_serviceOffering == null) {
logger.warn("Can't find system service offering specified by global config, uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm");
}
}
if (_serviceOffering == null || !_serviceOffering.getSystemUse()) {
final int ramSize = NumbersUtil.parseInt(_configDao.getValue("ssvm.ram.size"), DEFAULT_SS_VM_RAMSIZE);
final List<ServiceOfferingVO> offerings = _offeringDao.createSystemServiceOfferings("System Offering For Secondary Storage VM", ServiceOffering.ssvmDefaultOffUniqueName, 1, ramSize, null, null, false, null, Storage.ProvisioningType.THIN, true, null, true, VirtualMachine.Type.SecondaryStorageVm, true);
// this can sometimes happen, if DB is manually or programmatically manipulated
if (offerings == null || offerings.size() < 2) {
final String msg = "Data integrity problem : System Offering For Secondary Storage VM has been removed?";
logger.error(msg);
throw new ConfigurationException(msg);
}
}
if (_useServiceVM) {
_loadScanner = new SystemVmLoadScanner<>(this);
_loadScanner.initScan(STARTUP_DELAY, _capacityScanInterval);
}
String _httpProxy = configs.get(Config.SecStorageProxy.key());
if (_httpProxy != null) {
boolean valid = true;
String errMsg = null;
try {
final URI uri = new URI(_httpProxy);
if (!"http".equalsIgnoreCase(uri.getScheme())) {
errMsg = "Only support http proxy";
valid = false;
} else if (uri.getHost() == null) {
errMsg = "host can not be null";
valid = false;
} else if (uri.getPort() == -1) {
_httpProxy = _httpProxy + ":3128";
}
} catch (final URISyntaxException e) {
errMsg = e.toString();
logger.debug("Caught exception paring ssvm proxy uri.");
} finally {
if (!valid) {
logger.warn("ssvm http proxy " + _httpProxy + " is invalid: " + errMsg);
throw new ConfigurationException("ssvm http proxy " + _httpProxy + "is invalid: " + errMsg);
}
}
}
logger.info("Secondary storage vm Manager is configured.");
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
return true;
}
use of javax.naming.ConfigurationException in project cloudstack by apache.
the class ServerResourceBase method configure.
@Override
public boolean configure(final String name, Map<String, Object> params) throws ConfigurationException {
_name = name;
String publicNic = (String) params.get("public.network.device");
if (publicNic == null) {
publicNic = "xenbr1";
}
String privateNic = (String) params.get("private.network.device");
if (privateNic == null) {
privateNic = "xenbr0";
}
final String storageNic = (String) params.get("storage.network.device");
final String storageNic2 = (String) params.get("storage.network.device.2");
_privateNic = getNetworkInterface(privateNic);
_publicNic = getNetworkInterface(publicNic);
_storageNic = getNetworkInterface(storageNic);
_storageNic2 = getNetworkInterface(storageNic2);
if (_privateNic == null) {
s_logger.warn("Nics are not specified in properties file/db, will try to autodiscover");
Enumeration<NetworkInterface> nics = null;
try {
nics = NetworkInterface.getNetworkInterfaces();
if (nics == null || !nics.hasMoreElements()) {
throw new ConfigurationException("Private NIC is not configured");
}
} catch (final SocketException e) {
throw new ConfigurationException("Private NIC is not configured");
}
while (nics.hasMoreElements()) {
final NetworkInterface nic = nics.nextElement();
final String nicName = nic.getName();
// try {
if (// nic.isUp() &&
!nic.isVirtual() && !nicName.startsWith("vnif") && !nicName.startsWith("vnbr") && !nicName.startsWith("peth") && !nicName.startsWith("vif") && !nicName.startsWith("virbr") && !nicName.contains(":")) {
final String[] info = NetUtils.getNicParams(nicName);
if (info != null && info[0] != null) {
_privateNic = nic;
s_logger.info("Designating private to be nic " + nicName);
break;
}
}
// } catch (final SocketException e) {
// s_logger.warn("Error looking at " + nicName, e);
// }
s_logger.debug("Skipping nic " + nicName);
}
if (_privateNic == null) {
throw new ConfigurationException("Private NIC is not configured");
}
}
String[] infos = NetUtils.getNetworkParams(_privateNic);
if (infos == null) {
s_logger.warn("Incorrect details for private Nic during initialization of ServerResourceBase");
return false;
}
params.put("host.ip", infos[0]);
params.put("host.mac.address", infos[1]);
return true;
}
use of javax.naming.ConfigurationException in project gora by apache.
the class HBaseStore method readMapping.
@SuppressWarnings("unchecked")
public HBaseMapping readMapping(InputStream mappingStream) throws IOException {
HBaseMappingBuilder mappingBuilder = new HBaseMappingBuilder();
try {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(mappingStream);
Element root = doc.getRootElement();
List<Element> tableElements = root.getChildren("table");
for (Element tableElement : tableElements) {
String tableName = tableElement.getAttributeValue("name");
List<Element> fieldElements = tableElement.getChildren("family");
for (Element fieldElement : fieldElements) {
String familyName = fieldElement.getAttributeValue("name");
String compression = fieldElement.getAttributeValue("compression");
String blockCache = fieldElement.getAttributeValue("blockCache");
String blockSize = fieldElement.getAttributeValue("blockSize");
String bloomFilter = fieldElement.getAttributeValue("bloomFilter");
String maxVersions = fieldElement.getAttributeValue("maxVersions");
String timeToLive = fieldElement.getAttributeValue("timeToLive");
String inMemory = fieldElement.getAttributeValue("inMemory");
mappingBuilder.addFamilyProps(tableName, familyName, compression, blockCache, blockSize, bloomFilter, maxVersions, timeToLive, inMemory);
}
}
List<Element> classElements = root.getChildren("class");
boolean keyClassMatches = false;
for (Element classElement : classElements) {
if (classElement.getAttributeValue("keyClass").equals(keyClass.getCanonicalName()) && classElement.getAttributeValue("name").equals(persistentClass.getCanonicalName())) {
LOG.debug("Keyclass and nameclass match.");
keyClassMatches = true;
String tableNameFromMapping = classElement.getAttributeValue("table");
String tableName = getSchemaName(tableNameFromMapping, persistentClass);
// tableNameFromMapping could be null here
if (!tableName.equals(tableNameFromMapping)) {
// TODO this might not be the desired behavior as the user might have actually made a mistake.
LOG.warn("Mismatching schema's names. Mappingfile schema: '{}'. PersistentClass schema's name: '{}'. Assuming they are the same.", tableNameFromMapping, tableName);
if (tableNameFromMapping != null) {
mappingBuilder.renameTable(tableNameFromMapping, tableName);
}
}
mappingBuilder.setTableName(tableName);
List<Element> fields = classElement.getChildren("field");
for (Element field : fields) {
String fieldName = field.getAttributeValue("name");
String family = field.getAttributeValue("family");
String qualifier = field.getAttributeValue("qualifier");
mappingBuilder.addField(fieldName, family, qualifier);
mappingBuilder.addColumnFamily(tableName, family);
}
// do not continue on other class definitions
break;
}
}
if (!keyClassMatches) {
throw new ConfigurationException("Gora-hbase-mapping does not include the name and keyClass in the databean.");
}
} catch (MalformedURLException ex) {
LOG.error("Error while trying to read the mapping. " + "Mapping was not found.");
LOG.error("Actual classpath = {}", Arrays.asList(((URLClassLoader) getClass().getClassLoader()).getURLs()));
throw ex;
} catch (IOException ex) {
LOG.error(ex.getMessage(), ex);
throw ex;
} catch (Exception ex) {
LOG.error(ex.getMessage(), ex);
throw new IOException(ex);
}
return mappingBuilder.build();
}
Aggregations