mirror of
https://github.com/ceph/ceph
synced 2025-01-01 08:32:24 +00:00
common,test: update mClockPriorityQueue to accomodate the change in dmc
* cost is required to be a positive number * PullPriorityQueue's construct uses an enum instead of a bool for specifying the behavior when request breaches the limit. Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
bdc7c5fdfa
commit
e3242088ab
@ -210,7 +210,8 @@ namespace ceph {
|
||||
|
||||
SubQueues high_queue;
|
||||
|
||||
dmc::PullPriorityQueue<K,T,true> queue;
|
||||
using Queue = dmc::PullPriorityQueue<K,T,false>;
|
||||
Queue queue;
|
||||
|
||||
// when enqueue_front is called, rather than try to re-calc tags
|
||||
// to put in mClock priority queue, we'll just keep a separate
|
||||
@ -221,9 +222,9 @@ namespace ceph {
|
||||
public:
|
||||
|
||||
mClockQueue(
|
||||
const typename dmc::PullPriorityQueue<K,T,true>::ClientInfoFunc& info_func,
|
||||
const typename Queue::ClientInfoFunc& info_func,
|
||||
double anticipation_timeout = 0.0) :
|
||||
queue(info_func, true, anticipation_timeout)
|
||||
queue(info_func, dmc::AtLimit::Allow, anticipation_timeout)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace ceph {
|
||||
unsigned priority,
|
||||
unsigned cost,
|
||||
Request&& item) {
|
||||
queue.enqueue(get_inner_client(cl, item), priority, 0u, std::move(item));
|
||||
queue.enqueue(get_inner_client(cl, item), priority, 1u, std::move(item));
|
||||
}
|
||||
|
||||
// Enqueue the op in the front of the regular queue
|
||||
@ -86,7 +86,7 @@ namespace ceph {
|
||||
unsigned priority,
|
||||
unsigned cost,
|
||||
Request&& item) {
|
||||
queue.enqueue_front(get_inner_client(cl, item), priority, 0u,
|
||||
queue.enqueue_front(get_inner_client(cl, item), priority, 1u,
|
||||
std::move(item));
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ namespace ceph {
|
||||
Request&& item) override final {
|
||||
queue.enqueue(client_info_mgr.osd_op_type(item),
|
||||
priority,
|
||||
0u,
|
||||
1u,
|
||||
std::move(item));
|
||||
}
|
||||
|
||||
|
@ -74,8 +74,8 @@ TEST(mClockPriorityQueue, Sizes)
|
||||
q.enqueue_strict(c1, 1, Request(1));
|
||||
q.enqueue_strict(c2, 2, Request(2));
|
||||
q.enqueue_strict(c1, 2, Request(3));
|
||||
q.enqueue(c2, 1, 0, Request(4));
|
||||
q.enqueue(c1, 2, 0, Request(5));
|
||||
q.enqueue(c2, 1, 1u, Request(4));
|
||||
q.enqueue(c1, 2, 1u, Request(5));
|
||||
q.enqueue_strict(c2, 1, Request(6));
|
||||
|
||||
ASSERT_FALSE(q.empty());
|
||||
@ -150,10 +150,10 @@ TEST(mClockPriorityQueue, JustNotStrict)
|
||||
|
||||
// non-strict queue ignores priorites, but will divide between
|
||||
// clients evenly and maintain orders between clients
|
||||
q.enqueue(c1, 1, 0, Request(1));
|
||||
q.enqueue(c1, 2, 0, Request(2));
|
||||
q.enqueue(c2, 3, 0, Request(3));
|
||||
q.enqueue(c2, 4, 0, Request(4));
|
||||
q.enqueue(c1, 1, 1u, Request(1));
|
||||
q.enqueue(c1, 2, 1u, Request(2));
|
||||
q.enqueue(c2, 3, 1u, Request(3));
|
||||
q.enqueue(c2, 4, 1u, Request(4));
|
||||
|
||||
Request r1, r2;
|
||||
|
||||
@ -184,10 +184,10 @@ TEST(mClockPriorityQueue, EnqueuFront)
|
||||
|
||||
// non-strict queue ignores priorites, but will divide between
|
||||
// clients evenly and maintain orders between clients
|
||||
q.enqueue(c1, 1, 0, Request(1));
|
||||
q.enqueue(c1, 2, 0, Request(2));
|
||||
q.enqueue(c2, 3, 0, Request(3));
|
||||
q.enqueue(c2, 4, 0, Request(4));
|
||||
q.enqueue(c1, 1, 1u, Request(1));
|
||||
q.enqueue(c1, 2, 1u, Request(2));
|
||||
q.enqueue(c2, 3, 1u, Request(3));
|
||||
q.enqueue(c2, 4, 1u, Request(4));
|
||||
q.enqueue_strict(c2, 6, Request(6));
|
||||
q.enqueue_strict(c1, 7, Request(7));
|
||||
|
||||
@ -237,15 +237,15 @@ TEST(mClockPriorityQueue, RemoveByClass)
|
||||
Client c2(2);
|
||||
Client c3(3);
|
||||
|
||||
q.enqueue(c1, 1, 0, Request(1));
|
||||
q.enqueue(c2, 1, 0, Request(2));
|
||||
q.enqueue(c3, 1, 0, Request(4));
|
||||
q.enqueue(c1, 1, 1u, Request(1));
|
||||
q.enqueue(c2, 1, 1u, Request(2));
|
||||
q.enqueue(c3, 1, 1u, Request(4));
|
||||
q.enqueue_strict(c1, 2, Request(8));
|
||||
q.enqueue_strict(c2, 1, Request(16));
|
||||
q.enqueue_strict(c3, 3, Request(32));
|
||||
q.enqueue(c3, 1, 0, Request(64));
|
||||
q.enqueue(c2, 1, 0, Request(128));
|
||||
q.enqueue(c1, 1, 0, Request(256));
|
||||
q.enqueue(c3, 1, 1u, Request(64));
|
||||
q.enqueue(c2, 1, 1u, Request(128));
|
||||
q.enqueue(c1, 1, 1u, Request(256));
|
||||
|
||||
int out_mask = 2 | 16 | 128;
|
||||
int in_mask = 1 | 8 | 256;
|
||||
@ -281,15 +281,15 @@ TEST(mClockPriorityQueue, RemoveByFilter)
|
||||
Client c2(2);
|
||||
Client c3(3);
|
||||
|
||||
q.enqueue(c1, 1, 0, Request(1));
|
||||
q.enqueue(c2, 1, 0, Request(2));
|
||||
q.enqueue(c3, 1, 0, Request(3));
|
||||
q.enqueue(c1, 1, 1u, Request(1));
|
||||
q.enqueue(c2, 1, 1u, Request(2));
|
||||
q.enqueue(c3, 1, 1u, Request(3));
|
||||
q.enqueue_strict(c1, 2, Request(4));
|
||||
q.enqueue_strict(c2, 1, Request(5));
|
||||
q.enqueue_strict(c3, 3, Request(6));
|
||||
q.enqueue(c3, 1, 0, Request(7));
|
||||
q.enqueue(c2, 1, 0, Request(8));
|
||||
q.enqueue(c1, 1, 0, Request(9));
|
||||
q.enqueue(c3, 1, 1u, Request(7));
|
||||
q.enqueue(c2, 1, 1u, Request(8));
|
||||
q.enqueue(c1, 1, 1u, Request(9));
|
||||
|
||||
std::list<Request> filtered;
|
||||
|
||||
|
@ -66,11 +66,11 @@ TEST_F(MClockClientQueueTest, TestSize) {
|
||||
ASSERT_TRUE(q.empty());
|
||||
ASSERT_EQ(0u, q.length());
|
||||
|
||||
q.enqueue(client1, 12, 0, create_snaptrim(100, client1));
|
||||
q.enqueue(client1, 12, 1u, create_snaptrim(100, client1));
|
||||
q.enqueue_strict(client2, 12, create_snaptrim(101, client2));
|
||||
q.enqueue(client2, 12, 0, create_snaptrim(102, client2));
|
||||
q.enqueue(client2, 12, 1u, create_snaptrim(102, client2));
|
||||
q.enqueue_strict(client3, 12, create_snaptrim(103, client3));
|
||||
q.enqueue(client1, 12, 0, create_snaptrim(104, client1));
|
||||
q.enqueue(client1, 12, 1u, create_snaptrim(104, client1));
|
||||
|
||||
ASSERT_FALSE(q.empty());
|
||||
ASSERT_EQ(5u, q.length());
|
||||
@ -84,7 +84,7 @@ TEST_F(MClockClientQueueTest, TestSize) {
|
||||
ASSERT_FALSE(q.empty());
|
||||
ASSERT_EQ(2u, q.length());
|
||||
|
||||
q.enqueue_front(client2, 12, 0, std::move(reqs.back()));
|
||||
q.enqueue_front(client2, 12, 1u, std::move(reqs.back()));
|
||||
reqs.pop_back();
|
||||
|
||||
q.enqueue_strict_front(client3, 12, std::move(reqs.back()));
|
||||
@ -106,11 +106,11 @@ TEST_F(MClockClientQueueTest, TestSize) {
|
||||
|
||||
|
||||
TEST_F(MClockClientQueueTest, TestEnqueue) {
|
||||
q.enqueue(client1, 12, 0, create_snaptrim(100, client1));
|
||||
q.enqueue(client2, 12, 0, create_snaptrim(101, client2));
|
||||
q.enqueue(client2, 12, 0, create_snaptrim(102, client2));
|
||||
q.enqueue(client3, 12, 0, create_snaptrim(103, client3));
|
||||
q.enqueue(client1, 12, 0, create_snaptrim(104, client1));
|
||||
q.enqueue(client1, 12, 1u, create_snaptrim(100, client1));
|
||||
q.enqueue(client2, 12, 1u, create_snaptrim(101, client2));
|
||||
q.enqueue(client2, 12, 1u, create_snaptrim(102, client2));
|
||||
q.enqueue(client3, 12, 1u, create_snaptrim(103, client3));
|
||||
q.enqueue(client1, 12, 1u, create_snaptrim(104, client1));
|
||||
|
||||
Request r = q.dequeue();
|
||||
ASSERT_EQ(100u, r.get_map_epoch());
|
||||
@ -156,11 +156,11 @@ TEST_F(MClockClientQueueTest, TestEnqueueStrict) {
|
||||
|
||||
|
||||
TEST_F(MClockClientQueueTest, TestRemoveByClass) {
|
||||
q.enqueue(client1, 12, 0, create_snaptrim(100, client1));
|
||||
q.enqueue(client1, 12, 1u, create_snaptrim(100, client1));
|
||||
q.enqueue_strict(client2, 12, create_snaptrim(101, client2));
|
||||
q.enqueue(client2, 12, 0, create_snaptrim(102, client2));
|
||||
q.enqueue(client2, 12, 1u, create_snaptrim(102, client2));
|
||||
q.enqueue_strict(client3, 12, create_snaptrim(103, client3));
|
||||
q.enqueue(client1, 12, 0, create_snaptrim(104, client1));
|
||||
q.enqueue(client1, 12, 1u, create_snaptrim(104, client1));
|
||||
|
||||
std::list<Request> filtered_out;
|
||||
q.remove_by_class(client2, &filtered_out);
|
||||
|
Loading…
Reference in New Issue
Block a user