Esempio n. 1
0
  /**
   * Loads global settings for properties that haven't been initialized from command line or config
   * file
   *
   * @param config configuration
   */
  protected void readGlobalSettings(IConfiguration config) {
    if (m_port == 0) {
      m_port = DEFAULT_LISTEN_PORT;
    }
    if (m_threadCount == 0) {
      m_threadCount = DEFAULT_SIMULT_FAST_OPERATIONS;
    }
    if (m_memoryQuota == 0) {
      m_memoryQuota = config.getLongProperty(PROXY_PREFIX + MEMORY_QUOTA, DEFAULT_MEMORY_QUOTA_MB);
    }
    m_memoryQuota *= 1024 * 1024;

    m_memoryMultiplier = config.getDoubleProperty(PROXY_PREFIX + MEMORY_MULT, DEFAULT_MEMORY_MULT);

    m_quotaTimeout = config.getLongProperty(PROXY_PREFIX + QUOTA_TIMEOUT, DEFAULT_QUOTA_TIMEOUT);

    // check max memory setting
    long maxMessageSize = IndexEmailParser.getMaxIndexableDocSizeBytes();
    long cfgMaxBatchSize =
        1024L
            * config.getIntProperty(
                IIndexContentManager.CONFIG_MAX_KILOBYTES_IN_BATCH,
                IndexSubmissionBufferRegulator.DEFAULT_MAX_KB_PER_BATCH);
    setMaxBatchSize(effectiveMemoryCost(maxMessageSize + cfgMaxBatchSize));
    if (m_maxBatchSize > m_memoryQuota) {
      throw new IllegalArgumentException(
          "Invalid memory configuration: max effective batch size ("
              + m_maxBatchSize
              + " bytes) cannot be greater than the memory quota ("
              + m_memoryQuota
              + " bytes)");
    }

    m_proxyStats.configure(config);
  }