1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#include "rgw_service.h"
#include "services/svc_finisher.h"
#include "services/svc_notify.h"
#include "services/svc_rados.h"
#include "services/svc_zone.h"
#include "services/svc_zone_utils.h"
#include "services/svc_quota.h"
#include "services/svc_sync_modules.h"
#include "services/svc_sys_obj.h"
#include "services/svc_sys_obj_cache.h"
#include "services/svc_sys_obj_core.h"
#include "common/errno.h"
#define dout_subsys ceph_subsys_rgw
RGWServices_Def::RGWServices_Def() = default;
RGWServices_Def::~RGWServices_Def()
{
shutdown();
}
int RGWServices_Def::init(CephContext *cct,
bool have_cache,
bool raw)
{
finisher = std::make_unique<RGWSI_Finisher>(cct);
notify = std::make_unique<RGWSI_Notify>(cct);
rados = std::make_unique<RGWSI_RADOS>(cct);
zone = std::make_unique<RGWSI_Zone>(cct);
zone_utils = std::make_unique<RGWSI_ZoneUtils>(cct);
quota = std::make_unique<RGWSI_Quota>(cct);
sync_modules = std::make_unique<RGWSI_SyncModules>(cct);
sysobj = std::make_unique<RGWSI_SysObj>(cct);
sysobj_core = std::make_unique<RGWSI_SysObj_Core>(cct);
if (have_cache) {
sysobj_cache = std::make_unique<RGWSI_SysObj_Cache>(cct);
}
finisher->init();
notify->init(zone.get(), rados.get(), finisher.get());
rados->init();
zone->init(sysobj.get(), rados.get(), sync_modules.get());
zone_utils->init(rados.get(), zone.get());
quota->init(zone.get());
sync_modules->init();
sysobj_core->core_init(rados.get(), zone.get());
if (have_cache) {
sysobj_cache->init(rados.get(), zone.get(), notify.get());
sysobj->init(rados.get(), sysobj_cache.get());
} else {
sysobj->init(rados.get(), sysobj_core.get());
}
can_shutdown = true;
int r = finisher->start();
if (r < 0) {
ldout(cct, 0) << "ERROR: failed to start finisher service (" << cpp_strerror(-r) << dendl;
return r;
}
if (!raw) {
r = notify->start();
if (r < 0) {
ldout(cct, 0) << "ERROR: failed to start notify service (" << cpp_strerror(-r) << dendl;
return r;
}
}
r = rados->start();
if (r < 0) {
ldout(cct, 0) << "ERROR: failed to start rados service (" << cpp_strerror(-r) << dendl;
return r;
}
if (!raw) {
r = zone->start();
if (r < 0) {
ldout(cct, 0) << "ERROR: failed to start zone service (" << cpp_strerror(-r) << dendl;
return r;
}
}
r = zone_utils->start();
if (r < 0) {
ldout(cct, 0) << "ERROR: failed to start zone_utils service (" << cpp_strerror(-r) << dendl;
return r;
}
r = quota->start();
if (r < 0) {
ldout(cct, 0) << "ERROR: failed to start quota service (" << cpp_strerror(-r) << dendl;
return r;
}
r = sysobj_core->start();
if (r < 0) {
ldout(cct, 0) << "ERROR: failed to start sysobj_core service (" << cpp_strerror(-r) << dendl;
return r;
}
if (have_cache) {
r = sysobj_cache->start();
if (r < 0) {
ldout(cct, 0) << "ERROR: failed to start sysobj_cache service (" << cpp_strerror(-r) << dendl;
return r;
}
}
r = sysobj->start();
if (r < 0) {
ldout(cct, 0) << "ERROR: failed to start sysobj service (" << cpp_strerror(-r) << dendl;
return r;
}
/* cache or core services will be started by sysobj */
return 0;
}
void RGWServices_Def::shutdown()
{
if (!can_shutdown) {
return;
}
if (has_shutdown) {
return;
}
sysobj->shutdown();
sysobj_core->shutdown();
notify->shutdown();
if (sysobj_cache) {
sysobj_cache->shutdown();
}
quota->shutdown();
zone_utils->shutdown();
zone->shutdown();
rados->shutdown();
has_shutdown = true;
}
int RGWServices::do_init(CephContext *cct, bool have_cache, bool raw)
{
int r = _svc.init(cct, have_cache, raw);
if (r < 0) {
return r;
}
finisher = _svc.finisher.get();
notify = _svc.notify.get();
rados = _svc.rados.get();
zone = _svc.zone.get();
zone_utils = _svc.zone_utils.get();
quota = _svc.quota.get();
sync_modules = _svc.sync_modules.get();
sysobj = _svc.sysobj.get();
cache = _svc.sysobj_cache.get();
core = _svc.sysobj_core.get();
return 0;
}
int RGWServiceInstance::start()
{
if (start_state != StateInit) {
return 0;
}
start_state = StateStarting;; /* setting started prior to do_start() on purpose so that circular
references can call start() on each other */
int r = do_start();
if (r < 0) {
return r;
}
start_state = StateStarted;
return 0;
}
|