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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations