From: Adam Stokes astokes@fedoraproject.org
- We hardcoded reconnect to True in our agent code but this can hinder us when wanting to automate testing. We set reconnect to false by default and have the user decide whether or not they want their agents to keep trying to connect to a failed/misconfigured broker. --- src/lib/mh_agent.cpp | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/lib/mh_agent.cpp b/src/lib/mh_agent.cpp index d8f8417..23f5e3f 100644 --- a/src/lib/mh_agent.cpp +++ b/src/lib/mh_agent.cpp @@ -91,6 +91,7 @@ struct option opt[] = { {"password", required_argument, NULL, 'P'}, {"service", required_argument, NULL, 's'}, {"port", required_argument, NULL, 'p'}, + {"reconnect", no_argument, NULL, 'r'}, {0, 0, 0, 0} };
@@ -106,6 +107,7 @@ print_usage(const char *proc_name) printf("\t-P | --password password to use for authentication purproses.\n"); printf("\t-s | --service service name to use for authentication purproses.\n"); printf("\t-p | --port specify broker port.\n"); + printf("\t-r | --reconnect attempt to reconnect on failure.\n"); } #endif
@@ -140,6 +142,7 @@ MatahariAgent::init(int argc, char **argv, const char* proc_name) #endif
bool gssapi = false; + bool reconnect = false; char *servername = NULL; char *username = NULL; char *password = NULL; @@ -201,7 +204,7 @@ MatahariAgent::init(int argc, char **argv, const char* proc_name) #else
// Get args - while ((arg = getopt_long(argc, argv, "hdb:gu:P:s:p:v", opt, &idx)) != -1) { + while ((arg = getopt_long(argc, argv, "hdb:gru:P:s:p:v", opt, &idx)) != -1) { switch (arg) { case 'h': case '?': @@ -242,6 +245,9 @@ MatahariAgent::init(int argc, char **argv, const char* proc_name) case 'g': gssapi = true; break; + case 'r': + reconnect = true; + break; case 'p': if (optarg) { serverport = atoi(optarg); @@ -288,7 +294,7 @@ MatahariAgent::init(int argc, char **argv, const char* proc_name)
// Create a v2 API options map. qpid::types::Variant::Map options; - options["reconnect"] = bool(true); + options["reconnect"] = reconnect; if (username && *username) { options["username"] = username; }
On Mon, May 9, 2011 at 3:06 PM, astokes@fedoraproject.org wrote:
From: Adam Stokes astokes@fedoraproject.org
- We hardcoded reconnect to True in our agent code but this can hinder us when wanting to automate testing. We set reconnect to false by default and have the user decide whether or not they want their agents to keep trying to connect to a failed/misconfigured broker.
Add Signed-off-by:
This code looks good to me. Do you want to keep the options for Windows and everything else in sync? If so, some registry read code needs to be added for this new option. If not, ACK.
Add Signed-off-by:
This code looks good to me. Do you want to keep the options for Windows and everything else in sync? If so, some registry read code needs to be added for this new option. If not, ACK.
-- Russell Bryant
Do you think something like this should be in a registry setting for Windows? I didn't see one for gssapi boolean so I figured this could go along that path. What do you think?
Thanks
On Mon, May 9, 2011 at 8:31 PM, Adam Stokes adam.stokes@gmail.com wrote:
Add Signed-off-by:
This code looks good to me. Do you want to keep the options for Windows and everything else in sync? If so, some registry read code needs to be added for this new option. If not, ACK.
-- Russell Bryant
Do you think something like this should be in a registry setting for Windows? I didn't see one for gssapi boolean so I figured this could go along that path. What do you think?
I just thought I remembered that being the way all options were handled for Windows. I was just pointing out that it looked like this option would be non-Windows only. It seems like it would be good to try to keep the options in sync across all platforms unless there is a really good reason not to for a particular option.
On Mon, May 9, 2011 at 10:06 PM, astokes@fedoraproject.org wrote:
From: Adam Stokes astokes@fedoraproject.org
- We hardcoded reconnect to True in our agent code but this can hinder us when wanting to automate testing. We set reconnect to false by default and have the user decide whether or not they want their agents to keep trying to connect to a failed/misconfigured broker.
The code part is fine, but we need to turn it on by default in our sysconfig file. Both for compatibility reasons and because thats what most people are going to want.
src/lib/mh_agent.cpp | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/lib/mh_agent.cpp b/src/lib/mh_agent.cpp index d8f8417..23f5e3f 100644 --- a/src/lib/mh_agent.cpp +++ b/src/lib/mh_agent.cpp @@ -91,6 +91,7 @@ struct option opt[] = { {"password", required_argument, NULL, 'P'}, {"service", required_argument, NULL, 's'}, {"port", required_argument, NULL, 'p'},
- {"reconnect", no_argument, NULL, 'r'},
{0, 0, 0, 0} };
@@ -106,6 +107,7 @@ print_usage(const char *proc_name) printf("\t-P | --password password to use for authentication purproses.\n"); printf("\t-s | --service service name to use for authentication purproses.\n"); printf("\t-p | --port specify broker port.\n");
- printf("\t-r | --reconnect attempt to reconnect on failure.\n");
} #endif
@@ -140,6 +142,7 @@ MatahariAgent::init(int argc, char **argv, const char* proc_name) #endif
bool gssapi = false;
- bool reconnect = false;
char *servername = NULL; char *username = NULL; char *password = NULL; @@ -201,7 +204,7 @@ MatahariAgent::init(int argc, char **argv, const char* proc_name) #else
// Get args
- while ((arg = getopt_long(argc, argv, "hdb:gu:P:s:p:v", opt, &idx)) != -1) {
- while ((arg = getopt_long(argc, argv, "hdb:gru:P:s:p:v", opt, &idx)) != -1) {
switch (arg) { case 'h': case '?': @@ -242,6 +245,9 @@ MatahariAgent::init(int argc, char **argv, const char* proc_name) case 'g': gssapi = true; break;
- case 'r':
- reconnect = true;
- break;
case 'p': if (optarg) { serverport = atoi(optarg); @@ -288,7 +294,7 @@ MatahariAgent::init(int argc, char **argv, const char* proc_name)
// Create a v2 API options map. qpid::types::Variant::Map options;
- options["reconnect"] = bool(true);
- options["reconnect"] = reconnect;
if (username && *username) { options["username"] = username; } -- 1.7.4.4
Matahari mailing list Matahari@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/matahari
On Tue, May 10, 2011 at 6:40 AM, Andrew Beekhof andrew@beekhof.net wrote:
On Mon, May 9, 2011 at 10:06 PM, astokes@fedoraproject.org wrote:
From: Adam Stokes astokes@fedoraproject.org
- We hardcoded reconnect to True in our agent code but this can hinder us when wanting to automate testing. We set reconnect to false by default and have the user decide whether or not they want their agents to keep trying to connect to a failed/misconfigured broker.
The code part is fine, but we need to turn it on by default in our sysconfig file. Both for compatibility reasons and because thats what most people are going to want.
If that's the default you want, why not make it that way in the code?
On Tue, May 10, 2011 at 4:35 PM, Russell Bryant russell@russellbryant.net wrote:
On Tue, May 10, 2011 at 6:40 AM, Andrew Beekhof andrew@beekhof.net wrote:
On Mon, May 9, 2011 at 10:06 PM, astokes@fedoraproject.org wrote:
From: Adam Stokes astokes@fedoraproject.org
- We hardcoded reconnect to True in our agent code but this can hinder us when wanting to automate testing. We set reconnect to false by default and have the user decide whether or not they want their agents to keep trying to connect to a failed/misconfigured broker.
The code part is fine, but we need to turn it on by default in our sysconfig file. Both for compatibility reasons and because thats what most people are going to want.
If that's the default you want, why not make it that way in the code?
because --reconnect is clear and concise and has an obvious short form but negating it you get something like --do-not-reconnect and -d. which isn't ideal.
unless we make it --reconnect {bool}, but then is it True, true, TRUE or 1? Annoying.
i could also just be over thinking it :-)
On Tue, May 10, 2011 at 9:43 AM, Andrew Beekhof andrew@beekhof.net wrote:
On Tue, May 10, 2011 at 4:35 PM, Russell Bryant russell@russellbryant.net wrote:
On Tue, May 10, 2011 at 6:40 AM, Andrew Beekhof andrew@beekhof.net wrote:
On Mon, May 9, 2011 at 10:06 PM, astokes@fedoraproject.org wrote:
From: Adam Stokes astokes@fedoraproject.org
- We hardcoded reconnect to True in our agent code but this can hinder us when wanting to automate testing. We set reconnect to false by default and have the user decide whether or not they want their agents to keep trying to connect to a failed/misconfigured broker.
The code part is fine, but we need to turn it on by default in our sysconfig file. Both for compatibility reasons and because thats what most people are going to want.
If that's the default you want, why not make it that way in the code?
because --reconnect is clear and concise and has an obvious short form but negating it you get something like --do-not-reconnect and -d. which isn't ideal.
unless we make it --reconnect {bool}, but then is it True, true, TRUE or 1? Annoying.
i could also just be over thinking it :-)
Sure, make it a boolean option. --reconnect [yes|no]. It doesn't really matter as long as it's documented. Speaking of which, where should these options be documented?
I'm just saying make the code the definitive place where defaults are handled. One reason is portability. Not every system has /etc/sysconfig, right?
On Tue, May 10, 2011 at 9:14 PM, Russell Bryant russell@russellbryant.net wrote:
On Tue, May 10, 2011 at 9:43 AM, Andrew Beekhof andrew@beekhof.net wrote:
On Tue, May 10, 2011 at 4:35 PM, Russell Bryant russell@russellbryant.net wrote:
On Tue, May 10, 2011 at 6:40 AM, Andrew Beekhof andrew@beekhof.net wrote:
On Mon, May 9, 2011 at 10:06 PM, astokes@fedoraproject.org wrote:
From: Adam Stokes astokes@fedoraproject.org
- We hardcoded reconnect to True in our agent code but this can hinder us when wanting to automate testing. We set reconnect to false by default and have the user decide whether or not they want their agents to keep trying to connect to a failed/misconfigured broker.
The code part is fine, but we need to turn it on by default in our sysconfig file. Both for compatibility reasons and because thats what most people are going to want.
If that's the default you want, why not make it that way in the code?
because --reconnect is clear and concise and has an obvious short form but negating it you get something like --do-not-reconnect and -d. which isn't ideal.
unless we make it --reconnect {bool}, but then is it True, true, TRUE or 1? Annoying.
i could also just be over thinking it :-)
Sure, make it a boolean option. --reconnect [yes|no]. It doesn't really matter as long as it's documented.
You're probably right. Adam: Can you take care of this please?
Speaking of which, where should these options be documented?
For now they're all in print_usage() because all agents support exactly the same options.
I'm just saying make the code the definitive place where defaults are handled.
Agreed
One reason is portability. Not every system has /etc/sysconfig, right?
-- Russell Bryant
matahari@lists.fedorahosted.org