Skip to content

Commit

Permalink
Merge pull request #1106 from noobaa/evgb-ContentTieringDemo
Browse files Browse the repository at this point in the history
Evgb content tiering demo
  • Loading branch information
tamireran committed Apr 27, 2016
2 parents 88a9c0a + f03ae23 commit ad4ff7e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
19 changes: 17 additions & 2 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) {
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 @@ -105,6 +108,18 @@ function allocate_node(pools, avoid_nodes) {
return group && group.nodes;
})))
};

// 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
);
}

let num_nodes = alloc_group ? alloc_group.nodes.length : 0;
dbg.log1('allocate_node: pool_set', pool_set,
'num_nodes', num_nodes,
Expand Down Expand Up @@ -133,4 +148,4 @@ function get_round_robin(nodes) {
var rr = (nodes.rr || 0) % nodes.length;
nodes.rr = rr + 1;
return nodes[rr];
}
}
6 changes: 5 additions & 1 deletion src/server/mapper/map_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ class MapBuilder {
'digest_type',
'digest_b64');
block._id = md_store.make_md_id();
let node = block_allocator.allocate_node(alloc.pools, avoid_nodes);
// 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
});
if (!node) {
dbg.error('MapBuilder: no nodes for allocation');
chunk.had_errors = true;
Expand Down
3 changes: 2 additions & 1 deletion src/server/stores/nodes_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const NODE_FIELDS_FOR_MAP = Object.freeze({
heartbeat: 1,
rpc_address: 1,
storage: 1,
latency_of_disk_read: 1,
});

module.exports = {
Expand Down Expand Up @@ -175,7 +176,7 @@ function aggregate_nodes_by_pool(query) {
}
))
.then(res => {
var bins = {};
var bins = {};
_.each(res, r => {
var t = bins[r._id[0]] = bins[r._id[0]] || {};
t[r._id[1]] = r.value;
Expand Down

0 comments on commit ad4ff7e

Please sign in to comment.