diff options
| author | Alan Conway <aconway@apache.org> | 2013-09-03 16:07:29 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2013-09-03 16:07:29 +0000 |
| commit | 02cc596734dc9a8b775b553bc1ee8fff109316c7 (patch) | |
| tree | 72f165a95956664e8604c6fd73ec1fc0b336d105 | |
| parent | 7ee553fc7fd90d55b672507fdfccadbb6d2a76c2 (diff) | |
| download | qpid-python-02cc596734dc9a8b775b553bc1ee8fff109316c7.tar.gz | |
NO-JIRA: Remove obsolete qpid-cluster and qpid-cluster-store tools.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1519739 13f79535-47bb-0310-9956-ffa450edef68
| -rwxr-xr-x | qpid/cpp/src/tests/qpid-cluster-lag.py | 93 | ||||
| -rw-r--r-- | qpid/cpp/src/tests/test_env.ps1.in | 1 | ||||
| -rwxr-xr-x | qpid/tools/setup.py | 4 | ||||
| -rw-r--r-- | qpid/tools/src/py/.gitignore | 1 | ||||
| -rwxr-xr-x | qpid/tools/src/py/qpid-cluster | 326 | ||||
| -rwxr-xr-x | qpid/tools/src/py/qpid-cluster-store | 75 |
6 files changed, 1 insertions, 499 deletions
diff --git a/qpid/cpp/src/tests/qpid-cluster-lag.py b/qpid/cpp/src/tests/qpid-cluster-lag.py deleted file mode 100755 index 5b24353241..0000000000 --- a/qpid/cpp/src/tests/qpid-cluster-lag.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env python - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -"""%prog [options] broker... -Check for brokers that lag behind other brokers in a cluster.""" - -import os, os.path, sys, socket, time, re -from qpid.messaging import * -from optparse import OptionParser -from threading import Thread - -class Browser(Thread): - def __init__(self, broker, queue, timeout): - Thread.__init__(self) - self.broker = broker - self.queue = queue - self.timeout = timeout - self.error = None - self.time = None - - def run(self): - try: - self.connection = Connection(self.broker) - self.connection.open() - self.session = self.connection.session() - self.receiver = self.session.receiver("%s;{mode:browse}"%self.queue) - self.msg = self.receiver.fetch(timeout=self.timeout) - self.time = time.time() - if (self.msg.content != self.queue): - raise Exception("Wrong message content, expected '%s' found '%s'"% - (self.queue, self.msg.content)) - except Empty: - self.error = "No message on queue %s"%self.queue - except Exception, e: - self.error = "Error: %s"%e - -def main(argv): - op = OptionParser(usage=__doc__) - op.add_option("--timeout", type="float", default=None, metavar="TIMEOUT", - help="Give up after TIMEOUT milliseconds, default never timeout") - (opts, args) = op.parse_args(argv) - if (len(args) <= 1): op.error("No brokers were specified") - brokers = args[1:] - - # Put a message on a uniquely named queue. - queue = "%s:%s:%s"%(os.path.basename(args[0]), socket.gethostname(), os.getpid()) - connection = Connection(brokers[0]) - connection.open() - session = connection.session() - sender = session.sender( - "%s;{create:always,delete:always,node:{durable:False}}"%queue) - sender.send(Message(content=queue)) - start = time.time() - # Browse for the message on each broker - if opts.timeout: opts.timeout - threads = [Browser(b, queue, opts.timeout) for b in brokers] - for t in threads: t.start() - delays=[] - - for t in threads: - t.join() - if t.error: - delay=t.error - else: - delay = t.time-start - delays.append([delay, t.broker]) - print "%s: %s"%(t.broker,delay) - if delays: - delays.sort() - print "lag: %s (%s-%s)"%(delays[-1][0] - delays[0][0], delays[-1][1], delays[0][1]) - # Clean up - sender.close() - session.close() - connection.close() - -if __name__ == "__main__": sys.exit(main(sys.argv)) diff --git a/qpid/cpp/src/tests/test_env.ps1.in b/qpid/cpp/src/tests/test_env.ps1.in index 5fa3a0ac31..12373b5b35 100644 --- a/qpid/cpp/src/tests/test_env.ps1.in +++ b/qpid/cpp/src/tests/test_env.ps1.in @@ -41,7 +41,6 @@ $PYTHON_COMMANDS="$QPID_TOOLS\src\py" $env:PYTHONPATH="$srcdir;$PYTHON_DIR;$PYTHON_COMMANDS;$QPID_TESTS_PY;$QPID_TOOLS_LIBS;$QMF_LIB;$env:PYTHONPATH" $QPID_CONFIG_EXEC="$PYTHON_COMMANDS\qpid-config" $QPID_ROUTE_EXEC="$PYTHON_COMMANDS\qpid-route" -$QPID_CLUSTER_EXEC="$PYTHON_COMMANDS\qpid-cluster" $QPID_HA_TOOL_EXEC="$PYTHON_COMMANDS\qpid-ha-tool" # Executables diff --git a/qpid/tools/setup.py b/qpid/tools/setup.py index 02d8367d5a..00bffc4905 100755 --- a/qpid/tools/setup.py +++ b/qpid/tools/setup.py @@ -25,9 +25,7 @@ setup(name="qpid-tools", author_email="dev@qpid.apache.org", package_dir={'' : 'src/py'}, packages=["qpidtoollibs"], - scripts=["src/py/qpid-cluster", - "src/py/qpid-cluster-store", - "src/py/qpid-config", + scripts=["src/py/qpid-config", "src/py/qpid-ha", "src/py/qpid-printevents", "src/py/qpid-queue-stats", diff --git a/qpid/tools/src/py/.gitignore b/qpid/tools/src/py/.gitignore index b775fd83a1..628d81888c 100644 --- a/qpid/tools/src/py/.gitignore +++ b/qpid/tools/src/py/.gitignore @@ -17,7 +17,6 @@ # to you under the Apache License, Version 2.0 (the # under the License. # with the License. You may obtain a copy of the License at -/qpid-clusterc /qpid-configc /qpid-hac /qpid-routec diff --git a/qpid/tools/src/py/qpid-cluster b/qpid/tools/src/py/qpid-cluster deleted file mode 100755 index d75a10f6e8..0000000000 --- a/qpid/tools/src/py/qpid-cluster +++ /dev/null @@ -1,326 +0,0 @@ -#!/usr/bin/env python - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -import os -from optparse import OptionParser, OptionGroup -import sys -import locale -import socket -import re -from qmf.console import Session - -class Config: - def __init__(self): - self._host = "localhost" - self._connTimeout = 10 - self._stopId = None - self._stopAll = False - self._force = False - self._numeric = False - self._showConn = False - self._delConn = None - -class IpAddr: - def __init__(self, text): - if text.find("@") != -1: - tokens = text.split("@") - text = tokens[1] - if text.find(":") != -1: - tokens = text.split(":") - text = tokens[0] - self.port = int(tokens[1]) - else: - self.port = 5672 - self.dottedQuad = socket.gethostbyname(text) - nums = self.dottedQuad.split(".") - self.addr = (int(nums[0]) << 24) + (int(nums[1]) << 16) + (int(nums[2]) << 8) + int(nums[3]) - - def bestAddr(self, addrPortList): - bestDiff = 0xFFFFFFFFL - bestAddr = None - for addrPort in addrPortList: - diff = IpAddr(addrPort[0]).addr ^ self.addr - if diff < bestDiff: - bestDiff = diff - bestAddr = addrPort - return bestAddr - -class BrokerManager: - def __init__(self, config, conn_options): - self.config = config - self.cert = None - self.conn_options = conn_options - self.brokerName = None - self.qmf = None - self.broker = None - self.brokers = [] - - def SetBroker(self, brokerUrl): - self.url = brokerUrl - self.qmf = Session() - self.broker = self.qmf.addBroker(brokerUrl, self.config._connTimeout, **self.conn_options) - agents = self.qmf.getAgents() - for a in agents: - if a.getAgentBank() == '0': - self.brokerAgent = a - - def Disconnect(self): - """ Release any allocated brokers. Ignore any failures as the tool is - shutting down. - """ - try: - if self.broker: - self.qmf.delBroker(self.broker) - self.broker = None - while len(self.brokers): - b = self.brokers.pop() - self.qmf.delBroker(b) - except: - pass - - def _getClusters(self): - packages = self.qmf.getPackages() - if "org.apache.qpid.cluster" not in packages: - raise Exception("Clustering is not installed on the broker.") - - clusters = self.qmf.getObjects(_class="cluster", _agent=self.brokerAgent) - if len(clusters) == 0: - raise Exception("Clustering is installed but not enabled on the broker.") - - return clusters - - def _getHostList(self, urlList): - hosts = [] - hostAddr = IpAddr(self.config._host) - for url in urlList: - if url.find("amqp:") != 0: - raise Exception("Invalid URL 1") - url = url[5:] - addrs = str(url).split(",") - addrList = [] - for addr in addrs: - tokens = addr.split(":") - if len(tokens) != 3: - raise Exception("Invalid URL 2") - addrList.append((tokens[1], tokens[2])) - - # Find the address in the list that is most likely to be in the same subnet as the address - # with which we made the original QMF connection. This increases the probability that we will - # be able to reach the cluster member. - - best = hostAddr.bestAddr(addrList) - bestUrl = best[0] + ":" + best[1] - hosts.append(bestUrl) - return hosts - - def overview(self): - clusters = self._getClusters() - cluster = clusters[0] - memberList = cluster.members.split(";") - idList = cluster.memberIDs.split(";") - - print " Cluster Name: %s" % cluster.clusterName - print "Cluster Status: %s" % cluster.status - print " Cluster Size: %d" % cluster.clusterSize - print " Members: ID=%s URL=%s" % (idList[0], memberList[0]) - for idx in range(1,len(idList)): - print " : ID=%s URL=%s" % (idList[idx], memberList[idx]) - - def stopMember(self, id): - clusters = self._getClusters() - cluster = clusters[0] - idList = cluster.memberIDs.split(";") - if id not in idList: - raise Exception("No member with matching ID found") - - if not self.config._force: - prompt = "Warning: " - if len(idList) == 1: - prompt += "This command will shut down the last running cluster member." - else: - prompt += "This command will shut down a cluster member." - prompt += " Are you sure? [N]: " - - confirm = raw_input(prompt) - if len(confirm) == 0 or confirm[0].upper() != 'Y': - raise Exception("Operation canceled") - - cluster.stopClusterNode(id) - - def stopAll(self): - clusters = self._getClusters() - if not self.config._force: - prompt = "Warning: This command will shut down the entire cluster." - prompt += " Are you sure? [N]: " - - confirm = raw_input(prompt) - if len(confirm) == 0 or confirm[0].upper() != 'Y': - raise Exception("Operation canceled") - - cluster = clusters[0] - cluster.stopFullCluster() - - def showConnections(self): - clusters = self._getClusters() - cluster = clusters[0] - memberList = cluster.members.split(";") - idList = cluster.memberIDs.split(";") - displayList = [] - hostList = self._getHostList(memberList) - self.qmf.delBroker(self.broker) - self.broker = None - - idx = 0 - for host in hostList: - if self.config._showConn == "all" or self.config._showConn == idList[idx] or self.config._delConn: - self.brokers.append(self.qmf.addBroker(host, self.config._connTimeout)) - displayList.append(idList[idx]) - idx += 1 - - idx = 0 - found = False - for broker in self.brokers: - if not self.config._delConn: - print "Clients on Member: ID=%s:" % displayList[idx] - connList = self.qmf.getObjects(_class="connection", _package="org.apache.qpid.broker", _broker=broker) - for conn in connList: - if not conn.shadow: - if self.config._numeric or self.config._delConn: - a = conn.address - else: - tokens = conn.address.split(":") - try: - hostList = socket.gethostbyaddr(tokens[0]) - host = hostList[0] - except: - host = tokens[0] - a = host + ":" + tokens[1] - if self.config._delConn: - tokens = self.config._delConn.split(":") - ip = socket.gethostbyname(tokens[0]) - toDelete = ip + ":" + tokens[1] - if a == toDelete: - print "Closing connection from client: %s" % a - conn.close() - found = True - else: - print " %s" % a - idx += 1 - if not self.config._delConn: - print - if self.config._delConn and not found: - print "Client connection '%s' not found" % self.config._delConn - - while len(self.brokers): - broker = self.brokers.pop() - self.qmf.delBroker(broker) - -def main(argv=None): - - try: - config = Config() - - parser = OptionParser(usage="usage: %prog [options] BROKER", - description="Example: $ qpid-cluster -C broker-host:10000") - - parser.add_option("-t", "--timeout", action="store", type="int", default=10, metavar="SECS", help="Maximum time to wait for broker connection (in seconds)") - parser.add_option("--sasl-mechanism", action="store", type="string", metavar="<mech>", help="SASL mechanism for authentication (e.g. EXTERNAL, ANONYMOUS, PLAIN, CRAM-MD, DIGEST-MD5, GSSAPI). SASL automatically picks the most secure available mechanism - use this option to override.") - parser.add_option("--ssl-certificate", action="store", type="string", metavar="<cert>", help="Client SSL certificate (PEM Format)") - parser.add_option("--ssl-key", action="store", type="string", metavar="<key>", help="Client SSL private key (PEM Format)") - parser.add_option("-C", "--all-connections", action="store_true", default=False, help="View client connections to all cluster members") - parser.add_option("-c", "--connections", metavar="ID", help="View client connections to specified member") - parser.add_option("-d", "--del-connection", metavar="HOST:PORT", help="Disconnect a client connection") - parser.add_option("-s", "--stop", metavar="ID", help="Stop one member of the cluster by its ID") - parser.add_option("-k", "--all-stop", action="store_true", default=False, help="Shut down the whole cluster") - parser.add_option("-f", "--force", action="store_true", default=False, help="Suppress the 'are you sure' prompt") - parser.add_option("-n", "--numeric", action="store_true", default=False, help="Don't resolve names") - - opts, args = parser.parse_args(args=argv) - - if args: - config._host = args[0] - - if opts.timeout != 0: - config._connTimeout = opts.timeout - else: - config._connTimeout = None - - if opts.all_connections: - config._showConn = "all" - - if opts.connections: - config._connections = opts.connections - if len(config._connections.split(":")) != 2: - parser.error("Member ID must be of form: <host or ip>:<number>") - - if opts.del_connection: - config._delConn = opts.del_connection - if len(config._delConn.split(":")) != 2: - parser.error("Member ID must be of form: <host or ip>:<number>") - - if opts.stop: - config._stopId = opts.stop - if len(config._stopId.split(":")) != 2: - parser.error("Member ID must be of form: <host or ip>:<number>") - - if opts.ssl_key and not opts.ssl_certificate: - parser.error("missing '--ssl-certificate' (required by '--ssl-key')") - - config._stopAll = opts.all_stop - config._force = opts.force - config._numeric = opts.numeric - - conn_options = {} - if opts.sasl_mechanism: - conn_options['mechanisms'] = opts.sasl_mechanism - if opts.ssl_certificate: - conn_options['ssl_certfile'] = opts.ssl_certificate - if opts.ssl_key: - conn_options['ssl_keyfile'] = opts.ssl_key - - bm = BrokerManager(config, conn_options) - - try: - bm.SetBroker(config._host) - if config._stopId: - bm.stopMember(config._stopId) - elif config._stopAll: - bm.stopAll() - elif config._showConn or config._delConn: - bm.showConnections() - else: - bm.overview() - except KeyboardInterrupt: - print - except Exception,e: - bm.Disconnect() # try to deallocate brokers - ignores errors - if str(e).find("connection aborted") > 0: - # we expect this when asking the connected broker to shut down - return 0 - raise Exception("Failed: %s - %s" % (e.__class__.__name__, e)) - - bm.Disconnect() - except Exception, e: - print str(e) - return 1 - -if __name__ == "__main__": - sys.exit(main()) diff --git a/qpid/tools/src/py/qpid-cluster-store b/qpid/tools/src/py/qpid-cluster-store deleted file mode 100755 index 3541b6679c..0000000000 --- a/qpid/tools/src/py/qpid-cluster-store +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - - -from qpid.datatypes import uuid4, UUID, parseUUID -import optparse, os.path, sys, string - -op = optparse.OptionParser( - usage="usage: %prog [options] DATADIR", - description="View or modify cluster store status for broker with data-directory DATADIR") -op.add_option("-d", "--display", default=False, action="store_true", help="display store status." ) -op.add_option("-c", "--mark-clean", default=False, action="store_true", help="mark the store as clean." ) - -class ClusterStoreStatus: - """Load/save/display store status file""" - - null_uuid=UUID(bytes='\0'*16) - - def __init__(self, file): - self.file = file - self.read() - - def read(self): - f = open(self.file) - try: self.cluster_id, self.shutdown_id = [parseUUID(string.rstrip(s)) for s in f.readlines()] - finally: f.close() - - def write(self): - f = open(self.file,"w") - try: - for u in [self.cluster_id, self.shutdown_id]: f.write(str(u)+"\n") - finally: f.close() - - def status(self): - if (self.cluster_id == self.null_uuid): return "empty" - if (self.shutdown_id == self.null_uuid): return "dirty" - return "clean" - - def __str__(self): - return "status: %s\ncluster-id: %s\nshutdown_id: %s" % ( - self.status(), self.cluster_id, self.shutdown_id) - - def mark_clean(self): - self.shutdown_id = uuid4() - self.write() - -def main(argv=None): - opts, args = op.parse_args(args=argv) - if len(args) != 1: op.error("incorrect number of arguments") - try: status = ClusterStoreStatus(args[0]+"/cluster/store.status") - except Exception,e: print e; return 1 - if opts.display: print status - if opts.mark_clean: status.mark_clean(); print status - return 0 - -if __name__ == "__main__": - sys.exit(main()) |
