diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ProtobufRpcEngine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ProtobufRpcEngine.java index 9b42b2daca3..08b4834c941 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ProtobufRpcEngine.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ProtobufRpcEngine.java @@ -46,7 +46,6 @@ import org.apache.hadoop.hbase.security.token.AuthenticationTokenSecretManager; import org.apache.hadoop.ipc.RemoteException; import org.apache.hadoop.security.authorize.ServiceAuthorizationManager; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.hbase.util.Objects; import org.codehaus.jackson.map.ObjectMapper; import com.google.protobuf.Message; @@ -370,7 +369,7 @@ class ProtobufRpcEngine implements RpcEngine { "; Served: " + protocol.getSimpleName()+"#"+method.getName() + " queueTime=" + qTime + " processingTime=" + processingTime + - " contents=" + Objects.describeQuantity(param)); + " contents=" + param.toString()); } rpcMetrics.rpcQueueTime.inc(qTime); rpcMetrics.rpcProcessingTime.inc(processingTime); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Objects.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Objects.java deleted file mode 100644 index 94a1be948f4..00000000000 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Objects.java +++ /dev/null @@ -1,190 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) 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 org.apache.hadoop.hbase.util; - -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.client.Action; -import org.apache.hadoop.hbase.client.Delete; -import org.apache.hadoop.hbase.client.Get; -import org.apache.hadoop.hbase.client.Increment; -import org.apache.hadoop.hbase.client.MultiAction; -import org.apache.hadoop.hbase.client.Put; - -/** - * Utility methods for interacting with object instances. - */ -@InterfaceAudience.Private -public class Objects { - private static class QuantityMap extends HashMap { - public void increment(String type, int count) { - Quantity q = get(type); - if (q == null) { - q = new Quantity(); - q.what = type; - put(type, q); - } - q.increment(count); - } - - public void stat(String type, int value) { - Quantity q = get(type); - if (q == null) { - q = new Stat(); - q.what = type; - put(type, q); - } - q.increment(value); - } - } - - private static class Quantity { - int count; - String what; - - public void increment(int amount) { - count += amount; - } - - public void appendToString(StringBuilder out) { - if (out.length() > 0) out.append(", "); - - out.append(count).append(" ").append(what); - if (count != 1 && !what.endsWith("s")) { - out.append("s"); - } - } - } - - private static class Stat extends Quantity { - int min; - int max; - long total; - - public void increment(int amount) { - if (count == 0) { - min = max = amount; - } else { - min = Math.min(min, amount); - max = Math.max(max, amount); - } - total += amount; - count++; - } - - public void appendToString(StringBuilder out) { - super.appendToString(out); - - out.append(" [ "); - if (count > 0) { - out.append("min=").append(min) - .append(" max=").append(max) - .append(" avg=").append((int)(total/count)); - } else { - out.append("none"); - } - out.append(" ]"); - } - } - - private static class QuantityComparator implements Comparator { - @Override - public int compare(Quantity q1, Quantity q2) { - if (q1.count < q2.count) { - return -1; - } else if (q1.count > q2.count) { - return 1; - } - return 0; - } - } - - /** - * Attempts to construct a text description of the given object, by - * introspecting known classes and building a description of size. - * @param obj - * @return Description - */ - public static String describeQuantity(Object obj) { - StringBuilder str = new StringBuilder(); - QuantityMap quantities = new QuantityMap(); - quantify(obj, quantities); - List totals = new ArrayList(quantities.values()); - Collections.sort(totals, new QuantityComparator()); - for (Quantity q : totals) { - q.appendToString(str); - } - return str.toString(); - } - - public static void quantify(Object obj, QuantityMap quantities) { - if (obj == null) { - return; - } - - if (obj.getClass().isArray()) { - Class type = obj.getClass().getComponentType(); - int length = Array.getLength(obj); - if (type.isPrimitive()) { - quantities.increment(type.getSimpleName(), length); - } else { - for (int i=0; i keyValues : ((Put)obj).getFamilyMap().values()) { - for (KeyValue kv : keyValues) { - quantities.stat("values", kv.getValueLength()); - } - } - } else if (obj instanceof Delete) { - quantities.increment("Delete", 1); - for (List kvs : ((Delete)obj).getFamilyMap().values()) { - quantities.increment("KeyValue", kvs.size()); - } - } else if (obj instanceof Increment) { - quantities.increment("Increment", 1); - quantities.increment("KeyValue", ((Increment)obj).numColumns()); - } else if (obj instanceof Get) { - quantities.increment("Get", 1); - } else { - String type = obj.getClass().getSimpleName(); - quantities.increment(type, 1); - } - } -}