Skip to content

Commit

Permalink
Fix codacey issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHogan committed Apr 2, 2021
1 parent e8b4c0d commit e6553f3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 30 deletions.
25 changes: 9 additions & 16 deletions src/buffer_organizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,23 @@

namespace hermes {

int PlaceInHierarchy(SharedMemoryContext *context, RpcContext *rpc,
SwapBlob swap_blob, const std::string &name,
api::Context &ctx) {
int result = 0;
Status PlaceInHierarchy(SharedMemoryContext *context, RpcContext *rpc,
SwapBlob swap_blob, const std::string &name,
api::Context &ctx) {
std::vector<PlacementSchema> schemas;
std::vector<size_t> sizes(1, swap_blob.size);
Status ret = CalculatePlacement(context, rpc, sizes, schemas, ctx);
Status result = CalculatePlacement(context, rpc, sizes, schemas, ctx);

if (ret.Succeeded()) {
if (result.Succeeded()) {
std::vector<u8> blob_mem(swap_blob.size);
Blob blob = {};
blob.data = blob_mem.data();
blob.size = blob_mem.size();
size_t bytes_read = ReadFromSwap(context, blob, swap_blob);
if (bytes_read != swap_blob.size) {
// TODO(chogan): @errorhandling
result = 1;
}

ret = PlaceBlob(context, rpc, schemas[0], blob, name.c_str(),
swap_blob.bucket_id, ctx, true);
ReadFromSwap(context, blob, swap_blob);
result = PlaceBlob(context, rpc, schemas[0], blob, name,
swap_blob.bucket_id, ctx, true);
} else {
// TODO(chogan): @errorhandling
result = 1;
LOG(ERROR) << result.Msg();
}

return result;
Expand Down
6 changes: 3 additions & 3 deletions src/buffer_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,9 @@ std::vector<f32> GetBandwidths(SharedMemoryContext *context);

u32 GetBufferSize(SharedMemoryContext *context, RpcContext *rpc, BufferID id);
bool BufferIsByteAddressable(SharedMemoryContext *context, BufferID id);
int PlaceInHierarchy(SharedMemoryContext *context, RpcContext *rpc,
SwapBlob swap_blob, const std::string &blob_name,
api::Context &ctx);
api::Status PlaceInHierarchy(SharedMemoryContext *context, RpcContext *rpc,
SwapBlob swap_blob, const std::string &blob_name,
api::Context &ctx);
api::Status PlaceBlob(SharedMemoryContext *context, RpcContext *rpc,
PlacementSchema &schema, Blob blob,
const std::string &name, BucketID bucket_id,
Expand Down
16 changes: 6 additions & 10 deletions src/rpc_thallium.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void ThalliumStartRpcServer(SharedMemoryContext *context, RpcContext *rpc,
auto rpc_rename_bucket =
[context, rpc](const request &req, BucketID id, const string &old_name,
const string &new_name) {
LocalRenameBucket(context, rpc, id, old_name.c_str(), new_name.c_str());
LocalRenameBucket(context, rpc, id, old_name, new_name);
req.respond(true);
};

Expand Down Expand Up @@ -410,16 +410,16 @@ void StartBufferOrganizer(SharedMemoryContext *context, RpcContext *rpc,
LOG(INFO) << "Buffer Organizer placing blob '" << name
<< "' in hierarchy. Attempt " << i + 1 << " of "
<< ctx.buffer_organizer_retries << std::endl;
int result = PlaceInHierarchy(context, rpc, swap_blob, name, ctx);
if (result == 0) {
api::Status result = PlaceInHierarchy(context, rpc, swap_blob, name, ctx);
if (result.Succeeded()) {
break;
} else {
// TODO(chogan): We probably don't want to sleep here, but for now this
// enables testing.
double sleep_ms = 2000;
ThalliumState *state = GetThalliumState(rpc);

if (state && state->bo_engine) {
// TODO(chogan): We probably don't want to sleep here, but for now
// this enables testing.
double sleep_ms = 2000;
tl::thread::self().sleep(*state->bo_engine, sleep_ms);
}
}
Expand All @@ -435,10 +435,6 @@ void StartBufferOrganizer(SharedMemoryContext *context, RpcContext *rpc,
for (int i = 0; i < retries; ++i) {
// TODO(chogan): MoveToTarget(context, rpc, target_id, swap_blob);
HERMES_NOT_IMPLEMENTED_YET;
int result = 0;
if (result == 0) {
break;
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/buffer_pool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static void TestBlobOverwrite() {

// NOTE(chogan): Overwrite the data
hapi::Blob new_blob(blob_size, '2');
status = bucket.Put(blob_name, new_blob, ctx);
Assert(bucket.Put(blob_name, new_blob, ctx).Succeeded());

Assert(buffers_available[slab_index] == 1);

Expand Down

0 comments on commit e6553f3

Please sign in to comment.