process_param.h 3.0 KB
Newer Older
羽飞's avatar
羽飞 已提交
1
/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
羽飞's avatar
羽飞 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
         http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details. */

//
// Created by Longda on 2010
//

#ifndef __COMMON_OS_PROCESS_PARAM_H__
#define __COMMON_OS_PROCESS_PARAM_H__

#include <string>
#include <vector>
namespace common {

class ProcessParam {

24 25 26
public:
  ProcessParam()
  {}
羽飞's avatar
羽飞 已提交
27

28 29
  virtual ~ProcessParam()
  {}
羽飞's avatar
羽飞 已提交
30 31 32

  void init_default(std::string &process_name);

33 34 35 36
  const std::string &get_std_out() const
  {
    return std_out_;
  }
羽飞's avatar
羽飞 已提交
37

38 39 40 41
  void set_std_out(const std::string &std_out)
  {
    ProcessParam::std_out_ = std_out;
  }
羽飞's avatar
羽飞 已提交
42

43 44 45 46
  const std::string &get_std_err() const
  {
    return std_err_;
  }
羽飞's avatar
羽飞 已提交
47

48 49 50 51
  void set_std_err(const std::string &std_err)
  {
    ProcessParam::std_err_ = std_err;
  }
羽飞's avatar
羽飞 已提交
52

53 54 55 56
  const std::string &get_conf() const
  {
    return conf;
  }
羽飞's avatar
羽飞 已提交
57

58 59 60 61
  void set_conf(const std::string &conf)
  {
    ProcessParam::conf = conf;
  }
羽飞's avatar
羽飞 已提交
62

63 64 65 66
  const std::string &get_process_name() const
  {
    return process_name_;
  }
羽飞's avatar
羽飞 已提交
67

68 69
  void set_process_name(const std::string &processName)
  {
羽飞's avatar
羽飞 已提交
70 71 72
    ProcessParam::process_name_ = processName;
  }

73 74 75 76
  bool is_demon() const
  {
    return demon;
  }
羽飞's avatar
羽飞 已提交
77

78 79 80 81
  void set_demon(bool demon)
  {
    ProcessParam::demon = demon;
  }
羽飞's avatar
羽飞 已提交
82

83 84 85 86
  const std::vector<std::string> &get_args() const
  {
    return args;
  }
羽飞's avatar
羽飞 已提交
87

88 89
  void set_args(const std::vector<std::string> &args)
  {
羽飞's avatar
羽飞 已提交
90 91 92
    ProcessParam::args = args;
  }

93 94
  void set_server_port(int port)
  {
羽飞's avatar
羽飞 已提交
95 96 97
    server_port_ = port;
  }

98 99
  int get_server_port() const
  {
羽飞's avatar
羽飞 已提交
100 101 102
    return server_port_;
  }

103 104
  void set_unix_socket_path(const char *unix_socket_path)
  {
羽飞's avatar
羽飞 已提交
105 106
    unix_socket_path_ = unix_socket_path;
  }
107 108 109

  const std::string &get_unix_socket_path() const
  {
羽飞's avatar
羽飞 已提交
110 111 112
    return unix_socket_path_;
  }

羽飞's avatar
羽飞 已提交
113 114 115 116 117 118 119 120 121 122
  void set_protocol(const char *protocol)
  {
    protocol_ = protocol;
  }

  const std::string &get_protocol() const
  {
    return protocol_;
  }

羽飞's avatar
羽飞 已提交
123 124 125 126 127 128 129 130 131 132 133
  void set_trx_kit_name(const char *kit_name)
  {
    if (kit_name) {
      trx_kit_name_ = kit_name;
    }
  }
  const std::string &trx_kit_name() const
  {
    return trx_kit_name_;
  }

134 135 136 137 138 139 140 141
private:
  std::string std_out_;           // The output file
  std::string std_err_;           // The err output file
  std::string conf;               // The configuration file
  std::string process_name_;      // The process name
  bool demon = false;             // whether demon or not
  std::vector<std::string> args;  // arguments
  int server_port_ = -1;          // server port(if valid, will overwrite the port in the config file)
羽飞's avatar
羽飞 已提交
142
  std::string unix_socket_path_;
羽飞's avatar
羽飞 已提交
143
  std::string protocol_;
羽飞's avatar
羽飞 已提交
144
  std::string trx_kit_name_;
羽飞's avatar
羽飞 已提交
145 146
};

147
ProcessParam *&the_process_param();
羽飞's avatar
羽飞 已提交
148

149 150
}  // namespace common
#endif  //__COMMON_OS_PROCESS_PARAM_H__