MCPcopy Create free account
hub / github.com/OpenTSDB/asynchbase / sendRPCHeader

Method sendRPCHeader

src/SecureRpcHelper96.java:179–206  ·  view source on GitHub ↗

Writes a header to the region server with the authenticated username. It will also mark the region client as ready to process so that any pending RPCs will be flushed to the server. @param chan The channel to write to

(final Channel chan)

Source from the content-addressed store, hash-verified

177 * @param chan The channel to write to
178 */
179 private void sendRPCHeader(final Channel chan) {
180 final RPCPB.UserInformation user = RPCPB.UserInformation.newBuilder()
181 .setEffectiveUser(client_auth_provider.getClientUsername())
182 .build();
183 final RPCPB.ConnectionHeader pb = RPCPB.ConnectionHeader.newBuilder()
184 .setUserInfo(user)
185 .setServiceName("ClientService")
186 .setCellBlockCodecClass("org.apache.hadoop.hbase.codec.KeyValueCodec")
187 .build();
188 final int pblen = pb.getSerializedSize();
189 final byte[] buf = new byte[4 + pblen];
190 final ChannelBuffer header = ChannelBuffers.wrappedBuffer(buf);
191 header.clear();
192 header.writeInt(pblen); // 4 bytes
193 try {
194 final CodedOutputStream output =
195 CodedOutputStream.newInstance(buf, 4, pblen);
196 pb.writeTo(output);
197 output.checkNoSpaceLeft();
198 } catch (IOException e) {
199 throw new RuntimeException("Should never happen", e);
200 }
201 // We wrote to the underlying buffer but Netty didn't see the writes,
202 // so move the write index forward.
203 header.writerIndex(buf.length);
204 Channels.write(chan, wrap(header));
205 region_client.becomeReady(chan, RegionClient.SERVER_VERSION_095_OR_ABOVE);
206 }
207}

Callers 2

sendHelloMethod · 0.95
handleResponseMethod · 0.95

Calls 4

clearMethod · 0.80
becomeReadyMethod · 0.80
getClientUsernameMethod · 0.45
wrapMethod · 0.45

Tested by

no test coverage detected