@Override
  public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {

    Map<String, String> configs = _configDao.getConfiguration("Network", params);
    _numWorkerThreads =
        NumbersUtil.parseInt(
            configs.get(Config.SecurityGroupWorkerThreads.key()), WORKER_THREAD_COUNT);
    _timeBetweenCleanups =
        NumbersUtil.parseInt(
            configs.get(Config.SecurityGroupWorkCleanupInterval.key()), TIME_BETWEEN_CLEANUPS);
    _globalWorkLockTimeout =
        NumbersUtil.parseInt(configs.get(Config.SecurityGroupWorkGlobalLockTimeout.key()), 300);
    /* register state listener, no matter security group is enabled or not */
    VirtualMachine.State.getStateMachine().registerListener(this);

    _answerListener = new SecurityGroupListener(this, _agentMgr, _workDao);
    _agentMgr.registerForHostEvents(_answerListener, true, true, true);

    _serverId = ((ManagementServer) ComponentLocator.getComponent(ManagementServer.Name)).getId();

    s_logger.info(
        "SecurityGroupManager: num worker threads="
            + _numWorkerThreads
            + ", time between cleanups="
            + _timeBetweenCleanups
            + " global lock timeout="
            + _globalWorkLockTimeout);
    createThreadPools();

    return true;
  }
Ejemplo n.º 2
0
  @Override
  public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    _vmCapacityReleaseInterval =
        NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600);
    _storageOverProvisioningFactor =
        NumbersUtil.parseFloat(
            _configDao.getValue(Config.StorageOverprovisioningFactor.key()), 1.0f);

    _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("HostCapacity-Checker"));
    VirtualMachine.State.getStateMachine().registerListener(this);
    _agentManager.registerForHostEvents(
        new StorageCapacityListener(_capacityDao, _storageOverProvisioningFactor),
        true,
        false,
        false);
    _agentManager.registerForHostEvents(
        new ComputeCapacityListener(_capacityDao, this), true, false, false);

    return true;
  }