public void init(String[] args) throws ConfigurationException { // PropertiesUtil is used both in management server and agent packages, // it searches path under class path and common J2EE containers // For KVM agent, do it specially here File file = new File("/etc/cloudstack/agent/log4j-cloud.xml"); if (!file.exists()) { file = PropertiesUtil.findConfigFile("log4j-cloud.xml"); } DOMConfigurator.configureAndWatch(file.getAbsolutePath()); s_logger.info("Agent started"); final Class<?> c = this.getClass(); _version = c.getPackage().getImplementationVersion(); if (_version == null) { throw new CloudRuntimeException("Unable to find the implementation version of this agent"); } s_logger.info("Implementation Version is " + _version); loadProperties(); parseCommand(args); if (s_logger.isDebugEnabled()) { List<String> properties = Collections.list((Enumeration<String>) _properties.propertyNames()); for (String property : properties) { s_logger.debug("Found property: " + property); } } s_logger.info("Defaulting to using properties file for storage"); _storage = new PropertiesStorage(); _storage.configure("Storage", new HashMap<String, Object>()); // merge with properties from command line to let resource access // command line parameters for (Map.Entry<String, Object> cmdLineProp : getCmdLineProperties().entrySet()) { _properties.put(cmdLineProp.getKey(), cmdLineProp.getValue()); } s_logger.info("Defaulting to the constant time backoff algorithm"); _backoff = new ConstantTimeBackoff(); _backoff.configure("ConstantTimeBackoff", new HashMap<String, Object>()); }
@Override public void setPersistentProperty(String prefix, String name, String value) { if (prefix != null) _storage.persist(prefix + "." + name, value); else _storage.persist(name, value); }
@Override public String getPersistentProperty(String prefix, String name) { if (prefix != null) return _storage.get(prefix + "." + name); return _storage.get(name); }