Skip to content

Commit

Permalink
Merge 52cee82 into b9ac73e
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHogan committed Apr 16, 2021
2 parents b9ac73e + 52cee82 commit 22d2799
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/buffer_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,8 @@ api::Status PlaceBlob(SharedMemoryContext *context, RpcContext *rpc,
HERMES_END_TIMED_BLOCK();

// NOTE(chogan): Update all metadata associated with this Put
AttachBlobToBucket(context, rpc, name.c_str(), bucket_id, buffer_ids);
AttachBlobToBucket(context, rpc, name.c_str(), bucket_id, buffer_ids,
false, called_from_buffer_organizer);
} else {
if (called_from_buffer_organizer) {
result = PLACE_SWAP_BLOB_TO_BUF_FAILED;
Expand Down
18 changes: 17 additions & 1 deletion src/metadata_management.cc
Original file line number Diff line number Diff line change
Expand Up @@ -619,12 +619,28 @@ BufferIdArray GetBufferIdsFromBlobId(Arena *arena,
void AttachBlobToBucket(SharedMemoryContext *context, RpcContext *rpc,
const char *blob_name, BucketID bucket_id,
const std::vector<BufferID> &buffer_ids,
bool is_swap_blob) {
bool is_swap_blob, bool called_from_buffer_organizer) {
MetadataManager *mdm = GetMetadataManagerFromContext(context);

std::string internal_name = MakeInternalBlobName(blob_name, bucket_id);
int target_node = HashString(mdm, rpc, internal_name.c_str());

BlobID blob_id = {};
if (called_from_buffer_organizer) {
blob_id = GetBlobId(context, rpc, blob_name, bucket_id);

if (!IsNullBlobId(blob_id)) {
// Remove old BlobID from the bucket's list of Blobs
RemoveBlobFromBucketInfo(context, rpc, bucket_id, blob_id);

// Release the IDs that represented the SwapBlob info
FreeBufferIdList(context, rpc, blob_id);
} else {
LOG(WARNING) << "Expected to find BlobID " << blob_id.as_int
<< " in Map but didn't." << std::endl;
}
}

// NOTE(chogan): A negative node_id indicates a swap blob
blob_id.bits.node_id = is_swap_blob ? -target_node : target_node;
blob_id.bits.buffer_ids_offset = AllocateBufferIdList(context, rpc,
Expand Down
9 changes: 8 additions & 1 deletion src/metadata_management.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ VBucketID GetOrCreateVBucketId(SharedMemoryContext *context, RpcContext *rpc,
void AttachBlobToBucket(SharedMemoryContext *context, RpcContext *rpc,
const char *blob_name, BucketID bucket_id,
const std::vector<BufferID> &buffer_ids,
bool is_swap_blob = false);
bool is_swap_blob = false,
bool called_from_buffer_organizer = false);

/**
*
Expand Down Expand Up @@ -343,6 +344,12 @@ void AttachBlobToVBucket(SharedMemoryContext *context, RpcContext *rpc,
const char *blob_name, const char *bucket_name,
VBucketID vbucket_id);

/**
*
*/
void RemoveBlobFromBucketInfo(SharedMemoryContext *context, RpcContext *rpc,
BucketID bucket_id, BlobID blob_id);

/**
*
*/
Expand Down

0 comments on commit 22d2799

Please sign in to comment.