未验证 提交 c0dff150 编写于 作者: O oceanbase-admin 提交者: GitHub

Merge pull request #6 from wgs13579/feature_pieceinfo

add some features、fix bugs、fix coverity problems
......@@ -45,10 +45,10 @@ namespace oceanbase
{
namespace common
{
static const int64_t MAX_CACHE_NUM = 16;
static const int64_t MAX_CACHE_NUM = 16;
static const int64_t MAX_TENANT_NUM_PER_SERVER = 1024;
static const int32_t MAX_CACHE_NAME_LENGTH = 127;
static const double CACHE_SCORE_DECAY_FACTOR = 0.9;
static const int32_t MAX_CACHE_NAME_LENGTH = 127;
static const double CACHE_SCORE_DECAY_FACTOR = 0.9;
class ObIKVCacheKey
{
......
......@@ -21,42 +21,42 @@ namespace common
/**
* Calculate the cpu cost of a basic operator
*/
const int64_t CPU_OPERATOR_COST = 1;
const int64_t CPU_OPERATOR_COST = 1;
const int64_t NO_ROW_FAKE_COST = 100;
const int64_t NO_ROW_FAKE_COST = 100;
///The basic cost of a rpc
const int64_t NET_BASE_COST = 100;
const int64_t NET_BASE_COST = 100;
///The basic cost of rpc sending a row of data
const double NET_PER_ROW_COST = 0.4;
const double NET_PER_ROW_COST = 0.4;
///The cost of updating a row of data. Temporarily written
const int64_t UPDATE_ONE_ROW_COST = 1;
const int64_t UPDATE_ONE_ROW_COST = 1;
///The cost of DELETE a row of data. Temporarily written
const int64_t DELETE_ONE_ROW_COST = 1;
const int64_t DELETE_ONE_ROW_COST = 1;
/**
* The cpu cost of processing a row of data
*/
const int64_t CPU_TUPLE_COST = 1;
const int64_t CPU_TUPLE_COST = 1;
/**
* The default selection rate of equivalent expressions such as ("A = b")
*/
const double DEFAULT_EQ_SEL = 0.005;
const double DEFAULT_EQ_SEL = 0.005;
/**
* The default selection rate for non-equivalent expressions (such as "A <b")
*/
const double DEFAULT_INEQ_SEL = 1.0 / 3.0;
const double DEFAULT_INEQ_SEL = 1.0 / 3.0;
/**
* The default selection rate that can't be guessed: half and half
*/
const double DEFAULT_SEL = 0.5;
const double DEFAULT_SEL = 0.5;
/**
* The default distinct number
*/
const int64_t DEFAULT_DISTINCT = 10;
const int64_t DEFAULT_DISTINCT = 10;
//Oracle give range that exceeds limit a additional selectivity
......@@ -73,118 +73,118 @@ const int64_t DEFAULT_DISTINCT = 10;
* min - r min max a max + r
* */
//We can control the decreasing range r by changine DEFAULT_RANGE_EXCEED_LIMIT_DECAY_RATIO
// r = (max - min) * DEFAULT_RANGE_EXCEED_LIMIT_DECAY_RATIO
// r = (max - min) * DEFAULT_RANGE_EXCEED_LIMIT_DECAY_RATIO
//For scan, assuming even distribution, area A represents probability of row falling in range (min,max), which is 1.0
//if we have range i > a, then its probability is area of y
//if we have range i < a, then its probability is A plus x
//the logic is in ObOptimizerCost::do_calc_range_selectivity
const double DEFAULT_RANGE_EXCEED_LIMIT_DECAY_RATIO = 0.5;
const double DEFAULT_RANGE_EXCEED_LIMIT_DECAY_RATIO = 0.5;
const double DEFAULT_GET_EXIST_RATE = 1.0;
const double DEFAULT_CACHE_HIT_RATE = 0.8;
const double DEFAULT_BLOCK_CACHE_HIT_RATE = DEFAULT_CACHE_HIT_RATE;
const double DEFAULT_ROW_CACHE_HIT_RATE = DEFAULT_CACHE_HIT_RATE;
const double DEFAULT_GET_EXIST_RATE = 1.0;
const double DEFAULT_CACHE_HIT_RATE = 0.8;
const double DEFAULT_BLOCK_CACHE_HIT_RATE = DEFAULT_CACHE_HIT_RATE;
const double DEFAULT_ROW_CACHE_HIT_RATE = DEFAULT_CACHE_HIT_RATE;
const double LN_2 = 0.69314718055994530941723212145818;
const double LN_2 = 0.69314718055994530941723212145818;
#define LOGN(x) (log(x))
#define LOG2(x) (LOGN(static_cast<double>(x)) / LN_2)
//cost params for table scan
//all one-time cost during a scan process
const double SCAN_STARTUP_T = 10.0;
const double SCAN_STARTUP_T = 10.0;
//one-time cost during processing a row
const double SCAN_ROW_CONST_T = 0.186;
const double SCAN_ROW_CONST_T = 0.186;
//cost related to processing one obj
const double SCAN_ROW_ONE_COLUMN_T = 0.018;
const double SCAN_ROW_ONE_COLUMN_T = 0.018;
//cost related to processing a micro block
const double SCAN_MICRO_CONST_T = 6.95;
const double SCAN_MICRO_CONST_T = 6.95;
//additional cost related to processing a micro block if micro block cache miss
const double SCAN_MICRO_BLOCK_CACHE_MISS_T = 20.58;
const double SCAN_MICRO_BLOCK_CACHE_MISS_T = 20.58;
//cost related to processing a macro block
const double SCAN_MACRO_CONST_T = 14.0;
const double SCAN_MACRO_CONST_T = 14.0;
const double SCAN_OPEN_CACHE_HIT_PER_MICRO_T = 1.0;
const double SCAN_OPEN_CACHE_MISS_PER_MICRO_T = 8.0;
const double SCAN_OPEN_CACHE_HIT_PER_MICRO_T = 1.0;
const double SCAN_OPEN_CACHE_MISS_PER_MICRO_T = 8.0;
//cost params for table get
const double GET_STARTUP_T = 10.0;
const double GET_ROW_NOT_EXIST_T = 1.0;
const double GET_ROW_CONST_T = 7.67;
const double GET_ROW_ONE_COLUMN_T = 0.037;
const double GET_ROW_CACHE_HIT_T = 1.85;
const double GET_ROW_CACHE_MISS_T = 9.56;
const double GET_BLOCK_CACHE_MISS_T = 15.3;
const double GET_STARTUP_T = 10.0;
const double GET_ROW_NOT_EXIST_T = 1.0;
const double GET_ROW_CONST_T = 7.67;
const double GET_ROW_ONE_COLUMN_T = 0.037;
const double GET_ROW_CACHE_HIT_T = 1.85;
const double GET_ROW_CACHE_MISS_T = 9.56;
const double GET_BLOCK_CACHE_MISS_T = 15.3;
const double GET_OPEN_ROW_CONST_T = 5.36;
const double GET_OPEN_BF_NOT_EXIST_T = 1.0;
const double GET_OPEN_ROW_CACHE_HIT_T = 3.80;
const double GET_OPEN_ROW_CACHE_MISS_T = 4.73;
const double GET_OPEN_BLOCK_CACHE_HIT_T = 0.067;
const double GET_OPEN_BLOCK_CACHE_MISS_T = 7.76;
const double GET_OPEN_ROW_CONST_T = 5.36;
const double GET_OPEN_BF_NOT_EXIST_T = 1.0;
const double GET_OPEN_ROW_CACHE_HIT_T = 3.80;
const double GET_OPEN_ROW_CACHE_MISS_T = 4.73;
const double GET_OPEN_BLOCK_CACHE_HIT_T = 0.067;
const double GET_OPEN_BLOCK_CACHE_MISS_T = 7.76;
const double DEFAULT_IO_RTT_T = 2000;
const double DEFAULT_IO_RTT_T = 2000;
const int64_t MICRO_PER_MACRO_16K_2M = 115;
const int64_t MICRO_PER_MACRO_16K_2M = 115;
//default sizes and counts when stat is not available
const int64_t DEFAULT_ROW_SIZE = 100;
const int64_t DEFAULT_MICRO_BLOCK_SIZE = 16L * 1024;
const int64_t DEFAULT_MACRO_BLOCK_SIZE = 2L * 1024 * 1024;
const int64_t DEFAULT_ROW_SIZE = 100;
const int64_t DEFAULT_MICRO_BLOCK_SIZE = 16L * 1024;
const int64_t DEFAULT_MACRO_BLOCK_SIZE = 2L * 1024 * 1024;
//if stat is not available, consider relatively small table
//note that default micro block size is 16KB, 128 micros per macro
const int64_t DEFAULT_MACRO_COUNT = 10;
const int64_t DEFAULT_MACRO_COUNT = 10;
const int64_t DEFAULT_MICRO_COUNT = DEFAULT_MACRO_COUNT * MICRO_PER_MACRO_16K_2M;
const int64_t DEFAULT_MICRO_COUNT = DEFAULT_MACRO_COUNT * MICRO_PER_MACRO_16K_2M;
const int64_t OB_EST_DEFAULT_ROW_COUNT = 1000;
const int64_t OB_EST_DEFAULT_ROW_COUNT = 1000;
const int64_t EST_DEF_COL_NUM_DISTINCT = 500;
const int64_t EST_DEF_COL_NUM_DISTINCT = 500;
const double EST_DEF_COL_NULL_RATIO = 0.01;
const double EST_DEF_COL_NULL_RATIO = 0.01;
const double EST_DEF_COL_NOT_NULL_RATIO = 1 - EST_DEF_COL_NULL_RATIO;
const double EST_DEF_COL_NOT_NULL_RATIO = 1 - EST_DEF_COL_NULL_RATIO;
const double EST_DEF_VAR_EQ_SEL = EST_DEF_COL_NOT_NULL_RATIO / EST_DEF_COL_NUM_DISTINCT;
const double EST_DEF_VAR_EQ_SEL = EST_DEF_COL_NOT_NULL_RATIO / EST_DEF_COL_NUM_DISTINCT;
const double OB_COLUMN_DISTINCT_RATIO = 2.0 / 3.0;
const double OB_COLUMN_DISTINCT_RATIO = 2.0 / 3.0;
const int64_t OB_EST_DEFAULT_NUM_NULL = static_cast<int64_t>(static_cast<double>(OB_EST_DEFAULT_ROW_COUNT) * EST_DEF_COL_NULL_RATIO);
const int64_t OB_EST_DEFAULT_NUM_NULL = static_cast<int64_t>(static_cast<double>(OB_EST_DEFAULT_ROW_COUNT) * EST_DEF_COL_NULL_RATIO);
const int64_t OB_EST_DEFAULT_DATA_SIZE = OB_EST_DEFAULT_ROW_COUNT * DEFAULT_ROW_SIZE;
const int64_t OB_EST_DEFAULT_DATA_SIZE = OB_EST_DEFAULT_ROW_COUNT * DEFAULT_ROW_SIZE;
const int64_t OB_EST_DEFAULT_MACRO_BLOCKS = OB_EST_DEFAULT_DATA_SIZE / DEFAULT_MACRO_BLOCK_SIZE;
const int64_t OB_EST_DEFAULT_MACRO_BLOCKS = OB_EST_DEFAULT_DATA_SIZE / DEFAULT_MACRO_BLOCK_SIZE;
const int64_t OB_EST_DEFAULT_MICRO_BLOCKS = OB_EST_DEFAULT_DATA_SIZE / DEFAULT_MICRO_BLOCK_SIZE;
const int64_t OB_EST_DEFAULT_MICRO_BLOCKS = OB_EST_DEFAULT_DATA_SIZE / DEFAULT_MICRO_BLOCK_SIZE;
const double OB_DEFAULT_HALF_OPEN_RANGE_SEL = 0.2;
const double OB_DEFAULT_HALF_OPEN_RANGE_SEL = 0.2;
const double OB_DEFAULT_CLOSED_RANGE_SEL = 0.1;
const double OB_DEFAULT_CLOSED_RANGE_SEL = 0.1;
const double ESTIMATE_UNRELIABLE_RATIO = 0.25;
const double ESTIMATE_UNRELIABLE_RATIO = 0.25;
const int64_t OB_DEFAULT_UNEXPECTED_PATH_COST = INT32_MAX;
const int64_t OB_DEFAULT_UNEXPECTED_PATH_COST = INT32_MAX;
//these are cost params for operators
//fixed cost for every sort
const double SORT_ONCE_T = 60;
const double SORT_ONCE_T = 60;
//fixed cost for comparing one column
const double SORT_COMPARE_COL_T = 0.0047;
const double SORT_COMPARE_COL_T = 0.0047;
//fixed cost for every row
const double SORT_ROW_ONCE_T = 1.125;
const double SORT_ROW_ONCE_T = 1.125;
//fixed setup time for calc other conds(filters) in join
const double JOIN_OTHER_COND_INIT_T = 0.15;
const double JOIN_OTHER_COND_INIT_T = 0.15;
//average cost for calc a filter (sampled with filter t1.a + t2.a < K).
//can be inaccurate
const double JOIN_OTHER_COND_SINGLE_T = 0.17;
const double JOIN_OTHER_COND_SINGLE_T = 0.17;
/*
......@@ -193,100 +193,100 @@ const double JOIN_OTHER_COND_SINGLE_T = 0.17;
*/
//fixed setup time for calc equal conds(filters) in join
const double JOIN_EQUAL_COND_INIT_T = 0.054;
const double JOIN_EQUAL_COND_INIT_T = 0.054;
//average cost for calc a equal cond
const double JOIN_EQUAL_COND_SINGLE_T = 0.04;
const double JOIN_EQUAL_COND_SINGLE_T = 0.04;
//cost params for material
const double MATERIAL_ONCE_T = 38;
const double MATERIAL_ROW_READ_ONCE_T = 0.15;
const double MATERIAL_ROW_COL_READ_T = 0.023;
const double MATERIAL_ROW_WRITE_ONCE_T = 0.15;
const double MATERIAL_ROW_COL_WRITE_T = 0.023;
const double MATERIAL_ONCE_T = 38;
const double MATERIAL_ROW_READ_ONCE_T = 0.15;
const double MATERIAL_ROW_COL_READ_T = 0.023;
const double MATERIAL_ROW_WRITE_ONCE_T = 0.15;
const double MATERIAL_ROW_COL_WRITE_T = 0.023;
//cost params for nestloop join
const double NESTLOOP_ONCE_T = 25.465184;
const double NESTLOOP_ONCE_T = 25.465184;
//each left scan cause a right rescan and etc, so more expensive
const double NESTLOOP_ROW_LEFT_T = 0.186347;
const double NESTLOOP_ROW_RIGHT_T = 0.033857;
const double NESTLOOP_ROW_OUT_T = 0.249701;
const double NESTLOOP_ROW_QUAL_FAIL_T = 0.128629;
const double BLK_NESTLOOP_ONCE_START_T = 8.030292;
const double BLK_NESTLOOP_ONCE_RES_T = 0.249750;
const double BLK_NESTLOOP_QUAL_FAIL_T = 0.129177;
const double BLK_NESTLOOP_ROW_LEFT_T = 0.19983;
const double BLK_NESTLOOP_ROW_RIGHT_T = 0.034;
const double BLK_NESTLOOP_CACHE_SCAN_T = 0.264018;
const double BLK_NESTLOOP_CACHE_COUNT_T = 54.348476;
const double NESTLOOP_ROW_LEFT_T = 0.186347;
const double NESTLOOP_ROW_RIGHT_T = 0.033857;
const double NESTLOOP_ROW_OUT_T = 0.249701;
const double NESTLOOP_ROW_QUAL_FAIL_T = 0.128629;
const double BLK_NESTLOOP_ONCE_START_T = 8.030292;
const double BLK_NESTLOOP_ONCE_RES_T = 0.249750;
const double BLK_NESTLOOP_QUAL_FAIL_T = 0.129177;
const double BLK_NESTLOOP_ROW_LEFT_T = 0.19983;
const double BLK_NESTLOOP_ROW_RIGHT_T = 0.034;
const double BLK_NESTLOOP_CACHE_SCAN_T = 0.264018;
const double BLK_NESTLOOP_CACHE_COUNT_T = 54.348476;
//cost params for merge join
const double MERGE_ONCE_T = 0.005255;
const double MERGE_ONCE_T = 0.005255;
//cost for scan left rows
//for simplicity, dont separate used from unused, fitting result is acceptable
const double MERGE_ROW_LEFT_T = 0.005015;
const double MERGE_ROW_LEFT_T = 0.005015;
//cost for right rows.
//unlike NL, this splits into three type
//because right rows can come from "right cache"
const double MERGE_ROW_RIGHT_OP_T = 0.000001;
const double MERGE_ROW_RIGHT_CACHE_T = 0.000001;
const double MERGE_ROW_RIGHT_UNUSED_T = 0.006961; //very small, can ignore?
const double MARGE_ROW_QUAL_FAIL_T = 0.132598;
const double MERGE_ROW_RIGHT_OP_T = 0.000001;
const double MERGE_ROW_RIGHT_CACHE_T = 0.000001;
const double MERGE_ROW_RIGHT_UNUSED_T = 0.006961; //very small, can ignore?
const double MARGE_ROW_QUAL_FAIL_T = 0.132598;
//there is a cache clear operation each match group
const double MERGE_MATCH_GROUP_T = 0.808002;
const double MERGE_ROW_ONCE_RES_T = 0.751524;
const double MERGE_MATCH_GROUP_T = 0.808002;
const double MERGE_ROW_ONCE_RES_T = 0.751524;
//cost params for merge group by
const double MGB_STARTUP_T = 177.0;
const double MGB_STARTUP_T = 177.0;
//for each input row, there are:
// cost for judging whether it starts a new group(Proportional to Ngroup_col)
// cost for calc each aggr column(Proportional to Naggr_col)
const double MGB_INPUT_ONCE_T = 1.5;
const double MGB_INPUT_AGGR_COL_T = 0.073;
const double MGB_INPUT_GROUP_COL_T = 0.011;
const double MGB_INPUT_ONCE_T = 1.5;
const double MGB_INPUT_AGGR_COL_T = 0.073;
const double MGB_INPUT_GROUP_COL_T = 0.011;
//for each output row(i.e. a group), there are
// cost for deep copy first input row twice(Proportional to Ninput_col)
// cost for calc and copy each aggr column(Proportional to Naggr_col)
//Here, we use AVG aggr func as the sampling target.
const double MGB_RES_ONCE_T = 1.68;
const double MGB_RES_AGGR_COL_T = 3.66;
const double MGB_RES_INPUT_COL_T = 0.018;
const double MGB_RES_ONCE_T = 1.68;
const double MGB_RES_AGGR_COL_T = 3.66;
const double MGB_RES_INPUT_COL_T = 0.018;
const int64_t MGB_DEFAULT_GROUP_COL_COUNT = 1;
const int64_t MGB_DEFAULT_INPUT_COL_COUNT = 10;
const int64_t MGB_DEFAULT_GROUP_COL_COUNT = 1;
const int64_t MGB_DEFAULT_INPUT_COL_COUNT = 10;
//cost param for distinct.Refering Merge group by
const double MERGE_DISTINCT_STARTUP_T = 50;
const double MERGE_DISTINCT_ONE_T = 1.5;
const double MERGE_DISTINCT_COL_T = 0.018;
const double MERGE_DISTINCT_STARTUP_T = 50;
const double MERGE_DISTINCT_ONE_T = 1.5;
const double MERGE_DISTINCT_COL_T = 0.018;
//cost params for hash group by
const double HGB_STARTUP_T = 979;
const double HGB_STARTUP_T = 979;
const double HGB_INPUT_ONCE_T = 0.144;
const double HGB_INPUT_ONCE_T = 0.144;
const double HGB_INPUT_AGGR_COL_T = 0.366;
const double HGB_INPUT_AGGR_COL_T = 0.366;
const double HGB_INPUT_GROUP_COL_T = 0.0824;
const double HGB_INPUT_GROUP_COL_T = 0.0824;
const double HGB_RES_ONCE_T = 0.857;
const double HGB_RES_ONCE_T = 0.857;
const double HGB_RES_INPUT_COL_T = 0.043;
const double HGB_RES_INPUT_COL_T = 0.043;
const double HGB_RES_AGGR_COL_T = 2.500;
const double HGB_RES_AGGR_COL_T = 2.500;
//cost param for virtual table
const double VIRTUAL_INDEX_GET_COST = 20; // typical get latency for hash table
const double VIRTUAL_INDEX_GET_COST = 20; // typical get latency for hash table
const double SCALAR_STARTUP_T = 177.0;
const double SCALAR_INPUT_ONCE_T = 0.144;
const double SCALAR_INPUT_AGGR_COL_T = 0.073;
const double SCALAR_STARTUP_T = 177.0;
const double SCALAR_INPUT_ONCE_T = 0.144;
const double SCALAR_INPUT_AGGR_COL_T = 0.073;
const int64_t HALF_OPEN_RANGE_MIN_ROWS = 20;
const int64_t CLOSE_RANGE_MIN_ROWS = 10;
const int64_t HALF_OPEN_RANGE_MIN_ROWS = 20;
const int64_t CLOSE_RANGE_MIN_ROWS = 10;
} //namespace common
} //namespace oceanabse
......
......@@ -107,7 +107,7 @@ static int copy_string(const ObObjCastParams &params,
} else {
int64_t zf = params.zf_info_->max_length_ - len;
if (zf > 0) {
MEMSET(buf, '0', zf);
MEMSET(buf, 0, zf);
MEMCPY(buf + zf, str, len);
len = str_len; // set string length
} else {
......
......@@ -22,7 +22,7 @@ namespace common
// modify ObObjTypeClass and ob_obj_type_class when append new object type.
enum ObObjType
{
ObNullType = 0,
ObNullType = 0,
ObTinyIntType=1, // int8, aka mysql boolean type
ObSmallIntType=2, // int16
......@@ -59,21 +59,21 @@ enum ObObjType
ObExtendType=25, // Min, Max, NOP etc.
ObUnknownType=26, // For question mark(?) in prepared statement, no need to serialize
// @note future new types to be defined here !!!
ObTinyTextType = 27,
ObTextType = 28,
ObMediumTextType = 29,
ObLongTextType = 30,
ObBitType = 31,
ObEnumType = 32,
ObSetType = 33,
ObEnumInnerType = 34,
ObSetInnerType = 35,
ObTinyTextType = 27,
ObTextType = 28,
ObMediumTextType = 29,
ObLongTextType = 30,
ObBitType = 31,
ObEnumType = 32,
ObSetType = 33,
ObEnumInnerType = 34,
ObSetInnerType = 35,
/*
ObTinyBlobType = 31,
ObMediumBlobType = 32,
ObBlobType = 33,
ObLongBlobType = 34,
ObTinyBlobType = 31,
ObMediumBlobType = 32,
ObBlobType = 33,
ObLongBlobType = 34,
ObBitType=35
ObEnumType=36
......@@ -107,7 +107,7 @@ enum ObObjTypeClass
ObStringTC = 10, // varchar, char, varbinary, binary.
ObExtendTC = 11, // extend
ObUnknownTC = 12, // unknown
ObTextTC = 13, //TinyText,MediumText, Text ,LongText
ObTextTC = 13, //TinyText,MediumText, Text ,LongText
ObMaxTC,
// invalid type classes are below, only used as the result of XXXX_type_promotion()
// to indicate that the two obj can't be promoted to the same type.
......
......@@ -18,7 +18,7 @@ namespace oceanbase
namespace common
{
template <typename PageAllocatorT, typename PageArenaT>
const int64_t ObStringBufT<PageAllocatorT, PageArenaT>::DEF_MEM_BLOCK_SIZE = 64 * 1024L;
const int64_t ObStringBufT<PageAllocatorT, PageArenaT>::DEF_MEM_BLOCK_SIZE = 64 * 1024L;
template <typename PageAllocatorT, typename PageArenaT>
const int64_t ObStringBufT<PageAllocatorT, PageArenaT>::MIN_DEF_MEM_BLOCK_SIZE =
......
......@@ -20,7 +20,7 @@ namespace oceanbase
namespace common
{
static const char *zone_type_strs[] = { "ReadWrite", "ReadOnly", "Invalid" };
static const char *zone_type_strs[] = { "ReadWrite", "ReadOnly", "Encryption", "Invalid" };
const char *zone_type_to_str(ObZoneType zone_type)
{
const char *zone_type_str = NULL;
......
......@@ -21,7 +21,8 @@ enum ObZoneType
{
ZONE_TYPE_READWRITE = 0,
ZONE_TYPE_READONLY = 1,
ZONE_TYPE_INVALID = 2,
ZONE_TYPE_ENCRYPTION = 2,
ZONE_TYPE_INVALID = 3,
};
const char *zone_type_to_str(ObZoneType zone_type);
......
......@@ -28,7 +28,7 @@ namespace lib
class AChunk;
static const uint64_t MAXADDR = (1L << 52);
static const uint64_t MAXADDR = (1L << 52);
static const uint64_t CHUNK_BITMAP_SIZE = MAXADDR / MEMCHK_CHUNK_ALIGN;
class AChunkMgr
......
......@@ -30,13 +30,13 @@ namespace lib
// allocates because we can only process with memory address past in
// ranged between 0 and this size.
static const uint64_t MEMCHK_CHUNK_ALIGN_BITS = 20;
static const uint64_t MEMCHK_CHUNK_ALIGN = 4UL << MEMCHK_CHUNK_ALIGN_BITS;
static const uint64_t MEMCHK_CHUNK_ALIGN = 4UL << MEMCHK_CHUNK_ALIGN_BITS;
static const uint32_t AOBJECT_TAIL_SIZE = 8;
static const uint32_t MIN_AOBJECT_SIZE = 16; // 16 bytes, 2 pointers
static const uint32_t AOBJECT_CELL_BYTES = 8; // 8 bytes
static const uint32_t NORMAL_AOBJECT_SIZE = 1 << 13; // 8K
static const uint32_t INTACT_ACHUNK_SIZE = 1 << 21; // 2M
static const uint32_t AOBJECT_TAIL_SIZE = 8;
static const uint32_t MIN_AOBJECT_SIZE = 16; // 16 bytes, 2 pointers
static const uint32_t AOBJECT_CELL_BYTES = 8; // 8 bytes
static const uint32_t NORMAL_AOBJECT_SIZE = 1 << 13; // 8K
static const uint32_t INTACT_ACHUNK_SIZE = 1 << 21; // 2M
static const int64_t ALLOC_ABLOCK_CONCURRENCY = 4;
......@@ -154,26 +154,26 @@ static const uint16_t AOBJECT_MAGIC_CODE = 0XCED1;
static const uint16_t FREE_BIG_AOBJECT_MAGIC_CODE = 0XCED2;
static const uint16_t BIG_AOBJECT_MAGIC_CODE = 0XCED3;
static const uint32_t AOBJECT_HEADER_SIZE = offsetof(AObject, data_);
static const uint32_t AOBJECT_META_SIZE = AOBJECT_HEADER_SIZE + AOBJECT_TAIL_SIZE;
static const uint32_t INTACT_NORMAL_AOBJECT_SIZE = NORMAL_AOBJECT_SIZE + AOBJECT_META_SIZE;
static const uint32_t AOBJECT_HEADER_SIZE = offsetof(AObject, data_);
static const uint32_t AOBJECT_META_SIZE = AOBJECT_HEADER_SIZE + AOBJECT_TAIL_SIZE;
static const uint32_t INTACT_NORMAL_AOBJECT_SIZE = NORMAL_AOBJECT_SIZE + AOBJECT_META_SIZE;
static const uint32_t ABLOCK_HEADER_SIZE = offsetof(ABlock, data_);
static const uint32_t ABLOCK_SIZE = INTACT_NORMAL_AOBJECT_SIZE;
static const uint32_t INTACT_ABLOCK_SIZE = ABLOCK_SIZE + ABLOCK_HEADER_SIZE;
static const uint32_t ABLOCK_HEADER_SIZE = offsetof(ABlock, data_);
static const uint32_t ABLOCK_SIZE = INTACT_NORMAL_AOBJECT_SIZE;
static const uint32_t INTACT_ABLOCK_SIZE = ABLOCK_SIZE + ABLOCK_HEADER_SIZE;
static const uint32_t ACHUNK_HEADER_SIZE = offsetof(AChunk, data_);
static const uint32_t ACHUNK_SIZE = INTACT_ACHUNK_SIZE - ACHUNK_HEADER_SIZE;
static const uint32_t INTACT_BIG_ABLOCK_SIZE = ACHUNK_SIZE;
static const uint32_t BIG_ABLOCK_SIZE = INTACT_BIG_ABLOCK_SIZE - ABLOCK_HEADER_SIZE;
static const uint32_t INTACT_BIG_AOBJECT_SIZE = BIG_ABLOCK_SIZE;
static const uint32_t BIG_AOBJECT_SIZE = INTACT_BIG_AOBJECT_SIZE - AOBJECT_META_SIZE;
static const uint32_t ACHUNK_HEADER_SIZE = offsetof(AChunk, data_);
static const uint32_t ACHUNK_SIZE = INTACT_ACHUNK_SIZE - ACHUNK_HEADER_SIZE;
static const uint32_t INTACT_BIG_ABLOCK_SIZE = ACHUNK_SIZE;
static const uint32_t BIG_ABLOCK_SIZE = INTACT_BIG_ABLOCK_SIZE - ABLOCK_HEADER_SIZE;
static const uint32_t INTACT_BIG_AOBJECT_SIZE = BIG_ABLOCK_SIZE;
static const uint32_t BIG_AOBJECT_SIZE = INTACT_BIG_AOBJECT_SIZE - AOBJECT_META_SIZE;
static const uint32_t CELLS_PER_BLOCK = ABLOCK_SIZE / AOBJECT_CELL_BYTES;
static const uint64_t BLOCKS_PER_CHUNK = ACHUNK_SIZE / INTACT_ABLOCK_SIZE;
static const uint32_t CELLS_PER_BLOCK = ABLOCK_SIZE / AOBJECT_CELL_BYTES;
static const uint64_t BLOCKS_PER_CHUNK = ACHUNK_SIZE / INTACT_ABLOCK_SIZE;
static const uint32_t MAX_ABLOCK_COUNT = ACHUNK_SIZE / ABLOCK_SIZE - 1;
static const uint32_t MAX_ABLOCK_SIZE = MAX_ABLOCK_COUNT * ABLOCK_SIZE;
static const uint32_t MAX_ABLOCK_COUNT = ACHUNK_SIZE / ABLOCK_SIZE - 1;
static const uint32_t MAX_ABLOCK_SIZE = MAX_ABLOCK_COUNT * ABLOCK_SIZE;
inline uint64_t align_up(uint64_t x, uint64_t align)
{
......
......@@ -28,7 +28,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
{
z_stream stream;
int err;
stream.total_out = 0;
stream.next_in = (z_const Bytef *)source;
stream.avail_in = (uInt)sourceLen;
#ifdef MAXSEG_64K
......
......@@ -30,6 +30,7 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen)
z_stream stream;
int err;
stream.total_out = 0;
stream.next_in = (z_const Bytef *)source;
stream.avail_in = (uInt)sourceLen;
/* Check for source > 64K on 16-bit machine: */
......
......@@ -31,7 +31,7 @@ const uint32_t ObEncryptedHelper::sha_const_key[5] =
0x10325476,
0xC3D2E1F0
};
const uint32_t ObEncryptedHelper::K[4] =
const uint32_t ObEncryptedHelper::K[4] =
{
0x5A827999,
0x6ED9EBA1,
......
......@@ -81,9 +81,6 @@ bool CNetUtil::isLocalAddr(uint32_t ip, bool loopSkip)
return false;
}
/**
* 10.0.100.89 => 1499725834
*/
uint32_t CNetUtil::getAddr(const char *ip)
{
if (ip == NULL) return 0;
......
此差异已折叠。
......@@ -417,6 +417,9 @@ public:
instance = NULL;
ATOMIC_BCAS(&once_, 1, 0);
} else {
if (instance_ != NULL) {
delete instance_;
}
instance_ = instance;
(void)ATOMIC_BCAS(&once_, 1, 2);
}
......
......@@ -1534,6 +1534,9 @@ void ObLogger::do_async_flush_to_file(ObLogItem **log_item, const int64_t count)
struct iovec wf_vec[MAX_FD_FILE][GROUP_COMMIT_MAX_ITEM_COUNT];
int wf_iovcnt[MAX_FD_FILE] = {0};
memset(vec, 0, sizeof(vec));
memset(wf_vec, 0, sizeof(wf_vec));
ObLogFDType fd_type = MAX_FD_FILE;
for (int64_t i = 0; i < count; ++i) {
if (OB_ISNULL(log_item[i])) {
......
......@@ -21,7 +21,7 @@ namespace oceanbase
namespace common
{
const char *const TraceLog::LOG_LEVEL_ENV_KEY = "_OB_TRACE_LOG_LEVEL_";
const char *const TraceLog::level_strs_[] = {"ERROR", "USER_ERR", "WARN", "INFO", "TRACE", "DEBUG"};
const char *const TraceLog::level_strs_[] = {"ERROR", "USER_ERR", "WARN", "INFO", "TRACE", "DEBUG"};
volatile int TraceLog::log_level_ = OB_LOG_LEVEL_TRACE;
bool TraceLog::got_env_ = false;
......
......@@ -37,7 +37,7 @@ namespace oceanbase
{
namespace common
{
const char *ObTimeUtility::mday_name_[31] =
const char *ObTimeUtility::mday_name_[31] =
{
"1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th",
"11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th",
......@@ -45,28 +45,28 @@ const char *ObTimeUtility::mday_name_[31] =
"31st"
};
const char *ObTimeUtility::weekday_name_[7] =
const char *ObTimeUtility::weekday_name_[7] =
{
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
};
const char *ObTimeUtility::weekday_abbr_name_[7] =
const char *ObTimeUtility::weekday_abbr_name_[7] =
{
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
const char *ObTimeUtility::month_abbr_name_[12] =
const char *ObTimeUtility::month_abbr_name_[12] =
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
const char *ObTimeUtility::month_name_[12] =
const char *ObTimeUtility::month_name_[12] =
{
"January", "February", "March", "April", "May", "June", "July", "August", "September",
"October", "November", "December"
};
const char *ObTimeUtility::STD_TS_FORMAT_WITH_USEC = "%Y-%m-%d %H:%i:%s.%f";
const char *ObTimeUtility::STD_TS_FORMAT_WITH_USEC = "%Y-%m-%d %H:%i:%s.%f";
const char *ObTimeUtility::STD_TS_FORMAT_WITHOUT_USEC = "%Y-%m-%d %H:%i:%s";
......
......@@ -33,12 +33,12 @@ ObTimeConverter::~ObTimeConverter()
{
}
const int32_t DT_PART_BASE[DATETIME_PART_CNT] = { 100, 12, -1, 24, 60, 60, 1000000};
const int32_t DT_PART_MIN[DATETIME_PART_CNT] = { 0, 1, 1, 0, 0, 0, 0};
const int32_t DT_PART_MAX[DATETIME_PART_CNT] = {9999, 12, 31, 23, 59, 59, 1000000};
const int32_t DT_PART_BASE[DATETIME_PART_CNT] = { 100, 12, -1, 24, 60, 60, 1000000};
const int32_t DT_PART_MIN[DATETIME_PART_CNT] = { 0, 1, 1, 0, 0, 0, 0};
const int32_t DT_PART_MAX[DATETIME_PART_CNT] = {9999, 12, 31, 23, 59, 59, 1000000};
// 1000000 for usecond, because sometimes we round .9999999 to .1000000
static const int8_t DAYS_PER_MON[2][12 + 1] = {
static const int8_t DAYS_PER_MON[2][12 + 1] = {
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
};
......@@ -922,7 +922,7 @@ int ObTimeConverter::int_to_ob_time_without_date(int64_t int64, ObTime &ob_time)
//int ObTimeConverter::uint_to_ob_time_with_date(int64_t int64, ObTime &ob_time)
//int ObTimeConverter::uint_to_ob_time_without_date(int64_t int64, ObTime &ob_time)
static const int32_t DATETIME_PART_LENS_MAX[] = {
static const int32_t DATETIME_PART_LENS_MAX[] = {
INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX, 7};
static const int32_t DATETIME_PART_LENS_YEAR4[] = {4, 2, 2, 2, 2, 2, 7};
static const int32_t DATETIME_PART_LENS_YEAR2[] = {2, 2, 2, 2, 2, 2, 7};
......
......@@ -26,69 +26,69 @@ namespace common
{
namespace serialization
{
const uint64_t OB_MAX_V1B = (__UINT64_C(1) << 7) - 1;
const uint64_t OB_MAX_V2B = (__UINT64_C(1) << 14) - 1;
const uint64_t OB_MAX_V3B = (__UINT64_C(1) << 21) - 1;
const uint64_t OB_MAX_V4B = (__UINT64_C(1) << 28) - 1;
const uint64_t OB_MAX_V5B = (__UINT64_C(1) << 35) - 1;
const uint64_t OB_MAX_V6B = (__UINT64_C(1) << 42) - 1;
const uint64_t OB_MAX_V7B = (__UINT64_C(1) << 49) - 1;
const uint64_t OB_MAX_V8B = (__UINT64_C(1) << 56) - 1;
const uint64_t OB_MAX_V9B = (__UINT64_C(1) << 63) - 1;
const uint64_t OB_MAX_1B = (__UINT64_C(1) << 8) - 1;
const uint64_t OB_MAX_2B = (__UINT64_C(1) << 16) - 1;
const uint64_t OB_MAX_3B = (__UINT64_C(1) << 24) - 1;
const uint64_t OB_MAX_4B = (__UINT64_C(1) << 32) - 1;
const uint64_t OB_MAX_5B = (__UINT64_C(1) << 40) - 1;
const uint64_t OB_MAX_6B = (__UINT64_C(1) << 48) - 1;
const uint64_t OB_MAX_7B = (__UINT64_C(1) << 56) - 1;
const uint64_t OB_MAX_8B = UINT64_MAX;
const uint64_t OB_MAX_INT_1B = (__UINT64_C(23));
const uint64_t OB_MAX_INT_2B = (__UINT64_C(1) << 8) - 1;
const uint64_t OB_MAX_INT_3B = (__UINT64_C(1) << 16) - 1;
const uint64_t OB_MAX_INT_4B = (__UINT64_C(1) << 24) - 1;
const uint64_t OB_MAX_INT_5B = (__UINT64_C(1) << 32) - 1;
const uint64_t OB_MAX_INT_7B = (__UINT64_C(1) << 48) - 1;
const uint64_t OB_MAX_INT_9B = UINT64_MAX;
const int64_t OB_MAX_1B_STR_LEN = (__INT64_C(55));
const int64_t OB_MAX_2B_STR_LEN = (__INT64_C(1) << 8) - 1;
const int64_t OB_MAX_3B_STR_LEN = (__INT64_C(1) << 16) - 1;
const int64_t OB_MAX_4B_STR_LEN = (__INT64_C(1) << 24) - 1;
const int64_t OB_MAX_5B_STR_LEN = (__INT64_C(1) << 32) - 1;
const int8_t OB_INT_TYPE_BIT_POS = 7;
const int8_t OB_INT_OPERATION_BIT_POS = 6;
const int8_t OB_INT_SIGN_BIT_POS = 5;
const int8_t OB_DATETIME_OPERATION_BIT = 3;
const int8_t OB_DATETIME_SIGN_BIT = 2;
const int8_t OB_FLOAT_OPERATION_BIT_POS = 0;
const uint64_t OB_MAX_V1B = (__UINT64_C(1) << 7) - 1;
const uint64_t OB_MAX_V2B = (__UINT64_C(1) << 14) - 1;
const uint64_t OB_MAX_V3B = (__UINT64_C(1) << 21) - 1;
const uint64_t OB_MAX_V4B = (__UINT64_C(1) << 28) - 1;
const uint64_t OB_MAX_V5B = (__UINT64_C(1) << 35) - 1;
const uint64_t OB_MAX_V6B = (__UINT64_C(1) << 42) - 1;
const uint64_t OB_MAX_V7B = (__UINT64_C(1) << 49) - 1;
const uint64_t OB_MAX_V8B = (__UINT64_C(1) << 56) - 1;
const uint64_t OB_MAX_V9B = (__UINT64_C(1) << 63) - 1;
const uint64_t OB_MAX_1B = (__UINT64_C(1) << 8) - 1;
const uint64_t OB_MAX_2B = (__UINT64_C(1) << 16) - 1;
const uint64_t OB_MAX_3B = (__UINT64_C(1) << 24) - 1;
const uint64_t OB_MAX_4B = (__UINT64_C(1) << 32) - 1;
const uint64_t OB_MAX_5B = (__UINT64_C(1) << 40) - 1;
const uint64_t OB_MAX_6B = (__UINT64_C(1) << 48) - 1;
const uint64_t OB_MAX_7B = (__UINT64_C(1) << 56) - 1;
const uint64_t OB_MAX_8B = UINT64_MAX;
const uint64_t OB_MAX_INT_1B = (__UINT64_C(23));
const uint64_t OB_MAX_INT_2B = (__UINT64_C(1) << 8) - 1;
const uint64_t OB_MAX_INT_3B = (__UINT64_C(1) << 16) - 1;
const uint64_t OB_MAX_INT_4B = (__UINT64_C(1) << 24) - 1;
const uint64_t OB_MAX_INT_5B = (__UINT64_C(1) << 32) - 1;
const uint64_t OB_MAX_INT_7B = (__UINT64_C(1) << 48) - 1;
const uint64_t OB_MAX_INT_9B = UINT64_MAX;
const int64_t OB_MAX_1B_STR_LEN = (__INT64_C(55));
const int64_t OB_MAX_2B_STR_LEN = (__INT64_C(1) << 8) - 1;
const int64_t OB_MAX_3B_STR_LEN = (__INT64_C(1) << 16) - 1;
const int64_t OB_MAX_4B_STR_LEN = (__INT64_C(1) << 24) - 1;
const int64_t OB_MAX_5B_STR_LEN = (__INT64_C(1) << 32) - 1;
const int8_t OB_INT_TYPE_BIT_POS = 7;
const int8_t OB_INT_OPERATION_BIT_POS = 6;
const int8_t OB_INT_SIGN_BIT_POS = 5;
const int8_t OB_DATETIME_OPERATION_BIT = 3;
const int8_t OB_DATETIME_SIGN_BIT = 2;
const int8_t OB_FLOAT_OPERATION_BIT_POS = 0;
const int8_t OB_DECIMAL_OPERATION_BIT_POS = 7;
const int8_t OB_INT_VALUE_MASK = 0x1f;
const int8_t OB_VARCHAR_LEN_MASK = 0x3f;
const int8_t OB_DATETIME_LEN_MASK = 0x3;
const int8_t OB_VARCHAR_TYPE = static_cast<int8_t>((0x1 << 7));
const int8_t OB_SEQ_TYPE = static_cast<int8_t>(0xc0);
const int8_t OB_DATETIME_TYPE = static_cast<int8_t>(0xd0);
const int8_t OB_PRECISE_DATETIME_TYPE = static_cast<int8_t>(0xe0);
const int8_t OB_MODIFYTIME_TYPE = static_cast<int8_t>(0xf0);
const int8_t OB_CREATETIME_TYPE = static_cast<int8_t>(0xf4);
const int8_t OB_FLOAT_TYPE = static_cast<int8_t>(0xf8);
const int8_t OB_DOUBLE_TYPE = static_cast<int8_t>(0xfa);
const int8_t OB_NULL_TYPE = static_cast<int8_t>(0xfc);
const int8_t OB_BOOL_TYPE = static_cast<int8_t>(0xfd);
const int8_t OB_EXTEND_TYPE = static_cast<int8_t>(0xfe);
const int8_t OB_DECIMAL_TYPE = static_cast<int8_t>(0xff);
const int8_t OB_NUMBER_TYPE = OB_DECIMAL_TYPE; // 2014number
const int8_t OB_INT_VALUE_MASK = 0x1f;
const int8_t OB_VARCHAR_LEN_MASK = 0x3f;
const int8_t OB_DATETIME_LEN_MASK = 0x3;
const int8_t OB_VARCHAR_TYPE = static_cast<int8_t>((0x1 << 7));
const int8_t OB_SEQ_TYPE = static_cast<int8_t>(0xc0);
const int8_t OB_DATETIME_TYPE = static_cast<int8_t>(0xd0);
const int8_t OB_PRECISE_DATETIME_TYPE = static_cast<int8_t>(0xe0);
const int8_t OB_MODIFYTIME_TYPE = static_cast<int8_t>(0xf0);
const int8_t OB_CREATETIME_TYPE = static_cast<int8_t>(0xf4);
const int8_t OB_FLOAT_TYPE = static_cast<int8_t>(0xf8);
const int8_t OB_DOUBLE_TYPE = static_cast<int8_t>(0xfa);
const int8_t OB_NULL_TYPE = static_cast<int8_t>(0xfc);
const int8_t OB_BOOL_TYPE = static_cast<int8_t>(0xfd);
const int8_t OB_EXTEND_TYPE = static_cast<int8_t>(0xfe);
const int8_t OB_DECIMAL_TYPE = static_cast<int8_t>(0xff);
const int8_t OB_NUMBER_TYPE = OB_DECIMAL_TYPE; // 2014number
inline void set_bit(int8_t &v, int8_t pos)
{
v |= static_cast<int8_t>(1 << pos);
......
......@@ -1230,7 +1230,7 @@ static int read_pid(const char *pidfile, long &pid)
pid = strtol(buf, NULL, 10);
}
if (fd > 0) {
if (fd >= 0) {
close(fd);
}
......
......@@ -30,14 +30,14 @@ namespace obproxy
{
namespace obutils
{
const ObString JSON_CONFIG_VERSION = ObString::make_string("json_config_version");
const ObString JSON_CONFIG_BIN_URL = ObString::make_string("json_config_bin_url");
const ObString JSON_CONFIG_DB = ObString::make_string("json_config_meta_table_db");
const ObString JSON_CONFIG_USER = ObString::make_string("json_config_meta_table_user");
const ObString JSON_CONFIG_PASSWORD = ObString::make_string("json_config_meta_table_password");
const ObString JSON_CONFIG_VERSION = ObString::make_string("json_config_version");
const ObString JSON_CONFIG_BIN_URL = ObString::make_string("json_config_bin_url");
const ObString JSON_CONFIG_DB = ObString::make_string("json_config_meta_table_db");
const ObString JSON_CONFIG_USER = ObString::make_string("json_config_meta_table_user");
const ObString JSON_CONFIG_PASSWORD = ObString::make_string("json_config_meta_table_password");
const ObString JSON_CONFIG_REAL_CLUSTER = ObString::make_string("json_config_real_meta_cluster");
const ObString JSON_CONFIG_CLUSTER = ObString::make_string("json_config_cluster_count");
const ObString JSON_CONFIG_MODIFIED = ObString::make_string("json_config_modified_time");
const ObString JSON_CONFIG_CLUSTER = ObString::make_string("json_config_cluster_count");
const ObString JSON_CONFIG_MODIFIED = ObString::make_string("json_config_modified_time");
//ConfigColumnID
enum
......
......@@ -88,7 +88,7 @@ enum
OB_SSC_MAX_STAT_COLUMN_ID,
};
const ObProxyColumnSchema LIST_COLUMN_ARRAY[OB_SLC_MAX_SLIST_COLUMN_ID] = {
const ObProxyColumnSchema LIST_COLUMN_ARRAY[OB_SLC_MAX_SLIST_COLUMN_ID] = {
ObProxyColumnSchema::make_schema(OB_SLC_ID, "Id", OB_MYSQL_TYPE_LONGLONG),
ObProxyColumnSchema::make_schema(OB_SLC_TENANT, "Tenant", OB_MYSQL_TYPE_VARCHAR),
ObProxyColumnSchema::make_schema(OB_SLC_USER, "User", OB_MYSQL_TYPE_VARCHAR),
......@@ -116,13 +116,13 @@ const ObProxyColumnSchema INTERNAL_LIST_COLUMN_ARRAY[OB_SILC_MAX_SLIST_COLUMN_ID
ObProxyColumnSchema::make_schema(OB_SILC_PID, "pid", OB_MYSQL_TYPE_LONG),
};
const ObProxyColumnSchema ATTRIBUTE_COLUMN_ARRAY[OB_SLC_MAX_SLIST_COLUMN_ID] = {
const ObProxyColumnSchema ATTRIBUTE_COLUMN_ARRAY[OB_SLC_MAX_SLIST_COLUMN_ID] = {
ObProxyColumnSchema::make_schema(OB_SAC_NAME, "attribute_name", OB_MYSQL_TYPE_VARCHAR),
ObProxyColumnSchema::make_schema(OB_SAC_VALUE, "value", OB_MYSQL_TYPE_VARCHAR),
ObProxyColumnSchema::make_schema(OB_SAC_INFO, "info", OB_MYSQL_TYPE_VARCHAR),
};
const ObProxyColumnSchema VARIABLES_COLUMN_ARRAY[OB_SVC_MAX_VARIABLES_COLUMN_ID] = {
const ObProxyColumnSchema VARIABLES_COLUMN_ARRAY[OB_SVC_MAX_VARIABLES_COLUMN_ID] = {
ObProxyColumnSchema::make_schema(OB_SVC_NAME, "variable_name", OB_MYSQL_TYPE_VARCHAR),
ObProxyColumnSchema::make_schema(OB_SVC_VALUE, "value", OB_MYSQL_TYPE_VARCHAR),
ObProxyColumnSchema::make_schema(OB_SVC_INFO, "info", OB_MYSQL_TYPE_VARCHAR),
......@@ -130,7 +130,7 @@ const ObProxyColumnSchema VARIABLES_COLUMN_ARRAY[OB_SVC_MAX_VARIABLES_COLUMN_ID]
ObProxyColumnSchema::make_schema(OB_SVC_FLAG, "sys_variable_flag", OB_MYSQL_TYPE_VARCHAR),
};
const ObProxyColumnSchema STAT_COLUMN_ARRAY[OB_SSC_MAX_STAT_COLUMN_ID] = {
const ObProxyColumnSchema STAT_COLUMN_ARRAY[OB_SSC_MAX_STAT_COLUMN_ID] = {
ObProxyColumnSchema::make_schema(OB_SSC_NAME, "stat_name", OB_MYSQL_TYPE_VARCHAR),
ObProxyColumnSchema::make_schema(OB_SSC_VALUE, "value", OB_MYSQL_TYPE_LONGLONG),
};
......
......@@ -42,122 +42,122 @@ namespace obproxy
namespace dbconfig
{
static const ObString LOCAL_DIR = ObString::make_string(".");
static const ObString PARENT_DIR = ObString::make_string("..");
static const ObString LOCAL_DIR = ObString::make_string(".");
static const ObString PARENT_DIR = ObString::make_string("..");
// ObDbConfigChild
static const char *CONFIG_VERSION = "version";
static const char *CONFIG_VALUES = "variables";
static const char *CONFIG_VERSION = "version";
static const char *CONFIG_VALUES = "variables";
// LogicTenantInfo
static const char *TENANT_NAME = "tenant_name";
static const char *TENANT_DATABASES = "databases";
static const char *TENANT_NAME = "tenant_name";
static const char *TENANT_DATABASES = "databases";
// CR Reference
static const char *REF_KIND = "kind";
static const char *REF_NAMESPACE = "namespace";
static const char *REF_PARENT = "parent";
static const char *REF_VALUE = "reference";
static const char *TESTLOAD_REF_VALUE = "test_load_reference";
static const char *REF_KIND = "kind";
static const char *REF_NAMESPACE = "namespace";
static const char *REF_PARENT = "parent";
static const char *REF_VALUE = "reference";
static const char *TESTLOAD_REF_VALUE = "test_load_reference";
// DatabaseVariables
static const ObString DATABASE_VARS = ObString::make_string(CONFIG_VALUES);
static const ObString REMOTE_ACCESS = ObString::make_string("remoteAccess");
static const ObString SEQUENCE_MIN_VALUE = ObString::make_string("sequenceInitMinValue");
static const ObString SEQUENCE_MAX_VALUE = ObString::make_string("sequenceInitMaxValue");
static const ObString SEQUENCE_STEP = ObString::make_string("sequenceInitStep");
static const ObString DATABASE_VARS = ObString::make_string(CONFIG_VALUES);
static const ObString REMOTE_ACCESS = ObString::make_string("remoteAccess");
static const ObString SEQUENCE_MIN_VALUE = ObString::make_string("sequenceInitMinValue");
static const ObString SEQUENCE_MAX_VALUE = ObString::make_string("sequenceInitMaxValue");
static const ObString SEQUENCE_STEP = ObString::make_string("sequenceInitStep");
static const ObString SEQUENCE_RETRY_COUNT = ObString::make_string("sequenceRetryCount");
static const ObString SEQUENCE_TABLE = ObString::make_string("sequenceTable");
static const ObString SEQUENCE_ENABLE = ObString::make_string("sequenceEnable");
static const ObString SEQUENCE_TNT_ID_COL = ObString::make_string("sequenceTntId");
static const ObString TESTLOAD_TABLE_MAP = ObString::make_string("testLoadTableMap");//testLoadTableMap
static const ObString SEQUENCE_TABLE = ObString::make_string("sequenceTable");
static const ObString SEQUENCE_ENABLE = ObString::make_string("sequenceEnable");
static const ObString SEQUENCE_TNT_ID_COL = ObString::make_string("sequenceTntId");
static const ObString TESTLOAD_TABLE_MAP = ObString::make_string("testLoadTableMap");//testLoadTableMap
// LogicDbInfo
static const char *LOGIC_DB_NAME = "database_name";
static const char *LOGIC_DB_CLUSTER = "cluster_name";
static const char *LOGIC_DB_MODE = "database_mode";
static const char *LOGIC_DB_TYPE = "database_type";
static const char *TESTLOAD_PREFIX = "test_load_prefix";
static const char *LOGIC_DB_NAME = "database_name";
static const char *LOGIC_DB_CLUSTER = "cluster_name";
static const char *LOGIC_DB_MODE = "database_mode";
static const char *LOGIC_DB_TYPE = "database_type";
static const char *TESTLOAD_PREFIX = "test_load_prefix";
// DatabaseAuth
static const char *AUTH_HAS_PRIV = "Y";
static const char *AUTH_NO_PRIV = "N";
static const char *AUTH_USERS = "users";
static const char *AUTH_ALTER_PRIV = "alter_priv";
static const char *AUTH_CREATE_PRIV = "create_priv";
static const char *AUTH_DELETE_PRIV = "delete_priv";
static const char *AUTH_DROP_PRIV = "drop_priv";
static const char *AUTH_INSERT_PRIV = "insert_priv";
static const char *AUTH_UPDATE_PRIV = "update_priv";
static const char *AUTH_SELECT_PRIV = "select_priv";
static const char *AUTH_INDEX_PRIV = "index_priv";
static const char *AUTH_HOST = "host";
static const char *AUTH_HAS_PRIV = "Y";
static const char *AUTH_NO_PRIV = "N";
static const char *AUTH_USERS = "users";
static const char *AUTH_ALTER_PRIV = "alter_priv";
static const char *AUTH_CREATE_PRIV = "create_priv";
static const char *AUTH_DELETE_PRIV = "delete_priv";
static const char *AUTH_DROP_PRIV = "drop_priv";
static const char *AUTH_INSERT_PRIV = "insert_priv";
static const char *AUTH_UPDATE_PRIV = "update_priv";
static const char *AUTH_SELECT_PRIV = "select_priv";
static const char *AUTH_INDEX_PRIV = "index_priv";
static const char *AUTH_HOST = "host";
// ObDataBaseProp
static const char *DB_PROP_NAME = "properties_name";
static const char *DB_PROP_RULE = "properties_rule";
static const char *DB_PROP_TYPE = "propsType";
static const char *TESTLOAD_DBKEY_TYPE = "testLoadDbKeyType";
static const char *MIRROR_DBKEY_TYPE = "mirrorDbKeyType";
static const char *DB_PROP_NAME = "properties_name";
static const char *DB_PROP_RULE = "properties_rule";
static const char *DB_PROP_TYPE = "propsType";
static const char *TESTLOAD_DBKEY_TYPE = "testLoadDbKeyType";
static const char *MIRROR_DBKEY_TYPE = "mirrorDbKeyType";
static const char *DB_PROP_TESTLOAD = "testload";
static const char *DB_PROP_MIRROR = "mirror";
static const char *DB_PROP_SELFADJUST = "selfadjust";
static const char *DB_PROP_WHITELIST = "whitelist";
static const char *DB_PROP_TESTLOAD = "testload";
static const char *DB_PROP_MIRROR = "mirror";
static const char *DB_PROP_SELFADJUST = "selfadjust";
static const char *DB_PROP_WHITELIST = "whitelist";
// ObShardTpo
static const char *SHARDS_TPO_NAME = "topology_name";
static const char *SHARDS_TPO_ARCH = "architecture";
static const char *SHARDS_TPO_GROUPS = "specific_layer";
static const char *SHARDS_TPO_SPEC_MODE = "specific_mode";
static const char *SHARDS_TPO_SPEC = "specification";
static const char *STRICT_SPEC_MODE = "strict";
static const char *NORMAL_SPEC_MODE = "normal";
static const char *SHARDS_TPO_NAME = "topology_name";
static const char *SHARDS_TPO_ARCH = "architecture";
static const char *SHARDS_TPO_GROUPS = "specific_layer";
static const char *SHARDS_TPO_SPEC_MODE = "specific_mode";
static const char *SHARDS_TPO_SPEC = "specification";
static const char *STRICT_SPEC_MODE = "strict";
static const char *NORMAL_SPEC_MODE = "normal";
// ObShardRule
static const char *RULE_TB_NAME = "mark";
static const char *ROUTER_SEQUENCE = "sequence";
static const char *RULE_ROUTER = "router";
static const char *RULE_RULES = "rules";
static const char *RULE_TB_NAME_PATTERN = "tbNamePattern";
static const char *RULE_DB_NAME_PATTERN = "dbNamePattern";
static const char *RULE_TB_SUFFIX_PADDING = "tbSuffixPadding";
static const char *RULE_TB_RULES = "tbRules";
static const char *RULE_DB_RULES = "dbRules";
static const char *RULE_ES_RULES = "elasticRules";
static const char *RULE_TB_NAME = "mark";
static const char *ROUTER_SEQUENCE = "sequence";
static const char *RULE_ROUTER = "router";
static const char *RULE_RULES = "rules";
static const char *RULE_TB_NAME_PATTERN = "tbNamePattern";
static const char *RULE_DB_NAME_PATTERN = "dbNamePattern";
static const char *RULE_TB_SUFFIX_PADDING = "tbSuffixPadding";
static const char *RULE_TB_RULES = "tbRules";
static const char *RULE_DB_RULES = "dbRules";
static const char *RULE_ES_RULES = "elasticRules";
// ObShardRouter
static const char *ROUTER_RULES = "routers";
static const char *ROUTER_RULES = "routers";
// ObShardConnector
static const char *SHARDS_NAME = "shards_name";
static const char *SHARDS_TYPE = "shards_type";
static const char *SHARDS_AUTH = "shards_authority";
static const char *SHARDS_ENC_TYPE = "encType";
static const char *SHARDS_URL = "shards_connector";
static const char *SHARDS_USERNAME = "user";
static const char *SHARDS_PASSWORD = "password";
static const char *SHARDS_NAME = "shards_name";
static const char *SHARDS_TYPE = "shards_type";
static const char *SHARDS_AUTH = "shards_authority";
static const char *SHARDS_ENC_TYPE = "encType";
static const char *SHARDS_URL = "shards_connector";
static const char *SHARDS_USERNAME = "user";
static const char *SHARDS_PASSWORD = "password";
// ObShardProp
static const char *SHARDS_CONN_PROP = "connectionProperties";
static const char *SHARDS_CONN_TIMEOUT = "connectTimeout";
static const char *SHARDS_SOCK_TIMEOUT = "socketTimeout";
static const char *SHARDS_IDLE_TIMEOUT = "idleTimeoutMinutes";
static const char *SHARDS_NEED_PREFILL = "prefill";
static const char *SHARDS_BLOCKING_TIMEOUT = "blockingTimeoutMillis";
static const char *SHARDS_READ_CONSISTENCY = "obReadConsistency";
static const char* SHARDS_ZONE_PROPERTIES = "zoneProperties";
static const char* SHARDS_ZONE_MIN_CONN_PROP = "minConn";
static const char* SHARDS_ZONE_MAX_CONN_PROP = "maxConn";
static const char *SHARDS_CONN_PROP = "connectionProperties";
static const char *SHARDS_CONN_TIMEOUT = "connectTimeout";
static const char *SHARDS_SOCK_TIMEOUT = "socketTimeout";
static const char *SHARDS_IDLE_TIMEOUT = "idleTimeoutMinutes";
static const char *SHARDS_NEED_PREFILL = "prefill";
static const char *SHARDS_BLOCKING_TIMEOUT = "blockingTimeoutMillis";
static const char *SHARDS_READ_CONSISTENCY = "obReadConsistency";
static const char* SHARDS_ZONE_PROPERTIES = "zoneProperties";
static const char* SHARDS_ZONE_MIN_CONN_PROP = "minConn";
static const char* SHARDS_ZONE_MAX_CONN_PROP = "maxConn";
static const ObString SHARDS_ZONE_CURRENT_CONN_PROP = ObString::make_string("current");
static const ObString SHARDS_ZONE_OTHERS_CONN_PROP = ObString::make_string("others");
static const ObString SHARDS_ZONE_OTHERS_CONN_PROP = ObString::make_string("others");
// OBShardDist
static const char *SHARD_DISTS = "distributions";
static const char *SHARD_DISTS_DIST = "distribution";
static const char *SHARD_DISTS_MARK = "mark";
static const char *SHARD_DISTS = "distributions";
static const char *SHARD_DISTS_DIST = "distribution";
static const char *SHARD_DISTS_MARK = "mark";
ObDbConfigCache &get_global_dbconfig_cache()
......
......@@ -70,14 +70,14 @@ static const std::regex ELASTIC_PATTERN2("^toint\\(substr\\(\\#(\\w+)\\#,\\s*(\\
const char *OBPROXY_CONFIG_LOG_TIMESTAMP_FORMAT = "%Y-%m-%d %H:%i:%s.%f";
//static const char *CONFIG_
static const char *CONFIG_TIMESTAMP = "timestamp";
static const char *CONFIG_INSTANCE_IP = "instance_ip";
static const char *CONFIG_INSTANCE_ZONE = "instance_zone";
static const char *CONFIG_TENANT = "tenant";
static const char *CONFIG_LOGICAL_DB = "logical_db";
static const char *CONFIG_TYPE = "type";
static const char *CONFIG_NAME = "name";
static const char *CONFIG_VALUE = "value";
static const char *CONFIG_TIMESTAMP = "timestamp";
static const char *CONFIG_INSTANCE_IP = "instance_ip";
static const char *CONFIG_INSTANCE_ZONE = "instance_zone";
static const char *CONFIG_TENANT = "tenant";
static const char *CONFIG_LOGICAL_DB = "logical_db";
static const char *CONFIG_TYPE = "type";
static const char *CONFIG_NAME = "name";
static const char *CONFIG_VALUE = "value";
int ObProxyPbUtils::parse_database_prop_rule(const std::string &prop_rule, ObDataBaseProp &child_info)
{
......
......@@ -50,7 +50,7 @@ public:
} PacketErrorInfo;
const int16_t OP_DEFAULT_ERROR_NO = 8001;
const char* OP_DEFAULT_ERROR_MSG = "Inner error occured in Operator and not have any other info";
const char* OP_DEFAULT_ERROR_MSG = "Inner error occured in Operator and not have any other info";
int change_sql_field(const ObMysqlField *src_field, obmysql::ObMySQLField *&dst_field,
common::ObIAllocator &allocator)
......
......@@ -370,7 +370,17 @@ ObBaseSort::ObBaseSort(SortColumnArray &sort_columns, common::ObIAllocator &allo
*err_ = common::OB_SUCCESS;
*sort_err_ = common::OB_SUCCESS;
}
ObBaseSort::~ObBaseSort()
{
if (err_ != NULL) {
delete err_;
err_ = NULL;
}
if (sort_err_ != NULL) {
delete sort_err_;
sort_err_ = NULL;
}
}
bool ObBaseSort::compare_row(ResultRow &row1, ResultRow &row2, int &ret) //row1 <= row2 true, row1 > row2 false
{
*err_ = common::OB_SUCCESS;
......
......@@ -141,7 +141,7 @@ class ObBaseSort
{
public:
ObBaseSort(SortColumnArray &sort_columns, common::ObIAllocator &allocator_, ResultRows &sort_rows);
virtual ~ObBaseSort() {};
virtual ~ObBaseSort();
virtual void set_sort_columns(SortColumnArray &sort_columns)
{
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_ACTION_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define USING_LOG_PREFIX PROXY_EVENT
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_BLOCKING_TASK_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_BUF_ALLOCATOR_H
......
......@@ -9,6 +9,24 @@
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ***************************************************************
*
* Continuations have a handle_event() method to invoke them. Userscan
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define USING_LOG_PREFIX PROXY_EVENT
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define USING_LOG_PREFIX PROXY_EVENT
......
......@@ -86,7 +86,7 @@ namespace event
#define API_EVENT_EVENTS_START 60000
typedef int32_t ObEventThreadType;
const int32_t ET_CALL = 0;
const int32_t ET_CALL = 0;
const int32_t MAX_EVENT_TYPES = 6; // conservative, these are dynamically allocated
class ObEThread;
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define USING_LOG_PREFIX PROXY_EVENT
......
......@@ -50,9 +50,9 @@ const int64_t MAX_THREADS_IN_EACH_TYPE = 256;
#endif
#ifdef OB_MAX_NUMBER_EVENT_THREADS
const int64_t MAX_EVENT_THREADS = OB_MAX_NUMBER_EVENT_THREADS;
const int64_t MAX_EVENT_THREADS = OB_MAX_NUMBER_EVENT_THREADS;
#else
const int64_t MAX_EVENT_THREADS = 512;
const int64_t MAX_EVENT_THREADS = 512;
#endif
#ifndef offsetof
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define USING_LOG_PREFIX PROXY_EVENT
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_EVENTSYSTEM_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "iocore/eventsystem/ob_event_system.h"
......
......@@ -11,6 +11,24 @@
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* *************************************************************
*
* I/O Buffer classes
*
* Watermarks can be used as an interface between the data transferring
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define USING_LOG_PREFIX PROXY_EVENT
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_LOCK_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_PRIORITY_EVENT_QUEUE_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_PROCESSOR_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define USING_LOG_PREFIX PROXY_EVENT
......
......@@ -9,6 +9,24 @@
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* **************************************************************
*
* Protected Queue, a FIFO queue with the following functionality:
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define USING_LOG_PREFIX PROXY_EVENT
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_RESOURCE_TRACKER_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define USING_LOG_PREFIX PROXY_EVENT
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_TASK_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#define USING_LOG_PREFIX PROXY_EVENT
......
......@@ -48,7 +48,7 @@ typedef void *(*ThreadFunction)(void *arg);
extern ObProxyMutex *global_mutex;
static const int MAX_THREAD_NAME_LENGTH = 32;
static const int DEFAULT_STACKSIZE = 1048576; // 1MB
static const int DEFAULT_STACKSIZE = 1048576; // 1MB
/**
* Base class for the threads in the ObEvent System. ObThread is the base
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_THREAD_ALLOCATOR_H
......@@ -22,10 +41,10 @@ namespace obproxy
namespace event
{
static const int64_t g_thread_freelist_high_watermark = 512;
static const int64_t g_thread_freelist_low_watermark = 32;
static const int64_t g_thread_freelist_high_watermark = 512;
static const int64_t g_thread_freelist_low_watermark = 32;
static const int64_t g_thread_freelist_low_watermark_for_8k = 0;
static const int64_t size_8k = 8 * 1024;
static const int64_t size_8k = 8 * 1024;
struct ObProxyThreadAllocator
{
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_EVENT_THREAD_H
......
......@@ -8,6 +8,24 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "iocore/net/ob_connection.h"
......@@ -111,11 +129,11 @@ ObConnection::~ObConnection()
* order to tweak options.
*/
const ObNetVCOptions ObConnection::DEFAULT_OPTIONS;
const int32_t ObConnection::SOCKOPT_ON = 1;
const int32_t ObConnection::SOCKOPT_OFF = 0;
const int32_t ObConnection::SOCKOPT_ON = 1;
const int32_t ObConnection::SOCKOPT_OFF = 0;
const int32_t ObConnection::SNDBUF_AND_RCVBUF_PREC = 1024;
const int32_t ObServerConnection::LISTEN_BACKLOG = 1024;
const int32_t ObServerConnection::LISTEN_BACKLOG = 1024;
int ObConnection::open(const ObNetVCOptions &opt)
{
......@@ -340,7 +358,7 @@ int ObServerConnection::accept(ObConnection *c)
ret = OB_INVALID_ARGUMENT;
PROXY_SOCK_LOG(WARN, "invalid argument conn", K(c), K(ret));
} else {
int64_t sz = sizeof(c->addr_);
int64_t sz = sizeof(c->addr_.sa_);
if (OB_FAIL(ObSocketManager::accept(fd_, &c->addr_.sa_, &sz, c->fd_))) {
if (OB_SYS_EAGAIN != ret) {
PROXY_SOCK_LOG(WARN, "fail to accept", K(fd_), K(ret));
......
......@@ -11,6 +11,24 @@
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* *************************************************************
*
* Description:
* struct ObConnection
* struct ObServerConnection
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_EVENT_IO_H
......
......@@ -56,16 +56,16 @@ static inline bool IN6_IS_ADDR_UNSPECIFIED(const in6_addr *addr)
#endif
// Buffer size sufficient for IPv6 address and port.
static const int64_t INET6_ADDRPORTSTRLEN = INET6_ADDRSTRLEN + 6;
static const int64_t INET6_ADDRPORTSTRLEN = INET6_ADDRSTRLEN + 6;
// Convenience type for address formatting.
typedef char ip_text_buffer[INET6_ADDRSTRLEN];
typedef char ip_port_text_buffer[INET6_ADDRPORTSTRLEN];
static const int64_t MAX_HOST_NAME_LEN = 256;
static const int64_t MAX_HOST_NAME_LEN = 256;
static const int64_t MAX_LOCAL_ADDR_LIST_COUNT = 64;
// Size in bytes of an IPv6 address.
static const int64_t IP6_SIZE = sizeof(in6_addr);
static const int64_t IP6_SIZE = sizeof(in6_addr);
struct ObIpAddr;
......@@ -511,10 +511,7 @@ inline bool ops_is_ip_private(const sockaddr &ip)
bool zret = false;
if (ops_is_ip4(ip)) {
in_addr_t a = ops_ip4_addr_cast(ip);
zret = ((a & htonl(0xFF000000)) == htonl(0x0A000000)) // 10.0.0.0/8
|| ((a & htonl(0xFFC00000)) == htonl(0x64400000)) // 100.64.0.0/10
|| ((a & htonl(0xFFF00000)) == htonl(0xAC100000)) // 172.16.0.0/12
|| ((a & htonl(0xFFFF0000)) == htonl(0xC0A80000)); // 192.168.0.0/16
zret = ((a & htonl(0xFFFF0000)) == htonl(0xC0A80000)); // 192.168.0.0/16
} else if (ops_is_ip6(ip)) {
in6_addr a = ops_ip6_addr_cast(ip);
zret = ((a.s6_addr[0] & 0xFE) == 0xFC); // fc00::/7
......@@ -527,26 +524,6 @@ inline bool ops_is_ip_private(const ObIpEndpoint &ip)
return ops_is_ip_private(ip.sa_);
}
// Check for Link Local.
// @return @true if ip is link local.
inline bool ops_is_ip_linklocal(const sockaddr &ip)
{
bool zret = false;
if (ops_is_ip4(ip)) {
in_addr_t a = ops_ip4_addr_cast(ip);
zret = ((a & htonl(0xFFFF0000)) == htonl(0xA9FE0000)); // 169.254.0.0/16
} else if (ops_is_ip6(ip)) {
in6_addr a = ops_ip6_addr_cast(ip);
zret = ((a.s6_addr[0] == 0xFE) && ((a.s6_addr[1] & 0xC0) == 0x80)); // fe80::/10
}
return zret;
}
inline bool ops_is_ip_linklocal(const ObIpEndpoint &ip)
{
return ops_is_ip_linklocal(ip.sa_);
}
// Check for being "any" address.
// @return true if ip is the any / unspecified address.
inline bool ops_is_ip_any(const sockaddr &ip)
......@@ -567,6 +544,7 @@ inline bool ops_is_ip_any(const sockaddr &ip)
inline bool ops_ip_copy(sockaddr &dst, const sockaddr &src)
{
int64_t n = 0;
int64_t n2 = 0;
switch (src.sa_family) {
case AF_INET:
n = sizeof(sockaddr_in);
......@@ -576,7 +554,16 @@ inline bool ops_ip_copy(sockaddr &dst, const sockaddr &src)
n = sizeof(sockaddr_in6);
break;
}
if (n) {
switch (dst.sa_family) {
case AF_INET:
n2 = sizeof(sockaddr_in);
break;
case AF_INET6:
n2 = sizeof(sockaddr_in6);
break;
}
if (n && n <= n2) {
MEMCPY(&dst, &src, n);
#if HAVE_STRUCT_SOCKADDR_SA_LEN
dst.sa_len = n;
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "iocore/net/ob_net.h"
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_NET_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "iocore/net/ob_net_accept.h"
......
......@@ -11,6 +11,24 @@
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* *************************************************************
*
* ObNetAccept is a generalized facility which allows
* Connections of different classes to be accepted either
* from a blockable thread or by adaptive polling.
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_NET_PROCESSOR_H
......
......@@ -11,6 +11,24 @@
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* *************************************************************
*
* State information for a particular channel of a ObNetVConnection
* This information is private to the Net module. It is only here
* because of the the C++ compiler needs it to define ObNetVConnection.
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_POLL_DESCRIPTOR_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_SESSION_ACCEPT_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_SOCKET_MANAGER_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <pthread.h>
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_UNIX_NET_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "iocore/net/ob_unix_net_processor.h"
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_UNIX_NET_PROCESSOR_H
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "lib/profile/ob_trace_id.h"
......
......@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef OBPROXY_UNIX_NET_VCONNECTION_H
......
......@@ -146,8 +146,8 @@ void ObProxyMain::print_usage() const
MPRINT(" -t,--regression_test TEST_NAME regression test");
MPRINT("example:");
MPRINT(" run without config server:");
MPRINT(" ./bin/obproxy -p6789 -r'10.125.224.11:26506;10.125.224.22:26577' -n test -o enable_cluster_checkout=false,syslog_level=INFO");
MPRINT(" OR ./bin/obproxy -p6789 -r'10.125.224.11:26506;10.125.224.22:26577' -c 'ob_test' -n test -o syslog_level=INFO \n");
MPRINT(" ./bin/obproxy -p6789 -r'ip:port;ip:port' -n test -o enable_cluster_checkout=false,syslog_level=INFO");
MPRINT(" OR ./bin/obproxy -p6789 -r'ip:port;ip:port' -c 'ob_test' -n test -o syslog_level=INFO \n");
MPRINT(" run with config server:");
MPRINT(" ./bin/obproxy -p6789 -e -n test -o obproxy_config_server_url='your config url',syslog_level=INFO\n");
MPRINT(" Non-first start with local config file:");
......@@ -155,7 +155,7 @@ void ObProxyMain::print_usage() const
MPRINT(" dump config update sql:");
MPRINT(" ./bin/obproxy -d\n");
MPRINT(" run regression tests:");
MPRINT(" ./bin/obproxy -p6789 -r10.125.224.11:26506 -ntest -o obproxy_config_server_url='' -t ''");
MPRINT(" ./bin/obproxy -p6789 -rip:port -ntest -o obproxy_config_server_url='' -t ''");
MPRINT("----------------------------------------------------------------------------------");
}
......
......@@ -27,7 +27,7 @@ namespace obproxy
{
namespace obutils
{
static const int EVENT_COMPLETE = CLIENT_TRANSPORT_MYSQL_RESP_EVENT;
static const int EVENT_COMPLETE = CLIENT_TRANSPORT_MYSQL_RESP_EVENT;
static const int EVENT_INFORM_OUT = ASYNC_PROCESS_INFORM_OUT_EVENT;
int ObAsyncCommonTask::main_handler(int event, void *data)
......
......@@ -938,7 +938,7 @@ int ObConfigServerProcessor::do_fetch_proxy_bin(const char *bin_save_path, const
LOG_WARN("fail to fetch new proxy bin", K(bin_url), K(bin_save_path), K(ret));
} else { }
if (fd > 0) {
if (fd >= 0) {
::close(fd);
}
}
......@@ -1085,7 +1085,7 @@ int ObConfigServerProcessor::get_kernel_release_by_redhat(ObProxyKernelRelease &
"release", get_kernel_release_string(release));
}
if (fd > 0) {
if (fd >= 0) {
::close(fd);
}
return ret;
......
......@@ -223,28 +223,30 @@ int get_binary_md5(const char *binary, char *md5_buf, const int64_t md5_buf_len)
} else if (OB_UNLIKELY(0 != sigaction(SIGCHLD, &action, &old_action))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("fail to sigaction SIGCHLD", KERRMSGS, K(ret));
} else if (OB_ISNULL((fp = popen(shell_str, "r")))) {
ret = ob_get_sys_errno();
LOG_WARN("failed to popen fp", K(shell_str), K(binary), KERRMSGS, K(ret));
} else if (OB_ISNULL(fgets(md5_buf, static_cast<int32_t>(md5_buf_len), fp))) {
ret = ob_get_sys_errno();
LOG_WARN("fail to fgets md5_str", K(shell_str), K(md5_buf), KERRMSGS, K(ret));
} else {
LOG_INFO("succeed to get binary md5", K(shell_str), K(md5_buf), K(md5_buf_len));
}
if (OB_LIKELY(NULL != fp)) {
if (-1 == pclose(fp)) {
if (OB_ISNULL((fp = popen(shell_str, "r")))) {
ret = ob_get_sys_errno();
LOG_WARN("failed to pclose fp", K(fp), KERRMSGS, K(ret));
LOG_WARN("failed to popen fp", K(shell_str), K(binary), KERRMSGS, K(ret));
} else if (OB_ISNULL(fgets(md5_buf, static_cast<int32_t>(md5_buf_len), fp))) {
ret = ob_get_sys_errno();
LOG_WARN("fail to fgets md5_str", K(shell_str), K(md5_buf), KERRMSGS, K(ret));
} else {
fp = NULL;
LOG_INFO("succeed to get binary md5", K(shell_str), K(md5_buf), K(md5_buf_len));
}
}
if (OB_UNLIKELY(0 != sigaction(SIGCHLD, &old_action, NULL))) {//reset it
ret = OB_ERR_UNEXPECTED;
LOG_WARN("fail to sigaction SIGCHLD", KERRMSGS, K(ret));
if (OB_LIKELY(NULL != fp)) {
if (-1 == pclose(fp)) {
ret = ob_get_sys_errno();
LOG_WARN("failed to pclose fp", K(fp), KERRMSGS, K(ret));
} else {
fp = NULL;
}
}
if (OB_UNLIKELY(0 != sigaction(SIGCHLD, &old_action, NULL))) {//reset it
ret = OB_ERR_UNEXPECTED;
LOG_WARN("fail to sigaction SIGCHLD", KERRMSGS, K(ret));
}
}
}
......@@ -588,37 +590,39 @@ int ObHotUpgradeProcessor::check_proxy_bin_release(const char *binary)
} else if (OB_UNLIKELY(0 != sigaction(SIGCHLD, &action, &old_action))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("fail to sigaction SIGCHLD", KERRMSGS, K(ret));
} else if (OB_ISNULL((fp = popen(shell_str, "r")))) {
ret = ob_get_sys_errno();
LOG_WARN("failed to popen fp", K(shell_str), K(binary), KERRMSGS, K(ret));
} else {
char *result_buf = shell_str;
MEMSET(result_buf, 0, MAX_SHELL_STR_LENGTH);
fgets(result_buf, static_cast<int32_t>(MAX_SHELL_STR_LENGTH), fp);
if (0 != STRLEN(result_buf)
&& (NULL != strstr(result_buf, ".el") || NULL != strstr(result_buf, ".alios"))) {
if (OB_FAIL(get_global_config_server_processor().check_kernel_release(result_buf))) {
LOG_WARN("failed to parser linux kernel release in result_buf", K(result_buf), K(ret));
if (OB_ISNULL((fp = popen(shell_str, "r")))) {
ret = ob_get_sys_errno();
LOG_WARN("failed to popen fp", K(shell_str), K(binary), KERRMSGS, K(ret));
} else {
char *result_buf = shell_str;
MEMSET(result_buf, 0, MAX_SHELL_STR_LENGTH);
fgets(result_buf, static_cast<int32_t>(MAX_SHELL_STR_LENGTH), fp);
if (0 != STRLEN(result_buf)
&& (NULL != strstr(result_buf, ".el") || NULL != strstr(result_buf, ".alios"))) {
if (OB_FAIL(get_global_config_server_processor().check_kernel_release(result_buf))) {
LOG_WARN("failed to parser linux kernel release in result_buf", K(result_buf), K(ret));
} else {
LOG_INFO("succeed to check proxy binary release", K(result_buf));
}
} else {
LOG_INFO("succeed to check proxy binary release", K(result_buf));
LOG_INFO("maybe upgrade to old proxy, treat it succ", K(result_buf));
}
} else {
LOG_INFO("maybe upgrade to old proxy, treat it succ", K(result_buf));
}
}
if (OB_LIKELY(NULL != fp)) {
if (-1 == pclose(fp)) {
ret = ob_get_sys_errno();
LOG_WARN("failed to pclose fp", K(fp), KERRMSGS, K(ret));
} else {
fp = NULL;
if (OB_LIKELY(NULL != fp)) {
if (-1 == pclose(fp)) {
ret = ob_get_sys_errno();
LOG_WARN("failed to pclose fp", K(fp), KERRMSGS, K(ret));
} else {
fp = NULL;
}
}
}
if (OB_UNLIKELY(0 != sigaction(SIGCHLD, &old_action, NULL))) {//reset it
ret = OB_ERR_UNEXPECTED;
LOG_WARN("fail to sigaction SIGCHLD", KERRMSGS, K(ret));
if (OB_UNLIKELY(0 != sigaction(SIGCHLD, &old_action, NULL))) {//reset it
ret = OB_ERR_UNEXPECTED;
LOG_WARN("fail to sigaction SIGCHLD", KERRMSGS, K(ret));
}
}
if (NULL != shell_str) {
......
......@@ -26,9 +26,9 @@ namespace obproxy
namespace obutils
{
static const int64_t MT_HASHTABLE_PARTITION_BITS = 6;
static const int64_t MT_HASHTABLE_PARTITIONS = 1 << MT_HASHTABLE_PARTITION_BITS;
static const uint64_t MT_HASHTABLE_PARTITION_MASK = MT_HASHTABLE_PARTITIONS - 1;
static const int64_t MT_HASHTABLE_PARTITION_BITS = 6;
static const int64_t MT_HASHTABLE_PARTITIONS = 1 << MT_HASHTABLE_PARTITION_BITS;
static const uint64_t MT_HASHTABLE_PARTITION_MASK = MT_HASHTABLE_PARTITIONS - 1;
static const int64_t MT_HASHTABLE_MAX_CHAIN_AVG_LEN = 4;
template <class Key, class Value>
......
......@@ -40,54 +40,54 @@ namespace obproxy
namespace obutils
{
const static char *CONFIG_META = "meta";
const static char *CONFIG_SPEC = "spec";
const static char *CONFIG_META = "meta";
const static char *CONFIG_SPEC = "spec";
const static char *CONFIG_API_VERSION = "api_version";
const static char *CONFIG_VERSION = "version";
const static char *CONFIG_APP_NAME = "app_name";
const static char *CONFIG_TYPE = "config_type";
const static char *CONFIG_SYNC = "need_sync";
const static char *CONFIG_API_VERSION = "api_version";
const static char *CONFIG_VERSION = "version";
const static char *CONFIG_APP_NAME = "app_name";
const static char *CONFIG_TYPE = "config_type";
const static char *CONFIG_SYNC = "need_sync";
// index config
const static char *CONFIG_REFERENCE = "reference";
const static char *CONFIG_DATAID = "data_id";
const static char *CONFIG_REFERENCE = "reference";
const static char *CONFIG_DATAID = "data_id";
// config spec
const static char *CONFIG_VALUE = "value";
const static char *CONFIG_ATTR = "category";
const static char *CONFIG_PERSISTENT = "persistent";
const static char *CONFIG_VALUE = "value";
const static char *CONFIG_ATTR = "category";
const static char *CONFIG_PERSISTENT = "persistent";
// limit config
const static char *LIMITERS = "limiters";
const static char *CLUSTER_NAME = "cluster";
const static char *TENANT_NAME = "tenant";
const static char *DATABASE_NAME = "database";
const static char *USER_NAME = "username";
const static char *LIMIT_NAME = "limitName";
const static char *LIMIT_MODE = "mode";
const static char *LIMIT_RULE = "rule";
const static char *LIMIT_PRIORITY = "priority";
const static char *LIMIT_STATUS = "status";
const static char *LIMITERS = "limiters";
const static char *CLUSTER_NAME = "cluster";
const static char *TENANT_NAME = "tenant";
const static char *DATABASE_NAME = "database";
const static char *USER_NAME = "username";
const static char *LIMIT_NAME = "limitName";
const static char *LIMIT_MODE = "mode";
const static char *LIMIT_RULE = "rule";
const static char *LIMIT_PRIORITY = "priority";
const static char *LIMIT_STATUS = "status";
// limit rule
const static char *LIMIT_SQL_TYPE = "sqlType";
const static char *LIMIT_KEY_WORDS = "keyWords";
const static char *LIMIT_TABLE_NAME = "tableName";
const static char *LIMIT_QPS = "qps";
const static char *LIMIT_RT = "averageRt";
const static char *LIMIT_CONDITION = "scene";
const static char *LIMIT_SQL_TYPE = "sqlType";
const static char *LIMIT_KEY_WORDS = "keyWords";
const static char *LIMIT_TABLE_NAME = "tableName";
const static char *LIMIT_QPS = "qps";
const static char *LIMIT_RT = "averageRt";
const static char *LIMIT_CONDITION = "scene";
const static char *LIMIT_CONDITION_USE_LIKE = "Uselike";
const static char *LIMIT_CONDITION_NO_WHERE = "Nowhere";
const static char *LIMIT_TIME_WINDOW = "timeWindow";
const static char *LIMIT_CONN = "limitConn";
const static char *LIMIT_FUSE_TIME = "fuseTime";
const static char *LIMIT_TIME_WINDOW = "timeWindow";
const static char *LIMIT_CONN = "limitConn";
const static char *LIMIT_FUSE_TIME = "fuseTime";
// security
const static char *SECURITY_SOURCE_TYPE = "sourceType";
const static char *SECURITY_CA = "CA";
const static char *SECURITY_PUBLIC_KEY = "publicKey";
const static char *SECURITY_PRIVATE_KEY = "privateKey";
const static char *SECURITY_SOURCE_TYPE = "sourceType";
const static char *SECURITY_CA = "CA";
const static char *SECURITY_PUBLIC_KEY = "publicKey";
const static char *SECURITY_PRIVATE_KEY = "privateKey";
#define MONITOR_LIMIT_LOG_FORMAT "%s,%s,%s," \
"%s,%.*s:%.*s:%.*s,%s," \
......
......@@ -29,10 +29,10 @@ namespace obproxy
{
namespace obutils
{
static const ObString LOCAL_DIR = ObString::make_string(".");
static const ObString PARENT_DIR = ObString::make_string("..");
static const ObString LOCAL_DIR = ObString::make_string(".");
static const ObString PARENT_DIR = ObString::make_string("..");
const char *INSERT_KV_TABLE_VERSION_SQL =
const char *INSERT_KV_TABLE_VERSION_SQL =
"INSERT INTO %s "
"(name, datatype, value, info) VALUES ('%s', %d, '%ld', '%s') "
"ON DUPLICATE KEY UPDATE name = VALUES(name);\n";
......@@ -45,7 +45,7 @@ const char *INSERT_KV_TABLE_ALL_PROXY_UPGRADE_SQL =
"('%.*s%.*s', %d, '%.*s', '%s'), ('%.*s%.*s', %d, '%.*s', '%s'), ('%.*s%.*s', %d, '%.*s', '%s') "
"ON DUPLICATE KEY UPDATE name = VALUES(name);\n";
const char *INSERT_CONFIG_TABLE_ALL_PROXY_SQL =
const char *INSERT_CONFIG_TABLE_ALL_PROXY_SQL =
"INSERT INTO %s "
"(app_name, name, value, need_reboot, info) VALUES "
"('all_proxy', '%s', '%s', '%s', '%s') "
......@@ -708,7 +708,7 @@ int ObProxyFileUtils::write_and_backup_file(const char *path, const char *tmp_pa
}
}
}
if (fd > 0) {
if (fd >= 0) {
::close(fd);
}
}
......@@ -792,7 +792,7 @@ int ObProxyFileUtils::read_from_file(const char *dir, const char *file_name,
} else if (OB_LIKELY(read_len < len)) {
buf[read_len] = '\0';
}
if (fd > 0) ::close(fd);
if (fd >= 0) ::close(fd);
}
}
......
......@@ -30,11 +30,11 @@ class ObMysqlProxy;
namespace obutils
{
static const char *const CFG_DUMP_NAME = "./obproxy_config.bin";
static const char *const CFG_SERVER_INFO_DUMP_NAME = "./obproxy_config_server_info.json";
static const char *const CFG_DUMP_NAME = "./obproxy_config.bin";
static const char *const CFG_SERVER_INFO_DUMP_NAME = "./obproxy_config_server_info.json";
static const char *const CFG_SERVER_SHARD_INFO_DUMP_NAME = "./obproxy_shard_config_server_info.json";
static const char *const CFG_RSLIST_INFO_DUMP_NAME = "./obproxy_rslist_info.json";
static const char *const CFG_IDC_LIST_INFO_DUMP_NAME = "./obproxy_idc_list_info.json";
static const char *const CFG_RSLIST_INFO_DUMP_NAME = "./obproxy_rslist_info.json";
static const char *const CFG_IDC_LIST_INFO_DUMP_NAME = "./obproxy_idc_list_info.json";
class ObProxyConfig;
class ObProxyConfigUtils
......
......@@ -30,43 +30,43 @@ namespace obproxy
namespace obutils
{
static const char *JSON_HTTP_MESSAGE = "Message";
static const char *HTTP_SUCC_MESSAGE = "successful";
static const char *JSON_HTTP_STATUS = "Success";
static const char *JSON_HTTP_CODE = "Code";
static const char *JSON_CONFIG_DATA = "Data";
static const char *JSON_CONFIG_VERSION = "Version";
static const char *JSON_CLUSTER_LIST = "ObRootServiceInfoUrlList";
static const char *JSON_OB_REGION = "ObRegion";
static const char *JSON_OB_CLUSTER = "ObCluster";
static const char *JSON_OB_REGION_ID = "ObRegionId";
static const char *JSON_OB_CLUSTER_ID = "ObClusterId";
static const char *JSON_OB_CLUSTER_TYPE = "Type";
static const char *JSON_REAL_META_REGION = "ObRealMetaRegion";
static const char *JSON_RS_URL = "ObRootServiceInfoUrl";
static const char *JSON_RS_LIST = "RsList";
static const char *JSON_ADDRESS = "address";
static const char *JSON_SQL_PORT = "sql_port";
static const char *JSON_ROLE = "role";
static const char *JSON_META_TABLE_INFO = "ObProxyDatabaseInfo";
static const char *JSON_META_DATABASE = "DataBase";
static const char *JSON_META_USER = "User";
static const char *JSON_META_PASSWORD = "Password";
static const char *JSON_BIN_URL = "ObProxyBinUrl";
static const char *JSON_IDC_LIST = "IDCList";
static const char *JSON_REGION = "region";
static const char *JSON_IDC = "idc";
static const char *JSON_READONLY_RS_LIST = "ReadonlyRsList";
static const char *LEADER_ROLE = "LEADER";
static const char *FOLLOWER_ROLE = "FOLLOWER";
static const char *PRIMARY_ROLE = "PRIMARY";
static const char *STANDBY_ROLE = "STANDBY";
static const char *JSON_ROOT_SERVICE_INFO_URL_TEMPLATE = "ObRootServiceInfoUrlTemplate";
static const char *JSON_HTTP_MESSAGE = "Message";
static const char *HTTP_SUCC_MESSAGE = "successful";
static const char *JSON_HTTP_STATUS = "Success";
static const char *JSON_HTTP_CODE = "Code";
static const char *JSON_CONFIG_DATA = "Data";
static const char *JSON_CONFIG_VERSION = "Version";
static const char *JSON_CLUSTER_LIST = "ObRootServiceInfoUrlList";
static const char *JSON_OB_REGION = "ObRegion";
static const char *JSON_OB_CLUSTER = "ObCluster";
static const char *JSON_OB_REGION_ID = "ObRegionId";
static const char *JSON_OB_CLUSTER_ID = "ObClusterId";
static const char *JSON_OB_CLUSTER_TYPE = "Type";
static const char *JSON_REAL_META_REGION = "ObRealMetaRegion";
static const char *JSON_RS_URL = "ObRootServiceInfoUrl";
static const char *JSON_RS_LIST = "RsList";
static const char *JSON_ADDRESS = "address";
static const char *JSON_SQL_PORT = "sql_port";
static const char *JSON_ROLE = "role";
static const char *JSON_META_TABLE_INFO = "ObProxyDatabaseInfo";
static const char *JSON_META_DATABASE = "DataBase";
static const char *JSON_META_USER = "User";
static const char *JSON_META_PASSWORD = "Password";
static const char *JSON_BIN_URL = "ObProxyBinUrl";
static const char *JSON_IDC_LIST = "IDCList";
static const char *JSON_REGION = "region";
static const char *JSON_IDC = "idc";
static const char *JSON_READONLY_RS_LIST = "ReadonlyRsList";
static const char *LEADER_ROLE = "LEADER";
static const char *FOLLOWER_ROLE = "FOLLOWER";
static const char *PRIMARY_ROLE = "PRIMARY";
static const char *STANDBY_ROLE = "STANDBY";
static const char *JSON_ROOT_SERVICE_INFO_URL_TEMPLATE = "ObRootServiceInfoUrlTemplate";
static const char *JSON_ROOT_SERVICE_INFO_URL_TEMPLATE_V2 = "ObRootServiceInfoUrlTemplateV2";
static const char *JSON_DATA_CLUSTER_LIST = "ObClusterList";
static const char *JSON_DATA_CLUSTER_LIST = "ObClusterList";
static const char *REGION_TEMPLATE = "${ObRegion}";
static const char *CLUSTER_TEMPLATE = "${ObCluster}";
static const char *REGION_TEMPLATE = "${ObRegion}";
static const char *CLUSTER_TEMPLATE = "${ObCluster}";
const char *cluster_role_to_str(ObClusterRole role)
{
......@@ -1090,6 +1090,9 @@ int ObProxyJsonConfigInfo::parse_rslist_data(const Value *json_value, const ObSt
}
if (OB_SUCC(ret)) {
if (is_from_local) {
if (cluster_id == OB_DEFAULT_CLUSTER_ID) {
cluster_id = json_cluster_id;
}
if (cluster_name == OB_META_DB_CLUSTER_NAME) {
if (!real_meta_cluster_name.empty()) {
data_info_.meta_table_info_.real_cluster_name_.set_value(real_meta_cluster_name);
......
......@@ -27,15 +27,15 @@ namespace obproxy
{
namespace proxy
{
static const char *PROXY_SELECT_SEQUENCE_INFO_SQL =
static const char *PROXY_SELECT_SEQUENCE_INFO_SQL =
"SELECT CURRENT_TIMESTAMP(6) as now, value, min_value, max_value, step, gmt_create, gmt_modified "
"FROM %.*s.%.*s WHERE name = '%.*s' LIMIT 1";
static const char* PROXY_INSERT_SEQUENCE_INFO_SQL =
static const char* PROXY_INSERT_SEQUENCE_INFO_SQL =
"INSERT INTO %.*s.%.*s(name, min_value, max_value, step, value, gmt_create, gmt_modified) "
"VALUES('%.*s', '%ld','%ld', '%ld', '%ld', '%.*s', '%.*s')";
static const char* PROXY_UPDATE_SEQUENCE_INFO_SQL =
static const char* PROXY_UPDATE_SEQUENCE_INFO_SQL =
"UPDATE %.*s.%.*s SET value = '%ld', gmt_modified = now() WHERE name = '%.*s' and value = '%ld'";
static const char *PROXY_SELECT_SEQUENCE_INFO_WITH_TNT_SQL =
......
......@@ -559,6 +559,7 @@ int ObSqlParseResult::load_result(const ObProxyParseResult &parse_result,
has_shard_comment_ = parse_result.has_shard_comment_;
has_last_insert_id_ = parse_result.has_last_insert_id_;
hint_query_timeout_ = parse_result.query_timeout_;
has_anonymous_block_ = parse_result.has_anonymous_block_;
stmt_type_ = parse_result.stmt_type_;
cmd_sub_type_ = parse_result.sub_stmt_type_;
hint_consistency_level_ = static_cast<ObConsistencyLevel>(parse_result.read_consistency_type_);
......
......@@ -627,6 +627,7 @@ struct ObSqlParseResult
bool has_explain() const { return has_explain_; }
bool has_simple_route_info() const { return has_simple_route_info_; }
bool has_shard_comment() const { return has_shard_comment_; }
bool has_anonymous_block() const { return has_anonymous_block_; }
bool is_simple_route_info_valid() const { return route_info_.is_valid(); }
......@@ -724,6 +725,7 @@ struct ObSqlParseResult
has_row_count_ = other.has_row_count_;
has_explain_ = other.has_explain_;
has_simple_route_info_ = other.has_simple_route_info_;
has_anonymous_block_ = other.has_anonymous_block_;
stmt_type_ = other.stmt_type_;
hint_query_timeout_ = other.hint_query_timeout_;
parsed_length_ = other.parsed_length_;
......@@ -814,6 +816,7 @@ private:
bool has_simple_route_info_;
bool has_shard_comment_;
bool is_dual_request_;
bool has_anonymous_block_;
ObProxyBasicStmtType stmt_type_;
int64_t hint_query_timeout_;
int64_t parsed_length_; // next parser can starts with (orig_sql + parsed_length_)
......@@ -868,12 +871,12 @@ private:
ObProxyStmt* proxy_stmt_;
};
const int OB_T_IDENT_NUM_CHILD = 0;
const int OB_T_RELATION_FACTOR_NUM_CHILD = 2;
const int OB_T_COLUMN_REF_NUM_CHILD = 3;
const int OB_T_ALIAS_TABLE_NAME_NUM_CHILD = 5;
const int OB_T_ALIAS_CLUMN_NAME_NUM_CHILD = 2;
const int OB_T_INDEX_NUM_CHILD = 3;
const int OB_T_IDENT_NUM_CHILD = 0;
const int OB_T_RELATION_FACTOR_NUM_CHILD = 2;
const int OB_T_COLUMN_REF_NUM_CHILD = 3;
const int OB_T_ALIAS_TABLE_NAME_NUM_CHILD = 5;
const int OB_T_ALIAS_CLUMN_NAME_NUM_CHILD = 2;
const int OB_T_INDEX_NUM_CHILD = 3;
const int OB_T_RELATION_FACTOR_IN_HINT_NUM_CHILD = 2;
class ObProxySqlParser
......@@ -913,6 +916,7 @@ inline void ObSqlParseResult::reset(bool is_reset_origin_db_table /* true */)
has_simple_route_info_ = false;
has_shard_comment_ = false;
is_dual_request_ = false;
has_anonymous_block_ = false;
stmt_type_ = OBPROXY_T_INVALID;
cmd_sub_type_ = OBPROXY_T_SUB_INVALID;
cmd_err_type_ = OBPROXY_T_ERR_INVALID;
......
......@@ -43,12 +43,12 @@ enum ObProxyRowStatus
};
//.upgrade_start_time | .upgrade_duration_time
const int64_t OB_MAX_PROXY_UPGRADEN_TIME_LEN = 24;
const int64_t OB_MAX_PROXY_UPGRADEN_TIME_LEN = 24;
//upgrade_off | upgrade_part | upgrade_on | upgrade_bin
const int64_t OB_MAX_PROXY_UPGRADEN_SWITCH_LEN = 16;
//all_proxy
const int64_t OB_ALL_PROXY_HEADER_LEN = sizeof("all_proxy");
const int64_t OB_PROXY_CONFIG_VERSION_LEN = sizeof(".config_version");
const int64_t OB_ALL_PROXY_HEADER_LEN = sizeof("all_proxy");
const int64_t OB_PROXY_CONFIG_VERSION_LEN = sizeof(".config_version");
class ObProxyServerInfo
{
......
......@@ -36,7 +36,7 @@ namespace obproxy
{
namespace obutils
{
static const char *INADDR_ANY_IP = "0.0.0.0";
static const char *INADDR_ANY_IP = "0.0.0.0";
static const char *INADDR_LOOPBACK_IP = "127.0.0.1";
static const char *GET_PROXY_INFO_SQL =
......@@ -134,7 +134,7 @@ static const char *GET_PROXY_ALL_VIP_TENANT_SQL =
"SELECT /*+READ_CONSISTENCY(WEAK)*/ vid, vip, vport, tenant_name, cluster_name, info FROM %s LIMIT %ld";
static const char *JSON_REQUEST_TARGET = "REQUEST_TARGET";
static const char *JSON_RW_TYPE = "RW_TYPE";
static const char *JSON_RW_TYPE = "RW_TYPE";
int ObProxyTableProcessorUtils::get_proxy_info(ObMysqlProxy &mysql_proxy,
......
......@@ -44,19 +44,19 @@ namespace obutils
{
ObResourcePoolProcessor g_rp_processor;
const static char *CHEK_CLUSTER_NAME_SQL =
const static char *CHEK_CLUSTER_NAME_SQL =
"SELECT /*+READ_CONSISTENCY(WEAK)*/ cluster FROM oceanbase.%s LIMIT 1";
const static char *CHEK_CLUSTER_ROLE_SQL =
const static char *CHEK_CLUSTER_ROLE_SQL =
"SELECT /*+READ_CONSISTENCY(WEAK)*/ cluster_role, cluster_status FROM oceanbase.%s LIMIT 1";
const static char *OBPROXY_V_DATABASE_TNAME = "v$ob_cluster";
const static char *INIT_SS_INFO_SQL =
const static char *INIT_SS_INFO_SQL =
"SELECT /*+READ_CONSISTENCY(WEAK)*/ *, zs.status AS zone_status, ss.status AS server_status "
"FROM oceanbase.%s zs, oceanbase.%s ss "
"WHERE zs.zone=ss.zone "
"AND ss.svr_port > 0 LIMIT %ld;";
const static char *PRIMARY_ROLE = "PRIMARY";
const static char *ROLE_VALID = "VALID";
const static char *PRIMARY_ROLE = "PRIMARY";
const static char *ROLE_VALID = "VALID";
//-------ObClusterInfoKey------
DEF_TO_STRING(ObClusterInfoKey)
......
......@@ -40,7 +40,7 @@ namespace obproxy
namespace obutils
{
static const char *SELECT_ZONE_STATE_INFO_SQL =
static const char *SELECT_ZONE_STATE_INFO_SQL =
//zone, is_merging, status, region
"SELECT /*+READ_CONSISTENCY(WEAK)*/ * "
"FROM oceanbase.%s LIMIT %ld";
......@@ -48,19 +48,19 @@ static const char *SELECT_ZONE_STATE_INFO_SQL =
//when server fail to start, its status is inactive, but its port == 0.
//it is design defect, but proxy need compatible with it.
//so select svr_port > 0 one
const static char *SELECT_SERVER_STATE_INFO_SQL =
const static char *SELECT_SERVER_STATE_INFO_SQL =
"SELECT /*+READ_CONSISTENCY(WEAK)*/ svr_ip, svr_port, zone, status, start_service_time, stop_time "
"FROM oceanbase.%s "
"WHERE svr_port > 0 ORDER BY zone LIMIT %ld";
const static char *SELECT_CLUSTER_ROEL_SQL =
const static char *SELECT_CLUSTER_ROEL_SQL =
"SELECT /*+READ_CONSISTENCY(WEAK)*/ cluster_role, cluster_status, primary_cluster_id "
"FROM oceanbase.v$ob_cluster LIMIT 1";
const static char *SYS_LDG_INFO_SQL =
const static char *SYS_LDG_INFO_SQL =
"SELECT TENANT_ID, TENANT_NAME, CLUSTER_ID, CLUSTER_NAME, LDG_ROLE "
"FROM oceanbase.ldg_standby_status";
const static char *SELECT_ALL_TENANT_SQL =
const static char *SELECT_ALL_TENANT_SQL =
"SELECT /*+READ_CONSISTENCY(WEAK)*/ tenant_name, locality FROM oceanbase.__all_tenant "
"where previous_locality = '' and tenant_id != 1";
......@@ -1658,6 +1658,8 @@ int ObServerStateRefreshUtils::get_server_state_info(
} else {
if (server_state.zone_state_->is_readonly_zone()) {
server_state.replica_.replica_type_ = REPLICA_TYPE_READONLY;
} else if (server_state.zone_state_->is_encryption_zone()) {
server_state.replica_.replica_type_ = REPLICA_TYPE_ENCRYPTION_LOGONLY;
} else {
server_state.replica_.replica_type_ = REPLICA_TYPE_FULL;
}
......
......@@ -36,6 +36,7 @@ struct ObZoneStateInfo
int set_idc_name(const common::ObString &idc_name);
int64_t to_string(char *buffer, const int64_t size) const;
bool is_readonly_zone() { return common::ZONE_TYPE_READONLY == zone_type_; }
bool is_encryption_zone() { return common::ZONE_TYPE_ENCRYPTION == zone_type_; }
ObZoneStateInfo &operator=(const ObZoneStateInfo &other);
common::ObString zone_name_;
......
......@@ -29,9 +29,7 @@ obproxy/opsql/expr_parser/ob_expr_parser.h
opsql_expr_resolver_sources:=\
obproxy/opsql/expr_resolver/ob_expr_resolver.h\
obproxy/opsql/expr_resolver/ob_expr_resolver.cpp\
obproxy/opsql/expr_resolver/ob_proxy_obj_caster.h\
obproxy/opsql/expr_resolver/ob_proxy_obj_caster.cpp
obproxy/opsql/expr_resolver/ob_expr_resolver.cpp
opsql_func_expr_parser_sources:=\
obproxy/opsql/func_expr_parser/ob_func_expr_parser_lex.c\
......
/**
* Copyright (c) 2021 OceanBase
* OceanBase Database Proxy(ODP) is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* 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 PubL v2 for more details.
*/
#include "opsql/expr_resolver/ob_proxy_obj_caster.h"
using namespace oceanbase::common;
namespace oceanbase
{
namespace obproxy
{
namespace opsql
{
ObProxyObjCaster::ObProxyObjCaster(ObIAllocator &allocator) : allocator_(allocator)
, casted_cell_()
, cast_ctx_(&allocator_,
NULL,
CM_NONE,
CS_TYPE_UTF8MB4_GENERAL_CI)
{
}
int ObProxyObjCaster::cast(const ObObj orig_obj, const ObObjType expect_type, const ObObj *&res_obj)
{
return ObObjCasterV2::to_type(expect_type, cast_ctx_, orig_obj, casted_cell_, res_obj);
}
} // end of opsql
} // end of obproxy
} // end of oceanbase
......@@ -404,6 +404,7 @@ typedef struct _ObProxyParseResult
bool has_row_count_;
bool has_explain_;
bool has_simple_route_info_;
bool has_anonymous_block_;
ObProxyBasicStmtType stmt_type_;
ObProxyBasicStmtSubType sub_stmt_type_; //for sharding
int64_t stmt_count_;
......
......@@ -193,6 +193,15 @@ do {\
}\
return word_type;\
} while (0);
#define SET_HAS_ANONYMOUS_BLOCK() \
do { \
ObProxyParseResult *p = yyget_extra(yyscanner);\
if (OB_NOTNULL(p)) {\
if (OBPROXY_T_INVALID == p->cur_stmt_type_) {\
p->has_anonymous_block_ = true;\
} \
}\
} while (0);
#define PUSH_STATE(state) \
{ yy_push_state(state, yyscanner); }
......@@ -249,6 +258,7 @@ do {\
%x bt
%x bt_in_expr
%x in_expr
%x in_anonymous_block
%x in_subquery
%x in_no_select_query
%x prepare
......@@ -352,12 +362,14 @@ REPLACE { SET_DML_STMT(OBPROXY_T_REPLACE); return REPLACE; }
MERGE { SET_DML_STMT(OBPROXY_T_MERGE); return MERGE; }
SHOW { SET_BASIC_STMT(OBPROXY_T_SHOW); return SHOW; }
XA { RETURN_NON_RESERVED_KEYWORD(XA); }
BEGIN { RETURN_NON_RESERVED_KEYWORD(BEGI); }
/* if begin is for starting transaction, will set has_anonymous_block = false in yacc */
BEGIN { SET_HAS_ANONYMOUS_BLOCK(); RETURN_NON_RESERVED_KEYWORD(BEGI); }
START { RETURN_NON_RESERVED_KEYWORD(START); }
COMMIT { SET_BASIC_STMT(OBPROXY_T_COMMIT); RETURN_IGNORED_WORD(); }
ROLLBACK { SET_BASIC_STMT(OBPROXY_T_ROLLBACK); RETURN_IGNORED_WORD(); }
SET { SET_BASIC_STMT(OBPROXY_T_SET); PUSH_STATE_IF_NOT_ICMD(set_expr); return SET; }
CALL { SET_BASIC_STMT(OBPROXY_T_CALL); return CALL; }
DECLARE { SET_HAS_ANONYMOUS_BLOCK(); PUSH_STATE(in_anonymous_block); }
WHEN { ObProxyParseResult *p = yyget_extra(yyscanner);
if (OB_NOTNULL(p)) {
if (OBPROXY_T_INSERT == p->cur_stmt_type_)
......@@ -1030,6 +1042,9 @@ LAST_INSERT_ID { SET_LAST_INSERT_ID(); RETURN_NON_RESERVED_KEYWORD(NAME_OB); }
<prepare>{dquote} { POP_STATE(); }
<prepare>{quote} { POP_STATE(); }
<in_anonymous_block>"BEGIN" { POP_STATE(); return BEGI;}
<in_anonymous_block>. {}
<<EOF>> { return END_P; }
. { RETURN_IGNORED_WORD(); }
%%
......
......@@ -1007,7 +1007,10 @@ opt_count: /* empty */
| COUNT '*'
/* begin stmt */
begin_stmt: BEGI { result->cur_stmt_type_ = OBPROXY_T_BEGIN; }
begin_stmt: BEGI {
result->has_anonymous_block_ = false ;
result->cur_stmt_type_ = OBPROXY_T_BEGIN;
}
| START TRANSACTION opt_transaction_characteristics { result->cur_stmt_type_ = OBPROXY_T_BEGIN; }
| XA BEGI NAME_OB { result->cur_stmt_type_ = OBPROXY_T_BEGIN; }
| XA START NAME_OB { result->cur_stmt_type_ = OBPROXY_T_BEGIN; }
......
......@@ -235,12 +235,13 @@ void obproxyfree (void * ,yyscan_t yyscanner );
#define bt 13
#define bt_in_expr 14
#define in_expr 15
#define in_subquery 16
#define in_no_select_query 17
#define prepare 18
#define insert_all_expr 19
#define set_expr 20
#define show_topology 21
#define in_anonymous_block 16
#define in_subquery 17
#define in_no_select_query 18
#define prepare 19
#define insert_all_expr 20
#define set_expr 21
#define show_topology 22
#endif
......@@ -358,9 +359,9 @@ extern int obproxylex \
#undef YY_DECL
#endif
#line 1035 "ob_proxy_parser.l"
#line 1050 "ob_proxy_parser.l"
#line 365 "ob_proxy_parser_lex.h"
#line 366 "ob_proxy_parser_lex.h"
#undef obproxyIN_HEADER
#endif /* obproxyHEADER_H */
......@@ -1088,14 +1088,14 @@ static const yytype_uint16 yyrline[] =
941, 942, 946, 947, 950, 952, 953, 954, 955, 959,
960, 963, 965, 966, 967, 971, 972, 973, 977, 978,
979, 983, 987, 991, 992, 996, 997, 1001, 1002, 1003,
1006, 1007, 1010, 1011, 1012, 1013, 1015, 1016, 1018, 1019,
1022, 1023, 1026, 1032, 1035, 1037, 1038, 1039, 1041, 1046,
1049, 1053, 1057, 1062, 1066, 1072, 1073, 1074, 1075, 1076,
1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086,
1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096,
1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106,
1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1117,
1118
1006, 1007, 1010, 1014, 1015, 1016, 1018, 1019, 1021, 1022,
1025, 1026, 1029, 1035, 1038, 1040, 1041, 1042, 1044, 1049,
1052, 1056, 1060, 1065, 1069, 1075, 1076, 1077, 1078, 1079,
1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089,
1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099,
1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109,
1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1120,
1121
};
#endif
......@@ -4026,7 +4026,10 @@ yyreduce:
case 352:
{ result->cur_stmt_type_ = OBPROXY_T_BEGIN; ;}
{
result->has_anonymous_block_ = false ;
result->cur_stmt_type_ = OBPROXY_T_BEGIN;
;}
break;
case 353:
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册