List of usage examples for javax.naming ConfigurationException ConfigurationException
public ConfigurationException(String explanation)
From source file:com.cloud.storage.resource.NfsSecondaryStorageResource.java
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { _eth1ip = (String) params.get("eth1ip"); _eth1mask = (String) params.get("eth1mask"); if (_eth1ip != null) { //can only happen inside service vm params.put("private.network.device", "eth1"); } else {//from w w w . j a v a 2s .co m s_logger.warn("Wait, what's going on? eth1ip is null!!"); } String eth2ip = (String) params.get("eth2ip"); if (eth2ip != null) { params.put("public.network.device", "eth2"); } _publicIp = (String) params.get("eth2ip"); _hostname = (String) params.get("name"); _storageIp = (String) params.get("storageip"); if (_storageIp == null) { s_logger.warn("Wait, there is no storageip in /proc/cmdline, something wrong!"); } _storageNetmask = (String) params.get("storagenetmask"); _storageGateway = (String) params.get("storagegateway"); super.configure(name, params); _params = params; String value = (String) params.get("scripts.timeout"); _timeout = NumbersUtil.parseInt(value, 1440) * 1000; _storage = (StorageLayer) params.get(StorageLayer.InstanceConfigKey); if (_storage == null) { value = (String) params.get(StorageLayer.ClassConfigKey); if (value == null) { value = "com.cloud.storage.JavaStorageLayer"; } try { Class<?> clazz = Class.forName(value); _storage = (StorageLayer) clazz.newInstance(); _storage.configure("StorageLayer", params); } catch (ClassNotFoundException e) { throw new ConfigurationException("Unable to find class " + value); } catch (InstantiationException e) { throw new ConfigurationException("Unable to find class " + value); } catch (IllegalAccessException e) { throw new ConfigurationException("Unable to find class " + value); } } _storage.mkdirs(_parent); _configSslScr = Script.findScript(getDefaultScriptsDir(), "config_ssl.sh"); if (_configSslScr != null) { s_logger.info("config_ssl.sh found in " + _configSslScr); } _configAuthScr = Script.findScript(getDefaultScriptsDir(), "config_auth.sh"); if (_configSslScr != null) { s_logger.info("config_auth.sh found in " + _configAuthScr); } _configIpFirewallScr = Script.findScript(getDefaultScriptsDir(), "ipfirewall.sh"); if (_configIpFirewallScr != null) { s_logger.info("_configIpFirewallScr found in " + _configIpFirewallScr); } _role = (String) params.get("role"); if (_role == null) _role = SecondaryStorageVm.Role.templateProcessor.toString(); s_logger.info("Secondary storage runs in role " + _role); _guid = (String) params.get("guid"); if (_guid == null) { throw new ConfigurationException("Unable to find the guid"); } _dc = (String) params.get("zone"); if (_dc == null) { throw new ConfigurationException("Unable to find the zone"); } _pod = (String) params.get("pod"); _instance = (String) params.get("instance"); String inSystemVM = (String) params.get("secondary.storage.vm"); if (inSystemVM == null || "true".equalsIgnoreCase(inSystemVM)) { _inSystemVM = true; _localgw = (String) params.get("localgw"); if (_localgw != null) { // can only happen inside service vm String mgmtHost = (String) params.get("host"); addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, mgmtHost); String internalDns1 = (String) params.get("internaldns1"); if (internalDns1 == null) { s_logger.warn("No DNS entry found during configuration of NfsSecondaryStorage"); } else { addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, internalDns1); } String internalDns2 = (String) params.get("internaldns2"); if (internalDns2 != null) { addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, internalDns2); } } startAdditionalServices(); _params.put("install.numthreads", "50"); _params.put("secondary.storage.vm", "true"); } try { _params.put(StorageLayer.InstanceConfigKey, _storage); _dlMgr = new DownloadManagerImpl(); _dlMgr.configure("DownloadManager", _params); _upldMgr = new UploadManagerImpl(); _upldMgr.configure("UploadManager", params); } catch (ConfigurationException e) { s_logger.warn("Caught problem while configuring DownloadManager", e); return false; } return true; }
From source file:org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.java
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { _eth1ip = (String) params.get("eth1ip"); _eth1mask = (String) params.get("eth1mask"); if (_eth1ip != null) { // can only happen inside service vm params.put("private.network.device", "eth1"); } else {// w ww . j a v a 2 s. co m s_logger.warn("eth1ip parameter has not been configured, assuming that we are not inside a system vm"); } String eth2ip = (String) params.get("eth2ip"); if (eth2ip != null) { params.put("public.network.device", "eth2"); } _publicIp = (String) params.get("eth2ip"); _hostname = (String) params.get("name"); String inSystemVM = (String) params.get("secondary.storage.vm"); if (inSystemVM == null || "true".equalsIgnoreCase(inSystemVM)) { s_logger.debug("conf secondary.storage.vm is true, act as if executing in SSVM"); _inSystemVM = true; } _storageIp = (String) params.get("storageip"); if (_storageIp == null && _inSystemVM) { s_logger.warn("There is no storageip in /proc/cmdline, something wrong!"); } _storageNetmask = (String) params.get("storagenetmask"); _storageGateway = (String) params.get("storagegateway"); super.configure(name, params); _params = params; String value = (String) params.get("scripts.timeout"); _timeout = NumbersUtil.parseInt(value, 1440) * 1000; _storage = (StorageLayer) params.get(StorageLayer.InstanceConfigKey); configureStorageLayerClass(params); if (_inSystemVM) { _storage.mkdirs(_parent); } _configSslScr = Script.findScript(getDefaultScriptsDir(), "config_ssl.sh"); if (_configSslScr != null) { s_logger.info("config_ssl.sh found in " + _configSslScr); } _configAuthScr = Script.findScript(getDefaultScriptsDir(), "config_auth.sh"); if (_configAuthScr != null) { s_logger.info("config_auth.sh found in " + _configAuthScr); } _configIpFirewallScr = Script.findScript(getDefaultScriptsDir(), "ipfirewall.sh"); if (_configIpFirewallScr != null) { s_logger.info("_configIpFirewallScr found in " + _configIpFirewallScr); } createTemplateFromSnapshotXenScript = Script.findScript(getDefaultScriptsDir(), "create_privatetemplate_from_snapshot_xen.sh"); if (createTemplateFromSnapshotXenScript == null) { throw new ConfigurationException( "create_privatetemplate_from_snapshot_xen.sh not found in " + getDefaultScriptsDir()); } _role = (String) params.get("role"); if (_role == null) { _role = SecondaryStorageVm.Role.templateProcessor.toString(); } s_logger.info("Secondary storage runs in role " + _role); _guid = (String) params.get("guid"); if (_guid == null) { throw new ConfigurationException("Unable to find the guid"); } _dc = (String) params.get("zone"); if (_dc == null) { throw new ConfigurationException("Unable to find the zone"); } _pod = (String) params.get("pod"); _instance = (String) params.get("instance"); if (!_inSystemVM) { _parent = (String) params.get("mount.path"); } if (_inSystemVM) { _localgw = (String) params.get("localgw"); if (_localgw != null) { // can only happen inside service vm String mgmtHost = (String) params.get("host"); addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, mgmtHost); String internalDns1 = (String) params.get("internaldns1"); if (internalDns1 == null) { s_logger.warn("No DNS entry found during configuration of NfsSecondaryStorage"); } else { addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, internalDns1); } String internalDns2 = (String) params.get("internaldns2"); if (internalDns2 != null) { addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, internalDns2); } } startAdditionalServices(); _params.put("install.numthreads", "50"); _params.put("secondary.storage.vm", "true"); _nfsVersion = retrieveNfsVersionFromParams(params); } try { _params.put(StorageLayer.InstanceConfigKey, _storage); _dlMgr = new DownloadManagerImpl(); _dlMgr.configure("DownloadManager", _params); _upldMgr = new UploadManagerImpl(); _upldMgr.configure("UploadManager", params); } catch (ConfigurationException e) { s_logger.warn("Caught problem while configuring DownloadManager", e); return false; } return true; }
From source file:org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.java
protected void configureStorageLayerClass(Map<String, Object> params) throws ConfigurationException { String value;/*from www. ja va2s . co m*/ if (_storage == null) { value = (String) params.get(StorageLayer.ClassConfigKey); if (value == null) { value = "com.cloud.storage.JavaStorageLayer"; } try { Class<?> clazz = Class.forName(value); _storage = (StorageLayer) clazz.newInstance(); _storage.configure("StorageLayer", params); } catch (ClassNotFoundException e) { throw new ConfigurationException("Unable to find class " + value); } catch (InstantiationException e) { throw new ConfigurationException("Unable to find class " + value); } catch (IllegalAccessException e) { throw new ConfigurationException("Unable to find class " + value); } } }
From source file:com.cloud.hypervisor.hyperv.resource.HypervDirectConnectResource.java
@Override public final boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException { /* todo: update, make consistent with the xen server equivalent. */ if (params != null) { _guid = (String) params.get("guid"); _zoneId = (String) params.get("zone"); _podId = (String) params.get("pod"); _clusterId = (String) params.get("cluster"); _agentIp = (String) params.get("ipaddress"); // was agentIp _name = name;/*from w ww. jav a2s. c o m*/ _clusterGuid = (String) params.get("cluster.guid"); _username = (String) params.get("url"); _password = (String) params.get("password"); _username = (String) params.get("username"); _configureCalled = true; } _vrResource = new VirtualRoutingResource(this); if (!_vrResource.configure(name, new HashMap<String, Object>())) { throw new ConfigurationException("Unable to configure VirtualRoutingResource"); } return true; }
From source file:com.cloud.hypervisor.xen.resource.CitrixResourceBase.java
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { _name = name;// w ww .j a va 2 s .co m try { _dcId = Long.parseLong((String) params.get("zone")); } catch (NumberFormatException e) { throw new ConfigurationException("Unable to get the zone " + params.get("zone")); } _host.uuid = (String) params.get("guid"); _name = _host.uuid; _host.ip = (String) params.get("ipaddress"); _username = (String) params.get("username"); _password.add((String) params.get("password")); _pod = (String) params.get("pod"); _cluster = (String) params.get("cluster"); _privateNetworkName = (String) params.get("private.network.device"); _publicNetworkName = (String) params.get("public.network.device"); _guestNetworkName = (String) params.get("guest.network.device"); _instance = (String) params.get("instance.name"); _linkLocalPrivateNetworkName = (String) params.get("private.linkLocal.device"); if (_linkLocalPrivateNetworkName == null) { _linkLocalPrivateNetworkName = "cloud_link_local_network"; } _storageNetworkName1 = (String) params.get("storage.network.device1"); _storageNetworkName2 = (String) params.get("storage.network.device2"); _heartbeatInterval = NumbersUtil.parseInt((String) params.get("xen.heartbeat.interval"), 60); String value = (String) params.get("wait"); _wait = NumbersUtil.parseInt(value, 600); value = (String) params.get("migratewait"); _migratewait = NumbersUtil.parseInt(value, 3600); _maxNics = NumbersUtil.parseInt((String) params.get("xen.nics.max"), 7); if (_pod == null) { throw new ConfigurationException("Unable to get the pod"); } if (_host.ip == null) { throw new ConfigurationException("Unable to get the host address"); } if (_username == null) { throw new ConfigurationException("Unable to get the username"); } if (_password == null) { throw new ConfigurationException("Unable to get the password"); } if (_host.uuid == null) { throw new ConfigurationException("Unable to get the uuid"); } CheckXenHostInfo(); storageHandler = getStorageHandler(); return true; }
From source file:com.cloud.hypervisor.vmware.resource.VmwareResource.java
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { try {// w ww . jav a 2 s . c o m _name = name; _url = (String) params.get("url"); _username = (String) params.get("username"); _password = (String) params.get("password"); _dcId = (String) params.get("zone"); _pod = (String) params.get("pod"); _cluster = (String) params.get("cluster"); _guid = (String) params.get("guid"); String[] tokens = _guid.split("@"); _vCenterAddress = tokens[1]; _morHyperHost = new ManagedObjectReference(); String[] hostTokens = tokens[0].split(":"); _morHyperHost.setType(hostTokens[0]); _morHyperHost.setValue(hostTokens[1]); _guestTrafficInfo = (VmwareTrafficLabel) params.get("guestTrafficInfo"); _publicTrafficInfo = (VmwareTrafficLabel) params.get("publicTrafficInfo"); VmwareContext context = getServiceContext(); VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME); if (mgr == null) { throw new ConfigurationException( "Invalid vmwareContext: vmwareMgr stock object is not set or cleared."); } mgr.setupResourceStartupParams(params); CustomFieldsManagerMO cfmMo = new CustomFieldsManagerMO(context, context.getServiceContent().getCustomFieldsManager()); cfmMo.ensureCustomFieldDef("Datastore", CustomFieldConstants.CLOUD_UUID); if (_publicTrafficInfo != null && _publicTrafficInfo.getVirtualSwitchType() != VirtualSwitchType.StandardVirtualSwitch || _guestTrafficInfo != null && _guestTrafficInfo .getVirtualSwitchType() != VirtualSwitchType.StandardVirtualSwitch) { cfmMo.ensureCustomFieldDef("DistributedVirtualPortgroup", CustomFieldConstants.CLOUD_GC_DVP); } cfmMo.ensureCustomFieldDef("Network", CustomFieldConstants.CLOUD_GC); cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_UUID); cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_NIC_MASK); cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_VM_INTERNAL_NAME); cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_WORKER); cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_WORKER_TAG); VmwareHypervisorHost hostMo = this.getHyperHost(context); _hostName = hostMo.getHyperHostName(); if (_guestTrafficInfo.getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch || _publicTrafficInfo .getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch) { _privateNetworkVSwitchName = mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware); _vsmCredentials = mgr.getNexusVSMCredentialsByClusterId(Long.parseLong(_cluster)); } if (_privateNetworkVSwitchName == null) { _privateNetworkVSwitchName = (String) params.get("private.network.vswitch.name"); } String value = (String) params.get("vmware.recycle.hung.wokervm"); if (value != null && value.equalsIgnoreCase("true")) _recycleHungWorker = true; value = (String) params.get("vmware.root.disk.controller"); if (value != null && value.equalsIgnoreCase("scsi")) _rootDiskController = DiskControllerType.scsi; else if (value != null && value.equalsIgnoreCase("ide")) _rootDiskController = DiskControllerType.ide; else _rootDiskController = DiskControllerType.osdefault; Integer intObj = (Integer) params.get("ports.per.dvportgroup"); if (intObj != null) _portsPerDvPortGroup = intObj.intValue(); s_logger.info("VmwareResource network configuration info." + " private traffic over vSwitch: " + _privateNetworkVSwitchName + ", public traffic over " + _publicTrafficInfo.getVirtualSwitchType() + " : " + _publicTrafficInfo.getVirtualSwitchName() + ", guest traffic over " + _guestTrafficInfo.getVirtualSwitchType() + " : " + _guestTrafficInfo.getVirtualSwitchName()); Boolean boolObj = (Boolean) params.get("vmware.create.full.clone"); if (boolObj != null && boolObj.booleanValue()) { _fullCloneFlag = true; } else { _fullCloneFlag = false; } boolObj = (Boolean) params.get("vm.instancename.flag"); if (boolObj != null && boolObj.booleanValue()) { _instanceNameFlag = true; } else { _instanceNameFlag = false; } value = (String) params.get("scripts.timeout"); int timeout = NumbersUtil.parseInt(value, 1440) * 1000; storageNfsVersion = NfsSecondaryStorageResource.retrieveNfsVersionFromParams(params); _storageProcessor = new VmwareStorageProcessor((VmwareHostService) this, _fullCloneFlag, (VmwareStorageMount) mgr, timeout, this, _shutdownWaitMs, null, storageNfsVersion); storageHandler = new VmwareStorageSubsystemCommandHandler(_storageProcessor, storageNfsVersion); _vrResource = new VirtualRoutingResource(this); if (!_vrResource.configure(name, params)) { throw new ConfigurationException("Unable to configure VirtualRoutingResource"); } if (s_logger.isTraceEnabled()) { s_logger.trace("Successfully configured VmwareResource."); } return true; } catch (Exception e) { s_logger.error("Unexpected Exception ", e); throw new ConfigurationException("Failed to configure VmwareResource due to unexpect exception."); } finally { recycleServiceContext(); } }
From source file:com.cloud.hypervisor.xen.resource.CitrixResourceBase.java
private void CheckXenHostInfo() throws ConfigurationException { Connection conn = _connPool.slaveConnect(_host.ip, _username, _password); if (conn == null) { throw new ConfigurationException("Can not create slave connection to " + _host.ip); }/* w w w. j a v a2 s. c o m*/ try { Host.Record hostRec = null; try { Host host = Host.getByUuid(conn, _host.uuid); hostRec = host.getRecord(conn); Pool.Record poolRec = Pool.getAllRecords(conn).values().iterator().next(); _host.pool = poolRec.uuid; } catch (Exception e) { throw new ConfigurationException("Can not get host information from " + _host.ip); } if (!hostRec.address.equals(_host.ip)) { String msg = "Host " + _host.ip + " seems be reinstalled, please remove this host and readd"; s_logger.error(msg); throw new ConfigurationException(msg); } } finally { try { Session.localLogout(conn); } catch (Exception e) { } } }
From source file:org.apache.cloudstack.secondarystorage.SecondaryStorageManagerImpl.java
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { if (s_logger.isInfoEnabled()) { s_logger.info("Start configuring secondary storage vm manager : " + name); }/*from w w w . j av a 2 s . c om*/ Map<String, String> configs = _configDao.getConfiguration("management-server", params); _secStorageVmMtuSize = NumbersUtil.parseInt(configs.get("secstorage.vm.mtu.size"), DEFAULT_SS_VM_MTUSIZE); String useServiceVM = _configDao.getValue("secondary.storage.vm"); boolean _useServiceVM = false; if ("true".equalsIgnoreCase(useServiceVM)) { _useServiceVM = true; } String sslcopy = _configDao.getValue("secstorage.encrypt.copy"); if ("true".equalsIgnoreCase(sslcopy)) { _useSSlCopy = true; } //default to HTTP in case of missing domain String ssvmUrlDomain = _configDao.getValue("secstorage.ssl.cert.domain"); if (_useSSlCopy && (ssvmUrlDomain == null || ssvmUrlDomain.isEmpty())) { s_logger.warn("Empty secondary storage url domain, explicitly disabling SSL"); _useSSlCopy = false; } _allowedInternalSites = _configDao.getValue("secstorage.allowed.internal.sites"); String value = configs.get("secstorage.capacityscan.interval"); _capacityScanInterval = NumbersUtil.parseLong(value, DEFAULT_CAPACITY_SCAN_INTERVAL); _instance = configs.get("instance.name"); if (_instance == null) { _instance = "DEFAULT"; } Map<String, String> agentMgrConfigs = _configDao.getConfiguration("AgentManager", params); value = agentMgrConfigs.get("port"); _mgmtPort = NumbersUtil.parseInt(value, 8250); _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 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 (NumberFormatException ex) { s_logger.debug("The system service offering specified by global config is not id, but uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm"); } } if (_serviceOffering == null) { s_logger.warn("Can't find system service offering specified by global config, uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm"); } } if (_serviceOffering == null || !_serviceOffering.getSystemUse()) { int ramSize = NumbersUtil.parseInt(_configDao.getValue("ssvm.ram.size"), DEFAULT_SS_VM_RAMSIZE); int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("ssvm.cpu.mhz"), DEFAULT_SS_VM_CPUMHZ); List<ServiceOfferingVO> offerings = _offeringDao.createSystemServiceOfferings( "System Offering For Secondary Storage VM", ServiceOffering.ssvmDefaultOffUniqueName, 1, ramSize, cpuFreq, 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) { String msg = "Data integrity problem : System Offering For Secondary Storage VM has been removed?"; s_logger.error(msg); throw new ConfigurationException(msg); } } if (_useServiceVM) { _loadScanner = new SystemVmLoadScanner<Long>(this); _loadScanner.initScan(STARTUP_DELAY, _capacityScanInterval); } _httpProxy = configs.get(Config.SecStorageProxy.key()); if (_httpProxy != null) { boolean valid = true; String errMsg = null; try { 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 (URISyntaxException e) { errMsg = e.toString(); } finally { if (!valid) { s_logger.debug("ssvm http proxy " + _httpProxy + " is invalid: " + errMsg); throw new ConfigurationException("ssvm http proxy " + _httpProxy + "is invalid: " + errMsg); } } } if (s_logger.isInfoEnabled()) { s_logger.info("Secondary storage vm Manager is configured."); } _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this); return true; }
From source file:org.apache.gora.hbase.store.HBaseStore.java
@SuppressWarnings("unchecked") private HBaseMapping readMapping(InputStream mappingStream) throws IOException { HBaseMappingBuilder mappingBuilder = new HBaseMappingBuilder(); try {//from w ww .jav a 2 s .c o m 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); } //we found a matching key and value class definition, //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 file {}. " + "Expected to be in the classpath " + "(ClassLoader#getResource(java.lang.String)).", mappingStream); 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(); }
From source file:uk.ac.ebi.metabolights.repository.dao.filesystem.metabolightsuploader.IsaTabReplacer.java
private static void loadProperties() throws FileNotFoundException, IOException, ConfigurationException { //final String PROPS_FILE = "isatabidreplacer.properties"; final String PROPS_FILE = "idreplacer.properties"; //If properties are loaded if (!props.isEmpty()) { return;// ww w . jav a2 s .co m } logger.info("Loading properties using getClassLoader().getResourceAsStream(" + PROPS_FILE + ")"); //Load the properties from the property file props.load(IsaTabReplacer.class.getClassLoader().getResourceAsStream(PROPS_FILE)); //If property file is empty if (props.size() == 0) { //Dereference props = null; //Throw an exception throw new ConfigurationException("The application.properties file has been found, but it is empty."); } //Initialise idList String ids = props.getProperty(PROP_IDS); pubDateStr = props.getProperty("isatab.publicReleaseDate"); subDateStr = props.getProperty("isatab.studySubDate"); metaboliteProfTypeStr = props.getProperty("isatab.profilingType"); metaboliteProfValueStr = props.getProperty("isatab.profilingValue"); newOntologyType = props.getProperty("isatab.newOntologyType"); newOntologyValue = props.getProperty("isatab.newOntologyValue"); logger.info(PROP_IDS + " property retrieved :" + ids + "," + pubDateStr + "," + subDateStr); //Split it by ; to go through the array idList = ids.split(";"); //Initialize fileWithIds fileWithIds = props.getProperty(PROP_FILE_WITH_IDS); sampleFile = props.getProperty("isatab.sampleFile"); }