MCPcopy Create free account
hub / github.com/apache/kudu / SendMessage

Method SendMessage

src/kudu/subprocess/subprocess_protocol.cc:150–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148
149template <class M>
150Status SubprocessProtocol::SendMessage(const M& message) {
151 VLOG(1) << "Sending message: " << pb_util::SecureDebugString(message);
152
153 faststring buf;
154 switch (serialization_mode_) {
155 case SerializationMode::JSON:
156 {
157 string serialized;
158 const auto& google_status =
159 google::protobuf::util::MessageToJsonString(message, &serialized);
160 if (!google_status.ok()) {
161 return Status::InvalidArgument(Substitute(
162 "unable to serialize JSON: $0", pb_util::SecureDebugString(message)),
163 google_status.message().ToString());
164 }
165
166 buf.append(serialized);
167 buf.append("\n");
168 break;
169 }
170 case SerializationMode::PB:
171 {
172 size_t msg_size = message.ByteSizeLong();
173 buf.resize(sizeof(uint32_t) + msg_size);
174 NetworkByteOrder::Store32(buf.data(), msg_size);
175 if (!message.SerializeWithCachedSizesToArray(buf.data() + sizeof(uint32_t))) {
176 return Status::Corruption("failed to serialize PB to array");
177 }
178 break;
179 }
180 default:
181 break;
182 }
183 RETURN_NOT_OK_PREPEND(DoWrite(buf), "unable to send message");
184 return Status::OK();
185}
186
187Status SubprocessProtocol::DoRead(faststring* buf) const {
188 DCHECK_LE(buf->length(), std::numeric_limits<ssize_t>::max());

Callers 4

RunControlShellFunction · 0.80
SendReceiveMethod · 0.80
TEST_PFunction · 0.80
SendRequestMethod · 0.80

Calls 12

SecureDebugStringFunction · 0.85
InvalidArgumentFunction · 0.85
SubstituteFunction · 0.85
CorruptionFunction · 0.85
DoWriteFunction · 0.85
OKFunction · 0.85
okMethod · 0.80
ToStringMethod · 0.45
messageMethod · 0.45
appendMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45

Tested by 3

RunControlShellFunction · 0.64
SendReceiveMethod · 0.64
TEST_PFunction · 0.64