From f03ae23cc02f843e9834fb2221ce18cc4e1e9ca7 Mon Sep 17 00:00:00 2001 From: jeniawhite Date: Wed, 27 Apr 2016 16:48:07 +0300 Subject: [PATCH] Adding additional comments --- src/server/mapper/block_allocator.js | 13 ++++++++++--- src/server/mapper/map_builder.js | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/server/mapper/block_allocator.js b/src/server/mapper/block_allocator.js index 84a40c83a7..8e142e161e 100644 --- a/src/server/mapper/block_allocator.js +++ b/src/server/mapper/block_allocator.js @@ -93,9 +93,12 @@ function refresh_pool_alloc(pool) { * allocate_node * * @param avoid_nodes array of node ids to avoid + * @param content_tiering_params - in case of content tiering, the additional + * replicas will be saved in nodes that have the best disk read latency, but only + * from the chunk of nodes that we've received in pools. * */ -function allocate_node(pools, avoid_nodes, params) { +function allocate_node(pools, avoid_nodes, content_tiering_params) { let pool_set = _.map(pools, pool => pool._id.toString()).sort().join(','); let alloc_group = alloc_group_by_pool_set[pool_set] = @@ -106,9 +109,13 @@ function allocate_node(pools, avoid_nodes, params) { }))) }; - // Used in map_builder, for content tiering - if (params && params.special_replica) { + // If we are allocating a node for content tiering special replicas, + // we should run an additional sort, in order to get the best read latency nodes + if (content_tiering_params && content_tiering_params.special_replica) { alloc_group.nodes = _.sortBy(alloc_group.nodes, node => + // In order to sort the nodes by the best read latency values. + // We need to get the average of all the latency disk read values, + // and sort the nodes by the average that we've calculated. _.sum(node.latency_of_disk_read) / node.latency_of_disk_read.length ); } diff --git a/src/server/mapper/map_builder.js b/src/server/mapper/map_builder.js index 3d0635f811..40a8484f10 100644 --- a/src/server/mapper/map_builder.js +++ b/src/server/mapper/map_builder.js @@ -110,6 +110,8 @@ class MapBuilder { 'digest_type', 'digest_b64'); block._id = md_store.make_md_id(); + // We send an additional flag in order to allocate + // replicas of content tiering feature on the best read latency nodes let node = block_allocator.allocate_node(alloc.pools, avoid_nodes, { special_replica: true });