@@ -24,9 +24,6 @@ class TJsonVDiskEvict : public TViewerPipeClient {
2424protected:
2525 using TThis = TJsonVDiskEvict;
2626 using TBase = TViewerPipeClient;
27- IViewer* Viewer;
28- NMon::TEvHttpInfo::TPtr Event;
29- ui32 Timeout = 0 ;
3027 ui32 ActualRetries = 0 ;
3128 ui32 Retries = 0 ;
3229 TDuration RetryPeriod = TDuration::MilliSeconds(500 );
@@ -42,23 +39,19 @@ class TJsonVDiskEvict : public TViewerPipeClient {
4239
4340public:
4441 TJsonVDiskEvict (IViewer* viewer, NMon::TEvHttpInfo::TPtr& ev)
45- : Viewer(viewer)
46- , Event(ev)
42+ : TViewerPipeClient(viewer, ev)
4743 {}
4844
4945 inline ui32 GetRequiredParam (const TCgiParameters& params, const std::string& name, ui32& obj) {
5046 if (!TryFromString<ui32>(params.Get (name), obj)) {
51- TBase::Send (Event->Sender , new NMon::TEvHttpInfoRes (
52- Viewer->GetHTTPBADREQUEST (Event->Get (), " text/plain" , TStringBuilder () << " field '" << name << " ' or 'vdisk_id' are required" ),
53- 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
47+ TBase::ReplyAndPassAway (GetHTTPBADREQUEST (" text/plain" , TStringBuilder () << " field '" << name << " ' is required" ));
5448 return false ;
5549 }
5650 return true ;
5751 }
5852
5953 void Bootstrap () override {
60- const auto & params (Event->Get ()->Request .GetParams ());
61- TString vdisk_id = params.Get (" vdisk_id" );
54+ TString vdisk_id = Params.Get (" vdisk_id" );
6255 if (vdisk_id) {
6356 TVector<TString> parts = StringSplitter (vdisk_id).Split (' -' ).SkipEmpty ();
6457 if (parts.size () == 5 ) {
@@ -71,40 +64,33 @@ class TJsonVDiskEvict : public TViewerPipeClient {
7164 if (parts.size () != 5 || GroupId == Max<ui32>()
7265 || GroupGeneration == Max<ui32>() || FailRealmIdx == Max<ui32>()
7366 || FailDomainIdx == Max<ui32>() || VdiskIdx == Max<ui32>()) {
74- TBase::Send (Event->Sender , new NMon::TEvHttpInfoRes (
75- Viewer->GetHTTPBADREQUEST (Event->Get (), " text/plain" , TStringBuilder () << " Unable to parse the 'vdisk_id' parameter" ),
76- 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
77- return PassAway ();
67+ return TBase::ReplyAndPassAway (GetHTTPBADREQUEST (" text/plain" , " Unable to parse the 'vdisk_id' parameter" ), " BadRequest" );
7868 }
79- } else if (!GetRequiredParam (params, " group_id" , GroupId)
80- || !GetRequiredParam (params, " group_generation_id" , GroupGeneration)
81- || !GetRequiredParam (params, " fail_realm_idx" , FailRealmIdx)
82- || !GetRequiredParam (params, " fail_domain_idx" , FailDomainIdx)
83- || !GetRequiredParam (params, " vdisk_idx" , VdiskIdx)) {
84- return PassAway ();
69+ } else if (!GetRequiredParam (Params, " group_id" , GroupId)
70+ || !GetRequiredParam (Params, " group_generation_id" , GroupGeneration)
71+ || !GetRequiredParam (Params, " fail_realm_idx" , FailRealmIdx)
72+ || !GetRequiredParam (Params, " fail_domain_idx" , FailDomainIdx)
73+ || !GetRequiredParam (Params, " vdisk_idx" , VdiskIdx)) {
74+ return ;
75+ // return TBase::ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "Parameter 'vdisk_id' is required"), "BadRequest");
8576 }
8677
8778 if (Event->Get ()->Request .GetMethod () != HTTP_METHOD_POST) {
88- TBase::Send (Event->Sender , new NMon::TEvHttpInfoRes (
89- Viewer->GetHTTPBADREQUEST (Event->Get (), " text/plain" , " Only POST method is allowed" ),
90- 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
91- return PassAway ();
79+ return TBase::ReplyAndPassAway (GetHTTPBADREQUEST (" text/plain" , " Only POST method is allowed" ), " BadRequest" );
9280 }
93- TBase::InitConfig (params);
9481
95- Force = FromStringWithDefault<bool >(params.Get (" force" ), false );
96- Timeout = FromStringWithDefault<ui32>(params.Get (" timeout" ), 10000 );
97- Retries = FromStringWithDefault<ui32>(params.Get (" retries" ), 0 );
98- RetryPeriod = TDuration::MilliSeconds (FromStringWithDefault<ui32>(params.Get (" retry_period" ), RetryPeriod.MilliSeconds ()));
82+ Force = FromStringWithDefault<bool >(Params.Get (" force" ), false );
83+ Retries = FromStringWithDefault<ui32>(Params.Get (" retries" ), 0 );
84+ RetryPeriod = TDuration::MilliSeconds (FromStringWithDefault<ui32>(Params.Get (" retry_period" ), RetryPeriod.MilliSeconds ()));
9985
10086 if (Force && !Viewer->CheckAccessAdministration (Event->Get ())) {
101- TBase::Send (Event-> Sender , new NMon::TEvHttpInfoRes (Viewer-> GetHTTPFORBIDDEN (Event-> Get ()), 0 , NMon::IEvHttpInfoRes::EContentType::Custom) );
87+ return TBase::ReplyAndPassAway ( GetHTTPFORBIDDEN (), " BadRequest " );
10288 return PassAway ();
10389 }
10490
10591 SendRequest ();
10692
107- TBase::Become (&TThis::StateWork, TDuration::MilliSeconds ( Timeout) , new TEvents::TEvWakeup ());
93+ TBase::Become (&TThis::StateWork, Timeout, new TEvents::TEvWakeup ());
10894 }
10995
11096 STATEFN (StateWork) {
@@ -145,12 +131,6 @@ class TJsonVDiskEvict : public TViewerPipeClient {
145131 SendRequest ();
146132 }
147133
148- void HandleTimeout () {
149- Send (Event->Sender , new NMon::TEvHttpInfoRes (
150- Viewer->GetHTTPGATEWAYTIMEOUT (Event->Get (), " text/plain" , " Timeout receiving response from BSC" ),
151- 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
152- }
153-
154134 void PassAway () override {
155135 TBase::PassAway ();
156136 }
@@ -175,8 +155,7 @@ class TJsonVDiskEvict : public TViewerPipeClient {
175155 json[" result" ] = false ;
176156 json[" error" ] = " No response was received from BSC" ;
177157 }
178- TBase::Send (Event->Sender , new NMon::TEvHttpInfoRes (Viewer->GetHTTPOKJSON (Event->Get (), NJson::WriteJson (json)), 0 , NMon::IEvHttpInfoRes::EContentType::Custom));
179- PassAway ();
158+ TBase::ReplyAndPassAway (GetHTTPOKJSON (json));
180159 }
181160
182161 static YAML::Node GetSwagger () {
@@ -190,43 +169,18 @@ class TJsonVDiskEvict : public TViewerPipeClient {
190169 - name: vdisk_id
191170 in: query
192171 description: vdisk identifier
193- required: false
172+ required: true
194173 type: string
195- - name: group_id
196- in: query
197- description: group identifier
198- required: false
199- type: integer
200- - name: group_generation_id
201- in: query
202- description: group generation identifier
203- required: false
204- type: integer
205- - name: fail_realm_idx
206- in: query
207- description: fail realm identifier
208- required: false
209- type: integer
210- - name: fail_domain_ids
211- in: query
212- description: fail domain identifier
213- required: false
214- type: integer
215- - name: vdisk_idx
174+ - name: force
216175 in: query
217- description: vdisk idx identifier
176+ description: attempt forced operation, ignore warnings
218177 required: false
219- type: integer
178+ type: boolean
220179 - name: timeout
221180 in: query
222181 description: timeout in ms
223182 required: false
224183 type: integer
225- - name: force
226- in: query
227- description: attempt forced operation, ignore warnings
228- required: false
229- type: boolean
230184 responses:
231185 200:
232186 description: OK
0 commit comments