Skip to content

Commit

Permalink
Adding additional comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jeniawhite committed Apr 27, 2016
1 parent dbacd3d commit f03ae23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/server/mapper/block_allocator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand All @@ -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
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/server/mapper/map_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down

0 comments on commit f03ae23

Please sign in to comment.