void BladePacketQueueThread::set_thread_parameter(const int thread_count, IPacketQueueHandler * handler, void * args, int max_queue_length)
{
    set_thread_count(thread_count);
    handler_ = handler;
    args_ = args;
    queue_.Init(max_queue_length);
}
Exemple #2
0
          virtual int initialize()
          {
            set_batch_process(false);
            set_listen_port(MOCK_SERVER_LISTEN_PORT);
            set_dev_name("bond0");
            set_packet_factory(&factory_);
            set_default_queue_size(100);
            set_thread_count(1);
            set_packet_factory(&factory_);
            ObSingleServer::initialize();

            return OB_SUCCESS;
          }
    // reload config
    int ObMergeServer::reload_config()
    {
      int ret = OB_SUCCESS;
      if (OB_SUCCESS == ret)
      {
        ob_set_memory_size_limit(ms_config_.memory_size_limit_percentage
                                 * sysconf(_SC_PHYS_PAGES)
                                 * sysconf(_SC_PAGE_SIZE) / 100);
        log_interval_count_ = ms_config_.log_interval_count;
      }

      if (OB_SUCCESS == ret)
      {
        ret = set_default_queue_size((int32_t)ms_config_.task_queue_size);
        if (OB_SUCCESS == ret)
        {
          ret = set_thread_count((int32_t)ms_config_.task_thread_count);
        }
      }

      if (OB_SUCCESS == ret)
      {
        ret = set_min_left_time(ms_config_.task_left_time);
      }

      if (OB_SUCCESS == ret)
      {
        ret = service_.reload_config();
      }

      if (OB_SUCCESS == ret)
      {
        TBSYS_LOG(INFO, "enlarge frozen_data_cache_size to: %ld",
            static_cast<int64_t>(ms_config_.frozen_data_cache_size));
        frozen_data_cache_.enlarge_total_size(ms_config_.frozen_data_cache_size);

        TBSYS_LOG(INFO, "enlarge bloom_filter_cache_size to: %ld",
            static_cast<int64_t>(ms_config_.bloom_filter_cache_size));
        insert_cache_.enlarge_total_size(ms_config_.bloom_filter_cache_size);
      }

      return ret;
    }
Exemple #4
0
    int ObChunkServer::initialize()
    {
      int ret = OB_SUCCESS;
      // do not handle batch packet.
      // process packet one by one.
      set_batch_process(false);

      // read configure item value from configure file.
      // this step is the very first thing.
      ret = param_.load_from_config();

      // set listen port
      if (OB_SUCCESS == ret) 
      {
        ret = set_listen_port(param_.get_chunk_server_port());
      }

      if (OB_SUCCESS == ret)
      {
        ret = set_dev_name(param_.get_dev_name());
        if (OB_SUCCESS == ret)
        {
          ret = set_self(param_.get_dev_name(), 
              param_.get_chunk_server_port());
        }
      }

      // task queue and work thread count
      if (OB_SUCCESS == ret)
      {
        ret = set_default_queue_size(param_.get_task_queue_size());
      }

      if (OB_SUCCESS == ret)
      {
        ret = set_thread_count(param_.get_task_thread_count());
      }

      if (OB_SUCCESS == ret)
      {
        ret = set_min_left_time(param_.get_task_left_time());
      }

      // set packet factory object.
      if (OB_SUCCESS == ret)
      {
        ret = set_packet_factory(&packet_factory_);
      }

      // initialize client_manager_ for server remote procedure call.
      if (OB_SUCCESS == ret)
      {
        ret = client_manager_.initialize(get_transport(), get_packet_streamer());
      }

      if (OB_SUCCESS == ret)
      {
        ret = rs_rpc_stub_.init( param_.get_root_server(), &client_manager_);
      }

      if (OB_SUCCESS == ret)
      {
        ret = tablet_manager_.init(&param_);
      }

      // server initialize, including start transport, 
      // listen port, accept socket data from client
      if (OB_SUCCESS == ret)
      {
        ret = ObSingleServer::initialize();
      }

      if (OB_SUCCESS == ret)
      {
        ret = service_.initialize(this);
      }

      return ret;
    }
    int ObMergeServer::initialize()
    {
      int ret = OB_SUCCESS;
      // disable batch process mode
      set_batch_process(false);

      if (ret == OB_SUCCESS)
      {
        // set max memory size limit
        ob_set_memory_size_limit(ms_config_.memory_size_limit_percentage
                                 * sysconf(_SC_PHYS_PAGES)
                                 * sysconf(_SC_PAGE_SIZE) / 100);
      }

      if (ret == OB_SUCCESS)
      {
        memset(&server_handler_, 0, sizeof(easy_io_handler_pt));
        server_handler_.encode = ObTbnetCallback::encode;
        server_handler_.decode = ObTbnetCallback::decode;
        server_handler_.process = ObMergeCallback::process;
        //server_handler_.batch_process
        server_handler_.get_packet_id = ObTbnetCallback::get_packet_id;
        server_handler_.on_disconnect = ObTbnetCallback::on_disconnect;
        server_handler_.user_data = this;
      }

      if (ret == OB_SUCCESS)
      {
        ret = set_listen_port((int32_t)ms_config_.port);
      }

      if (ret == OB_SUCCESS)
      {
        ret = set_dev_name(ms_config_.devname);
        if (OB_SUCCESS == ret)
        {
          ret = set_self(ms_config_.devname,
                         (int32_t)ms_config_.port);
        }
      }
      if (ret == OB_SUCCESS)
      {
        set_self_to_thread_queue(self_);
      }
      if (ret == OB_SUCCESS)
      {
        ret = init_root_server();
      }

      if (ret == OB_SUCCESS)
      {
        ret = set_default_queue_size((int32_t)ms_config_.task_queue_size);
      }

      if (ret == OB_SUCCESS)
      {
        ret = set_io_thread_count((int32_t)ms_config_.io_thread_count);
      }

      if (ret == OB_SUCCESS)
      {
        ret = set_thread_count((int32_t)ms_config_.task_thread_count);
      }

      if (ret == OB_SUCCESS)
      {
        log_interval_count_ = ms_config_.log_interval_count;
        ret = set_min_left_time(ms_config_.task_left_time);
      }

      if (ret == OB_SUCCESS)
      {
        ret = frozen_data_cache_.init(ms_config_.frozen_data_cache_size);
      }
      if (ret == OB_SUCCESS)
      {
        ret = insert_cache_.init(ms_config_.bloom_filter_cache_size);
      }
      if (ret == OB_SUCCESS)
      {
        ret = scan_req_pool_.init();
      }
      if (ret == OB_SUCCESS)
      {
        ret = get_req_pool_.init();
      }

      if (ret == OB_SUCCESS)
      {
        ret = task_timer_.init();
      }

      if (OB_SUCCESS == ret)
      {
        ret = client_manager_.initialize(eio_, &server_handler_);
      }
      if (ret == OB_SUCCESS)
      {
        ret = ObSingleServer::initialize();
      }

      if (ret == OB_SUCCESS)
      {
        ret = service_.initialize(this);
      }

      return ret;
    }