Hermes  0.9.5-beta
Hierarchical Distributed I/O Buffering System
data_placement_engine.h
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Distributed under BSD 3-Clause license. *
3  * Copyright by The HDF Group. *
4  * Copyright by the Illinois Institute of Technology. *
5  * All rights reserved. *
6  * *
7  * This file is part of Hermes. The full Hermes copyright notice, including *
8  * terms governing use, modification, and redistribution, is contained in *
9  * the COPYING file, which can be found at the top directory. If you do not *
10  * have access to the file, you may request a copy from help@hdfgroup.org. *
11  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12 
13 #ifndef HERMES_DATA_PLACEMENT_ENGINE_H_
14 #define HERMES_DATA_PLACEMENT_ENGINE_H_
15 
16 #include <map>
17 
18 #include "hermes.h"
19 #include "hermes_status.h"
20 #include "hermes_types.h"
21 
22 namespace hermes {
23 
24 #define VERIFY_DPE_POLICY(ctx) \
25  if (ctx.policy != policy_) { \
26  return Status(); \
27  }
28 
29 using api::Status;
31 
35 class DPE {
36  protected:
37  PlacementPolicy policy_;
39  public:
40  std::vector<f32> bandwidths;
42  explicit DPE(PlacementPolicy policy) : policy_(policy) {}
43  virtual ~DPE() = default;
47  virtual Status Placement(const std::vector<size_t> &blob_sizes,
48  const std::vector<u64> &node_state,
49  const std::vector<TargetID> &targets,
50  const api::Context &ctx,
51  std::vector<PlacementSchema> &output) = 0;
52 
53  protected:
55  std::vector<int> GetValidSplitChoices(size_t blob_size);
56  bool SplitBlob(size_t blob_size);
58  void GetSplitSizes(size_t blob_size, std::vector<size_t> &output);
59 };
60 
62 
64  const std::vector<size_t> &blob_size,
65  std::vector<PlacementSchema> &output,
66  const api::Context &api_context);
67 
68 } // namespace hermes
69 #endif // HERMES_DATA_PLACEMENT_ENGINE_H_
Definition: hermes_status.h:80
Definition: data_placement_engine.h:35
bool SplitBlob(size_t blob_size)
Definition: data_placement_engine.cc:50
DPE(PlacementPolicy policy)
Definition: data_placement_engine.h:42
std::vector< f32 > bandwidths
Definition: data_placement_engine.h:40
std::vector< int > GetValidSplitChoices(size_t blob_size)
Definition: data_placement_engine.cc:33
PlacementPolicy policy_
Definition: data_placement_engine.h:37
void GetSplitSizes(size_t blob_size, std::vector< size_t > &output)
Definition: data_placement_engine.cc:65
virtual Status Placement(const std::vector< size_t > &blob_sizes, const std::vector< u64 > &node_state, const std::vector< TargetID > &targets, const api::Context &ctx, std::vector< PlacementSchema > &output)=0
PlacementPolicy
Definition: hermes_types.h:73
Definition: adapter_utils.cc:35
PlacementSchema AggregateBlobSchema(PlacementSchema &schema)
Definition: data_placement_engine.cc:84
std::vector< std::pair< size_t, TargetID > > PlacementSchema
Definition: hermes_types.h:226
Status CalculatePlacement(SharedMemoryContext *context, RpcContext *rpc, const std::vector< size_t > &blob_sizes, std::vector< PlacementSchema > &output, const api::Context &api_context)
Definition: data_placement_engine.cc:111
Definition: rpc.h:43
Definition: buffer_pool.h:273
Definition: hermes_types.h:137