Let gateway to pass metadata about extra sources
As the follow up of I3aa27d4df5bb151c09003a98209c7ccf91d25828, which enables storlet invocation over multi input objects, this patch let docker gateway to pass metadata for extra sources to SDaemon, so that storlet can refer user defined metadata of the extra source objects. Change-Id: Ic0696bcb80b581a358d4e30d044371f71acc6dc0
This commit is contained in:
@@ -528,6 +528,7 @@ class StorletInvocationProtocol(object):
|
||||
'extra_source no requires data_fd just data_iter')
|
||||
self.extra_data_sources.append(
|
||||
{'read_fd': None, 'write_fd': None,
|
||||
'user_metadata': source.user_metadata,
|
||||
'data_iter': source.data_iter})
|
||||
|
||||
if not os.path.exists(storlet_logger_path):
|
||||
@@ -578,8 +579,11 @@ class StorletInvocationProtocol(object):
|
||||
FDMetadata(SBUS_FD_OUTPUT_OBJECT_METADATA).to_dict(),
|
||||
FDMetadata(SBUS_FD_LOGGER).to_dict()]
|
||||
|
||||
for fd_metadata in self.extra_data_sources:
|
||||
fds_metadata.append(FDMetadata(SBUS_FD_INPUT_OBJECT).to_dict())
|
||||
for source in self.extra_data_sources:
|
||||
fdmd = FDMetadata(SBUS_FD_INPUT_OBJECT)
|
||||
if source['user_metadata']:
|
||||
fdmd.storage_metadata.update(source['user_metadata'])
|
||||
fds_metadata.append(fdmd.to_dict())
|
||||
return fds_metadata
|
||||
|
||||
@contextmanager
|
||||
|
||||
@@ -46,16 +46,18 @@ public class MultiInputStorlet implements IStorlet {
|
||||
* Copy metadata into out md
|
||||
*/
|
||||
HashMap<String, String> md = new HashMap<String, String>();
|
||||
HashMap<String, String> object_md;
|
||||
Iterator it;
|
||||
StorletInputStream sis = inputStreams.get(0);
|
||||
object_md = sis.getMetadata();
|
||||
it = object_md.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry pairs = (Map.Entry) it.next();
|
||||
log.emitLog("Putting metadata " + (String) pairs.getKey() + "="
|
||||
+ (String) pairs.getValue());
|
||||
md.put((String) pairs.getKey(), (String) pairs.getValue());
|
||||
for(StorletInputStream psis : inputStreams){
|
||||
HashMap<String, String> object_md;
|
||||
Iterator it;
|
||||
|
||||
object_md = psis.getMetadata();
|
||||
it = object_md.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry pairs = (Map.Entry) it.next();
|
||||
log.emitLog("Putting metadata " + (String) pairs.getKey() + "="
|
||||
+ (String) pairs.getValue());
|
||||
md.put((String) pairs.getKey(), (String) pairs.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -58,10 +58,12 @@ class TestMultiInputStorletOnProxy(StorletJavaFunctionalTest):
|
||||
copied_obj = 'copied'
|
||||
c.put_object(self.url, self.token,
|
||||
self.container, obj,
|
||||
'0123456789abcd')
|
||||
'0123456789abcd',
|
||||
headers={'X-Object-Meta-Key1': 'value1'})
|
||||
c.put_object(self.url, self.token,
|
||||
self.container, obj2,
|
||||
'efghijklmnopqr')
|
||||
'efghijklmnopqr',
|
||||
headers={'X-Object-Meta-Key2': 'value2'})
|
||||
|
||||
headers = {
|
||||
'X-Run-Storlet': self.storlet_name,
|
||||
@@ -84,6 +86,8 @@ class TestMultiInputStorletOnProxy(StorletJavaFunctionalTest):
|
||||
resp_headers, resp_content = c.get_object(
|
||||
self.url, self.token, self.container, copied_obj)
|
||||
self.assertEqual(expected_string, resp_content)
|
||||
self.assertEqual('value1', resp_headers['x-object-meta-key1'])
|
||||
self.assertEqual('value2', resp_headers['x-object-meta-key2'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user