Skip to content

Commit

Permalink
Add 'reconnect' to prdcr_start* to deprecate 'interval'
Browse files Browse the repository at this point in the history
ldmsd reports a warning message that 'interval' is being deprecated if
'interval' is used.
  • Loading branch information
nichamon committed Jun 17, 2024
1 parent 83ab2a2 commit 8f859ee
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 37 deletions.
14 changes: 11 additions & 3 deletions ldms/man/ldmsctl.man
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ A unit string is one of the followings:
.TP
.BI interval " interval"
.br
The connection retry interval. Deprecated. Please use 'reconnect'.
It is being precated. Please use 'reconnect'.
.TP
.BI [perm " permission"]
.br
Expand Down Expand Up @@ -263,7 +263,7 @@ attr=<value>
.br
The producer name
.TP
.BI [interval " interval"]
.BI [reconnect " interval"]
.br
The connection retry interval, which is a float followed by a unit string.
If no unit string is given, the default unit is microseconds.
Expand All @@ -275,6 +275,10 @@ A unit string is one of the followings:
h -- hours
d -- days
If unspecified, the previously configured value will be used. Optional.
.TP
.BI [interval " interval"]
.br
It is being deprecated. Please use 'reconnect'.
.RE

.SS Start all producers matching a regular expression
Expand All @@ -286,7 +290,7 @@ attr=<value>
.br
A regular expression
.TP
.BI [interval " interval"]
.BI [reconnect " interval"]
.br
The connection retry interval, which is a float followed by a unit string.
If no unit string is given, the default unit is microseconds.
Expand All @@ -298,6 +302,10 @@ A unit string is one of the followings:
h -- hours
d -- days
If unspecified, the previously configured value will be used. Optional.
.TP
.BI [interval " interval"]
.br
It is being deprecated. Please use 'reconnect'.
.RE

.SS Stop a producer
Expand Down
14 changes: 11 additions & 3 deletions ldms/man/ldmsd_controller.man
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ A unit string is one of the followings:
.TP
.BI interval " interval"
.br
The connection retry interval. Deprecated. Please use 'reconnect'.
It is being deprecated. Please use 'reconnect'.
.TP
.BI [perm " permission"]
.br
Expand Down Expand Up @@ -323,7 +323,7 @@ attr=<value>
.br
The producer name
.TP
.BI [interval " interval"]
.BI [reconnect " interval"]
.br
The connection retry interval, which is a float followed by a unit string.
If no unit string is given, the default unit is microseconds.
Expand All @@ -335,6 +335,10 @@ A unit string is one of the followings:
h -- hours
d -- days
If unspecified, the previously configured value will be used. Optional.
.TP
.BI [interval " interval"]
.br
It is being deprecated. Please use 'reconnect'.
.RE

.SS Start all producers matching a regular expression
Expand All @@ -346,7 +350,7 @@ attr=<value>
.br
A regular expression
.TP
.BI [interval " interval"]
.BI [reconnect " interval"]
.br
The connection retry interval, which is a float followed by a unit stirng.
If no unit string is given, the default unit is microseconds.
Expand All @@ -358,6 +362,10 @@ A unit string is one of the followings:
h -- hours
d -- days
If unspecified, the previously configured value will be used. Optional.
.TP
.BI [interval " interval"]
.br
It is being deprecated. Please use 'reconnect'.
.RE

.SS Stop a producer
Expand Down
10 changes: 4 additions & 6 deletions ldms/python/ldmsd/ldmsd_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@
'opt_attr' : [ 'auth', 'perm', 'interval', 'reconnect' ] },
'prdcr_del': {'req_attr': ['name']},
'prdcr_start': {'req_attr': ['name'],
'opt_attr': ['interval']},
'opt_attr': ['interval', 'reconnect']},
'prdcr_stop': {'req_attr': ['name']},
'prdcr_start_regex': {'req_attr': ['regex'],
'opt_attr': ['interval']},
'opt_attr': ['interval', 'reconnect']},
'prdcr_stop_regex': {'req_attr': ['regex']},
'prdcr_status': {'req_attr': [], 'opt_attr':['name']},
'prdcr_set_status': {'opt_attr': ['producer', 'instance', 'schema']},
Expand Down Expand Up @@ -260,7 +260,6 @@ class LDMSD_Req_Attr(object):
RESET = 36
DECOMPOSITION = 37
SUMMARY = 38
RECONNECT = 39
LAST = 40

NAME_ID_MAP = {'name': NAME,
Expand Down Expand Up @@ -304,7 +303,7 @@ class LDMSD_Req_Attr(object):
'auth': AUTH,
'decomposition' : DECOMPOSITION,
'summary' : SUMMARY,
'reconnect' : RECONNECT,
'reconnect' : INTERVAL,
'TERMINATING': LAST
}

Expand Down Expand Up @@ -346,7 +345,6 @@ class LDMSD_Req_Attr(object):
AUTH : 'auth',
DECOMPOSITION : 'decomposition',
SUMMARY : 'summary',
RECONNECT : 'reconnect',
LAST : 'TERMINATING'
}

