The request comes with an int 'pattern' and a payload of int array sent with sidecar. Scan the array to make sure every element matches 'pattern'.
| 254 | // The request comes with an int 'pattern' and a payload of int array sent with |
| 255 | // sidecar. Scan the array to make sure every element matches 'pattern'. |
| 256 | virtual void ScanMem(const ScanMemRequestPB* request, ScanMemResponsePB* response, |
| 257 | RpcContext* context) override { |
| 258 | int32_t pattern = request->pattern(); |
| 259 | Slice payload; |
| 260 | ASSERT_OK( |
| 261 | FromKuduStatus(context->GetInboundSidecar(request->sidecar_idx(), &payload))); |
| 262 | ASSERT_EQ(payload.size() % sizeof(int32_t), 0); |
| 263 | |
| 264 | const int32_t* v = reinterpret_cast<const int32_t*>(payload.data()); |
| 265 | for (int i = 0; i < payload.size() / sizeof(int32_t); ++i) { |
| 266 | int32_t val = v[i]; |
| 267 | if (val != pattern) { |
| 268 | // Incoming requests will already be tracked and we need to release the memory. |
| 269 | mem_tracker_.Release(context->GetTransferSize()); |
| 270 | context->RespondFailure(kudu::Status::Corruption( |
| 271 | Substitute("Expecting $1; Found $2", pattern, val))); |
| 272 | return; |
| 273 | } |
| 274 | } |
| 275 | // Incoming requests will already be tracked and we need to release the memory. |
| 276 | mem_tracker_.Release(context->GetTransferSize()); |
| 277 | context->RespondSuccess(); |
| 278 | } |
| 279 | |
| 280 | MemTracker* mem_tracker() { return &mem_tracker_; } |
| 281 |
no test coverage detected