1414
1515#pragma once
1616#include " gmock/gmock.h"
17- #include " ray/core_worker/reference_counter .h"
17+ #include " ray/core_worker/reference_counter_interface .h"
1818namespace ray {
1919namespace core {
2020
2121class MockReferenceCounter : public ReferenceCounterInterface {
2222 public:
2323 MockReferenceCounter () : ReferenceCounterInterface() {}
2424
25+ MOCK_METHOD1 (DrainAndShutdown, void (std::function<void ()> shutdown));
26+
27+ MOCK_CONST_METHOD0 (Size, size_t ());
28+
29+ MOCK_CONST_METHOD1 (OwnedByUs, bool (const ObjectID &object_id));
30+
2531 MOCK_METHOD2 (AddLocalReference,
26- void (const ObjectID &object_id, const std::string &call_sit ));
32+ void (const ObjectID &object_id, const std::string &call_site ));
2733
28- MOCK_METHOD4 (AddBorrowedObject,
29- bool (const ObjectID &object_id,
30- const ObjectID &outer_id,
31- const rpc::Address &owner_address,
32- bool foreign_owner_already_monitoring));
34+ MOCK_METHOD2 (RemoveLocalReference,
35+ void (const ObjectID &object_id, std::vector<ObjectID> *deleted));
36+
37+ MOCK_METHOD4 (UpdateSubmittedTaskReferences,
38+ void (const std::vector<ObjectID> &return_ids,
39+ const std::vector<ObjectID> &argument_ids_to_add,
40+ const std::vector<ObjectID> &argument_ids_to_remove,
41+ std::vector<ObjectID> *deleted));
42+
43+ MOCK_METHOD1 (UpdateResubmittedTaskReferences,
44+ void (const std::vector<ObjectID> &argument_ids));
45+
46+ MOCK_METHOD6 (UpdateFinishedTaskReferences,
47+ void (const std::vector<ObjectID> &return_ids,
48+ const std::vector<ObjectID> &argument_ids,
49+ bool release_lineage,
50+ const rpc::Address &worker_addr,
51+ const ::google::protobuf::RepeatedPtrField<rpc::ObjectReferenceCount>
52+ &borrowed_refs,
53+ std::vector<ObjectID> *deleted));
3354
3455 MOCK_METHOD9 (AddOwnedObject,
3556 void (const ObjectID &object_id,
@@ -42,6 +63,44 @@ class MockReferenceCounter : public ReferenceCounterInterface {
4263 const std::optional<NodeID> &pinned_at_node_id,
4364 rpc::TensorTransport tensor_transport));
4465
66+ MOCK_METHOD2 (AddDynamicReturn,
67+ void (const ObjectID &object_id, const ObjectID &generator_id));
68+
69+ MOCK_METHOD2 (OwnDynamicStreamingTaskReturnRef,
70+ void (const ObjectID &object_id, const ObjectID &generator_id));
71+
72+ MOCK_METHOD2 (TryReleaseLocalRefs,
73+ void (const std::vector<ObjectID> &object_ids,
74+ std::vector<ObjectID> *deleted));
75+
76+ MOCK_METHOD2 (CheckGeneratorRefsLineageOutOfScope,
77+ bool (const ObjectID &generator_id, int64_t num_objects_generated));
78+
79+ MOCK_METHOD2 (UpdateObjectSize, void (const ObjectID &object_id, int64_t object_size));
80+
81+ MOCK_METHOD4 (AddBorrowedObject,
82+ bool (const ObjectID &object_id,
83+ const ObjectID &outer_id,
84+ const rpc::Address &owner_address,
85+ bool foreign_owner_already_monitoring));
86+
87+ MOCK_CONST_METHOD2 (GetOwner,
88+ bool (const ObjectID &object_id, rpc::Address *owner_address));
89+
90+ MOCK_CONST_METHOD1 (HasOwner, bool (const ObjectID &object_id));
91+
92+ MOCK_CONST_METHOD1 (
93+ HasOwner, StatusSet<StatusT::NotFound>(const std::vector<ObjectID> &object_ids));
94+
95+ MOCK_CONST_METHOD1 (GetOwnerAddresses,
96+ std::vector<rpc::Address>(const std::vector<ObjectID> &object_ids));
97+
98+ MOCK_CONST_METHOD1 (IsPlasmaObjectFreed, bool (const ObjectID &object_id));
99+
100+ MOCK_METHOD1 (TryMarkFreedObjectInUseAgain, bool (const ObjectID &object_id));
101+
102+ MOCK_METHOD1 (FreePlasmaObjects, void (const std::vector<ObjectID> &object_ids));
103+
45104 MOCK_METHOD2 (AddObjectOutOfScopeOrFreedCallback,
46105 bool (const ObjectID &object_id,
47106 const std::function<void (const ObjectID &)> callback));
@@ -50,6 +109,106 @@ class MockReferenceCounter : public ReferenceCounterInterface {
50109 bool (const ObjectID &object_id,
51110 const std::function<void (const ObjectID &)> callback));
52111
112+ MOCK_METHOD3 (SubscribeRefRemoved,
113+ void (const ObjectID &object_id,
114+ const ObjectID &contained_in_id,
115+ const rpc::Address &owner_address));
116+
117+ MOCK_METHOD1 (SetReleaseLineageCallback, void (const LineageReleasedCallback &callback));
118+
119+ MOCK_METHOD1 (PublishRefRemoved, void (const ObjectID &object_id));
120+
121+ MOCK_CONST_METHOD0 (NumObjectIDsInScope, size_t ());
122+
123+ MOCK_CONST_METHOD0 (NumObjectsOwnedByUs, size_t ());
124+
125+ MOCK_CONST_METHOD0 (NumActorsOwnedByUs, size_t ());
126+
127+ MOCK_CONST_METHOD0 (GetAllInScopeObjectIDs, std::unordered_set<ObjectID>());
128+
129+ MOCK_CONST_METHOD0 (GetAllReferenceCounts,
130+ std::unordered_map<ObjectID, std::pair<size_t , size_t >>());
131+
132+ MOCK_CONST_METHOD0 (DebugString, std::string());
133+
134+ MOCK_METHOD3 (
135+ PopAndClearLocalBorrowers,
136+ void (const std::vector<ObjectID> &borrowed_ids,
137+ ::google::protobuf::RepeatedPtrField<rpc::ObjectReferenceCount> *proto,
138+ std::vector<ObjectID> *deleted));
139+
140+ MOCK_METHOD3 (AddNestedObjectIds,
141+ void (const ObjectID &object_id,
142+ const std::vector<ObjectID> &inner_ids,
143+ const rpc::Address &owner_address));
144+
145+ MOCK_METHOD2 (UpdateObjectPinnedAtRaylet,
146+ void (const ObjectID &object_id, const NodeID &node_id));
147+
148+ MOCK_CONST_METHOD4 (IsPlasmaObjectPinnedOrSpilled,
149+ bool (const ObjectID &object_id,
150+ bool *owned_by_us,
151+ NodeID *pinned_at,
152+ bool *spilled));
153+
154+ MOCK_METHOD1 (ResetObjectsOnRemovedNode, void (const NodeID &node_id));
155+
156+ MOCK_METHOD0 (FlushObjectsToRecover, std::vector<ObjectID>());
157+
158+ MOCK_CONST_METHOD1 (HasReference, bool (const ObjectID &object_id));
159+
160+ MOCK_CONST_METHOD3 (
161+ AddObjectRefStats,
162+ void (const absl::flat_hash_map<ObjectID, std::pair<int64_t , std::string>>
163+ &pinned_objects,
164+ rpc::CoreWorkerStats *stats,
165+ const int64_t limit));
166+
167+ MOCK_METHOD2 (AddObjectLocation, bool (const ObjectID &object_id, const NodeID &node_id));
168+
169+ MOCK_METHOD2 (RemoveObjectLocation,
170+ bool (const ObjectID &object_id, const NodeID &node_id));
171+
172+ MOCK_METHOD1 (GetObjectLocations,
173+ std::optional<absl::flat_hash_set<NodeID>>(const ObjectID &object_id));
174+
175+ MOCK_METHOD1 (PublishObjectLocationSnapshot, void (const ObjectID &object_id));
176+
177+ MOCK_METHOD2 (FillObjectInformation,
178+ void (const ObjectID &object_id,
179+ rpc::WorkerObjectLocationsPubMessage *object_info));
180+
181+ MOCK_METHOD3 (HandleObjectSpilled,
182+ bool (const ObjectID &object_id,
183+ const std::string &spilled_url,
184+ const NodeID &spilled_node_id));
185+
186+ MOCK_CONST_METHOD1 (GetLocalityData,
187+ std::optional<LocalityData>(const ObjectID &object_id));
188+
189+ MOCK_METHOD3 (ReportLocalityData,
190+ bool (const ObjectID &object_id,
191+ const absl::flat_hash_set<NodeID> &locations,
192+ uint64_t object_size));
193+
194+ MOCK_METHOD2 (AddBorrowerAddress,
195+ void (const ObjectID &object_id, const rpc::Address &borrower_address));
196+
197+ MOCK_CONST_METHOD2 (IsObjectReconstructable,
198+ bool (const ObjectID &object_id, bool *lineage_evicted));
199+
200+ MOCK_METHOD1 (EvictLineage, int64_t (int64_t min_bytes_to_evict));
201+
202+ MOCK_METHOD2 (UpdateObjectPendingCreation,
203+ void (const ObjectID &object_id, bool pending_creation));
204+
205+ MOCK_CONST_METHOD1 (IsObjectPendingCreation, bool (const ObjectID &object_id));
206+
207+ MOCK_METHOD0 (ReleaseAllLocalReferences, void ());
208+
209+ MOCK_CONST_METHOD1 (GetTensorTransport,
210+ std::optional<rpc::TensorTransport>(const ObjectID &object_id));
211+
53212 virtual ~MockReferenceCounter () {}
54213};
55214
0 commit comments