diff options
author | Peter Portante <peter.portante@redhat.com> | 2012-10-31 20:28:42 -0400 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2012-11-16 04:50:34 -0800 |
commit | b696fc0e595d14404d3659bf15069addf3cf95f6 (patch) | |
tree | eb86dc8544ed012eeaaf015a9da4de17172d8cf3 | |
parent | ffc7618270522bb4550d29a11a81ab5aeca42d99 (diff) |
object-storage: reduce diffs, bury metadata update
Further reduce the diffs we have to carry by moving the Gluster specific
metadata stored when we create an object to the DiskFile class's put() method.
Change-Id: I8cef5412627d3ddfdadbf78ef947e067db5bf620
BUG: 870589
Signed-off-by: Peter Portante <peter.portante@redhat.com>
Reviewed-on: http://review.gluster.org/4177
Reviewed-by: Pete Zaitcev <zaitcev@redhat.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Tested-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Mohammed Junaid <junaid@redhat.com>
-rw-r--r-- | swift/1.4.8/gluster-swift-plugin.spec | 2 | ||||
-rw-r--r-- | swift/1.4.8/gluster-swift.spec | 2 | ||||
-rw-r--r-- | swift/1.4.8/plugins/DiskFile.py | 28 | ||||
-rw-r--r-- | swift/1.4.8/swift.diff | 45 |
4 files changed, 29 insertions, 48 deletions
diff --git a/swift/1.4.8/gluster-swift-plugin.spec b/swift/1.4.8/gluster-swift-plugin.spec index 0dbf187e092..4e4ea4f527f 100644 --- a/swift/1.4.8/gluster-swift-plugin.spec +++ b/swift/1.4.8/gluster-swift-plugin.spec @@ -13,7 +13,7 @@ %define _confdir /etc/swift %define _swiftdir /usr/lib/python2.6/site-packages/swift %define _ufo_version 1.0 -%define _ufo_release 7 +%define _ufo_release 8 Summary : GlusterFS Unified File and Object Storage. Name : gluster-swift-plugin diff --git a/swift/1.4.8/gluster-swift.spec b/swift/1.4.8/gluster-swift.spec index 02dfe814934..f9d9289515c 100644 --- a/swift/1.4.8/gluster-swift.spec +++ b/swift/1.4.8/gluster-swift.spec @@ -4,7 +4,7 @@ Name: gluster-swift Version: 1.4.8 -Release: 7%{?dist} +Release: 8%{?dist} Summary: OpenStack Object Storage (swift) Group: Development/Languages diff --git a/swift/1.4.8/plugins/DiskFile.py b/swift/1.4.8/plugins/DiskFile.py index 1f74ff2a59f..61b1c9cf99b 100644 --- a/swift/1.4.8/plugins/DiskFile.py +++ b/swift/1.4.8/plugins/DiskFile.py @@ -167,25 +167,42 @@ class Gluster_DiskFile(DiskFile): :param metadata: dictionary of metadata to be written :param extention: extension to be used when making the file """ - #Marker dir. if extension == '.ts': + # TombStone marker (deleted) return True + + # Fix up the metadata to ensure it has a proper value for the + # Content-Type metadata, as well as an X_TYPE and X_OBJECT_TYPE + # metadata values. + + content_type = metadata['Content-Type'] + if not content_type: + metadata['Content-Type'] = FILE_TYPE + x_object_type = FILE + else: + x_object_type = MARKER_DIR if content_type.lower() == DIR_TYPE else FILE + metadata[X_TYPE] = OBJECT + metadata[X_OBJECT_TYPE] = x_object_type + if extension == '.meta': + # Metadata recorded separately from the file self.put_metadata(metadata) return True - else: - extension = '' + + extension = '' + if metadata[X_OBJECT_TYPE] == MARKER_DIR: self.create_dir_object(os.path.join(self.datadir, self.obj)) self.put_metadata(metadata) self.data_file = self.datadir + '/' + self.obj return True - #Check if directory already exists. + + # Check if directory already exists. if self.is_dir: self.logger.error('Directory already exists %s/%s' % \ (self.datadir , self.obj)) return False - #metadata['name'] = self.name + timestamp = normalize_timestamp(metadata[X_TIMESTAMP]) write_metadata(tmppath, metadata) if X_CONTENT_LENGTH in metadata: @@ -211,7 +228,6 @@ class Gluster_DiskFile(DiskFile): do_chown(os.path.join(self.datadir, self.obj + extension), \ self.uid, self.gid) self.metadata = metadata - #self.logger.error("Meta %s", self.metadata) self.data_file = self.datadir + '/' + self.obj + extension return True diff --git a/swift/1.4.8/swift.diff b/swift/1.4.8/swift.diff index c29199461e2..3f088e21ebd 100644 --- a/swift/1.4.8/swift.diff +++ b/swift/1.4.8/swift.diff @@ -112,7 +112,7 @@ index 8a18cfd..f5346ce 100644 db_dir = storage_directory(DATADIR, part, hsh) db_path = os.path.join(self.root, drive, db_dir, hsh + '.db') diff --git a/swift/obj/server.py b/swift/obj/server.py -index 9cca16b..7a671c2 100644 +index 9cca16b..1861f33 100644 --- a/swift/obj/server.py +++ b/swift/obj/server.py @@ -1,4 +1,5 @@ @@ -195,42 +195,7 @@ index 9cca16b..7a671c2 100644 obj, self.logger, disk_chunk_size=self.disk_chunk_size) orig_timestamp = file.metadata.get('X-Timestamp') upload_expiration = time.time() + self.max_upload_time -@@ -580,12 +603,28 @@ class ObjectController(object): - if 'etag' in request.headers and \ - request.headers['etag'].lower() != etag: - return HTTPUnprocessableEntity(request=request) -- metadata = { -- 'X-Timestamp': request.headers['x-timestamp'], -- 'Content-Type': request.headers['content-type'], -- 'ETag': etag, -- 'Content-Length': str(os.fstat(fd).st_size), -- } -+ content_type = request.headers['content-type'] -+ if not Gluster_enabled(): -+ metadata = { -+ 'X-Timestamp': request.headers['x-timestamp'], -+ 'Content-Type': content_type, -+ 'ETag': etag, -+ 'Content-Length': str(os.fstat(fd).st_size), -+ } -+ else: -+ if not content_type: -+ content_type = FILE_TYPE -+ x_object_type = FILE -+ else: -+ x_object_type = MARKER_DIR if content_type.lower() == DIR_TYPE else FILE -+ metadata = { -+ 'X-Timestamp': request.headers['x-timestamp'], -+ 'Content-Type': content_type, -+ 'ETag': etag, -+ 'Content-Length': str(os.fstat(fd).st_size), -+ X_TYPE: OBJECT, -+ X_OBJECT_TYPE: x_object_type, -+ } - metadata.update(val for val in request.headers.iteritems() - if val[0].lower().startswith('x-object-meta-') and - len(val[0]) > 14) -@@ -612,7 +651,7 @@ class ObjectController(object): +@@ -612,7 +635,7 @@ class ObjectController(object): 'x-timestamp': file.metadata['X-Timestamp'], 'x-etag': file.metadata['ETag'], 'x-trans-id': request.headers.get('x-trans-id', '-')}, @@ -239,7 +204,7 @@ index 9cca16b..7a671c2 100644 resp = HTTPCreated(request=request, etag=etag) return resp -@@ -626,9 +665,9 @@ class ObjectController(object): +@@ -626,9 +649,9 @@ class ObjectController(object): content_type='text/plain') if self.mount_check and not check_mount(self.devices, device): return Response(status='507 %s is not mounted' % device) @@ -252,7 +217,7 @@ index 9cca16b..7a671c2 100644 if file.is_deleted() or ('X-Delete-At' in file.metadata and int(file.metadata['X-Delete-At']) <= time.time()): if request.headers.get('if-match') == '*': -@@ -702,7 +741,7 @@ class ObjectController(object): +@@ -702,7 +725,7 @@ class ObjectController(object): return resp if self.mount_check and not check_mount(self.devices, device): return Response(status='507 %s is not mounted' % device) @@ -261,7 +226,7 @@ index 9cca16b..7a671c2 100644 obj, self.logger, disk_chunk_size=self.disk_chunk_size) if file.is_deleted() or ('X-Delete-At' in file.metadata and int(file.metadata['X-Delete-At']) <= time.time()): -@@ -744,7 +783,7 @@ class ObjectController(object): +@@ -744,7 +767,7 @@ class ObjectController(object): if self.mount_check and not check_mount(self.devices, device): return Response(status='507 %s is not mounted' % device) response_class = HTTPNoContent |