MCPcopy Index your code
hub / github.com/scality/cloudserver / _getReplicationInfo

Function _getReplicationInfo

lib/api/apiUtils/object/getReplicationInfo.js:33–66  ·  view source on GitHub ↗
(s3config, rule, replicationConfig, content, operationType,
    objectMD, bucketMD)

Source from the content-addressed store, hash-verified

31}
32
33function _getReplicationInfo(s3config, rule, replicationConfig, content, operationType,
34 objectMD, bucketMD) {
35 const storageTypes = [];
36 const backends = [];
37 const storageClasses = _getStorageClasses(s3config, rule);
38 if (!storageClasses) {
39 return undefined;
40 }
41 storageClasses.forEach(storageClass => {
42 const storageClassName =
43 storageClass.endsWith(':preferred_read') ?
44 storageClass.split(':')[0] : storageClass;
45 // TODO CLDSRV-646: for consistency, should we look at replicationEndpoints instead, like
46 // `_getStorageClasses()` ?
47 const location = s3config.locationConstraints[storageClassName];
48 if (location && replicationBackends[location.type]) {
49 storageTypes.push(location.type);
50 }
51 backends.push(_getBackend(objectMD, storageClassName));
52 });
53 if (storageTypes.length > 0 && operationType) {
54 content.push(operationType);
55 }
56 return {
57 status: 'PENDING',
58 backends,
59 content,
60 destination: replicationConfig.destination,
61 storageClass: storageClasses.join(','),
62 role: replicationConfig.role,
63 storageType: storageTypes.join(','),
64 isNFS: bucketMD.isNFS(),
65 };
66}
67
68/**
69 * Get the object replicationInfo to replicate data and metadata, or only

Callers 1

getReplicationInfoFunction · 0.85

Calls 2

_getStorageClassesFunction · 0.85
_getBackendFunction · 0.85

Tested by

no test coverage detected