Revision 2bbf1544
b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/node.py | ||
---|---|---|
1073 | 1073 |
|
1074 | 1074 |
return matches, prefixes |
1075 | 1075 |
|
1076 |
def latest_uuid(self, uuid): |
|
1077 |
"""Return a (path, serial) tuple, for the latest version of the given uuid.""" |
|
1076 |
def latest_uuid(self, uuid, cluster): |
|
1077 |
"""Return the latest version of the given uuid and cluster. |
|
1078 |
|
|
1079 |
Return a (path, serial) tuple. |
|
1080 |
If cluster is None, all clusters are considered. |
|
1081 |
|
|
1082 |
""" |
|
1078 | 1083 |
|
1079 | 1084 |
v = self.versions.alias('v') |
1080 | 1085 |
n = self.nodes.alias('n') |
1081 | 1086 |
s = select([n.c.path, v.c.serial]) |
1082 | 1087 |
filtered = select([func.max(self.versions.c.serial)]) |
1083 |
s = s.where(v.c.serial == filtered.where(self.versions.c.uuid == uuid)) |
|
1088 |
filtered = filtered.where(self.versions.c.uuid == uuid) |
|
1089 |
if cluster is not None: |
|
1090 |
filtered = filtered.where(self.versions.c.cluster == cluster) |
|
1091 |
s = s.where(v.c.serial == filtered) |
|
1084 | 1092 |
s = s.where(n.c.node == v.c.node) |
1085 | 1093 |
|
1086 | 1094 |
r = self.conn.execute(s) |
b/snf-pithos-backend/pithos/backends/lib/sqlite/node.py | ||
---|---|---|
972 | 972 |
|
973 | 973 |
return matches, prefixes |
974 | 974 |
|
975 |
def latest_uuid(self, uuid): |
|
976 |
"""Return a (path, serial) tuple, for the latest version of the given uuid.""" |
|
975 |
def latest_uuid(self, uuid, cluster): |
|
976 |
"""Return the latest version of the given uuid and cluster. |
|
977 |
|
|
978 |
Return a (path, serial) tuple. |
|
979 |
If cluster is None, all clusters are considered. |
|
980 |
|
|
981 |
""" |
|
982 |
if cluster is not None: |
|
983 |
cluster_where = "and cluster = ?" |
|
984 |
args = (uuid, int(cluster)) |
|
985 |
else: |
|
986 |
cluster_where = "" |
|
987 |
args = (uuid,) |
|
977 | 988 |
|
978 | 989 |
q = ("select n.path, v.serial " |
979 | 990 |
"from versions v, nodes n " |
980 | 991 |
"where v.serial = (select max(serial) " |
981 | 992 |
"from versions " |
982 |
"where uuid = ?) " |
|
983 |
"and n.node = v.node") |
|
984 |
self.execute(q, (uuid,))
|
|
993 |
"where uuid = ? %s) "
|
|
994 |
"and n.node = v.node") % cluster_where
|
|
995 |
self.execute(q, args)
|
|
985 | 996 |
return self.fetchone() |
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
1056 | 1056 |
"""Return the (account, container, name) for the UUID given.""" |
1057 | 1057 |
|
1058 | 1058 |
logger.debug("get_uuid: %s %s", user, uuid) |
1059 |
info = self.node.latest_uuid(uuid) |
|
1059 |
info = self.node.latest_uuid(uuid, CLUSTER_NORMAL)
|
|
1060 | 1060 |
if info is None: |
1061 | 1061 |
raise NameError |
1062 | 1062 |
path, serial = info |
Also available in: Unified diff