Search in sources :

Example 16 with NamedThreadFactory

use of com.cloud.utils.concurrency.NamedThreadFactory in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImpl method configure.

@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("RouterMonitor"));
    _checkExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("RouterStatusMonitor"));
    _networkStatsUpdateExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("NetworkStatsUpdater"));
    VirtualMachine.State.getStateMachine().registerListener(this);
    final Map<String, String> configs = _configDao.getConfiguration("AgentManager", params);
    _routerRamSize = NumbersUtil.parseInt(configs.get("router.ram.size"), DEFAULT_ROUTER_VM_RAMSIZE);
    _routerCpuMHz = NumbersUtil.parseInt(configs.get("router.cpu.mhz"), DEFAULT_ROUTER_CPU_MHZ);
    _routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
    final String guestOSString = configs.get("network.dhcp.nondefaultnetwork.setgateway.guestos");
    if (guestOSString != null) {
        final String[] guestOSList = guestOSString.split(",");
        for (final String os : guestOSList) {
            _guestOSNeedGatewayOnNonDefaultNetwork.add(os);
        }
    }
    String value = configs.get("router.stats.interval");
    _routerStatsInterval = NumbersUtil.parseInt(value, 300);
    value = configs.get("router.check.interval");
    _routerCheckInterval = NumbersUtil.parseInt(value, 30);
    value = configs.get("router.check.poolsize");
    _rvrStatusUpdatePoolSize = NumbersUtil.parseInt(value, 10);
    /*
         * We assume that one thread can handle 20 requests in 1 minute in
         * normal situation, so here we give the queue size up to 50 minutes.
         * It's mostly for buffer, since each time CheckRouterTask running, it
         * would add all the redundant networks in the queue immediately
         */
    _vrUpdateQueue = new LinkedBlockingQueue<Long>(_rvrStatusUpdatePoolSize * 1000);
    _rvrStatusUpdateExecutor = Executors.newFixedThreadPool(_rvrStatusUpdatePoolSize, new NamedThreadFactory("RedundantRouterStatusMonitor"));
    String instance = configs.get("instance.name");
    if (instance == null) {
        instance = "DEFAULT";
    }
    NetworkHelperImpl.setVMInstanceName(instance);
    final String rpValue = configs.get("network.disable.rpfilter");
    if (rpValue != null && rpValue.equalsIgnoreCase("true")) {
        _disableRpFilter = true;
    }
    _dnsBasicZoneUpdates = String.valueOf(_configDao.getValue(Config.DnsBasicZoneUpdates.key()));
    s_logger.info("Router configurations: " + "ramsize=" + _routerRamSize);
    _agentMgr.registerForHostEvents(new SshKeysDistriMonitor(_agentMgr, _hostDao, _configDao), true, false, false);
    final List<ServiceOfferingVO> offerings = _serviceOfferingDao.createSystemServiceOfferings("System Offering For Software Router", ServiceOffering.routerDefaultOffUniqueName, 1, _routerRamSize, _routerCpuMHz, null, null, true, null, ProvisioningType.THIN, true, null, true, VirtualMachine.Type.DomainRouter, true);
    // this can sometimes happen, if DB is manually or programmatically manipulated
    if (offerings == null || offerings.size() < 2) {
        final String msg = "Data integrity problem : System Offering For Software router VM has been removed?";
        s_logger.error(msg);
        throw new ConfigurationException(msg);
    }
    NetworkHelperImpl.setSystemAccount(_accountMgr.getSystemAccount());
    final String aggregationRange = configs.get("usage.stats.job.aggregation.range");
    _usageAggregationRange = NumbersUtil.parseInt(aggregationRange, 1440);
    _usageTimeZone = configs.get("usage.aggregation.timezone");
    if (_usageTimeZone == null) {
        _usageTimeZone = "GMT";
    }
    _agentMgr.registerForHostEvents(this, true, false, false);
    s_logger.info("DomainRouterManager is configured.");
    return true;
}
Also used : ConfigurationException(javax.naming.ConfigurationException) NamedThreadFactory(com.cloud.utils.concurrency.NamedThreadFactory) SshKeysDistriMonitor(com.cloud.network.SshKeysDistriMonitor) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO)

Aggregations

NamedThreadFactory (com.cloud.utils.concurrency.NamedThreadFactory)16 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)6 VMTemplateVO (com.cloud.storage.VMTemplateVO)4 ExecutorService (java.util.concurrent.ExecutorService)4 Test (org.junit.Test)4 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)3 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)3 ConfigurationException (javax.naming.ConfigurationException)3 PrimaryDataStore (org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore)3 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)3 ArrayList (java.util.ArrayList)2 EndPoint (org.apache.cloudstack.engine.subsystem.api.storage.EndPoint)2 PodVlanMapVO (com.cloud.dc.PodVlanMapVO)1 VlanVO (com.cloud.dc.VlanVO)1 HostVO (com.cloud.host.HostVO)1 Network (com.cloud.network.Network)1 Capability (com.cloud.network.Network.Capability)1 Provider (com.cloud.network.Network.Provider)1 Service (com.cloud.network.Network.Service)1 NetworkStateListener (com.cloud.network.NetworkStateListener)1