Search in sources :

Example 66 with ConfigurationException

use of javax.naming.ConfigurationException in project cosmic by MissionCriticalCloud.

the class AgentManagerImpl method loadResourcesWithoutHypervisor.

private ServerResource loadResourcesWithoutHypervisor(final HostVO host) {
    final String resourceName = host.getResource();
    ServerResource resource = null;
    try {
        final Class<?> clazz = Class.forName(resourceName);
        final Constructor<?> constructor = clazz.getConstructor();
        resource = (ServerResource) constructor.newInstance();
    } catch (final ClassNotFoundException e) {
        s_logger.warn("Unable to find class " + host.getResource(), e);
    } catch (final InstantiationException e) {
        s_logger.warn("Unablet to instantiate class " + host.getResource(), e);
    } catch (final IllegalAccessException e) {
        s_logger.warn("Illegal access " + host.getResource(), e);
    } catch (final SecurityException e) {
        s_logger.warn("Security error on " + host.getResource(), e);
    } catch (final NoSuchMethodException e) {
        s_logger.warn("NoSuchMethodException error on " + host.getResource(), e);
    } catch (final IllegalArgumentException e) {
        s_logger.warn("IllegalArgumentException error on " + host.getResource(), e);
    } catch (final InvocationTargetException e) {
        s_logger.warn("InvocationTargetException error on " + host.getResource(), e);
    }
    if (resource != null) {
        _hostDao.loadDetails(host);
        final HashMap<String, Object> params = new HashMap<>(host.getDetails().size() + 5);
        params.putAll(host.getDetails());
        params.put("guid", host.getGuid());
        params.put("zone", Long.toString(host.getDataCenterId()));
        if (host.getPodId() != null) {
            params.put("pod", Long.toString(host.getPodId()));
        }
        if (host.getClusterId() != null) {
            params.put("cluster", Long.toString(host.getClusterId()));
            String guid = null;
            final ClusterVO cluster = _clusterDao.findById(host.getClusterId());
            if (cluster.getGuid() == null) {
                guid = host.getDetail("pool");
            } else {
                guid = cluster.getGuid();
            }
            if (guid != null && !guid.isEmpty()) {
                params.put("pool", guid);
            }
        }
        params.put("ipaddress", host.getPrivateIpAddress());
        params.put("secondary.storage.vm", "false");
        try {
            resource.configure(host.getName(), params);
        } catch (final ConfigurationException e) {
            s_logger.warn("Unable to configure resource due to " + e.getMessage());
            return null;
        }
        if (!resource.start()) {
            s_logger.warn("Unable to start the resource");
            return null;
        }
    }
    return resource;
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ServerResource(com.cloud.resource.ServerResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConfigurationException(javax.naming.ConfigurationException)

Example 67 with ConfigurationException

use of javax.naming.ConfigurationException in project cosmic by MissionCriticalCloud.

the class AsyncJobManagerImpl method configure.

@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    try {
        final Properties dbProps = DbProperties.getDbProperties();
        final int cloudMaxActive = Integer.parseInt(dbProps.getProperty("db.cloud.maxActive"));
        final int apiPoolSize = cloudMaxActive / 2;
        final int workPoolSize = (cloudMaxActive * 2) / 3;
        s_logger.info("Start AsyncJobManager API executor thread pool in size " + apiPoolSize);
        _apiJobExecutor = Executors.newFixedThreadPool(apiPoolSize, new NamedThreadFactory(AsyncJobManager.API_JOB_POOL_THREAD_PREFIX));
        s_logger.info("Start AsyncJobManager Work executor thread pool in size " + workPoolSize);
        _workerJobExecutor = Executors.newFixedThreadPool(workPoolSize, new NamedThreadFactory(AsyncJobManager.WORK_JOB_POOL_THREAD_PREFIX));
    } catch (final Exception e) {
        throw new ConfigurationException("Unable to load db.properties to configure AsyncJobManagerImpl");
    }
    JoinJobSearch = _joinMapDao.createSearchBuilder(Long.class);
    JoinJobSearch.and(JoinJobSearch.entity().getJoinJobId(), Op.EQ, "joinJobId");
    JoinJobSearch.selectFields(JoinJobSearch.entity().getJobId());
    JoinJobSearch.done();
    JoinJobTimeSearch = _joinMapDao.createSearchBuilder(Long.class);
    JoinJobTimeSearch.and(JoinJobTimeSearch.entity().getNextWakeupTime(), Op.LT, "beginTime");
    JoinJobTimeSearch.and(JoinJobTimeSearch.entity().getExpiration(), Op.GT, "endTime");
    JoinJobTimeSearch.selectFields(JoinJobTimeSearch.entity().getJobId()).done();
    JobIdsSearch = _jobDao.createSearchBuilder();
    JobIdsSearch.and(JobIdsSearch.entity().getId(), Op.IN, "ids").done();
    QueueJobIdsSearch = _queueItemDao.createSearchBuilder();
    QueueJobIdsSearch.and(QueueJobIdsSearch.entity().getContentId(), Op.IN, "contentIds").done();
    JoinJobIdsSearch = _joinMapDao.createSearchBuilder(Long.class);
    JoinJobIdsSearch.selectFields(JoinJobIdsSearch.entity().getJobId());
    JoinJobIdsSearch.and(JoinJobIdsSearch.entity().getJoinJobId(), Op.EQ, "joinJobId");
    JoinJobIdsSearch.and(JoinJobIdsSearch.entity().getJobId(), Op.NIN, "jobIds");
    JoinJobIdsSearch.done();
    ContentIdsSearch = _queueItemDao.createSearchBuilder(Long.class);
    ContentIdsSearch.selectFields(ContentIdsSearch.entity().getContentId()).done();
    AsyncJobExecutionContext.init(this, _joinMapDao);
    OutcomeImpl.init(this);
    return true;
}
Also used : ConfigurationException(javax.naming.ConfigurationException) NamedThreadFactory(com.cloud.utils.concurrency.NamedThreadFactory) Properties(java.util.Properties) DbProperties(com.cloud.utils.db.DbProperties) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 68 with ConfigurationException

use of javax.naming.ConfigurationException in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResource method getVifDriverClass.

protected VifDriver getVifDriverClass(final String vifDriverClassName, final Map<String, Object> params) throws ConfigurationException {
    final VifDriver vifDriver;
    try {
        final Class<?> clazz = Class.forName(vifDriverClassName);
        vifDriver = (VifDriver) clazz.newInstance();
        vifDriver.configure(params);
    } catch (final ClassNotFoundException e) {
        throw new ConfigurationException("Unable to find class for libvirt.vif.driver " + e);
    } catch (final InstantiationException e) {
        throw new ConfigurationException("Unable to instantiate class for libvirt.vif.driver " + e);
    } catch (final IllegalAccessException e) {
        throw new ConfigurationException("Unable to instantiate class for libvirt.vif.driver " + e);
    }
    return vifDriver;
}
Also used : ConfigurationException(javax.naming.ConfigurationException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 69 with ConfigurationException

use of javax.naming.ConfigurationException in project cosmic by MissionCriticalCloud.

the class RabbitMQEventBus method configure.

@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    try {
        if (amqpHost == null || amqpHost.isEmpty()) {
            throw new ConfigurationException("Unable to get the AMQP server details");
        }
        if (username == null || username.isEmpty()) {
            throw new ConfigurationException("Unable to get the username details");
        }
        if (password == null || password.isEmpty()) {
            throw new ConfigurationException("Unable to get the password details");
        }
        if (amqpExchangeName == null || amqpExchangeName.isEmpty()) {
            throw new ConfigurationException("Unable to get the _exchange details on the AMQP server");
        }
        if (port == null) {
            throw new ConfigurationException("Unable to get the port details of AMQP server");
        }
        if (useSsl != null && !useSsl.isEmpty()) {
            if (!useSsl.equalsIgnoreCase("true") && !useSsl.equalsIgnoreCase("false")) {
                throw new ConfigurationException("Invalid configuration parameter for 'ssl'.");
            }
        }
        if (retryInterval == null) {
            // default to 10s to try out reconnect
            retryInterval = 10000;
        }
    } catch (final NumberFormatException e) {
        throw new ConfigurationException("Invalid port number/retry interval");
    }
    s_subscribers = new ConcurrentHashMap<>();
    executorService = Executors.newCachedThreadPool();
    disconnectHandler = new DisconnectHandler();
    blockedConnectionHandler = new BlockedConnectionHandler();
    return true;
}
Also used : ConfigurationException(javax.naming.ConfigurationException)

Example 70 with ConfigurationException

use of javax.naming.ConfigurationException in project cosmic by MissionCriticalCloud.

the class KvmStorageProcessor method configure.

public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    storageLayer = new JavaStorageLayer();
    storageLayer.configure("StorageLayer", params);
    String storageScriptsDir = (String) params.get("storage.scripts.dir");
    if (storageScriptsDir == null) {
        storageScriptsDir = getDefaultStorageScriptsDir();
    }
    createTmplPath = Script.findScript(storageScriptsDir, "createtmplt.sh");
    if (createTmplPath == null) {
        throw new ConfigurationException("Unable to find the createtmplt.sh");
    }
    manageSnapshotPath = Script.findScript(storageScriptsDir, "managesnapshot.sh");
    if (manageSnapshotPath == null) {
        throw new ConfigurationException("Unable to find the managesnapshot.sh");
    }
    cmdsTimeout = ((Integer) params.get("cmds.timeout")) * 1000;
    return true;
}
Also used : ConfigurationException(javax.naming.ConfigurationException) JavaStorageLayer(com.cloud.storage.JavaStorageLayer)

Aggregations

ConfigurationException (javax.naming.ConfigurationException)168 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)57 IOException (java.io.IOException)44 HashMap (java.util.HashMap)39 File (java.io.File)23 Map (java.util.Map)21 InternalErrorException (com.cloud.exception.InternalErrorException)19 Properties (java.util.Properties)19 StorageLayer (com.cloud.storage.StorageLayer)18 Processor (com.cloud.storage.template.Processor)17 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)17 Answer (com.cloud.agent.api.Answer)16 ServerResource (com.cloud.resource.ServerResource)16 TemplateLocation (com.cloud.storage.template.TemplateLocation)16 Script (com.cloud.utils.script.Script)16 FormatInfo (com.cloud.storage.template.Processor.FormatInfo)14 FileNotFoundException (java.io.FileNotFoundException)14 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)13 Host (com.cloud.host.Host)11 TransactionStatus (com.cloud.utils.db.TransactionStatus)11