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 {
8383 struct SectorPaths {
8484 public:
8585 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{} ;
9191
9292 void setPathByType (const SectorFileType &file_type,
9393 const std::string &path);
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ namespace fc::primitives {
3939 struct FsStat {
4040 uint64_t capacity = 0 ;
4141 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
4343 uint64_t reserved = 0 ;
4444 uint64_t max = 0 ;
4545 uint64_t used = 0 ;
@@ -91,6 +91,14 @@ namespace fc::primitives {
9191 std::vector<std::string> gpus;
9292 };
9393
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+
94102 struct WorkerInfo {
95103 std::string hostname;
96104 WorkerResources resources;
Original file line number Diff line number Diff line change @@ -260,7 +260,6 @@ namespace fc::sector_storage {
260260
261261 worker_handler->worker = std::move (worker);
262262 worker_handler->info = std::move (info);
263-
264263 scheduler_->newWorker (std::move (worker_handler));
265264
266265 return outcome::success ();
Original file line number Diff line number Diff line change @@ -137,6 +137,11 @@ namespace fc::sector_storage {
137137
138138 void SchedulerImpl::newWorker (std::unique_ptr<WorkerHandle> worker) {
139139 std::unique_lock<std::mutex> lock (workers_lock_);
140+ for (const auto &[key, value] : workers_){
141+ if (*value == *worker){
142+ return ;
143+ }
144+ }
140145 if (current_worker_id_ == std::numeric_limits<uint64_t >::max ()) {
141146 current_worker_id_ = 0 ; // TODO(ortyomka): maybe better mechanism
142147 }
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ namespace fc::sector_storage {
2424 ActiveResources active;
2525 };
2626
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+
2732 class WorkerSelector {
2833 public:
2934 virtual ~WorkerSelector () = default ;
You can’t perform that action at this time.
0 commit comments