Expand Down Expand Up @@ -1985,7 +1983,7 @@ def prdcr_add(self, name, ptype, xprt, host, port, reconnect, auth=None, perm=No
LDMSD_Req_Attr(attr_id = LDMSD_Req_Attr.XPRT, value=xprt),
LDMSD_Req_Attr(attr_id = LDMSD_Req_Attr.HOST, value=host),
LDMSD_Req_Attr(attr_id = LDMSD_Req_Attr.PORT, value=str(port)),
LDMSD_Req_Attr(attr_id = LDMSD_Req_Attr.RECONNECT, value=str(reconnect))
LDMSD_Req_Attr(attr_id = LDMSD_Req_Attr.INTERVAL, value=str(reconnect))
]
if auth:
attrs.append(LDMSD_Req_Attr(attr_id=LDMSD_Req_Attr.AUTH, value=auth))
Expand Down
18 changes: 13 additions & 5 deletions ldms/python/ldmsd/ldmsd_controller
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class LdmsdCmdParser(cmd.Cmd):
print(f"Both 'interval' and 'reconnect' is given. The 'reconnect' value will be used.")
else:
arg['reconnect'] = arg['interval']
print(f"'interval' is being deprecated'. Please, use 'reconnect' in the future.")
print(f"'interval' is being deprecated. Please, use 'reconnect' in the future.")
rc, msg = self.comm.prdcr_add(arg['name'],
arg['type'],
arg['xprt'],
Expand Down Expand Up @@ -407,12 +407,16 @@ class LdmsdCmdParser(cmd.Cmd):
Start the specified producer.
Parameters:
name= The name of the producer
[interval=] The connection retry interval in micro-seconds. If this is not
[reconnect=] The connection retry interval in micro-seconds. If this is not
specified, the previously configured value will be used.
[interval=] The same as reconnect. It is being deprecated. Please use 'reconnect'.
"""
arg = self.handle_args('prdcr_start', arg)
if arg:
rc, msg = self.comm.prdcr_start(arg['name'], regex=False, reconnect=arg['interval'])
if arg['reconnect'] is None and arg['interval'] is not None:
arg['reconnect'] = arg['interval']
print(f"'interval' is being deprecated. Please, use 'reconnect' in the future")
rc, msg = self.comm.prdcr_start(arg['name'], regex=False, reconnect=arg['reconnect'])
if rc:
print(f'Error starting prdcr {arg["name"]}: {msg}')

Expand All @@ -424,12 +428,16 @@ class LdmsdCmdParser(cmd.Cmd):
Start all producers matching a regular expression.
Parameters:
regex= A regular expression
[interval=] The connection retry interval in micro-seconds. If this is not
[reconnect=] The connection retry interval in micro-seconds. If this is not
specified, the previously configured value will be used.
[interval=] The same as reconnect. It is being deprecated. Please use 'reconnect'.
"""
arg = self.handle_args('prdcr_start_regex', arg)
if arg:
rc, msg = self.comm.prdcr_start(arg['regex'], reconnect=arg['interval'])
if arg['reconnect'] is None and arg['interval'] is not None:
arg['reconnect'] = arg['interval']
print(f"'interval' is being deprecated. Please, use 'reconnect' in the future.")
rc, msg = self.comm.prdcr_start(arg['regex'], reconnect=arg['reconnect'])
if rc:
print(f'Error starting prdcr(s) with regex {arg["regex"]}: {msg}')

Expand Down
25 changes: 18 additions & 7 deletions ldms/src/ldmsd/ldmsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,11 @@ static void help_prdcr_start()
printf( "\nStart the specified producer.\n\n"
"Parameters:\n"
" name= The name of the producer\n"
" [interval=] The connection retry interval in micro-seconds.\n"
" If this is not specified, the previously\n"
" configured value will be used.\n");
" [reconnect=] The connection retry interval in micro-seconds.\n"
" If this is not specified, the previously\n"
" configured value will be used.\n"
" [interval=] The same as 'reconnect'. It is being deprecated. "
" Please use 'reconnect' in the future.\n");
}

static void help_prdcr_stop()
Expand All @@ -493,10 +495,12 @@ static void help_prdcr_start_regex()
{
printf( "\nStart all producers matching a regular expression.\n\n"
"Parameters:\n\n"
" regex= A regular expression\n"
" [interval=] The connection retry interval in micro-seconds.\n"
" If this is not specified, the previously configured\n"
" value will be used.\n");
" regex= A regular expression\n"
" [reconnect=] The connection retry interval in micro-seconds.\n"
" If this is not specified, the previously configured\n"
" value will be used.\n"
" [interval=] The same as 'reconnect'. It is being deprecated. "
" Please use 'reconnect' in the future.\n");
}

static void help_prdcr_stop_regex()
Expand Down Expand Up @@ -2593,6 +2597,13 @@ static int __handle_cmd(struct ldmsctl_ctrl *ctrl, char *cmd_str)
return 0;
}

