提交 b961b30c 编写于 作者: B Bhuvnesh Chaudhary

wip

上级 fd5f11ba
......@@ -14,6 +14,7 @@ typedef struct {
segmentMode segment_mode;
checksumMode checksum_mode;
char *old_tablespace_file_path;
bool timing;
} GreenplumUserOpts;
static GreenplumUserOpts greenplum_user_opts;
......@@ -69,6 +70,10 @@ process_greenplum_option(greenplumOption option, char *option_value)
greenplum_user_opts.old_tablespace_file_path = pg_strdup(optarg);
break;
case GREENPLUM_TIMING:
greenplum_user_opts.timing = true;
break;
default:
return false;
}
......@@ -110,3 +115,9 @@ is_show_progress_mode(void)
{
return greenplum_user_opts.progress;
}
bool
is_timing_on(void)
{
return greenplum_user_opts.timing;
}
......@@ -9,6 +9,7 @@
#include "pg_upgrade.h"
#include <portability/instr_time.h>
#define PG_OPTIONS_UTILITY_MODE " PGOPTIONS='-c gp_session_role=utility' "
......@@ -43,7 +44,8 @@ typedef enum {
GREENPLUM_REMOVE_CHECKSUM_OPTION = 4,
GREENPLUM_OLD_GP_DBID = 5,
GREENPLUM_NEW_GP_DBID = 6,
GREENPLUM_OLD_TABLESPACES_FILE = 7
GREENPLUM_OLD_TABLESPACES_FILE = 7,
GREENPLUM_TIMING = 8,
} greenplumOption;
......@@ -54,7 +56,8 @@ typedef enum {
{"remove-checksum", no_argument, NULL, GREENPLUM_REMOVE_CHECKSUM_OPTION}, \
{"old-gp-dbid", required_argument, NULL, GREENPLUM_OLD_GP_DBID}, \
{"new-gp-dbid", required_argument, NULL, GREENPLUM_NEW_GP_DBID}, \
{"old-tablespaces-file", required_argument, NULL, GREENPLUM_OLD_TABLESPACES_FILE},
{"old-tablespaces-file", required_argument, NULL, GREENPLUM_OLD_TABLESPACES_FILE}, \
{"timing", no_argument, NULL, GREENPLUM_TIMING},
#define GREENPLUM_USAGE "\
--mode=TYPE designate node type to upgrade, \"segment\" or \"dispatcher\" (default \"segment\")\n\
......@@ -64,6 +67,7 @@ typedef enum {
--old-gp-dbid greenplum database id of the old segment\n\
--new-gp-dbid greenplum database id of the new segment\n\
--old-tablespaces-file file containing the tablespaces from an old gpdb five cluster\n\
--timing enable timing\n\
"
/* option_gp.c */
......@@ -73,6 +77,7 @@ bool is_greenplum_dispatcher_mode(void);
bool is_checksum_mode(checksumMode mode);
bool is_show_progress_mode(void);
void validate_greenplum_options(void);
bool is_timing_on(void);
/* pg_upgrade_greenplum.c */
void freeze_all_databases(void);
......@@ -118,6 +123,7 @@ void check_greenplum(void);
void report_progress(ClusterInfo *cluster, progress_type op, char *fmt,...)
pg_attribute_printf(3, 4);
void close_progress(void);
void duration(instr_time duration, char *res);
/* tablespace_gp.c */
......@@ -135,4 +141,11 @@ is_gpdb6(ClusterInfo *cluster)
return GET_MAJOR_VERSION(cluster->major_version) == 904;
}
static struct {
instr_time start_time;
instr_time end_time;
} step_timing;
void check_ok_with_timing(void);
#endif /* PG_UPGRADE_GREENPLUM_H */
......@@ -126,3 +126,21 @@ close_progress(void)
progress_counter = 0;
progress_prev = epoch_us();
}
void
duration(instr_time duration, char *res)
{
int seconds = INSTR_TIME_GET_DOUBLE(duration);
int h = (seconds/3600);
int m = (seconds -(3600*h))/60;
int s = (seconds -(3600*h)-(m*60));
if (h>0) {
sprintf(res, "[ %dh%dm%ds ]", h, m, s);
} else if (m>0) {
sprintf(res, "[ %dm%ds ]", m, s);
} else if (s>0){
sprintf(res, "[ %ds ]", s);
} else {
sprintf(res, "[ %.3f ms ]", INSTR_TIME_GET_MILLISEC(duration));
}
}
\ No newline at end of file
......@@ -38,6 +38,9 @@ void
transfer_all_new_tablespaces(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
char *old_pgdata, char *new_pgdata)
{
if (is_timing_on())
INSTR_TIME_SET_CURRENT(step_timing.start_time);
pg_log(PG_REPORT, "%s user relation files\n",
user_opts.transfer_mode == TRANSFER_MODE_LINK ? "Linking" : "Copying");
......
......@@ -70,6 +70,9 @@ prep_status(const char *fmt,...)
va_list args;
char message[MAX_STRING];
if (is_timing_on())
INSTR_TIME_SET_CURRENT(step_timing.start_time);
va_start(args, fmt);
vsnprintf(message, sizeof(message), fmt, args);
va_end(args);
......@@ -168,13 +171,29 @@ pg_fatal(const char *fmt,...)
exit(1);
}
void
check_ok_with_timing(void)
{
char *elapsed_time = "adsfasdfa";
INSTR_TIME_SET_CURRENT(step_timing.end_time);
INSTR_TIME_SUBTRACT(step_timing.end_time, step_timing.start_time);
// duration(step_timing.end_time, elapsed_time);
report_status(PG_REPORT, "ok %s", elapsed_time);
fflush(stdout);
// pfree(elapsed_time);
}
void
check_ok(void)
{
/* all seems well */
report_status(PG_REPORT, "ok");
fflush(stdout);
if (is_timing_on())
check_ok_with_timing();
else {
/* all seems well */
report_status(PG_REPORT, "ok");
fflush(stdout);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册