File tree Expand file tree Collapse file tree 5 files changed +24
-7
lines changed Expand file tree Collapse file tree 5 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -83,11 +83,11 @@ namespace fc::primitives::sector_file {
83
83
struct SectorPaths {
84
84
public:
85
85
SectorId id;
86
- std::string unsealed;
87
- std::string sealed;
88
- std::string cache;
89
- std::string update;
90
- std::string update_cache;
86
+ std::string unsealed{} ;
87
+ std::string sealed{} ;
88
+ std::string cache{} ;
89
+ std::string update{} ;
90
+ std::string update_cache{} ;
91
91
92
92
void setPathByType (const SectorFileType &file_type,
93
93
const std::string &path);
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ namespace fc::primitives {
39
39
struct FsStat {
40
40
uint64_t capacity = 0 ;
41
41
uint64_t available = 0 ;
42
- uint64_t fs_available = 0 ; // Available to use for sector storage
42
+ uint64_t fs_available = 0 ; // Available to use for sector storage
43
43
uint64_t reserved = 0 ;
44
44
uint64_t max = 0 ;
45
45
uint64_t used = 0 ;
@@ -91,6 +91,14 @@ namespace fc::primitives {
91
91
std::vector<std::string> gpus;
92
92
};
93
93
94
+ inline bool operator ==(const WorkerResources &lhs,
95
+ const WorkerResources &rhs) {
96
+ return (lhs.physical_memory == rhs.physical_memory
97
+ && lhs.swap_memory == rhs.swap_memory
98
+ && lhs.reserved_memory == rhs.reserved_memory
99
+ && lhs.cpus == rhs.cpus && lhs.gpus == rhs.gpus );
100
+ }
101
+
94
102
struct WorkerInfo {
95
103
std::string hostname;
96
104
WorkerResources resources;
Original file line number Diff line number Diff line change @@ -260,7 +260,6 @@ namespace fc::sector_storage {
260
260
261
261
worker_handler->worker = std::move (worker);
262
262
worker_handler->info = std::move (info);
263
-
264
263
scheduler_->newWorker (std::move (worker_handler));
265
264
266
265
return outcome::success ();
Original file line number Diff line number Diff line change @@ -137,6 +137,11 @@ namespace fc::sector_storage {
137
137
138
138
void SchedulerImpl::newWorker (std::unique_ptr<WorkerHandle> worker) {
139
139
std::unique_lock<std::mutex> lock (workers_lock_);
140
+ for (const auto &[key, value] : workers_){
141
+ if (*value == *worker){
142
+ return ;
143
+ }
144
+ }
140
145
if (current_worker_id_ == std::numeric_limits<uint64_t >::max ()) {
141
146
current_worker_id_ = 0 ; // TODO(ortyomka): maybe better mechanism
142
147
}
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ namespace fc::sector_storage {
24
24
ActiveResources active;
25
25
};
26
26
27
+ inline bool operator ==(const WorkerHandle &lhs, const WorkerHandle &rhs) {
28
+ return lhs.info .hostname == rhs.info .hostname
29
+ && lhs.info .resources == rhs.info .resources ;
30
+ }
31
+
27
32
class WorkerSelector {
28
33
public:
29
34
virtual ~WorkerSelector () = default ;
You can’t perform that action at this time.
0 commit comments