if ((0 == strcmp(key.token, "prdcr_add")) ||
(0 == strncmp(key.token, "prdcr_start", 11))) {
if (strstr(cmd_str, "interval")) {
printf("'interval' is begin deprecated. Please use 'reconnect' in the future.\n");
}
}

if (cmd->action) {
(void)cmd->action(ctrl, args);
free(dummy);
Expand Down
12 changes: 12 additions & 0 deletions ldms/src/ldmsd/ldmsd_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,18 @@ int __process_config_file(const char *path, int *lno, int trust,
if (!off)
goto next_line;

if (ldmsd_is_initialized()) {
if ((0 == strncmp(line, "prdcr_add", 9)) ||
(0 == strncmp(line, "prdcr_start", 11))) {
if (strstr(line, "interval")) {
ldmsd_log(LDMSD_LWARNING,
"'interval' is begin deprecated. "
"Please use 'reconnect' with 'prdcr_add' or 'prdcr_start*' "
"in the future.\n");
}
}
}

req_array = ldmsd_parse_config_str(line, msg_no, xprt.max_msg, ldmsd_log);
if (!req_array) {
rc = errno;
Expand Down
15 changes: 4 additions & 11 deletions ldms/src/ldmsd/ldmsd_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -1533,13 +1533,7 @@ static int prdcr_add_handler(ldmsd_req_ctxt_t reqc)
}

attr_name = "reconnect";
interval_s = ldmsd_req_attr_str_value_get_by_id(reqc, LDMSD_ATTR_RECONNECT);
if (!interval_s) {
interval_s = ldmsd_req_attr_str_value_get_by_id(reqc, LDMSD_ATTR_INTERVAL);
ldmsd_log(LDMSD_LWARNING, "The 'interval' in prdcr_add is "
"being deprecrated. Please use 'reconnect' instead.\n");
}

interval_s = ldmsd_req_attr_str_value_get_by_id(reqc, LDMSD_ATTR_INTERVAL);
if (!interval_s) {
goto einval;
} else {
Expand Down Expand Up @@ -1582,7 +1576,7 @@ static int prdcr_add_handler(ldmsd_req_ctxt_t reqc)
goto enomem;
}
__dlog(DLOG_CFGOK, "prdcr_add name=%s xprt=%s host=%s port=%u type=%s "
"interval=%ld auth=%s uid=%d gid=%d perm=%o\n",
"reconnect=%ld auth=%s uid=%d gid=%d perm=%o\n",
name, xprt, host, port_no, type_s,
interval_us, auth ? auth : "none", (int)uid, (int)gid,
(unsigned)perm);
Expand Down Expand Up @@ -1697,7 +1691,7 @@ static int prdcr_start_handler(ldmsd_req_ctxt_t reqc)
reqc->errcode = ldmsd_prdcr_start(name, interval_str, &sctxt);
switch (reqc->errcode) {
case 0:
__dlog(DLOG_CFGOK, "prdcr_start name=%s interval=%s\n",
__dlog(DLOG_CFGOK, "prdcr_start name=%s reconnect=%s\n",
name, interval_str);
break;
case EBUSY:
Expand Down Expand Up @@ -1798,15 +1792,14 @@ static int prdcr_start_regex_handler(ldmsd_req_ctxt_t reqc)
}

interval_str = ldmsd_req_attr_str_value_get_by_id(reqc, LDMSD_ATTR_INTERVAL);

ldmsd_req_ctxt_sec_get(reqc, &sctxt);

reqc->errcode = ldmsd_prdcr_start_regex(prdcr_regex, interval_str,
reqc->line_buf, reqc->line_len, &sctxt);
/* on error, reqc->line_buf will be filled */
if (reqc->line_buf[0] == '\0' || reqc->line_buf[0] == '0')
__dlog(DLOG_CFGOK, "prdcr_start_regex regex=%s%s%s\n",
prdcr_regex, interval_str ? " interval=" :"",
prdcr_regex, interval_str ? " reconnect=" :"",
interval_str ? interval_str : "");

send_reply:
Expand Down
1 change: 0 additions & 1 deletion ldms/src/ldmsd/ldmsd_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ enum ldmsd_request_attr {
LDMSD_ATTR_RESET,
LDMSD_ATTR_DECOMP,
LDMSD_ATTR_SUMMARY,
LDMSD_ATTR_RECONNECT,
LDMSD_ATTR_LAST,
};

Expand Down
1 change: 0 additions & 1 deletion ldms/src/ldmsd/ldmsd_request_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ const struct req_str_id attr_str_id_table[] = {
{ "port", LDMSD_ATTR_PORT },
{ "producer", LDMSD_ATTR_PRODUCER },
{ "push", LDMSD_ATTR_PUSH },
{ "reconnect", LDMSD_ATTR_RECONNECT },
{ "regex", LDMSD_ATTR_REGEX },
{ "schema", LDMSD_ATTR_SCHEMA },
{ "stream", LDMSD_ATTR_STREAM },
Expand Down

0 comments on commit 8f859ee

Please sign in to comment.