You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2010/04/06 17:28:40 UTC
svn commit: r931185 - in /qpid/trunk/qpid: python/qpid/datatypes.py
tools/setup.py tools/src/py/qpid-cluster-store
Author: aconway
Date: Tue Apr 6 15:28:39 2010
New Revision: 931185
URL: http://svn.apache.org/viewvc?rev=931185&view=rev
Log:
Added qpid-cluster-store tool to examine & modify cluster store status.
Added:
qpid/trunk/qpid/tools/src/py/qpid-cluster-store (with props)
Modified:
qpid/trunk/qpid/python/qpid/datatypes.py
qpid/trunk/qpid/tools/setup.py
Modified: qpid/trunk/qpid/python/qpid/datatypes.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/datatypes.py?rev=931185&r1=931184&r2=931185&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/datatypes.py (original)
+++ qpid/trunk/qpid/python/qpid/datatypes.py Tue Apr 6 15:28:39 2010
@@ -313,6 +313,12 @@ class UUID:
def __init__(self, bytes):
self.bytes = bytes
+ @staticmethod
+ def parse(str):
+ fields=str.split("-")
+ fields[4:5] = [fields[4][:4], fields[4][4:]]
+ return UUID(struct.pack("!LHHHHL", *[int(x,16) for x in fields]))
+
def __cmp__(self, other):
if isinstance(other, UUID):
return cmp(self.bytes, other.bytes)
Modified: qpid/trunk/qpid/tools/setup.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/setup.py?rev=931185&r1=931184&r2=931185&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/setup.py (original)
+++ qpid/trunk/qpid/tools/setup.py Tue Apr 6 15:28:39 2010
@@ -24,6 +24,7 @@ setup(name="qpid-tools",
author="Apache Qpid",
author_email="dev@qpid.apache.org",
scripts=["src/py/qpid-cluster",
+ "src/py/qpid-cluster-store",
"src/py/qpid-config",
"src/py/qpid-printevents",
"src/py/qpid-queue-stats",
Added: qpid/trunk/qpid/tools/src/py/qpid-cluster-store
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-cluster-store?rev=931185&view=auto
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-cluster-store (added)
+++ qpid/trunk/qpid/tools/src/py/qpid-cluster-store Tue Apr 6 15:28:39 2010
@@ -0,0 +1,73 @@
+#!/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
+import optparse, os.path, sys
+
+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('\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 = [UUID.parse(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():
+ opts, args = op.parse_args()
+ 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())
Propchange: qpid/trunk/qpid/tools/src/py/qpid-cluster-store
------------------------------------------------------------------------------
svn:executable = *
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org