/*
 * Licensed to the University of California, Berkeley under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for additional information regarding
 * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License. You may obtain a
 * copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package tachyon.client.netty;


import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.util.concurrent.SettableFuture;

import tachyon.Constants;
import tachyon.network.protocol.RPCResponse;

/**
 * A simple listener that waits for a single {@link RPCResponse} message from the remote server.
 */
public final class SingleResponseListener implements ClientHandler.ResponseListener {
  private static final Logger LOG = LoggerFactory.getLogger(Constants.LOGGER_TYPE);

  private SettableFuture<RPCResponse> mResponse = SettableFuture.create();

  @Override
  public void onResponseReceived(RPCResponse response) {
    mResponse.set(response);
  }

  public RPCResponse get() throws ExecutionException, InterruptedException {
    return mResponse.get();
  }

  public RPCResponse get(long timeout, TimeUnit unit)
      throws InterruptedException, ExecutionException, TimeoutException {
    return mResponse.get(timeout, unit);
  }
}

@@ -1600,115 +1600,739 @@
 %0A%0A  
-public RPCResponse get() throws ExecutionException, InterruptedException %7B%0A    return mResponse.get();%0A  %7D%0A
+/**%0A   * Waits to receive the response and returns the response message.%0A   *%0A   * @return The %7B@link RPCResponse%7D received from the remote server.%0A   * @throws ExecutionException%0A   * @throws InterruptedException%0A   */%0A  public RPCResponse get() throws ExecutionException, InterruptedException %7B%0A    return mResponse.get();%0A  %7D%0A%0A  /**%0A   * Waits to receive the response for at most a specified time, and returns the response message.%0A   *%0A   * @param timeout the maximum amount of time to wait.%0A   * @param unit the %7B@link TimeUnit%7D of the timeout parameter.%0A   * @return The %7B@link RPCResponse%7D received from the remote server.%0A   * @throws InterruptedException%0A   * @throws ExecutionException%0A   * @throws TimeoutException%0A   */
 %0A  p

add javadoc comments