You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by jo...@apache.org on 2010/12/22 23:22:14 UTC
svn commit: r1052086 - in /qpid/trunk/qpid: extras/qmf/src/py/qmf/console.py
tools/src/py/qpid-config tools/src/py/qpid-printevents
tools/src/py/qpid-stat tools/src/py/qpid-tool
Author: jonathan
Date: Wed Dec 22 22:22:13 2010
New Revision: 1052086
URL: http://svn.apache.org/viewvc?rev=1052086&view=rev
Log:
Added logging to QMF console connections.
Warning if a broker can not be found, error if SASL authentication fails or other connection errors when connecting to an existing broker. Default log level is ERROR.
qpid-printevents allows the log level to be set. It also allows the user to specify that a connection is required, in which case it terminates if a connection can not be established.
Examples:
$ ./qpid-printevents --sasl-mechanism PLAIN nonexistent-broker
=> Not an error. Waits for the broker to be started.
$ ./qpid-printevents --sasl-mechanism PLAIN localhost
2010-12-22 17:07:18,365 ERROR Could not connect to broker localhost:5672 (None, 'No acceptable SASL authentication mechanism available')
=> Connection error condition in output - SASL authentication failed
because user name and password are not supplied.
But qpid-printevents keeps running, waiting for you to start the
broker.
$ ./qpid-printevents --sasl-mechanism PLAIN --log-level critical
=> Connection error condition in output - SASL authentication failed
because user name and password are not supplied.
No output in this case, because the log level has been set to
critical.
$ ./qpid-printevents --sasl-mechanism PLAIN --require-connection localhost
2010-12-22 17:11:03,791 ERROR Could not connect to broker localhost:5672 (None, 'No acceptable SASL authentication mechanism available')
Failed: ConnectionFailed - (None, 'No acceptable SASL authentication mechanism available')
=> Connection error condition.
qpid-printevents terminates because --require-connection was specified.
Modified:
qpid/trunk/qpid/extras/qmf/src/py/qmf/console.py
qpid/trunk/qpid/tools/src/py/qpid-config
qpid/trunk/qpid/tools/src/py/qpid-printevents
qpid/trunk/qpid/tools/src/py/qpid-stat
qpid/trunk/qpid/tools/src/py/qpid-tool
Modified: qpid/trunk/qpid/extras/qmf/src/py/qmf/console.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/extras/qmf/src/py/qmf/console.py?rev=1052086&r1=1052085&r2=1052086&view=diff
==============================================================================
--- qpid/trunk/qpid/extras/qmf/src/py/qmf/console.py (original)
+++ qpid/trunk/qpid/extras/qmf/src/py/qmf/console.py Wed Dec 22 22:22:13 2010
@@ -39,8 +39,8 @@ from Queue import Queue, Empty
from time import time, strftime, gmtime, sleep
from cStringIO import StringIO
-#import qpid.log
-#qpid.log.enable(name="qpid.io.cmd", level=qpid.log.DEBUG)
+import qpid.log
+qpid.log.enable(name="qpid.qmf")
#===================================================================================================
# CONSOLE
@@ -2509,6 +2509,14 @@ class Broker(Thread):
except Exception, e:
self.error = "Exception during connection setup: %s - %s" % (e.__class__.__name__, e)
+
+ log = qpid.log.getLogger("qpid.qmf")
+
+ if e[0] == -2:
+ log.warning("Could not connect to broker " + self.host + ":" + str(self.port) + " " + str(e))
+ else:
+ log.error("Could not connect to broker " + self.host + ":" + str(self.port) + " " + str(e))
+
self.conn_exc = e
return False # connection failed
Modified: qpid/trunk/qpid/tools/src/py/qpid-config
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-config?rev=1052086&r1=1052085&r2=1052086&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-config (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-config Wed Dec 22 22:22:13 2010
@@ -24,6 +24,7 @@ from optparse import OptionParser, Optio
import sys
import locale
from qmf.console import Session
+import qpid.log
class Config:
def __init__(self):
@@ -546,6 +547,9 @@ def YN(bool):
def main(argv=None):
+
+ qpid.log.getLogger("qpid.qmf").setLevel(qpid.log.ERROR)
+
args = OptionsAndArguments(argv)
bm = BrokerManager()
@@ -591,13 +595,13 @@ def main(argv=None):
except KeyboardInterrupt:
print
except IOError, e:
- print e
+ print "Failed: %s: %s" % (e.__class__.__name__, e)
bm.Disconnect()
return 1
except SystemExit, e:
bm.Disconnect()
return 1
- except Exception,e:
+ except Exception, e:
if e.__class__.__name__ != "Timeout":
# ignore Timeout exception, handle in the loop below
print "Failed: %s: %s" % (e.__class__.__name__, e)
Modified: qpid/trunk/qpid/tools/src/py/qpid-printevents
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-printevents?rev=1052086&r1=1052085&r2=1052086&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-printevents (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-printevents Wed Dec 22 22:22:13 2010
@@ -26,7 +26,7 @@ import sys
import socket
from time import time, strftime, gmtime, sleep
from qmf.console import Console, Session
-
+import qpid.log
class EventConsole(Console):
def event(self, broker, event):
@@ -75,26 +75,52 @@ $ %prog guest/guest@broker-host:10000
"""
def main(argv=None):
+
p = optparse.OptionParser(usage=_usage, description=_description, formatter=JHelpFormatter())
p.add_option("--heartbeats", action="store_true", default=False, help="Use heartbeats.")
p.add_option("--sasl-mechanism", action="store", choices=["EXTERNAL","ANONYMOUS","PLAIN","CRAM-MD5","DIGEST-MD5","GSSAPI"], metavar="<mech>", help="SASL mechanism for authentication. SASL automatically picks the most secure available mechanism - use this option to override.")
+ p.add_option("--require-connection", action="store_true", help="Raise error if connection can not be established. By default, retries connections that could not be established, which allows events to be printed as brokers start and stop.")
+ p.add_option("--log-level", action="store", choices=["debug", "info", "warn", "error", "critical"], metavar="<level>", help="Logging level for connections")
+
options, arguments = p.parse_args(args=argv)
if len(arguments) == 0:
arguments.append("localhost")
+ LOG_LEVELS = {'debug': qpid.log.DEBUG,
+ 'info': qpid.log.INFO,
+ 'warn': qpid.log.WARN,
+ 'error': qpid.log.ERROR,
+ 'critical': qpid.log.CRITICAL}
+
+ if options.require_connection:
+ manageConnections=False
+ else:
+ manageConnections=True
+
+ if options.log_level:
+ qpid.log.getLogger("qpid.qmf").setLevel(LOG_LEVELS[options.log_level])
+ else:
+ qpid.log.getLogger("qpid.qmf").setLevel(qpid.log.ERROR)
+
console = EventConsole()
- session = Session(console, rcvObjects=False, rcvHeartbeats=options.heartbeats, manageConnections=True)
+ session = Session(console, rcvObjects=False, rcvHeartbeats=options.heartbeats, manageConnections=manageConnections)
brokers = []
try:
for host in arguments:
brokers.append(session.addBroker(host, None, options.sasl_mechanism))
- try:
+
while (True):
sleep(10)
- except KeyboardInterrupt:
+
+ except KeyboardInterrupt:
print
- sys.exit(0)
+ return 0
+
+ except Exception, e:
+ print "Failed: %s - %s" % (e.__class__.__name__, e)
+ return 1
+
finally:
while len(brokers):
b = brokers.pop()
Modified: qpid/trunk/qpid/tools/src/py/qpid-stat
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-stat?rev=1052086&r1=1052085&r2=1052086&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-stat (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-stat Wed Dec 22 22:22:13 2010
@@ -511,7 +511,7 @@ def main(argv=None):
return 0
except KeyboardInterrupt:
print
- except Exception,e:
+ except Exception, e:
print "Failed: %s - %s" % (e.__class__.__name__, e)
bm.Disconnect() # try to deallocate brokers
Modified: qpid/trunk/qpid/tools/src/py/qpid-tool
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-tool?rev=1052086&r1=1052085&r2=1052086&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-tool (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-tool Wed Dec 22 22:22:13 2010
@@ -30,6 +30,7 @@ from time import strftime, gmtime
from qpid.disp import Display
from qpid.peer import Closed
from qmf.console import Session, Console, SchemaClass, ObjectId
+import qpid.log
class Mcli(Cmd):
""" Management Command Interpreter """
@@ -677,6 +678,8 @@ def Usage():
# Main Program
#=========================================================
+qpid.log.getLogger("qpid.qmf").setLevel(qpid.log.ERROR)
+
# Get host name and port if specified on the command line
cargs = sys.argv[1:]
_host = "localhost"
@@ -692,6 +695,7 @@ if _host[0] == '-':
disp = Display()
+
# Attempt to make a connection to the target broker
try:
data = QmfData(disp, _host)
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org
Re: svn commit: r1052086 - in /qpid/trunk/qpid: extras/qmf/src/py/qmf/console.py
tools/src/py/qpid-config tools/src/py/qpid-printevents tools/src/py/qpid-stat
tools/src/py/qpid-tool
Posted by Jonathan Robie <jo...@redhat.com>.
It sounds like this is controversial enough that I should back out this
commit.
On 01/05/2011 01:12 PM, Gordon Sim wrote:
> The callbacks don't get triggered if the tool never connects at present.
> Perhaps there is (or should be) some way to get a callback when the
> connection cannot be established?
Ken, Ted, can I get a callback if a connection can not be established?
Jonathan
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org
Re: svn commit: r1052086 - in /qpid/trunk/qpid:
extras/qmf/src/py/qmf/console.py tools/src/py/qpid-config
tools/src/py/qpid-printevents tools/src/py/qpid-stat tools/src/py/qpid-tool
Posted by Ken Giusti <kg...@redhat.com>.
> The callbacks don't get triggered if the tool never connects at present.
> Perhaps there is (or should be) some way to get a callback when the
> connection cannot be established?
Ah, I like this approach: we could add a new callback method to the Console class that would be invoked should a connection attempt fail due to a misconfiguration-type error. That would be safer than making a call to "brokerDisconnect()", as existing applications may not expect a disconnect event without first getting a connect event.
There would be no api issues - it wouldn't affect existing client implementations that don't override it.
-K
----- Original Message -----
> On 01/05/2011 03:50 PM, Ken Giusti wrote:
> > Hi Gordon,
> >
> > Jonathan discussed some of these issues with me before working on
> > this change. Some of the changes here are due to the current state
> > of the underlying python qmf implementation (console.py) used by
> > these command line tools.
> >
> > Couple of things to keep in mind re: the qmf implementation used by
> > these tools:
> >
> > console.py provides two usage models, which are reflected by the
> > behavior of command line tools. console.py can be used for a
> > synchronous command-response tool (like qpid-route, qpid-config), or
> > it can be used as a passive monitor (qpid-tool, qpid-printevents).
> >
> > Connection failures when using qmf in the synchronous mode are
> > reported back immediately to the application, which deals with them
> > appropriately. No issue there.
> >
> > However, there's an ambiguity with the passive approach: what should
> > happen when the connection to the broker fails? The nature of the
> > qpid-printevents/qpid-tool allows them to be run in lieu of a broker
> > being available. A user can run the tool indefinitely, allowing
> > brokers to come and go over time.
>
> Understood.
>
> > Having a connection attempt fail due to broker not being available,
> > or going away, isn't really a hard error in this model. qmf merely
> > notifies the application that the broker has disconnected, and keeps
> > retrying the connection. However, that's a problem when the failure
> > may involve a misconfiguration - say invalid credentials - as qmf
> > will retry indefinitely until a human intervenes to fix the
> > misconfiguration.
> >
> > Part of what these changes attempt to alert the user to a hard
> > connection failure rather than a transient broker availability issue
> > when qmf is used in passive mode.
> >
> > Which brings us to logging in qmf: There currently isn't any
> > logging, which makes it hard for a user to determine the underlying
> > cause of a failure to connect with a broker. Part of these changes
> > are an attempt to provide more visibility in this area.
>
> Understood. Logging more detail on connection failures seems
> reasonable
> enough.
>
> My comments/questions are more on the rationale behind the particular
> changes in this commit. E.g. the decision on whether to log it as a
> warning or error, the setting of a log-level in several other tools
> for
> what is essentially at present one line, the point of the log-level
> option in qpid-printevents and how it fits in (or doesn't) with that
> tools other outputs etc.
>
> There are already callbacks from the console api that qpid-printevents
> uses to log connection and disconnection already. Providing more
> detail
> on the reason for disconnection there would seem a reasonable approach
> to me. The broker object passed in to the callback has an error
> attribute that contains a description of the last problem. Potentially
> that or some enhancement of it could be used.
>
> The callbacks don't get triggered if the tool never connects at
> present.
> Perhaps there is (or should be) some way to get a callback when the
> connection cannot be established?
>
> In summary, it doesn't seem to me that these changes represent the
> cleanest, simplest, most useful or most elegant solution to the stated
> problems.
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project: http://qpid.apache.org
> Use/Interact: mailto:dev-subscribe@qpid.apache.org
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org
Re: svn commit: r1052086 - in /qpid/trunk/qpid: extras/qmf/src/py/qmf/console.py
tools/src/py/qpid-config tools/src/py/qpid-printevents tools/src/py/qpid-stat
tools/src/py/qpid-tool
Posted by Gordon Sim <gs...@redhat.com>.
On 01/05/2011 03:50 PM, Ken Giusti wrote:
> Hi Gordon,
>
> Jonathan discussed some of these issues with me before working on
> this change. Some of the changes here are due to the current state
> of the underlying python qmf implementation (console.py) used by
> these command line tools.
>
> Couple of things to keep in mind re: the qmf implementation used by
> these tools:
>
> console.py provides two usage models, which are reflected by the
> behavior of command line tools. console.py can be used for a
> synchronous command-response tool (like qpid-route, qpid-config), or
> it can be used as a passive monitor (qpid-tool, qpid-printevents).
>
> Connection failures when using qmf in the synchronous mode are
> reported back immediately to the application, which deals with them
> appropriately. No issue there.
>
> However, there's an ambiguity with the passive approach: what should
> happen when the connection to the broker fails? The nature of the
> qpid-printevents/qpid-tool allows them to be run in lieu of a broker
> being available. A user can run the tool indefinitely, allowing
> brokers to come and go over time.
Understood.
> Having a connection attempt fail due to broker not being available,
> or going away, isn't really a hard error in this model. qmf merely
> notifies the application that the broker has disconnected, and keeps
> retrying the connection. However, that's a problem when the failure
> may involve a misconfiguration - say invalid credentials - as qmf
> will retry indefinitely until a human intervenes to fix the
> misconfiguration.
>
> Part of what these changes attempt to alert the user to a hard
> connection failure rather than a transient broker availability issue
> when qmf is used in passive mode.
>
> Which brings us to logging in qmf: There currently isn't any
> logging, which makes it hard for a user to determine the underlying
> cause of a failure to connect with a broker. Part of these changes
> are an attempt to provide more visibility in this area.
Understood. Logging more detail on connection failures seems reasonable
enough.
My comments/questions are more on the rationale behind the particular
changes in this commit. E.g. the decision on whether to log it as a
warning or error, the setting of a log-level in several other tools for
what is essentially at present one line, the point of the log-level
option in qpid-printevents and how it fits in (or doesn't) with that
tools other outputs etc.
There are already callbacks from the console api that qpid-printevents
uses to log connection and disconnection already. Providing more detail
on the reason for disconnection there would seem a reasonable approach
to me. The broker object passed in to the callback has an error
attribute that contains a description of the last problem. Potentially
that or some enhancement of it could be used.
The callbacks don't get triggered if the tool never connects at present.
Perhaps there is (or should be) some way to get a callback when the
connection cannot be established?
In summary, it doesn't seem to me that these changes represent the
cleanest, simplest, most useful or most elegant solution to the stated
problems.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org
Re: svn commit: r1052086 - in /qpid/trunk/qpid:
extras/qmf/src/py/qmf/console.py tools/src/py/qpid-config
tools/src/py/qpid-printevents tools/src/py/qpid-stat tools/src/py/qpid-tool
Posted by Ken Giusti <kg...@redhat.com>.
Hi Gordon,
Jonathan discussed some of these issues with me before working on this change. Some of the changes here are due to the current state of the underlying python qmf implementation (console.py) used by these command line tools.
Couple of things to keep in mind re: the qmf implementation used by these tools:
console.py provides two usage models, which are reflected by the behavior of command line tools. console.py can be used for a synchronous command-response tool (like qpid-route, qpid-config), or it can be used as a passive monitor (qpid-tool, qpid-printevents).
Connection failures when using qmf in the synchronous mode are reported back immediately to the application, which deals with them appropriately. No issue there.
However, there's an ambiguity with the passive approach: what should happen when the connection to the broker fails? The nature of the qpid-printevents/qpid-tool allows them to be run in lieu of a broker being available. A user can run the tool indefinitely, allowing brokers to come and go over time.
Having a connection attempt fail due to broker not being available, or going away, isn't really a hard error in this model. qmf merely notifies the application that the broker has disconnected, and keeps retrying the connection. However, that's a problem when the failure may involve a misconfiguration - say invalid credentials - as qmf will retry indefinitely until a human intervenes to fix the misconfiguration.
Part of what these changes attempt to alert the user to a hard connection failure rather than a transient broker availability issue when qmf is used in passive mode.
Which brings us to logging in qmf: There currently isn't any logging, which makes it hard for a user to determine the underlying cause of a failure to connect with a broker. Part of these changes are an attempt to provide more visibility in this area.
-K
----- Original Message -----
> On 01/04/2011 10:26 PM, Jonathan Robie wrote:
> > On 01/04/2011 03:47 PM, Gordon Sim wrote:
> >
> >>> URL: http://svn.apache.org/viewvc?rev=1052086&view=rev
> >>> Log:
> >>> Added logging to QMF console connections.
> >>>
> >>> Warning if a broker can not be found, error if SASL authentication
> >>> fails or other connection errors when connecting to an existing
> >>> broker. Default log level is ERROR.
> >>
> >> What is the usual default for the log level (i.e. what is the
> >> default
> >> for other uses of the log module)? It seems a little odd to set the
> >> log
> >> level to error on most tools, perhaps that's just me...
> >
> > It's easy to change the default.
>
> From the commit it looks like each tool sets the 'default'
> separately(?)
>
> > I'm not sure what the default log level should be for QMF console
> > applications - what would you suggest?
>
> What is the usual default (i.e. for other users of the qpid.log
> module)?
> What other log statements are there for 'qpid.qmf' (I couldn't find
> any)?
>
> >>> qpid-printevents allows the log level to be set.
> >>
> >> What about the other tools? Is it not useful for them to also be
> >> able to
> >> set the logging level? (As the topic of consistency came up
> >> recently,
> >> should the -v/--verbose option in qpid-route by rationalised with
> >> this?)
> >
> > It would be easy to add the log level option to the other tools.
> >
> > When I raised the topic of consistency in options recently, you
> > suggested we should start by determining which tools we need and
> > designing the right tool set. I'd like to avoid making changes that
> > are
> > not backwards compatible until we actually do that redesign.
> >
> > Ideally, I'd probably just use logging levels in qpid-route. But for
> > now, I'm reluctant to eliminate -v if there are scripts that might
> > use it.
>
> That is certainly an important consideration and I agree that we would
> not want to start eliminating options without due consideration. I
> think
> similar consideration before adding any options - particularly any
> that
> may increase the feeling of inconsistency - is also important.
>
> I guess the real issue is that I don't fully understand the particular
> choices made in this commit or what motivated them.
>
> What was your thinking around a lower log level (i.e. warn rather than
> error) for the case where 'a broker can not be found'? And what
> exactly
> do you mean by that? I seem to only get the warning level used where
> the
> hostname can't even be resolved; connection refused and no-route to
> host
> are both error level statements. This seems pretty odd to me.
>
> The changes to qpid-printevents seem to be addressing a different
> issue,
> in fact two further separate issues.
>
> The first is a new option that as I understand it disables the
> built-in
> connection retry (and in an ideal world would have been made via a
> distinct commit). While not opposed to the change in principle, it
> would
> be good to be clear on the motivation.
>
> The second is an option to alter the logging level for the qpid.qmf
> logger. What's the motivation for this? Are there any log statements
> for
> that logger other than the one added by this commit? The tool already
> has some sort of logging style output that this option doesn't affect.
>
> I suspect this commit was motivated by the fact that qpid-printevents
> appears just to hang if it can't establish the connection to begin
> with
> (if it is disconnected, that is already logged, as is subsequent
> reconnection).
>
> >>> It also allows the user to specify that a connection is required,
> >>> in
> >>> which case it terminates if a connection can not be established.
> >>
> >> I'm not mad on the name of this new option (i.e.
> >> require-connection). It
> >> seems like allow-reconnect or exit-on-failure would communicate a
> >> little
> >> more on the purpose of the option.
> >
> > It's more like exit-on-connection-failure, but that's rather
> > verbose.
> >
> > To me, exit-on-failure fails to communicate that this has to do with
> > connections,
>
> Alternatives in that case might be
> exit-on-disconnect/exit-if-not-connected/exit-unless-connected...
> however it actually also affects handling of other types of error,
> e.g.
> acl failures, so I'm not sure that exit-on-failure is even wrong.
>
> > and allow-reconnect is not the same as exiting if a
> > connection can not be established.
>
> The allow-reconnect option would indicate that it is ok to try to
> periodically reconnect; if not then the only choice would be to exit.
> Reversing the sense, disable-reconnect would also be reasonable in my
> view, and in fact I think that would probably be my preference.
>
> > I'm not convinced that either of
> > these really does a better job of explaining the purpose.
>
> I'm fairly convinced that I don't like require-connection.
>
> The tool *always* requires a connection else it cannot do anything.
> The
> question is whether it is allowed to remain running in the
> disconnected
> state while periodically trying to re-establish a connection or
> whether
> it should immediately exit.
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project: http://qpid.apache.org
> Use/Interact: mailto:dev-subscribe@qpid.apache.org
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org
Re: svn commit: r1052086 - in /qpid/trunk/qpid: extras/qmf/src/py/qmf/console.py
tools/src/py/qpid-config tools/src/py/qpid-printevents tools/src/py/qpid-stat
tools/src/py/qpid-tool
Posted by Gordon Sim <gs...@redhat.com>.
On 01/04/2011 10:26 PM, Jonathan Robie wrote:
> On 01/04/2011 03:47 PM, Gordon Sim wrote:
>
>>> URL: http://svn.apache.org/viewvc?rev=1052086&view=rev
>>> Log:
>>> Added logging to QMF console connections.
>>>
>>> Warning if a broker can not be found, error if SASL authentication
>>> fails or other connection errors when connecting to an existing
>>> broker. Default log level is ERROR.
>>
>> What is the usual default for the log level (i.e. what is the default
>> for other uses of the log module)? It seems a little odd to set the log
>> level to error on most tools, perhaps that's just me...
>
> It's easy to change the default.
From the commit it looks like each tool sets the 'default' separately(?)
> I'm not sure what the default log level should be for QMF console
> applications - what would you suggest?
What is the usual default (i.e. for other users of the qpid.log module)?
What other log statements are there for 'qpid.qmf' (I couldn't find any)?
>>> qpid-printevents allows the log level to be set.
>>
>> What about the other tools? Is it not useful for them to also be able to
>> set the logging level? (As the topic of consistency came up recently,
>> should the -v/--verbose option in qpid-route by rationalised with this?)
>
> It would be easy to add the log level option to the other tools.
>
> When I raised the topic of consistency in options recently, you
> suggested we should start by determining which tools we need and
> designing the right tool set. I'd like to avoid making changes that are
> not backwards compatible until we actually do that redesign.
>
> Ideally, I'd probably just use logging levels in qpid-route. But for
> now, I'm reluctant to eliminate -v if there are scripts that might use it.
That is certainly an important consideration and I agree that we would
not want to start eliminating options without due consideration. I think
similar consideration before adding any options - particularly any that
may increase the feeling of inconsistency - is also important.
I guess the real issue is that I don't fully understand the particular
choices made in this commit or what motivated them.
What was your thinking around a lower log level (i.e. warn rather than
error) for the case where 'a broker can not be found'? And what exactly
do you mean by that? I seem to only get the warning level used where the
hostname can't even be resolved; connection refused and no-route to host
are both error level statements. This seems pretty odd to me.
The changes to qpid-printevents seem to be addressing a different issue,
in fact two further separate issues.
The first is a new option that as I understand it disables the built-in
connection retry (and in an ideal world would have been made via a
distinct commit). While not opposed to the change in principle, it would
be good to be clear on the motivation.
The second is an option to alter the logging level for the qpid.qmf
logger. What's the motivation for this? Are there any log statements for
that logger other than the one added by this commit? The tool already
has some sort of logging style output that this option doesn't affect.
I suspect this commit was motivated by the fact that qpid-printevents
appears just to hang if it can't establish the connection to begin with
(if it is disconnected, that is already logged, as is subsequent
reconnection).
>>> It also allows the user to specify that a connection is required, in
>>> which case it terminates if a connection can not be established.
>>
>> I'm not mad on the name of this new option (i.e. require-connection). It
>> seems like allow-reconnect or exit-on-failure would communicate a little
>> more on the purpose of the option.
>
> It's more like exit-on-connection-failure, but that's rather verbose.
>
> To me, exit-on-failure fails to communicate that this has to do with
> connections,
Alternatives in that case might be
exit-on-disconnect/exit-if-not-connected/exit-unless-connected...
however it actually also affects handling of other types of error, e.g.
acl failures, so I'm not sure that exit-on-failure is even wrong.
> and allow-reconnect is not the same as exiting if a
> connection can not be established.
The allow-reconnect option would indicate that it is ok to try to
periodically reconnect; if not then the only choice would be to exit.
Reversing the sense, disable-reconnect would also be reasonable in my
view, and in fact I think that would probably be my preference.
> I'm not convinced that either of
> these really does a better job of explaining the purpose.
I'm fairly convinced that I don't like require-connection.
The tool *always* requires a connection else it cannot do anything. The
question is whether it is allowed to remain running in the disconnected
state while periodically trying to re-establish a connection or whether
it should immediately exit.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org
Re: svn commit: r1052086 - in /qpid/trunk/qpid: extras/qmf/src/py/qmf/console.py
tools/src/py/qpid-config tools/src/py/qpid-printevents tools/src/py/qpid-stat
tools/src/py/qpid-tool
Posted by Jonathan Robie <jo...@redhat.com>.
On 01/04/2011 03:47 PM, Gordon Sim wrote:
>> URL: http://svn.apache.org/viewvc?rev=1052086&view=rev
>> Log:
>> Added logging to QMF console connections.
>>
>> Warning if a broker can not be found, error if SASL authentication
>> fails or other connection errors when connecting to an existing
>> broker. Default log level is ERROR.
>
> What is the usual default for the log level (i.e. what is the default
> for other uses of the log module)? It seems a little odd to set the log
> level to error on most tools, perhaps that's just me...
It's easy to change the default.
I'm not sure what the default log level should be for QMF console
applications - what would you suggest?
>> qpid-printevents allows the log level to be set.
>
> What about the other tools? Is it not useful for them to also be able to
> set the logging level? (As the topic of consistency came up recently,
> should the -v/--verbose option in qpid-route by rationalised with this?)
It would be easy to add the log level option to the other tools.
When I raised the topic of consistency in options recently, you
suggested we should start by determining which tools we need and
designing the right tool set. I'd like to avoid making changes that are
not backwards compatible until we actually do that redesign.
Ideally, I'd probably just use logging levels in qpid-route. But for
now, I'm reluctant to eliminate -v if there are scripts that might use it.
>> It also allows the user to specify that a connection is required, in
>> which case it terminates if a connection can not be established.
>
> I'm not mad on the name of this new option (i.e. require-connection). It
> seems like allow-reconnect or exit-on-failure would communicate a little
> more on the purpose of the option.
It's more like exit-on-connection-failure, but that's rather verbose.
To me, exit-on-failure fails to communicate that this has to do with
connections, and allow-reconnect is not the same as exiting if a
connection can not be established. I'm not convinced that either of
these really does a better job of explaining the purpose.
>> Modified: qpid/trunk/qpid/extras/qmf/src/py/qmf/console.py
>> URL:
>> + if e[0] == -2:
>> + log.warning("Could not connect to broker " + self.host + ":" +
>> str(self.port) + " " + str(e))
>> + else:
>> + log.error("Could not connect to broker " + self.host + ":" +
>> str(self.port) + " " + str(e))
>> +
>
> What's the above if/else actually checking? Is there a way to make the
> code more obvious to a casual reader?
I agree. I'll try to improve that.
Jonathan
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org
Re: svn commit: r1052086 - in /qpid/trunk/qpid: extras/qmf/src/py/qmf/console.py
tools/src/py/qpid-config tools/src/py/qpid-printevents tools/src/py/qpid-stat
tools/src/py/qpid-tool
Posted by Gordon Sim <gs...@redhat.com>.
On 12/22/2010 10:22 PM, jonathan@apache.org wrote:
> Author: jonathan
> Date: Wed Dec 22 22:22:13 2010
> New Revision: 1052086
>
> URL: http://svn.apache.org/viewvc?rev=1052086&view=rev
> Log:
> Added logging to QMF console connections.
>
> Warning if a broker can not be found, error if SASL authentication fails or other connection errors when connecting to an existing broker. Default log level is ERROR.
What is the usual default for the log level (i.e. what is the default
for other uses of the log module)? It seems a little odd to set the log
level to error on most tools, perhaps that's just me...
> qpid-printevents allows the log level to be set.
What about the other tools? Is it not useful for them to also be able to
set the logging level? (As the topic of consistency came up recently,
should the -v/--verbose option in qpid-route by rationalised with this?)
> It also allows the user to specify that a connection is required, in which case it terminates if a connection can not be established.
I'm not mad on the name of this new option (i.e. require-connection). It
seems like allow-reconnect or exit-on-failure would communicate a little
more on the purpose of the option.
> Modified: qpid/trunk/qpid/extras/qmf/src/py/qmf/console.py
> URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/extras/qmf/src/py/qmf/console.py?rev=1052086&r1=1052085&r2=1052086&view=diff
> ==============================================================================
> --- qpid/trunk/qpid/extras/qmf/src/py/qmf/console.py (original)
> +++ qpid/trunk/qpid/extras/qmf/src/py/qmf/console.py Wed Dec 22 22:22:13 2010
> @@ -39,8 +39,8 @@ from Queue import Queue, Empty
> from time import time, strftime, gmtime, sleep
> from cStringIO import StringIO
>
> -#import qpid.log
> -#qpid.log.enable(name="qpid.io.cmd", level=qpid.log.DEBUG)
> +import qpid.log
> +qpid.log.enable(name="qpid.qmf")
>
> #===================================================================================================
> # CONSOLE
> @@ -2509,6 +2509,14 @@ class Broker(Thread):
>
> except Exception, e:
> self.error = "Exception during connection setup: %s - %s" % (e.__class__.__name__, e)
> +
> + log = qpid.log.getLogger("qpid.qmf")
> +
> + if e[0] == -2:
> + log.warning("Could not connect to broker " + self.host + ":" + str(self.port) + " " + str(e))
> + else:
> + log.error("Could not connect to broker " + self.host + ":" + str(self.port) + " " + str(e))
> +
What's the above if/else actually checking? Is there a way to make the
code more obvious to a casual reader?
> self.conn_exc = e
> return False # connection failed
>
>
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org