Search in sources :

Example 1 with PropertiesStorage

use of com.cloud.agent.dao.impl.PropertiesStorage in project cloudstack by apache.

the class AgentShell method init.

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");
    }
    if (null != file) {
        DOMConfigurator.configureAndWatch(file.getAbsolutePath());
        s_logger.info("Agent started");
    } else {
        s_logger.error("Could not start the Agent because the absolut path of the \"log4j-cloud.xml\" file cannot be determined.");
    }
    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>());
    // 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>());
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) PropertiesStorage(com.cloud.agent.dao.impl.PropertiesStorage) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) ConstantTimeBackoff(com.cloud.utils.backoff.impl.ConstantTimeBackoff)

Example 2 with PropertiesStorage

use of com.cloud.agent.dao.impl.PropertiesStorage in project cloudstack by apache.

the class LibvirtComputingResource method configureHostParams.

public boolean configureHostParams(final Map<String, String> params) {
    final File file = PropertiesUtil.findConfigFile("agent.properties");
    if (file == null) {
        s_logger.error("Unable to find the file agent.properties");
        return false;
    }
    // Save configurations in agent.properties
    PropertiesStorage storage = new PropertiesStorage();
    storage.configure("Storage", new HashMap<String, Object>());
    if (params.get("router.aggregation.command.each.timeout") != null) {
        String value = (String) params.get("router.aggregation.command.each.timeout");
        Long longValue = NumbersUtil.parseLong(value, 600);
        storage.persist("router.aggregation.command.each.timeout", String.valueOf(longValue));
    }
    if (params.get(Config.MigrateWait.toString()) != null) {
        String value = (String) params.get(Config.MigrateWait.toString());
        Integer intValue = NumbersUtil.parseInt(value, -1);
        storage.persist("vm.migrate.wait", String.valueOf(intValue));
        _migrateWait = intValue;
    }
    return true;
}
Also used : PropertiesStorage(com.cloud.agent.dao.impl.PropertiesStorage) QemuImgFile(org.apache.cloudstack.utils.qemu.QemuImgFile) File(java.io.File)

Example 3 with PropertiesStorage

use of com.cloud.agent.dao.impl.PropertiesStorage in project CloudStack-archive by CloudStack-extras.

the class AgentShell method init.

private void init(String[] args) throws ConfigurationException {
    final ComponentLocator locator = ComponentLocator.getLocator("agent");
    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);
    parseCommand(args);
    _storage = locator.getManager(StorageComponent.class);
    if (_storage == null) {
        s_logger.info("Defaulting to using properties file for storage");
        _storage = new PropertiesStorage();
        _storage.configure("Storage", new HashMap<String, Object>());
    }
    // command line parameters
    for (Map.Entry<String, Object> cmdLineProp : getCmdLineProperties().entrySet()) {
        _properties.put(cmdLineProp.getKey(), cmdLineProp.getValue());
    }
    final Adapters adapters = locator.getAdapters(BackoffAlgorithm.class);
    final Enumeration en = adapters.enumeration();
    while (en.hasMoreElements()) {
        _backoff = (BackoffAlgorithm) en.nextElement();
        break;
    }
    if (en.hasMoreElements()) {
        s_logger.info("More than one backoff algorithm specified.  Using the first one ");
    }
    if (_backoff == null) {
        s_logger.info("Defaulting to the constant time backoff algorithm");
        _backoff = new ConstantTimeBackoff();
        _backoff.configure("ConstantTimeBackoff", new HashMap<String, Object>());
    }
}
Also used : Enumeration(java.util.Enumeration) Adapters(com.cloud.utils.component.Adapters) StorageComponent(com.cloud.agent.dao.StorageComponent) ComponentLocator(com.cloud.utils.component.ComponentLocator) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) PropertiesStorage(com.cloud.agent.dao.impl.PropertiesStorage) HashMap(java.util.HashMap) Map(java.util.Map) ConstantTimeBackoff(com.cloud.utils.backoff.impl.ConstantTimeBackoff)

Aggregations

PropertiesStorage (com.cloud.agent.dao.impl.PropertiesStorage)3 ConstantTimeBackoff (com.cloud.utils.backoff.impl.ConstantTimeBackoff)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 File (java.io.File)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 StorageComponent (com.cloud.agent.dao.StorageComponent)1 Adapters (com.cloud.utils.component.Adapters)1 ComponentLocator (com.cloud.utils.component.ComponentLocator)1 Enumeration (java.util.Enumeration)1 QemuImgFile (org.apache.cloudstack.utils.qemu.QemuImgFile)1