001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.ipc;
019
020import java.io.IOException;
021import java.net.InetAddress;
022
023import org.apache.hadoop.hbase.CellScanner;
024import org.apache.yetus.audience.InterfaceAudience;
025import org.apache.hadoop.hbase.io.ByteBufferPool;
026import org.apache.hadoop.hbase.ipc.RpcServer.CallCleanup;
027import org.apache.hbase.thirdparty.com.google.protobuf.BlockingService;
028import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor;
029import org.apache.hbase.thirdparty.com.google.protobuf.Message;
030import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader;
031
032/**
033 * Datastructure that holds all necessary to a method invocation and then afterward, carries the
034 * result.
035 * @since 2.0.0
036 */
037@InterfaceAudience.Private
038class NettyServerCall extends ServerCall<NettyServerRpcConnection> {
039
040  NettyServerCall(int id, BlockingService service, MethodDescriptor md, RequestHeader header,
041      Message param, CellScanner cellScanner, NettyServerRpcConnection connection, long size,
042      InetAddress remoteAddress, long receiveTime, int timeout,
043      ByteBufferPool reservoir, CellBlockBuilder cellBlockBuilder, CallCleanup reqCleanup) {
044    super(id, service, md, header, param, cellScanner, connection, size, remoteAddress,
045        receiveTime, timeout, reservoir, cellBlockBuilder, reqCleanup);
046  }
047
048  /**
049   * If we have a response, and delay is not set, then respond immediately. Otherwise, do not
050   * respond to client. This is called by the RPC code in the context of the Handler thread.
051   */
052  @Override
053  public synchronized void sendResponseIfReady() throws IOException {
054    // set param null to reduce memory pressure
055    this.param = null;
056    connection.channel.writeAndFlush(this);
057  }
058}