Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不争之德
oceanbase
提交
2fd258cc
O
oceanbase
项目概览
不争之德
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2fd258cc
编写于
9月 09, 2021
作者:
G
gjw2284740
提交者:
wangzelin.wzl
9月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[opensource] add usec_tool
上级
751ce2ac
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
180 addition
and
10 deletion
+180
-10
tools/ob_admin/CMakeLists.txt
tools/ob_admin/CMakeLists.txt
+2
-0
tools/ob_admin/main.cpp
tools/ob_admin/main.cpp
+11
-5
tools/ob_admin/ob_admin_executor.cpp
tools/ob_admin/ob_admin_executor.cpp
+1
-1
tools/ob_admin/ob_admin_executor.h
tools/ob_admin/ob_admin_executor.h
+4
-4
tools/ob_admin/usec_tool/ob_admin_usec_executor.cpp
tools/ob_admin/usec_tool/ob_admin_usec_executor.cpp
+117
-0
tools/ob_admin/usec_tool/ob_admin_usec_executor.h
tools/ob_admin/usec_tool/ob_admin_usec_executor.h
+45
-0
未找到文件。
tools/ob_admin/CMakeLists.txt
浏览文件 @
2fd258cc
...
...
@@ -10,6 +10,8 @@ add_executable(ob_admin
clog_tool/ob_log_entry_filter.h
clog_tool/ob_log_entry_parser.cpp
clog_tool/ob_log_entry_parser.h
usec_tool/ob_admin_usec_executor.cpp
usec_tool/ob_admin_usec_executor.h
ob_admin_executor.h
ob_admin_executor.cpp
main.cpp
)
...
...
tools/ob_admin/main.cpp
浏览文件 @
2fd258cc
...
...
@@ -17,34 +17,40 @@
#include "share/ob_define.h"
#include "ob_admin_executor.h"
#include "clog_tool/ob_admin_clog_v2_executor.h"
#include "usec_tool/ob_admin_usec_executor.h"
using
namespace
oceanbase
::
common
;
using
namespace
oceanbase
::
tools
;
void
print_usage
()
{
fprintf
(
stderr
,
"
\n
Usage: ob_admin clog_tool
\n
"
);
fprintf
(
stderr
,
"
\n
USAGE:
\n
"
" ob_admin clog_tool
\n
"
" ob_admin usec_tool
\n
"
);
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
int
ret
=
0
;
OB_LOGGER
.
set_log_level
(
"INFO"
);
OB_LOGGER
.
set_file_name
(
"ob_admin.log"
,
true
,
false
);
const
char
*
log_level
=
getenv
(
"OB_ADMIN_LOG_LEVEL"
);
const
char
*
log_level
=
getenv
(
"OB_ADMIN_LOG_LEVEL"
);
if
(
NULL
!=
log_level
)
{
OB_LOGGER
.
set_log_level
(
log_level
);
}
std
::
ostringstream
ss
;
copy
(
argv
,
argv
+
argc
,
std
::
ostream_iterator
<
char
*>
(
ss
,
" "
));
copy
(
argv
,
argv
+
argc
,
std
::
ostream_iterator
<
char
*>
(
ss
,
" "
));
_OB_LOG
(
INFO
,
"cmd: [%s]"
,
ss
.
str
().
c_str
());
ObAdminExecutor
*
executor
=
NULL
;
ObAdminExecutor
*
executor
=
NULL
;
if
(
argc
<
2
)
{
print_usage
();
}
else
{
if
(
0
==
strcmp
(
"clog_tool"
,
argv
[
1
]))
{
executor
=
new
ObAdminClogV2Executor
();
}
else
if
(
0
==
strcmp
(
"usec_tool"
,
argv
[
1
]))
{
executor
=
new
ObAdminUsecExecutor
();
}
else
{
print_usage
();
}
...
...
tools/ob_admin/ob_admin_executor.cpp
浏览文件 @
2fd258cc
...
...
@@ -15,7 +15,7 @@
namespace
oceanbase
{
using
namespace
common
;
namespace
tools
{
int
ObAdminExecutor
::
parse_options
(
int
argc
,
char
*
argv
[])
int
ObAdminExecutor
::
parse_options
(
int
argc
,
char
*
argv
[])
{
int
ret
=
OB_SUCCESS
;
int
option_index
=
0
;
...
...
tools/ob_admin/ob_admin_executor.h
浏览文件 @
2fd258cc
...
...
@@ -25,17 +25,17 @@ public:
{}
virtual
~
ObAdminExecutor
()
{}
virtual
int
execute
(
int
argc
,
char
*
argv
[])
=
0
;
virtual
int
execute
(
int
argc
,
char
*
argv
[])
=
0
;
protected:
int
parse_options
(
int
argc
,
char
*
argv
[]);
int
parse_options
(
int
argc
,
char
*
argv
[]);
protected:
common
::
ObString
DB_host_
;
int32_t
DB_port_
;
uint64_t
tenant_id_
;
const
char
*
config_file_
;
const
char
*
wallet_file_
;
const
char
*
config_file_
;
const
char
*
wallet_file_
;
};
}
// namespace tools
}
// namespace oceanbase
...
...
tools/ob_admin/usec_tool/ob_admin_usec_executor.cpp
0 → 100644
浏览文件 @
2fd258cc
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE 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.
*/
#define USING_LOG_PREFIX COMMON
#include "ob_admin_usec_executor.h"
using
namespace
oceanbase
::
share
;
using
namespace
oceanbase
::
common
;
namespace
oceanbase
{
namespace
tools
{
ObAdminUsecExecutor
::
ObAdminUsecExecutor
()
:
cmd_
(
ObAdminUsecCmd
::
MAX_CMD
),
usec_
(
0
)
{}
int
ObAdminUsecExecutor
::
execute
(
int
argc
,
char
*
argv
[])
{
int
ret
=
OB_SUCCESS
;
reset
();
if
(
OB_FAIL
(
parse_cmd
(
argc
-
1
,
argv
+
1
)))
{
LOG_WARN
(
"fail to parse cmd"
,
K
(
ret
));
}
else
if
(
ObAdminUsecCmd
::
TO_TIME
==
cmd_
)
{
ObObj
result
;
int32_t
offset
=
0
;
char
buf
[
10
]
=
{
0
};
if
(
time_zone_
.
empty
())
{
// if the member time_zone is empty, we use UTC+8 by default.
time_zone_
.
assign_buffer
(
buf
,
10
);
strcpy
(
buf
,
"+8:00"
);
time_zone_
.
set_length
(
static_cast
<
int32_t
>
(
strlen
(
buf
)));
LOG_INFO
(
"use default time zone"
,
K_
(
time_zone
));
}
if
(
OB_FAIL
(
tz_info_
.
set_timezone
(
time_zone_
)))
{
LOG_WARN
(
"fail to set time zone"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
tz_info_
.
get_timezone_offset
(
USEC_TO_SEC
(
usec_
),
offset
)))
{
LOG_WARN
(
"fail to get offset between utc and local"
,
K
(
ret
));
}
else
{
usec_
+=
SEC_TO_USEC
(
offset
);
if
(
!
ObTimeConverter
::
is_valid_datetime
(
usec_
))
{
ret
=
OB_DATETIME_FUNCTION_OVERFLOW
;
LOG_WARN
(
"datetime overflow"
,
K
(
ret
),
K
(
usec_
));
}
else
{
result
.
set_timestamp
(
usec_
);
LOG_INFO
(
"usec to time"
,
K
(
result
),
K_
(
usec
),
K_
(
time_zone
),
K
(
offset
));
fprintf
(
stdout
,
"
\n
%s, UTC%s
\n
"
,
to_cstring
(
result
),
to_cstring
(
time_zone_
));
}
}
if
(
OB_FAIL
(
ret
))
{
print_usage
();
}
}
else
{
print_usage
();
}
return
ret
;
}
void
ObAdminUsecExecutor
::
reset
()
{
cmd_
=
ObAdminUsecCmd
::
MAX_CMD
;
usec_
=
0
;
}
int
ObAdminUsecExecutor
::
parse_cmd
(
int
argc
,
char
*
argv
[])
{
int
ret
=
OB_SUCCESS
;
int
opt
=
0
;
const
char
*
opt_string
=
"ht:z:"
;
struct
option
longopts
[]
=
{{
"help"
,
0
,
NULL
,
'h'
},
{
"to_time"
,
1
,
NULL
,
't'
},
{
"time_zone"
,
1
,
NULL
,
'z'
}};
while
((
opt
=
getopt_long
(
argc
,
argv
,
opt_string
,
longopts
,
NULL
))
!=
-
1
)
{
switch
(
opt
)
{
case
'h'
:
{
print_usage
();
break
;
}
case
't'
:
{
cmd_
=
ObAdminUsecCmd
::
TO_TIME
;
usec_
=
static_cast
<
int64_t
>
(
strtol
(
optarg
,
NULL
,
10
));
break
;
}
case
'z'
:
{
time_zone_
.
assign_ptr
(
optarg
,
strlen
(
optarg
));
break
;
}
default:
{
print_usage
();
ret
=
OB_INVALID_ARGUMENT
;
}
}
}
return
ret
;
}
void
ObAdminUsecExecutor
::
print_usage
()
{
fprintf
(
stderr
,
"
\n
USAGE:
\n
"
" ob_admin usec_tool -t usec [-z time_zone]
\n
"
"EXAMPLE:
\n
"
" ob_admin usec_tool -t 1625104800000000
\n
"
" ob_admin usec_tool -t 1625104800000000 -z +8:00
\n
"
" ob_admin usec_tool -t 1625104800000000 -z -8:00
\n
"
);
}
}
// namespace tools
}
// namespace oceanbase
tools/ob_admin/usec_tool/ob_admin_usec_executor.h
0 → 100644
浏览文件 @
2fd258cc
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE 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.
*/
#ifndef OB_ADMIN_USEC_EXECUTOR_H_
#define OB_ADMIN_USEC_EXECUTOR_H_
#include "../ob_admin_executor.h"
namespace
oceanbase
{
namespace
tools
{
enum
ObAdminUsecCmd
{
TO_TIME
,
MAX_CMD
,
};
class
ObAdminUsecExecutor
:
public
ObAdminExecutor
{
public:
ObAdminUsecExecutor
();
virtual
~
ObAdminUsecExecutor
()
=
default
;
virtual
int
execute
(
int
argc
,
char
*
argv
[]);
void
reset
();
private:
int
parse_cmd
(
int
argc
,
char
*
argv
[]);
void
print_usage
();
private:
ObAdminUsecCmd
cmd_
;
int64_t
usec_
;
common
::
ObString
time_zone_
;
ObTimeZoneInfo
tz_info_
;
};
}
// namespace tools
}
// namespace oceanbase
#endif
/* OB_ADMIN_USEC_EXECUTOR_H_ */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录