]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/osd/osd_operations/peering_event.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / crimson / osd / osd_operations / peering_event.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #pragma once
5
6 #include <iostream>
7 #include <seastar/core/future.hh>
8
9 #include "crimson/osd/osd_operation.h"
10 #include "osd/osd_types.h"
11 #include "osd/PGPeeringEvent.h"
12 #include "osd/PeeringState.h"
13
14 namespace ceph {
15 class Formatter;
16 }
17
18 namespace crimson::osd {
19
20 class OSD;
21 class ShardServices;
22 class PG;
23
24 class PeeringEvent : public OperationT<PeeringEvent> {
25 public:
26 static constexpr OperationTypeCode type = OperationTypeCode::peering_event;
27
28 class PGPipeline {
29 OrderedExclusivePhase await_map = {
30 "PeeringEvent::PGPipeline::await_map"
31 };
32 OrderedExclusivePhase process = {
33 "PeeringEvent::PGPipeline::process"
34 };
35 friend class PeeringEvent;
36 friend class PGAdvanceMap;
37 };
38
39 protected:
40 PipelineHandle handle;
41 PGPipeline &pp(PG &pg);
42
43 ShardServices &shard_services;
44 PeeringCtx ctx;
45 pg_shard_t from;
46 spg_t pgid;
47 float delay = 0;
48 PGPeeringEvent evt;
49
50 const pg_shard_t get_from() const {
51 return from;
52 }
53
54 const spg_t get_pgid() const {
55 return pgid;
56 }
57
58 const PGPeeringEvent &get_event() const {
59 return evt;
60 }
61
62 virtual void on_pg_absent();
63 virtual PeeringEvent::interruptible_future<> complete_rctx(Ref<PG>);
64 virtual seastar::future<> complete_rctx_no_pg() { return seastar::now();}
65 virtual seastar::future<Ref<PG>> get_pg() = 0;
66
67 public:
68 template <typename... Args>
69 PeeringEvent(
70 ShardServices &shard_services, const pg_shard_t &from, const spg_t &pgid,
71 Args&&... args) :
72 shard_services(shard_services),
73 from(from),
74 pgid(pgid),
75 evt(std::forward<Args>(args)...)
76 {}
77 template <typename... Args>
78 PeeringEvent(
79 ShardServices &shard_services, const pg_shard_t &from, const spg_t &pgid,
80 float delay, Args&&... args) :
81 shard_services(shard_services),
82 from(from),
83 pgid(pgid),
84 delay(delay),
85 evt(std::forward<Args>(args)...)
86 {}
87
88 void print(std::ostream &) const final;
89 void dump_detail(ceph::Formatter* f) const final;
90 seastar::future<> start();
91 };
92
93 class RemotePeeringEvent : public PeeringEvent {
94 protected:
95 OSD &osd;
96 crimson::net::ConnectionRef conn;
97
98 void on_pg_absent() final;
99 PeeringEvent::interruptible_future<> complete_rctx(Ref<PG> pg) override;
100 seastar::future<> complete_rctx_no_pg() override;
101 seastar::future<Ref<PG>> get_pg() final;
102
103 public:
104 class OSDPipeline {
105 OrderedExclusivePhase await_active = {
106 "PeeringRequest::OSDPipeline::await_active"
107 };
108 friend class RemotePeeringEvent;
109 };
110 class ConnectionPipeline {
111 OrderedExclusivePhase await_map = {
112 "PeeringRequest::ConnectionPipeline::await_map"
113 };
114 OrderedExclusivePhase get_pg = {
115 "PeeringRequest::ConnectionPipeline::get_pg"
116 };
117 friend class RemotePeeringEvent;
118 };
119
120 template <typename... Args>
121 RemotePeeringEvent(OSD &osd, crimson::net::ConnectionRef conn, Args&&... args) :
122 PeeringEvent(std::forward<Args>(args)...),
123 osd(osd),
124 conn(conn)
125 {}
126
127 private:
128 ConnectionPipeline &cp();
129 OSDPipeline &op();
130 };
131
132 class LocalPeeringEvent final : public PeeringEvent {
133 protected:
134 seastar::future<Ref<PG>> get_pg() final;
135
136 Ref<PG> pg;
137
138 public:
139 template <typename... Args>
140 LocalPeeringEvent(Ref<PG> pg, Args&&... args) :
141 PeeringEvent(std::forward<Args>(args)...),
142 pg(pg)
143 {}
144
145 virtual ~LocalPeeringEvent();
146 };
147
148
149 }