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.util.HashMap; 021import java.util.Map; 022import java.util.Set; 023import org.apache.yetus.audience.InterfaceAudience; 024 025@InterfaceAudience.Private 026public class CallQueueInfo { 027 private final Map<String, Map<String, Long>> callQueueMethodCountsSummary; 028 private final Map<String, Map<String, Long>> callQueueMethodSizeSummary; 029 030 CallQueueInfo() { 031 callQueueMethodCountsSummary = new HashMap<>(); 032 callQueueMethodSizeSummary = new HashMap<>(); 033 } 034 035 public Set<String> getCallQueueNames() { 036 return callQueueMethodCountsSummary.keySet(); 037 } 038 039 public Set<String> getCalledMethodNames(String callQueueName) { 040 return callQueueMethodCountsSummary.get(callQueueName).keySet(); 041 } 042 043 public long getCallMethodCount(String callQueueName, String methodName) { 044 long methodCount; 045 046 Map<String, Long> methodCountMap = 047 callQueueMethodCountsSummary.getOrDefault(callQueueName, null); 048 049 if (null != methodCountMap) { 050 methodCount = methodCountMap.getOrDefault(methodName, 0L); 051 } else { 052 methodCount = 0L; 053 } 054 055 return methodCount; 056 } 057 058 void setCallMethodCount(String callQueueName, Map<String, Long> methodCountMap) { 059 callQueueMethodCountsSummary.put(callQueueName, methodCountMap); 060 } 061 062 public long getCallMethodSize(String callQueueName, String methodName) { 063 long methodSize; 064 065 Map<String, Long> methodSizeMap = callQueueMethodSizeSummary.getOrDefault(callQueueName, null); 066 067 if (null != methodSizeMap) { 068 methodSize = methodSizeMap.getOrDefault(methodName, 0L); 069 } else { 070 methodSize = 0L; 071 } 072 073 return methodSize; 074 } 075 076 void setCallMethodSize(String callQueueName, Map<String, Long> methodSizeMap) { 077 callQueueMethodSizeSummary.put(callQueueName, methodSizeMap); 078 } 079 080}