Skip to content

Commit e0c6297

Browse files
lifecycle and indexes apis
1 parent 2d5f38b commit e0c6297

File tree

3 files changed

+67
-39
lines changed

3 files changed

+67
-39
lines changed

extensions/lifecycle/tasks/LifecycleTaskV2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class LifecycleTaskV2 extends LifecycleTask {
165165
// Undefined params can happen when lifecycle configuration rule is disabled for example.
166166
if (!params) {
167167
log.debug('no appropriate listing found', {
168-
method: 'LifecycleTaskV2._getObjectList',
168+
method: 'LifecycleTaskV2._getObjectVersions',
169169
bucketLCRules,
170170
currentDate,
171171
bucketData,
@@ -213,7 +213,7 @@ class LifecycleTaskV2 extends LifecycleTask {
213213
if (!err) {
214214
log.debug(
215215
'sent kafka entry for bucket consumption', {
216-
method: 'LifecycleTaskV2._getObjectList',
216+
method: 'LifecycleTaskV2._getObjectVersions',
217217
});
218218
}
219219
});

extensions/replication/tasks/ReplicateObject.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const {
1212
CloudserverClient,
1313
CloudserverClientConfig,
1414
GetObjectCommand,
15+
PutDataCommand,
1516
MultipleBackendPutObjectCommand,
1617
MultipleBackendInitiateMPUCommand,
1718
MultipleBackendPutMPUPartCommand,
@@ -555,7 +556,7 @@ class ReplicateObject extends BackbeatTask {
555556
this._publishReadMetrics(partSize, readStartTime);
556557
});
557558
log.debug('putting data', { entry: destEntry.getLogInfo(), part });
558-
const command = new MultipleBackendPutObjectCommand({
559+
const command = new PutDataCommand({
559560
Bucket: destEntry.getBucket(),
560561
Key: destEntry.getObjectKey(),
561562
CanonicalID: destEntry.getOwnerId(),

lib/BackbeatMetadataProxy.js

Lines changed: 63 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ const RoleCredentials = require('./credentials/RoleCredentials');
99
const { getAccountCredentials } = require('./credentials/AccountCredentials');
1010
const { http: HttpAgent } = require('httpagent');
1111
const { lifecycleListing: { NON_CURRENT_TYPE, CURRENT_TYPE, ORPHAN_DM_TYPE } } = require('./constants');
12+
const {
13+
CloudserverClient,
14+
CloudserverClientConfig,
15+
GetBucketIndexesCommand,
16+
PutBucketIndexesCommand,
17+
DeleteBucketIndexesCommand,
18+
ListLifecycleCurrentsCommand,
19+
ListLifecycleNonCurrentsCommand,
20+
ListLifecycleOrphansCommand
21+
} = require('./clients/smithy/build/smithy/source/typescript-codegen');
1222

1323
class BackbeatMetadataProxy extends BackbeatTask {
1424
constructor(s3Endpoint, s3Auth, sourceHTTPAgent) {
@@ -229,37 +239,43 @@ class BackbeatMetadataProxy extends BackbeatTask {
229239

230240
listLifecycle(listType, params, log, cb) {
231241
if (listType === CURRENT_TYPE) {
232-
return this.backbeatSource.listLifecycleCurrents(params, (err, data) => {
233-
if (err) {
242+
const command = new ListLifecycleCurrentsCommand(params);
243+
return this.cloudserverSourceClient.send(command)
244+
.then(data => {
245+
return cb(null, data.Contents, data.IsTruncated, {
246+
marker: data.NextMarker,
247+
});
248+
})
249+
.catch(err => {
234250
return cb(err);
235-
}
236-
return cb(null, data.Contents, data.IsTruncated, {
237-
marker: data.NextMarker,
238251
});
239-
});
240252
}
241253

242254
if (listType === NON_CURRENT_TYPE) {
243-
return this.backbeatSource.listLifecycleNonCurrents(params, (err, data) => {
244-
if (err) {
255+
const command = new ListLifecycleNonCurrentsCommand(params);
256+
return this.cloudserverSourceClient.send(command)
257+
.then(data => {
258+
return cb(null, data.Contents, data.IsTruncated, {
259+
keyMarker: data.NextKeyMarker,
260+
versionIdMarker: data.NextVersionIdMarker,
261+
});
262+
})
263+
.catch(err => {
245264
return cb(err);
246-
}
247-
return cb(null, data.Contents, data.IsTruncated, {
248-
keyMarker: data.NextKeyMarker,
249-
versionIdMarker: data.NextVersionIdMarker,
250265
});
251-
});
252266
}
253267

254268
if (listType === ORPHAN_DM_TYPE) {
255-
return this.backbeatSource.listLifecycleOrphans(params, (err, data) => {
256-
if (err) {
269+
const command = new ListLifecycleOrphansCommand(params);
270+
return this.cloudserverSourceClient.send(command)
271+
.then(data => {
272+
return cb(null, data.Contents, data.IsTruncated, {
273+
marker: data.NextMarker,
274+
});
275+
})
276+
.catch(err => {
257277
return cb(err);
258-
}
259-
return cb(null, data.Contents, data.IsTruncated, {
260-
marker: data.NextMarker,
261278
});
262-
});
263279
}
264280

265281
log.error('invalid listType', {
@@ -272,36 +288,47 @@ class BackbeatMetadataProxy extends BackbeatTask {
272288
}
273289

274290
getBucketIndexes(bucket, log, cb) {
275-
this.backbeatSource.getBucketIndexes({ Bucket: bucket }, (err, res) => {
276-
if (err) {
277-
return cb(err);
278-
}
279-
return cb(null, res.Indexes);
291+
const command = new GetBucketIndexesCommand({
292+
Bucket: bucket,
280293
});
294+
295+
return this.cloudserverSourceClient.send(command)
296+
.then(res => {
297+
return cb(null, res.Indexes);
298+
})
299+
.catch(err => {
300+
return cb(err);
301+
});
281302
}
282303

283304
putBucketIndexes(bucket, indexes, log, cb) {
284-
this.backbeatSource.putBucketIndexes({
305+
const command = new PutBucketIndexesCommand({
285306
Bucket: bucket,
286307
Body: JSON.stringify(indexes),
287-
}, err => {
288-
if (err) {
289-
return cb(err);
290-
}
291-
return cb(null);
292308
});
309+
310+
return this.cloudserverSourceClient.send(command)
311+
.then(() => {
312+
return cb(null);
313+
})
314+
.catch(err => {
315+
return cb(err);
316+
});
293317
}
294318

295319
deleteBucketIndexes(bucket, indexes, log, cb) {
296-
this.backbeatSource.deleteBucketIndexes({
320+
const command = new DeleteBucketIndexesCommand({
297321
Bucket: bucket,
298322
Body: JSON.stringify(indexes),
299-
}, err => {
300-
if (err) {
301-
return cb(err);
302-
}
303-
return cb(null);
304323
});
324+
325+
return this.cloudserverSourceClient.send(command)
326+
.then(() => {
327+
return cb(null);
328+
})
329+
.catch(err => {
330+
return cb(err);
331+
});
305332
}
306333

307334

0 commit comments

Comments
 (0)