http://git-wip-us.apache.org/repos/asf/hadoop/blob/4aa34324/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java index 4a33c33..42ce05b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java @@ -18,23 +18,12 @@ package org.apache.hadoop.hdfs; -import java.util.concurrent.TimeUnit; - import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.fs.CommonConfigurationKeys; import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys; import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicyDefault; import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.RamDiskReplicaLruTracker; -import org.apache.hadoop.hdfs.server.federation.resolver.FileSubclusterResolver; -import org.apache.hadoop.hdfs.server.federation.resolver.MountTableResolver; -import org.apache.hadoop.hdfs.server.federation.router.RouterRpcMonitor; -import org.apache.hadoop.hdfs.server.federation.metrics.FederationRPCPerformanceMonitor; -import org.apache.hadoop.hdfs.server.federation.resolver.ActiveNamenodeResolver; -import org.apache.hadoop.hdfs.server.federation.resolver.MembershipNamenodeResolver; -import org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreDriver; -import org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreSerializerPBImpl; -import org.apache.hadoop.hdfs.server.federation.store.driver.impl.StateStoreZooKeeperImpl; import org.apache.hadoop.http.HttpConfig; /** @@ -1014,199 +1003,6 @@ public class DFSConfigKeys extends CommonConfigurationKeys { "dfs.use.dfs.network.topology"; public static final boolean DFS_USE_DFS_NETWORK_TOPOLOGY_DEFAULT = true; - // HDFS federation - public static final String FEDERATION_PREFIX = "dfs.federation."; - - // HDFS Router-based federation - public static final String FEDERATION_ROUTER_PREFIX = - "dfs.federation.router."; - public static final String DFS_ROUTER_DEFAULT_NAMESERVICE = - FEDERATION_ROUTER_PREFIX + "default.nameserviceId"; - public static final String DFS_ROUTER_HANDLER_COUNT_KEY = - FEDERATION_ROUTER_PREFIX + "handler.count"; - public static final int DFS_ROUTER_HANDLER_COUNT_DEFAULT = 10; - public static final String DFS_ROUTER_READER_QUEUE_SIZE_KEY = - FEDERATION_ROUTER_PREFIX + "reader.queue.size"; - public static final int DFS_ROUTER_READER_QUEUE_SIZE_DEFAULT = 100; - public static final String DFS_ROUTER_READER_COUNT_KEY = - FEDERATION_ROUTER_PREFIX + "reader.count"; - public static final int DFS_ROUTER_READER_COUNT_DEFAULT = 1; - public static final String DFS_ROUTER_HANDLER_QUEUE_SIZE_KEY = - FEDERATION_ROUTER_PREFIX + "handler.queue.size"; - public static final int DFS_ROUTER_HANDLER_QUEUE_SIZE_DEFAULT = 100; - public static final String DFS_ROUTER_RPC_BIND_HOST_KEY = - FEDERATION_ROUTER_PREFIX + "rpc-bind-host"; - public static final int DFS_ROUTER_RPC_PORT_DEFAULT = 8888; - public static final String DFS_ROUTER_RPC_ADDRESS_KEY = - FEDERATION_ROUTER_PREFIX + "rpc-address"; - public static final String DFS_ROUTER_RPC_ADDRESS_DEFAULT = - "0.0.0.0:" + DFS_ROUTER_RPC_PORT_DEFAULT; - public static final String DFS_ROUTER_RPC_ENABLE = - FEDERATION_ROUTER_PREFIX + "rpc.enable"; - public static final boolean DFS_ROUTER_RPC_ENABLE_DEFAULT = true; - - public static final String DFS_ROUTER_METRICS_ENABLE = - FEDERATION_ROUTER_PREFIX + "metrics.enable"; - public static final boolean DFS_ROUTER_METRICS_ENABLE_DEFAULT = true; - public static final String DFS_ROUTER_METRICS_CLASS = - FEDERATION_ROUTER_PREFIX + "metrics.class"; - public static final Class<? extends RouterRpcMonitor> - DFS_ROUTER_METRICS_CLASS_DEFAULT = - FederationRPCPerformanceMonitor.class; - - // HDFS Router heartbeat - public static final String DFS_ROUTER_HEARTBEAT_ENABLE = - FEDERATION_ROUTER_PREFIX + "heartbeat.enable"; - public static final boolean DFS_ROUTER_HEARTBEAT_ENABLE_DEFAULT = true; - public static final String DFS_ROUTER_HEARTBEAT_INTERVAL_MS = - FEDERATION_ROUTER_PREFIX + "heartbeat.interval"; - public static final long DFS_ROUTER_HEARTBEAT_INTERVAL_MS_DEFAULT = - TimeUnit.SECONDS.toMillis(5); - public static final String DFS_ROUTER_MONITOR_NAMENODE = - FEDERATION_ROUTER_PREFIX + "monitor.namenode"; - public static final String DFS_ROUTER_MONITOR_LOCAL_NAMENODE = - FEDERATION_ROUTER_PREFIX + "monitor.localnamenode.enable"; - public static final boolean DFS_ROUTER_MONITOR_LOCAL_NAMENODE_DEFAULT = true; - public static final String DFS_ROUTER_HEARTBEAT_STATE_INTERVAL_MS = - FEDERATION_ROUTER_PREFIX + "heartbeat-state.interval"; - public static final long DFS_ROUTER_HEARTBEAT_STATE_INTERVAL_MS_DEFAULT = - TimeUnit.SECONDS.toMillis(5); - - // HDFS Router NN client - public static final String DFS_ROUTER_NAMENODE_CONNECTION_POOL_SIZE = - FEDERATION_ROUTER_PREFIX + "connection.pool-size"; - public static final int DFS_ROUTER_NAMENODE_CONNECTION_POOL_SIZE_DEFAULT = - 64; - public static final String DFS_ROUTER_NAMENODE_CONNECTION_POOL_CLEAN = - FEDERATION_ROUTER_PREFIX + "connection.pool.clean.ms"; - public static final long DFS_ROUTER_NAMENODE_CONNECTION_POOL_CLEAN_DEFAULT = - TimeUnit.MINUTES.toMillis(1); - public static final String DFS_ROUTER_NAMENODE_CONNECTION_CLEAN_MS = - FEDERATION_ROUTER_PREFIX + "connection.clean.ms"; - public static final long DFS_ROUTER_NAMENODE_CONNECTION_CLEAN_MS_DEFAULT = - TimeUnit.SECONDS.toMillis(10); - - // HDFS Router RPC client - public static final String DFS_ROUTER_CLIENT_THREADS_SIZE = - FEDERATION_ROUTER_PREFIX + "client.thread-size"; - public static final int DFS_ROUTER_CLIENT_THREADS_SIZE_DEFAULT = 32; - public static final String DFS_ROUTER_CLIENT_MAX_ATTEMPTS = - FEDERATION_ROUTER_PREFIX + "client.retry.max.attempts"; - public static final int DFS_ROUTER_CLIENT_MAX_ATTEMPTS_DEFAULT = 3; - - // HDFS Router State Store connection - public static final String FEDERATION_FILE_RESOLVER_CLIENT_CLASS = - FEDERATION_ROUTER_PREFIX + "file.resolver.client.class"; - public static final Class<? extends FileSubclusterResolver> - FEDERATION_FILE_RESOLVER_CLIENT_CLASS_DEFAULT = - MountTableResolver.class; - public static final String FEDERATION_NAMENODE_RESOLVER_CLIENT_CLASS = - FEDERATION_ROUTER_PREFIX + "namenode.resolver.client.class"; - public static final Class<? extends ActiveNamenodeResolver> - FEDERATION_NAMENODE_RESOLVER_CLIENT_CLASS_DEFAULT = - MembershipNamenodeResolver.class; - - // HDFS Router-based federation State Store - public static final String FEDERATION_STORE_PREFIX = - FEDERATION_ROUTER_PREFIX + "store."; - - public static final String DFS_ROUTER_STORE_ENABLE = - FEDERATION_STORE_PREFIX + "enable"; - public static final boolean DFS_ROUTER_STORE_ENABLE_DEFAULT = true; - - public static final String FEDERATION_STORE_SERIALIZER_CLASS = - DFSConfigKeys.FEDERATION_STORE_PREFIX + "serializer"; - public static final Class<StateStoreSerializerPBImpl> - FEDERATION_STORE_SERIALIZER_CLASS_DEFAULT = - StateStoreSerializerPBImpl.class; - - public static final String FEDERATION_STORE_DRIVER_CLASS = - FEDERATION_STORE_PREFIX + "driver.class"; - public static final Class<? extends StateStoreDriver> - FEDERATION_STORE_DRIVER_CLASS_DEFAULT = StateStoreZooKeeperImpl.class; - - public static final String FEDERATION_STORE_CONNECTION_TEST_MS = - FEDERATION_STORE_PREFIX + "connection.test"; - public static final long FEDERATION_STORE_CONNECTION_TEST_MS_DEFAULT = - TimeUnit.MINUTES.toMillis(1); - - public static final String DFS_ROUTER_CACHE_TIME_TO_LIVE_MS = - FEDERATION_ROUTER_PREFIX + "cache.ttl"; - public static final long DFS_ROUTER_CACHE_TIME_TO_LIVE_MS_DEFAULT = - TimeUnit.MINUTES.toMillis(1); - - public static final String FEDERATION_STORE_MEMBERSHIP_EXPIRATION_MS = - FEDERATION_STORE_PREFIX + "membership.expiration"; - public static final long FEDERATION_STORE_MEMBERSHIP_EXPIRATION_MS_DEFAULT = - TimeUnit.MINUTES.toMillis(5); - public static final String FEDERATION_STORE_ROUTER_EXPIRATION_MS = - FEDERATION_STORE_PREFIX + "router.expiration"; - public static final long FEDERATION_STORE_ROUTER_EXPIRATION_MS_DEFAULT = - TimeUnit.MINUTES.toMillis(5); - - // HDFS Router safe mode - public static final String DFS_ROUTER_SAFEMODE_ENABLE = - FEDERATION_ROUTER_PREFIX + "safemode.enable"; - public static final boolean DFS_ROUTER_SAFEMODE_ENABLE_DEFAULT = true; - public static final String DFS_ROUTER_SAFEMODE_EXTENSION = - FEDERATION_ROUTER_PREFIX + "safemode.extension"; - public static final long DFS_ROUTER_SAFEMODE_EXTENSION_DEFAULT = - TimeUnit.SECONDS.toMillis(30); - public static final String DFS_ROUTER_SAFEMODE_EXPIRATION = - FEDERATION_ROUTER_PREFIX + "safemode.expiration"; - public static final long DFS_ROUTER_SAFEMODE_EXPIRATION_DEFAULT = - 3 * DFS_ROUTER_CACHE_TIME_TO_LIVE_MS_DEFAULT; - - // HDFS Router-based federation mount table entries - /** Maximum number of cache entries to have. */ - public static final String FEDERATION_MOUNT_TABLE_MAX_CACHE_SIZE = - DFSConfigKeys.FEDERATION_ROUTER_PREFIX + "mount-table.max-cache-size"; - /** Remove cache entries if we have more than 10k. */ - public static final int FEDERATION_MOUNT_TABLE_MAX_CACHE_SIZE_DEFAULT = 10000; - - // HDFS Router-based federation admin - public static final String DFS_ROUTER_ADMIN_HANDLER_COUNT_KEY = - FEDERATION_ROUTER_PREFIX + "admin.handler.count"; - public static final int DFS_ROUTER_ADMIN_HANDLER_COUNT_DEFAULT = 1; - public static final int DFS_ROUTER_ADMIN_PORT_DEFAULT = 8111; - public static final String DFS_ROUTER_ADMIN_ADDRESS_KEY = - FEDERATION_ROUTER_PREFIX + "admin-address"; - public static final String DFS_ROUTER_ADMIN_ADDRESS_DEFAULT = - "0.0.0.0:" + DFS_ROUTER_ADMIN_PORT_DEFAULT; - public static final String DFS_ROUTER_ADMIN_BIND_HOST_KEY = - FEDERATION_ROUTER_PREFIX + "admin-bind-host"; - public static final String DFS_ROUTER_ADMIN_ENABLE = - FEDERATION_ROUTER_PREFIX + "admin.enable"; - public static final boolean DFS_ROUTER_ADMIN_ENABLE_DEFAULT = true; - - // HDFS Router-based federation web - public static final String DFS_ROUTER_HTTP_ENABLE = - FEDERATION_ROUTER_PREFIX + "http.enable"; - public static final boolean DFS_ROUTER_HTTP_ENABLE_DEFAULT = true; - public static final String DFS_ROUTER_HTTP_ADDRESS_KEY = - FEDERATION_ROUTER_PREFIX + "http-address"; - public static final int DFS_ROUTER_HTTP_PORT_DEFAULT = 50071; - public static final String DFS_ROUTER_HTTP_BIND_HOST_KEY = - FEDERATION_ROUTER_PREFIX + "http-bind-host"; - public static final String DFS_ROUTER_HTTP_ADDRESS_DEFAULT = - "0.0.0.0:" + DFS_ROUTER_HTTP_PORT_DEFAULT; - public static final String DFS_ROUTER_HTTPS_ADDRESS_KEY = - FEDERATION_ROUTER_PREFIX + "https-address"; - public static final int DFS_ROUTER_HTTPS_PORT_DEFAULT = 50072; - public static final String DFS_ROUTER_HTTPS_BIND_HOST_KEY = - FEDERATION_ROUTER_PREFIX + "https-bind-host"; - public static final String DFS_ROUTER_HTTPS_ADDRESS_DEFAULT = - "0.0.0.0:" + DFS_ROUTER_HTTPS_PORT_DEFAULT; - - // HDFS Router-based federation quota - public static final String DFS_ROUTER_QUOTA_ENABLE = - FEDERATION_ROUTER_PREFIX + "quota.enable"; - public static final boolean DFS_ROUTER_QUOTA_ENABLED_DEFAULT = false; - public static final String DFS_ROUTER_QUOTA_CACHE_UPATE_INTERVAL = - FEDERATION_ROUTER_PREFIX + "quota-cache.update.interval"; - public static final long DFS_ROUTER_QUOTA_CACHE_UPATE_INTERVAL_DEFAULT = - 60000; - // dfs.client.retry confs are moved to HdfsClientConfigKeys.Retry @Deprecated public static final String DFS_CLIENT_RETRY_POLICY_ENABLED_KEY
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4aa34324/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolPB.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolPB.java deleted file mode 100644 index 96fa794..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolPB.java +++ /dev/null @@ -1,44 +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.hdfs.protocolPB; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.hdfs.DFSConfigKeys; -import org.apache.hadoop.hdfs.protocol.HdfsConstants; -import org.apache.hadoop.hdfs.protocol.proto.RouterProtocolProtos.RouterAdminProtocolService; -import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSelector; -import org.apache.hadoop.ipc.ProtocolInfo; -import org.apache.hadoop.security.KerberosInfo; -import org.apache.hadoop.security.token.TokenInfo; - -/** - * Protocol that a clients use to communicate with the NameNode. - * Note: This extends the protocolbuffer service based interface to - * add annotations required for security. - */ [email protected] [email protected] -@KerberosInfo( - serverPrincipal = DFSConfigKeys.DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY) -@TokenInfo(DelegationTokenSelector.class) -@ProtocolInfo(protocolName = HdfsConstants.CLIENT_NAMENODE_PROTOCOL_NAME, - protocolVersion = 1) -public interface RouterAdminProtocolPB extends - RouterAdminProtocolService.BlockingInterface { -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hadoop/blob/4aa34324/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolServerSideTranslatorPB.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolServerSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolServerSideTranslatorPB.java deleted file mode 100644 index 159d5c2..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolServerSideTranslatorPB.java +++ /dev/null @@ -1,211 +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.hdfs.protocolPB; - -import java.io.IOException; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.AddMountTableEntryRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.AddMountTableEntryResponseProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.EnterSafeModeRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.EnterSafeModeResponseProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.GetMountTableEntriesRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.GetMountTableEntriesResponseProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.GetSafeModeRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.GetSafeModeResponseProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.LeaveSafeModeRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.LeaveSafeModeResponseProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RemoveMountTableEntryRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RemoveMountTableEntryResponseProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.UpdateMountTableEntryRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.UpdateMountTableEntryResponseProto; -import org.apache.hadoop.hdfs.server.federation.router.RouterAdminServer; -import org.apache.hadoop.hdfs.server.federation.store.protocol.AddMountTableEntryRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.AddMountTableEntryResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.EnterSafeModeRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.EnterSafeModeResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetMountTableEntriesRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetMountTableEntriesResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetSafeModeRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetSafeModeResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.LeaveSafeModeRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.LeaveSafeModeResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.RemoveMountTableEntryRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.RemoveMountTableEntryResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.UpdateMountTableEntryRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.UpdateMountTableEntryResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.AddMountTableEntryRequestPBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.AddMountTableEntryResponsePBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.EnterSafeModeRequestPBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.EnterSafeModeResponsePBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.GetMountTableEntriesRequestPBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.GetMountTableEntriesResponsePBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.GetSafeModeRequestPBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.GetSafeModeResponsePBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.LeaveSafeModeRequestPBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.LeaveSafeModeResponsePBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RemoveMountTableEntryRequestPBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RemoveMountTableEntryResponsePBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.UpdateMountTableEntryRequestPBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.UpdateMountTableEntryResponsePBImpl; - -import com.google.protobuf.RpcController; -import com.google.protobuf.ServiceException; - -/** - * This class is used on the server side. Calls come across the wire for the for - * protocol {@link RouterAdminProtocolPB}. This class translates the PB data - * types to the native data types used inside the HDFS Router as specified in - * the generic RouterAdminProtocol. - */ [email protected] [email protected] -public class RouterAdminProtocolServerSideTranslatorPB implements - RouterAdminProtocolPB { - - private final RouterAdminServer server; - - /** - * Constructor. - * @param server The NN server. - * @throws IOException - */ - public RouterAdminProtocolServerSideTranslatorPB(RouterAdminServer server) - throws IOException { - this.server = server; - } - - @Override - public AddMountTableEntryResponseProto addMountTableEntry( - RpcController controller, AddMountTableEntryRequestProto request) - throws ServiceException { - - try { - AddMountTableEntryRequest req = - new AddMountTableEntryRequestPBImpl(request); - AddMountTableEntryResponse response = server.addMountTableEntry(req); - AddMountTableEntryResponsePBImpl responsePB = - (AddMountTableEntryResponsePBImpl)response; - return responsePB.getProto(); - } catch (IOException e) { - throw new ServiceException(e); - } - } - - /** - * Remove an entry from the mount table. - */ - @Override - public RemoveMountTableEntryResponseProto removeMountTableEntry( - RpcController controller, RemoveMountTableEntryRequestProto request) - throws ServiceException { - try { - RemoveMountTableEntryRequest req = - new RemoveMountTableEntryRequestPBImpl(request); - RemoveMountTableEntryResponse response = - server.removeMountTableEntry(req); - RemoveMountTableEntryResponsePBImpl responsePB = - (RemoveMountTableEntryResponsePBImpl)response; - return responsePB.getProto(); - } catch (IOException e) { - throw new ServiceException(e); - } - } - - /** - * Get matching mount table entries. - */ - @Override - public GetMountTableEntriesResponseProto getMountTableEntries( - RpcController controller, GetMountTableEntriesRequestProto request) - throws ServiceException { - try { - GetMountTableEntriesRequest req = - new GetMountTableEntriesRequestPBImpl(request); - GetMountTableEntriesResponse response = server.getMountTableEntries(req); - GetMountTableEntriesResponsePBImpl responsePB = - (GetMountTableEntriesResponsePBImpl)response; - return responsePB.getProto(); - } catch (IOException e) { - throw new ServiceException(e); - } - } - - /** - * Update a single mount table entry. - */ - @Override - public UpdateMountTableEntryResponseProto updateMountTableEntry( - RpcController controller, UpdateMountTableEntryRequestProto request) - throws ServiceException { - try { - UpdateMountTableEntryRequest req = - new UpdateMountTableEntryRequestPBImpl(request); - UpdateMountTableEntryResponse response = - server.updateMountTableEntry(req); - UpdateMountTableEntryResponsePBImpl responsePB = - (UpdateMountTableEntryResponsePBImpl)response; - return responsePB.getProto(); - } catch (IOException e) { - throw new ServiceException(e); - } - } - - @Override - public EnterSafeModeResponseProto enterSafeMode(RpcController controller, - EnterSafeModeRequestProto request) throws ServiceException { - try { - EnterSafeModeRequest req = new EnterSafeModeRequestPBImpl(request); - EnterSafeModeResponse response = server.enterSafeMode(req); - EnterSafeModeResponsePBImpl responsePB = - (EnterSafeModeResponsePBImpl) response; - return responsePB.getProto(); - } catch (IOException e) { - throw new ServiceException(e); - } - } - - @Override - public LeaveSafeModeResponseProto leaveSafeMode(RpcController controller, - LeaveSafeModeRequestProto request) throws ServiceException { - try { - LeaveSafeModeRequest req = new LeaveSafeModeRequestPBImpl(request); - LeaveSafeModeResponse response = server.leaveSafeMode(req); - LeaveSafeModeResponsePBImpl responsePB = - (LeaveSafeModeResponsePBImpl) response; - return responsePB.getProto(); - } catch (IOException e) { - throw new ServiceException(e); - } - } - - @Override - public GetSafeModeResponseProto getSafeMode(RpcController controller, - GetSafeModeRequestProto request) throws ServiceException { - try { - GetSafeModeRequest req = new GetSafeModeRequestPBImpl(request); - GetSafeModeResponse response = server.getSafeMode(req); - GetSafeModeResponsePBImpl responsePB = - (GetSafeModeResponsePBImpl) response; - return responsePB.getProto(); - } catch (IOException e) { - throw new ServiceException(e); - } - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4aa34324/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolTranslatorPB.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolTranslatorPB.java deleted file mode 100644 index d6210ce..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolTranslatorPB.java +++ /dev/null @@ -1,208 +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.hdfs.protocolPB; - -import java.io.Closeable; -import java.io.IOException; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.AddMountTableEntryRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.AddMountTableEntryResponseProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.EnterSafeModeRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.EnterSafeModeResponseProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.GetMountTableEntriesRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.GetMountTableEntriesResponseProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.GetSafeModeRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.GetSafeModeResponseProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.LeaveSafeModeRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.LeaveSafeModeResponseProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RemoveMountTableEntryRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RemoveMountTableEntryResponseProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.UpdateMountTableEntryRequestProto; -import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.UpdateMountTableEntryResponseProto; -import org.apache.hadoop.hdfs.server.federation.resolver.MountTableManager; -import org.apache.hadoop.hdfs.server.federation.router.RouterStateManager; -import org.apache.hadoop.hdfs.server.federation.store.protocol.AddMountTableEntryRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.AddMountTableEntryResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.EnterSafeModeRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.EnterSafeModeResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetMountTableEntriesRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetMountTableEntriesResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetSafeModeRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetSafeModeResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.LeaveSafeModeRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.LeaveSafeModeResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.RemoveMountTableEntryRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.RemoveMountTableEntryResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.UpdateMountTableEntryRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.UpdateMountTableEntryResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.AddMountTableEntryRequestPBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.AddMountTableEntryResponsePBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.EnterSafeModeResponsePBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.GetMountTableEntriesRequestPBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.GetMountTableEntriesResponsePBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.GetSafeModeResponsePBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.LeaveSafeModeResponsePBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RemoveMountTableEntryRequestPBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RemoveMountTableEntryResponsePBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.UpdateMountTableEntryRequestPBImpl; -import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.UpdateMountTableEntryResponsePBImpl; -import org.apache.hadoop.ipc.ProtobufHelper; -import org.apache.hadoop.ipc.ProtocolMetaInterface; -import org.apache.hadoop.ipc.ProtocolTranslator; -import org.apache.hadoop.ipc.RPC; -import org.apache.hadoop.ipc.RpcClientUtil; - -import com.google.protobuf.ServiceException; - -/** - * This class forwards NN's ClientProtocol calls as RPC calls to the NN server - * while translating from the parameter types used in ClientProtocol to the - * new PB types. - */ [email protected] [email protected] -public class RouterAdminProtocolTranslatorPB - implements ProtocolMetaInterface, MountTableManager, - Closeable, ProtocolTranslator, RouterStateManager { - final private RouterAdminProtocolPB rpcProxy; - - public RouterAdminProtocolTranslatorPB(RouterAdminProtocolPB proxy) { - rpcProxy = proxy; - } - - @Override - public void close() { - RPC.stopProxy(rpcProxy); - } - - @Override - public Object getUnderlyingProxyObject() { - return rpcProxy; - } - - @Override - public boolean isMethodSupported(String methodName) throws IOException { - return RpcClientUtil.isMethodSupported(rpcProxy, - RouterAdminProtocolPB.class, RPC.RpcKind.RPC_PROTOCOL_BUFFER, - RPC.getProtocolVersion(RouterAdminProtocolPB.class), methodName); - } - - @Override - public AddMountTableEntryResponse addMountTableEntry( - AddMountTableEntryRequest request) throws IOException { - AddMountTableEntryRequestPBImpl requestPB = - (AddMountTableEntryRequestPBImpl)request; - AddMountTableEntryRequestProto proto = requestPB.getProto(); - try { - AddMountTableEntryResponseProto response = - rpcProxy.addMountTableEntry(null, proto); - return new AddMountTableEntryResponsePBImpl(response); - } catch (ServiceException e) { - throw new IOException(ProtobufHelper.getRemoteException(e).getMessage()); - } - } - - @Override - public UpdateMountTableEntryResponse updateMountTableEntry( - UpdateMountTableEntryRequest request) throws IOException { - UpdateMountTableEntryRequestPBImpl requestPB = - (UpdateMountTableEntryRequestPBImpl)request; - UpdateMountTableEntryRequestProto proto = requestPB.getProto(); - try { - UpdateMountTableEntryResponseProto response = - rpcProxy.updateMountTableEntry(null, proto); - return new UpdateMountTableEntryResponsePBImpl(response); - } catch (ServiceException e) { - throw new IOException(ProtobufHelper.getRemoteException(e).getMessage()); - } - } - - @Override - public RemoveMountTableEntryResponse removeMountTableEntry( - RemoveMountTableEntryRequest request) throws IOException { - RemoveMountTableEntryRequestPBImpl requestPB = - (RemoveMountTableEntryRequestPBImpl)request; - RemoveMountTableEntryRequestProto proto = requestPB.getProto(); - try { - RemoveMountTableEntryResponseProto responseProto = - rpcProxy.removeMountTableEntry(null, proto); - return new RemoveMountTableEntryResponsePBImpl(responseProto); - } catch (ServiceException e) { - throw new IOException(ProtobufHelper.getRemoteException(e).getMessage()); - } - } - - @Override - public GetMountTableEntriesResponse getMountTableEntries( - GetMountTableEntriesRequest request) throws IOException { - GetMountTableEntriesRequestPBImpl requestPB = - (GetMountTableEntriesRequestPBImpl)request; - GetMountTableEntriesRequestProto proto = requestPB.getProto(); - try { - GetMountTableEntriesResponseProto response = - rpcProxy.getMountTableEntries(null, proto); - return new GetMountTableEntriesResponsePBImpl(response); - } catch (ServiceException e) { - throw new IOException(ProtobufHelper.getRemoteException(e).getMessage()); - } - } - - @Override - public EnterSafeModeResponse enterSafeMode(EnterSafeModeRequest request) - throws IOException { - EnterSafeModeRequestProto proto = - EnterSafeModeRequestProto.newBuilder().build(); - try { - EnterSafeModeResponseProto response = - rpcProxy.enterSafeMode(null, proto); - return new EnterSafeModeResponsePBImpl(response); - } catch (ServiceException e) { - throw new IOException(ProtobufHelper.getRemoteException(e).getMessage()); - } - } - - @Override - public LeaveSafeModeResponse leaveSafeMode(LeaveSafeModeRequest request) - throws IOException { - LeaveSafeModeRequestProto proto = - LeaveSafeModeRequestProto.newBuilder().build(); - try { - LeaveSafeModeResponseProto response = - rpcProxy.leaveSafeMode(null, proto); - return new LeaveSafeModeResponsePBImpl(response); - } catch (ServiceException e) { - throw new IOException(ProtobufHelper.getRemoteException(e).getMessage()); - } - } - - @Override - public GetSafeModeResponse getSafeMode(GetSafeModeRequest request) - throws IOException { - GetSafeModeRequestProto proto = - GetSafeModeRequestProto.newBuilder().build(); - try { - GetSafeModeResponseProto response = - rpcProxy.getSafeMode(null, proto); - return new GetSafeModeResponsePBImpl(response); - } catch (ServiceException e) { - throw new IOException(ProtobufHelper.getRemoteException(e).getMessage()); - } - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4aa34324/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationMBean.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationMBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationMBean.java deleted file mode 100644 index 6412398..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationMBean.java +++ /dev/null @@ -1,217 +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.hdfs.server.federation.metrics; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; - -/** - * JMX interface for the federation statistics. - */ [email protected] [email protected] -public interface FederationMBean { - - /** - * Get information about all the namenodes in the federation or null if - * failure. - * @return JSON with all the Namenodes. - */ - String getNamenodes(); - - /** - * Get the latest info for each registered nameservice. - * @return JSON with all the nameservices. - */ - String getNameservices(); - - /** - * Get the mount table for the federated filesystem or null if failure. - * @return JSON with the mount table. - */ - String getMountTable(); - - /** - * Get the latest state of all routers. - * @return JSON with all of the known routers or null if failure. - */ - String getRouters(); - - /** - * Get the total capacity of the federated cluster. - * @return Total capacity of the federated cluster. - */ - long getTotalCapacity(); - - /** - * Get the used capacity of the federated cluster. - * @return Used capacity of the federated cluster. - */ - long getUsedCapacity(); - - /** - * Get the remaining capacity of the federated cluster. - * @return Remaining capacity of the federated cluster. - */ - long getRemainingCapacity(); - - /** - * Get the number of nameservices in the federation. - * @return Number of nameservices in the federation. - */ - int getNumNameservices(); - - /** - * Get the number of namenodes. - * @return Number of namenodes. - */ - int getNumNamenodes(); - - /** - * Get the number of expired namenodes. - * @return Number of expired namenodes. - */ - int getNumExpiredNamenodes(); - - /** - * Get the number of live datanodes. - * @return Number of live datanodes. - */ - int getNumLiveNodes(); - - /** - * Get the number of dead datanodes. - * @return Number of dead datanodes. - */ - int getNumDeadNodes(); - - /** - * Get the number of decommissioning datanodes. - * @return Number of decommissioning datanodes. - */ - int getNumDecommissioningNodes(); - - /** - * Get the number of live decommissioned datanodes. - * @return Number of live decommissioned datanodes. - */ - int getNumDecomLiveNodes(); - - /** - * Get the number of dead decommissioned datanodes. - * @return Number of dead decommissioned datanodes. - */ - int getNumDecomDeadNodes(); - - /** - * Get Max, Median, Min and Standard Deviation of DataNodes usage. - * @return the DataNode usage information, as a JSON string. - */ - String getNodeUsage(); - - /** - * Get the number of blocks in the federation. - * @return Number of blocks in the federation. - */ - long getNumBlocks(); - - /** - * Get the number of missing blocks in the federation. - * @return Number of missing blocks in the federation. - */ - long getNumOfMissingBlocks(); - - /** - * Get the number of pending replication blocks in the federation. - * @return Number of pending replication blocks in the federation. - */ - long getNumOfBlocksPendingReplication(); - - /** - * Get the number of under replicated blocks in the federation. - * @return Number of under replicated blocks in the federation. - */ - long getNumOfBlocksUnderReplicated(); - - /** - * Get the number of pending deletion blocks in the federation. - * @return Number of pending deletion blocks in the federation. - */ - long getNumOfBlocksPendingDeletion(); - - /** - * Get the number of files in the federation. - * @return Number of files in the federation. - */ - long getNumFiles(); - - /** - * When the router started. - * @return Date as a string the router started. - */ - String getRouterStarted(); - - /** - * Get the version of the router. - * @return Version of the router. - */ - String getVersion(); - - /** - * Get the compilation date of the router. - * @return Compilation date of the router. - */ - String getCompiledDate(); - - /** - * Get the compilation info of the router. - * @return Compilation info of the router. - */ - String getCompileInfo(); - - /** - * Get the host and port of the router. - * @return Host and port of the router. - */ - String getHostAndPort(); - - /** - * Get the identifier of the router. - * @return Identifier of the router. - */ - String getRouterId(); - - /** - * Get the host and port of the router. - * @return Host and port of the router. - */ - String getClusterId(); - - /** - * Get the host and port of the router. - * @return Host and port of the router. - */ - String getBlockPoolId(); - - /** - * Get the current state of the router. - * - * @return String label for the current router state. - */ - String getRouterStatus(); -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4aa34324/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationMetrics.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationMetrics.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationMetrics.java deleted file mode 100644 index 1a5a8be..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationMetrics.java +++ /dev/null @@ -1,810 +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.hdfs.server.federation.metrics; - -import static org.apache.hadoop.util.Time.now; - -import java.io.IOException; -import java.lang.reflect.Method; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.UnknownHostException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import javax.management.NotCompliantMBeanException; -import javax.management.ObjectName; -import javax.management.StandardMBean; - -import org.apache.hadoop.hdfs.protocol.DatanodeInfo; -import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType; -import org.apache.hadoop.hdfs.server.federation.resolver.ActiveNamenodeResolver; -import org.apache.hadoop.hdfs.server.federation.resolver.FederationNamenodeContext; -import org.apache.hadoop.hdfs.server.federation.resolver.FederationNamespaceInfo; -import org.apache.hadoop.hdfs.server.federation.resolver.RemoteLocation; -import org.apache.hadoop.hdfs.server.federation.router.Router; -import org.apache.hadoop.hdfs.server.federation.router.RouterRpcServer; -import org.apache.hadoop.hdfs.server.federation.store.MembershipStore; -import org.apache.hadoop.hdfs.server.federation.store.MountTableStore; -import org.apache.hadoop.hdfs.server.federation.store.RouterStore; -import org.apache.hadoop.hdfs.server.federation.store.StateStoreService; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetMountTableEntriesRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetMountTableEntriesResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetNamenodeRegistrationsRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetNamenodeRegistrationsResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetNamespaceInfoRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetNamespaceInfoResponse; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetRouterRegistrationsRequest; -import org.apache.hadoop.hdfs.server.federation.store.protocol.GetRouterRegistrationsResponse; -import org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord; -import org.apache.hadoop.hdfs.server.federation.store.records.MembershipState; -import org.apache.hadoop.hdfs.server.federation.store.records.MembershipStats; -import org.apache.hadoop.hdfs.server.federation.store.records.MountTable; -import org.apache.hadoop.hdfs.server.federation.store.records.RouterState; -import org.apache.hadoop.hdfs.server.federation.store.records.StateStoreVersion; -import org.apache.hadoop.metrics2.util.MBeans; -import org.apache.hadoop.util.StringUtils; -import org.apache.hadoop.util.VersionInfo; -import org.codehaus.jettison.json.JSONObject; -import org.mortbay.util.ajax.JSON; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.annotations.VisibleForTesting; - -/** - * Implementation of the Router metrics collector. - */ -public class FederationMetrics implements FederationMBean { - - private static final Logger LOG = - LoggerFactory.getLogger(FederationMetrics.class); - - /** Format for a date. */ - private static final String DATE_FORMAT = "yyyy/MM/dd HH:mm:ss"; - - /** Prevent holding the page from load too long. */ - private static final long TIME_OUT = TimeUnit.SECONDS.toMillis(1); - - - /** Router interface. */ - private final Router router; - - /** FederationState JMX bean. */ - private ObjectName beanName; - - /** Resolve the namenode for each namespace. */ - private final ActiveNamenodeResolver namenodeResolver; - - /** State store. */ - private final StateStoreService stateStore; - /** Membership state store. */ - private MembershipStore membershipStore; - /** Mount table store. */ - private MountTableStore mountTableStore; - /** Router state store. */ - private RouterStore routerStore; - - - public FederationMetrics(Router router) throws IOException { - this.router = router; - - try { - StandardMBean bean = new StandardMBean(this, FederationMBean.class); - this.beanName = MBeans.register("Router", "FederationState", bean); - LOG.info("Registered Router MBean: {}", this.beanName); - } catch (NotCompliantMBeanException e) { - throw new RuntimeException("Bad Router MBean setup", e); - } - - // Resolve namenode for each nameservice - this.namenodeResolver = this.router.getNamenodeResolver(); - - // State store interfaces - this.stateStore = this.router.getStateStore(); - if (this.stateStore == null) { - LOG.error("State store not available"); - } else { - this.membershipStore = stateStore.getRegisteredRecordStore( - MembershipStore.class); - this.mountTableStore = stateStore.getRegisteredRecordStore( - MountTableStore.class); - this.routerStore = stateStore.getRegisteredRecordStore( - RouterStore.class); - } - } - - /** - * Unregister the JMX beans. - */ - public void close() { - if (this.beanName != null) { - MBeans.unregister(beanName); - } - } - - @Override - public String getNamenodes() { - final Map<String, Map<String, Object>> info = new LinkedHashMap<>(); - try { - // Get the values from the store - GetNamenodeRegistrationsRequest request = - GetNamenodeRegistrationsRequest.newInstance(); - GetNamenodeRegistrationsResponse response = - membershipStore.getNamenodeRegistrations(request); - - // Order the namenodes - final List<MembershipState> namenodes = response.getNamenodeMemberships(); - if (namenodes == null || namenodes.size() == 0) { - return JSON.toString(info); - } - List<MembershipState> namenodesOrder = new ArrayList<>(namenodes); - Collections.sort(namenodesOrder, MembershipState.NAME_COMPARATOR); - - // Dump namenodes information into JSON - for (MembershipState namenode : namenodesOrder) { - Map<String, Object> innerInfo = new HashMap<>(); - Map<String, Object> map = getJson(namenode); - innerInfo.putAll(map); - long dateModified = namenode.getDateModified(); - long lastHeartbeat = getSecondsSince(dateModified); - innerInfo.put("lastHeartbeat", lastHeartbeat); - MembershipStats stats = namenode.getStats(); - long used = stats.getTotalSpace() - stats.getAvailableSpace(); - innerInfo.put("used", used); - info.put(namenode.getNamenodeKey(), - Collections.unmodifiableMap(innerInfo)); - } - } catch (IOException e) { - LOG.error("Enable to fetch json representation of namenodes {}", - e.getMessage()); - return "{}"; - } - return JSON.toString(info); - } - - @Override - public String getNameservices() { - final Map<String, Map<String, Object>> info = new LinkedHashMap<>(); - try { - final List<MembershipState> namenodes = getActiveNamenodeRegistrations(); - List<MembershipState> namenodesOrder = new ArrayList<>(namenodes); - Collections.sort(namenodesOrder, MembershipState.NAME_COMPARATOR); - - // Dump namenodes information into JSON - for (MembershipState namenode : namenodesOrder) { - Map<String, Object> innerInfo = new HashMap<>(); - Map<String, Object> map = getJson(namenode); - innerInfo.putAll(map); - long dateModified = namenode.getDateModified(); - long lastHeartbeat = getSecondsSince(dateModified); - innerInfo.put("lastHeartbeat", lastHeartbeat); - MembershipStats stats = namenode.getStats(); - long used = stats.getTotalSpace() - stats.getAvailableSpace(); - innerInfo.put("used", used); - info.put(namenode.getNamenodeKey(), - Collections.unmodifiableMap(innerInfo)); - } - } catch (IOException e) { - LOG.error("Cannot retrieve nameservices for JMX: {}", e.getMessage()); - return "{}"; - } - return JSON.toString(info); - } - - @Override - public String getMountTable() { - final List<Map<String, Object>> info = new LinkedList<>(); - - try { - // Get all the mount points in order - GetMountTableEntriesRequest request = - GetMountTableEntriesRequest.newInstance("/"); - GetMountTableEntriesResponse response = - mountTableStore.getMountTableEntries(request); - final List<MountTable> mounts = response.getEntries(); - List<MountTable> orderedMounts = new ArrayList<>(mounts); - Collections.sort(orderedMounts, MountTable.SOURCE_COMPARATOR); - - // Dump mount table entries information into JSON - for (MountTable entry : orderedMounts) { - // Sumarize destinations - Set<String> nameservices = new LinkedHashSet<>(); - Set<String> paths = new LinkedHashSet<>(); - for (RemoteLocation location : entry.getDestinations()) { - nameservices.add(location.getNameserviceId()); - paths.add(location.getDest()); - } - - Map<String, Object> map = getJson(entry); - // We add some values with a cleaner format - map.put("dateCreated", getDateString(entry.getDateCreated())); - map.put("dateModified", getDateString(entry.getDateModified())); - - Map<String, Object> innerInfo = new HashMap<>(); - innerInfo.putAll(map); - innerInfo.put("nameserviceId", StringUtils.join(",", nameservices)); - innerInfo.put("path", StringUtils.join(",", paths)); - if (nameservices.size() > 1) { - innerInfo.put("order", entry.getDestOrder().toString()); - } else { - innerInfo.put("order", ""); - } - innerInfo.put("readonly", entry.isReadOnly()); - info.add(Collections.unmodifiableMap(innerInfo)); - } - } catch (IOException e) { - LOG.error( - "Cannot generate JSON of mount table from store: {}", e.getMessage()); - return "[]"; - } - return JSON.toString(info); - } - - @Override - public String getRouters() { - final Map<String, Map<String, Object>> info = new LinkedHashMap<>(); - try { - // Get all the routers in order - GetRouterRegistrationsRequest request = - GetRouterRegistrationsRequest.newInstance(); - GetRouterRegistrationsResponse response = - routerStore.getRouterRegistrations(request); - final List<RouterState> routers = response.getRouters(); - List<RouterState> routersOrder = new ArrayList<>(routers); - Collections.sort(routersOrder); - - // Dump router information into JSON - for (RouterState record : routersOrder) { - Map<String, Object> innerInfo = new HashMap<>(); - Map<String, Object> map = getJson(record); - innerInfo.putAll(map); - long dateModified = record.getDateModified(); - long lastHeartbeat = getSecondsSince(dateModified); - innerInfo.put("lastHeartbeat", lastHeartbeat); - - StateStoreVersion stateStoreVersion = record.getStateStoreVersion(); - if (stateStoreVersion == null) { - LOG.error("Cannot get State Store versions"); - } else { - setStateStoreVersions(innerInfo, stateStoreVersion); - } - - info.put(record.getPrimaryKey(), - Collections.unmodifiableMap(innerInfo)); - } - } catch (IOException e) { - LOG.error("Cannot get Routers JSON from the State Store", e); - return "{}"; - } - return JSON.toString(info); - } - - /** - * Populate the map with the State Store versions. - * - * @param innerInfo Map with the information. - * @param version State Store versions. - */ - private static void setStateStoreVersions( - Map<String, Object> map, StateStoreVersion version) { - - long membershipVersion = version.getMembershipVersion(); - String lastMembershipUpdate = getDateString(membershipVersion); - map.put("lastMembershipUpdate", lastMembershipUpdate); - - long mountTableVersion = version.getMountTableVersion(); - String lastMountTableDate = getDateString(mountTableVersion); - map.put("lastMountTableUpdate", lastMountTableDate); - } - - @Override - public long getTotalCapacity() { - return getNameserviceAggregatedLong("getTotalSpace"); - } - - @Override - public long getRemainingCapacity() { - return getNameserviceAggregatedLong("getAvailableSpace"); - } - - @Override - public long getUsedCapacity() { - return getTotalCapacity() - getRemainingCapacity(); - } - - @Override - public int getNumNameservices() { - try { - Set<FederationNamespaceInfo> nss = namenodeResolver.getNamespaces(); - return nss.size(); - } catch (IOException e) { - LOG.error( - "Cannot fetch number of expired registrations from the store: {}", - e.getMessage()); - return 0; - } - } - - @Override - public int getNumNamenodes() { - try { - GetNamenodeRegistrationsRequest request = - GetNamenodeRegistrationsRequest.newInstance(); - GetNamenodeRegistrationsResponse response = - membershipStore.getNamenodeRegistrations(request); - List<MembershipState> memberships = response.getNamenodeMemberships(); - return memberships.size(); - } catch (IOException e) { - LOG.error("Cannot retrieve numNamenodes for JMX: {}", e.getMessage()); - return 0; - } - } - - @Override - public int getNumExpiredNamenodes() { - try { - GetNamenodeRegistrationsRequest request = - GetNamenodeRegistrationsRequest.newInstance(); - GetNamenodeRegistrationsResponse response = - membershipStore.getExpiredNamenodeRegistrations(request); - List<MembershipState> expiredMemberships = - response.getNamenodeMemberships(); - return expiredMemberships.size(); - } catch (IOException e) { - LOG.error( - "Cannot retrieve numExpiredNamenodes for JMX: {}", e.getMessage()); - return 0; - } - } - - @Override - public int getNumLiveNodes() { - return getNameserviceAggregatedInt("getNumOfActiveDatanodes"); - } - - @Override - public int getNumDeadNodes() { - return getNameserviceAggregatedInt("getNumOfDeadDatanodes"); - } - - @Override - public int getNumDecommissioningNodes() { - return getNameserviceAggregatedInt("getNumOfDecommissioningDatanodes"); - } - - @Override - public int getNumDecomLiveNodes() { - return getNameserviceAggregatedInt("getNumOfDecomActiveDatanodes"); - } - - @Override - public int getNumDecomDeadNodes() { - return getNameserviceAggregatedInt("getNumOfDecomDeadDatanodes"); - } - - @Override // NameNodeMXBean - public String getNodeUsage() { - float median = 0; - float max = 0; - float min = 0; - float dev = 0; - - final Map<String, Map<String, Object>> info = new HashMap<>(); - try { - RouterRpcServer rpcServer = this.router.getRpcServer(); - DatanodeInfo[] live = rpcServer.getDatanodeReport( - DatanodeReportType.LIVE, TIME_OUT); - - if (live.length > 0) { - float totalDfsUsed = 0; - float[] usages = new float[live.length]; - int i = 0; - for (DatanodeInfo dn : live) { - usages[i++] = dn.getDfsUsedPercent(); - totalDfsUsed += dn.getDfsUsedPercent(); - } - totalDfsUsed /= live.length; - Arrays.sort(usages); - median = usages[usages.length / 2]; - max = usages[usages.length - 1]; - min = usages[0]; - - for (i = 0; i < usages.length; i++) { - dev += (usages[i] - totalDfsUsed) * (usages[i] - totalDfsUsed); - } - dev = (float) Math.sqrt(dev / usages.length); - } - } catch (IOException e) { - LOG.info("Cannot get the live nodes: {}", e.getMessage()); - } - - final Map<String, Object> innerInfo = new HashMap<>(); - innerInfo.put("min", StringUtils.format("%.2f%%", min)); - innerInfo.put("median", StringUtils.format("%.2f%%", median)); - innerInfo.put("max", StringUtils.format("%.2f%%", max)); - innerInfo.put("stdDev", StringUtils.format("%.2f%%", dev)); - info.put("nodeUsage", innerInfo); - - return JSON.toString(info); - } - - @Override - public long getNumBlocks() { - return getNameserviceAggregatedLong("getNumOfBlocks"); - } - - @Override - public long getNumOfMissingBlocks() { - return getNameserviceAggregatedLong("getNumOfBlocksMissing"); - } - - @Override - public long getNumOfBlocksPendingReplication() { - return getNameserviceAggregatedLong("getNumOfBlocksPendingReplication"); - } - - @Override - public long getNumOfBlocksUnderReplicated() { - return getNameserviceAggregatedLong("getNumOfBlocksUnderReplicated"); - } - - @Override - public long getNumOfBlocksPendingDeletion() { - return getNameserviceAggregatedLong("getNumOfBlocksPendingDeletion"); - } - - @Override - public long getNumFiles() { - return getNameserviceAggregatedLong("getNumOfFiles"); - } - - @Override - public String getRouterStarted() { - long startTime = this.router.getStartTime(); - return new Date(startTime).toString(); - } - - @Override - public String getVersion() { - return VersionInfo.getVersion() + ", r" + VersionInfo.getRevision(); - } - - @Override - public String getCompiledDate() { - return VersionInfo.getDate(); - } - - @Override - public String getCompileInfo() { - return VersionInfo.getDate() + " by " + VersionInfo.getUser() + " from " - + VersionInfo.getBranch(); - } - - @Override - public String getHostAndPort() { - InetSocketAddress address = this.router.getHttpServerAddress(); - if (address != null) { - try { - String hostname = InetAddress.getLocalHost().getHostName(); - int port = address.getPort(); - return hostname + ":" + port; - } catch (UnknownHostException ignored) { } - } - return "Unknown"; - } - - @Override - public String getRouterId() { - return this.router.getRouterId(); - } - - @Override - public String getClusterId() { - try { - Collection<String> clusterIds = getNamespaceInfo("getClusterId"); - return clusterIds.toString(); - } catch (IOException e) { - LOG.error("Cannot fetch cluster ID metrics: {}", e.getMessage()); - return ""; - } - } - - @Override - public String getBlockPoolId() { - try { - Collection<String> blockpoolIds = getNamespaceInfo("getBlockPoolId"); - return blockpoolIds.toString(); - } catch (IOException e) { - LOG.error("Cannot fetch block pool ID metrics: {}", e.getMessage()); - return ""; - } - } - - @Override - public String getRouterStatus() { - return "RUNNING"; - } - - /** - * Build a set of unique values found in all namespaces. - * - * @param getterName String name of the appropriate FederationNamespaceInfo - * getter function - * @return Set of unique string values found in all discovered namespaces. - * @throws IOException if the query could not be executed. - */ - public Collection<String> getNamespaceInfo(String getterName) - throws IOException { - - GetNamespaceInfoRequest request = GetNamespaceInfoRequest.newInstance(); - GetNamespaceInfoResponse response = - membershipStore.getNamespaceInfo(request); - Set<FederationNamespaceInfo> namespacesInfo = response.getNamespaceInfo(); - - Set<String> ret = new HashSet<>(); - for (FederationNamespaceInfo namespace : namespacesInfo) { - try { - Method m = FederationNamespaceInfo.class.getDeclaredMethod(getterName); - String data = (String) m.invoke(namespace); - ret.add(data); - } catch (SecurityException | ReflectiveOperationException e) { - throw new IOException( - "Cannot invoke " + getterName + " from " + namespace); - } - } - return ret; - } - - /** - * Get the aggregated value for a method for all nameservices. - * @param f Method reference - * @return Aggregated integer. - */ - private int getNameserviceAggregatedInt(String methodName) { - int total = 0; - try { - Collection<Object> data = getNameservicesStats(methodName); - for (Object o : data) { - Integer l = (Integer) o; - total += l; - } - } catch (IOException e) { - LOG.error("Cannot invoke {} for JMX: {}", methodName, e.getMessage()); - return 0; - } - return total; - } - - /** - * Get the aggregated value for a method for all nameservices. - * @param f Method reference - * @return Aggregated long. - */ - private long getNameserviceAggregatedLong(String methodName) { - long total = 0; - try { - Collection<Object> data = getNameservicesStats(methodName); - for (Object o : data) { - Long l = (Long) o; - total += l; - } - } catch (IOException e) { - LOG.error("Cannot invoke {} for JMX: {}", methodName, e.getMessage()); - return 0; - } - return total; - } - - /** - * Aggregate a namenode data element from the most active namenode in each - * registered nameservice. - * - * @param getter String name of the getter function to invoke on the - * discovered NamenodeMembershipRecord object. - * @return Aggregated getter return values from all registered nameservices, - * one per nameservice. - * @throws IOException if the query could not be performed. - */ - private Collection<Object> getNameservicesStats(String getter) - throws IOException { - - List<Object> ret = new ArrayList<>(); - try { - Method metricsGetter = MembershipStats.class.getDeclaredMethod(getter); - List<MembershipState> namenodes = getActiveNamenodeRegistrations(); - for (MembershipState namenode : namenodes) { - try { - MembershipStats stats = namenode.getStats(); - if (stats != null) { - Object data = metricsGetter.invoke(stats); - ret.add(data); - } - } catch (ReflectiveOperationException e) { - throw new IOException( - "Cannot invoke " + getter + " from " + namenode); - } catch (IllegalArgumentException e) { - throw new IOException("Bad arguments invoking " + getter); - } - } - } catch (NoSuchMethodException e) { - throw new IOException( - "Cannot invoke " + getter + " from membership stats record"); - } catch (SecurityException e) { - throw new IOException( - "Cannot invoke " + getter + " from membership stats record"); - } - return ret; - } - - /** - * Fetches the most active namenode memberships for all known nameservices. - * The fetched membership may not or may not be active. Excludes expired - * memberships. - * @throws IOException if the query could not be performed. - * @return List of the most active NNs from each known nameservice. - */ - private List<MembershipState> getActiveNamenodeRegistrations() - throws IOException { - - List<MembershipState> resultList = new ArrayList<>(); - GetNamespaceInfoRequest request = GetNamespaceInfoRequest.newInstance(); - GetNamespaceInfoResponse response = - membershipStore.getNamespaceInfo(request); - for (FederationNamespaceInfo nsInfo : response.getNamespaceInfo()) { - // Fetch the most recent namenode registration - String nsId = nsInfo.getNameserviceId(); - List<? extends FederationNamenodeContext> nns = - namenodeResolver.getNamenodesForNameserviceId(nsId); - if (nns != null) { - FederationNamenodeContext nn = nns.get(0); - if (nn != null && nn instanceof MembershipState) { - resultList.add((MembershipState) nn); - } - } - } - return resultList; - } - - /** - * Get time as a date string. - * @param time Seconds since 1970. - * @return String representing the date. - */ - @VisibleForTesting - static String getDateString(long time) { - if (time <= 0) { - return "-"; - } - Date date = new Date(time); - - SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); - return sdf.format(date); - } - - /** - * Get the number of seconds passed since a date. - * - * @param timeMs to use as a reference. - * @return Seconds since the date. - */ - private static long getSecondsSince(long timeMs) { - if (timeMs < 0) { - return -1; - } - return (now() - timeMs) / 1000; - } - - /** - * Get JSON for this record. - * - * @return Map representing the data for the JSON representation. - */ - private static Map<String, Object> getJson(BaseRecord record) { - Map<String, Object> json = new HashMap<>(); - Map<String, Class<?>> fields = getFields(record); - - for (String fieldName : fields.keySet()) { - if (!fieldName.equalsIgnoreCase("proto")) { - try { - Object value = getField(record, fieldName); - if (value instanceof BaseRecord) { - BaseRecord recordField = (BaseRecord) value; - json.putAll(getJson(recordField)); - } else { - json.put(fieldName, value == null ? JSONObject.NULL : value); - } - } catch (Exception e) { - throw new IllegalArgumentException( - "Cannot serialize field " + fieldName + " into JSON"); - } - } - } - return json; - } - - /** - * Returns all serializable fields in the object. - * - * @return Map with the fields. - */ - private static Map<String, Class<?>> getFields(BaseRecord record) { - Map<String, Class<?>> getters = new HashMap<>(); - for (Method m : record.getClass().getDeclaredMethods()) { - if (m.getName().startsWith("get")) { - try { - Class<?> type = m.getReturnType(); - char[] c = m.getName().substring(3).toCharArray(); - c[0] = Character.toLowerCase(c[0]); - String key = new String(c); - getters.put(key, type); - } catch (Exception e) { - LOG.error("Cannot execute getter {} on {}", m.getName(), record); - } - } - } - return getters; - } - - /** - * Fetches the value for a field name. - * - * @param fieldName the legacy name of the field. - * @return The field data or null if not found. - */ - private static Object getField(BaseRecord record, String fieldName) { - Object result = null; - Method m = locateGetter(record, fieldName); - if (m != null) { - try { - result = m.invoke(record); - } catch (Exception e) { - LOG.error("Cannot get field {} on {}", fieldName, record); - } - } - return result; - } - - /** - * Finds the appropriate getter for a field name. - * - * @param fieldName The legacy name of the field. - * @return The matching getter or null if not found. - */ - private static Method locateGetter(BaseRecord record, String fieldName) { - for (Method m : record.getClass().getMethods()) { - if (m.getName().equalsIgnoreCase("get" + fieldName)) { - return m; - } - } - return null; - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4aa34324/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCMBean.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCMBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCMBean.java deleted file mode 100644 index 3e031fe..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCMBean.java +++ /dev/null @@ -1,92 +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.hdfs.server.federation.metrics; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; - -/** - * JMX interface for the RPC server. - * TODO use the default RPC MBean. - */ [email protected] [email protected] -public interface FederationRPCMBean { - - long getProxyOps(); - - double getProxyAvg(); - - long getProcessingOps(); - - double getProcessingAvg(); - - long getProxyOpFailureCommunicate(); - - long getProxyOpFailureStandby(); - - long getProxyOpNotImplemented(); - - long getProxyOpRetries(); - - long getRouterFailureStateStoreOps(); - - long getRouterFailureReadOnlyOps(); - - long getRouterFailureLockedOps(); - - long getRouterFailureSafemodeOps(); - - int getRpcServerCallQueue(); - - /** - * Get the number of RPC connections between the clients and the Router. - * @return Number of RPC connections between the clients and the Router. - */ - int getRpcServerNumOpenConnections(); - - /** - * Get the number of RPC connections between the Router and the NNs. - * @return Number of RPC connections between the Router and the NNs. - */ - int getRpcClientNumConnections(); - - /** - * Get the number of active RPC connections between the Router and the NNs. - * @return Number of active RPC connections between the Router and the NNs. - */ - int getRpcClientNumActiveConnections(); - - /** - * Get the number of RPC connections to be created. - * @return Number of RPC connections to be created. - */ - int getRpcClientNumCreatingConnections(); - - /** - * Get the number of connection pools between the Router and a NNs. - * @return Number of connection pools between the Router and a NNs. - */ - int getRpcClientNumConnectionPools(); - - /** - * JSON representation of the RPC connections from the Router to the NNs. - * @return JSON string representation. - */ - String getRpcClientConnections(); -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4aa34324/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCMetrics.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCMetrics.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCMetrics.java deleted file mode 100644 index 94d3383..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/FederationRPCMetrics.java +++ /dev/null @@ -1,250 +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.hdfs.server.federation.metrics; - -import static org.apache.hadoop.metrics2.impl.MsInfo.ProcessName; -import static org.apache.hadoop.metrics2.impl.MsInfo.SessionId; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hdfs.server.federation.router.RouterRpcServer; -import org.apache.hadoop.metrics2.MetricsSystem; -import org.apache.hadoop.metrics2.annotation.Metric; -import org.apache.hadoop.metrics2.annotation.Metrics; -import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; -import org.apache.hadoop.metrics2.lib.MetricsRegistry; -import org.apache.hadoop.metrics2.lib.MutableCounterLong; -import org.apache.hadoop.metrics2.lib.MutableRate; - -/** - * Implementation of the RPC metrics collector. - */ -@Metrics(name = "RouterRPCActivity", about = "Router RPC Activity", - context = "dfs") -public class FederationRPCMetrics implements FederationRPCMBean { - - private final MetricsRegistry registry = new MetricsRegistry("router"); - - private RouterRpcServer rpcServer; - - @Metric("Time for the router to process an operation internally") - private MutableRate processing; - @Metric("Number of operations the Router processed internally") - private MutableCounterLong processingOp; - @Metric("Time for the Router to proxy an operation to the Namenodes") - private MutableRate proxy; - @Metric("Number of operations the Router proxied to a Namenode") - private MutableCounterLong proxyOp; - - @Metric("Number of operations to fail to reach NN") - private MutableCounterLong proxyOpFailureStandby; - @Metric("Number of operations to hit a standby NN") - private MutableCounterLong proxyOpFailureCommunicate; - @Metric("Number of operations not implemented") - private MutableCounterLong proxyOpNotImplemented; - @Metric("Number of operation retries") - private MutableCounterLong proxyOpRetries; - - @Metric("Failed requests due to State Store unavailable") - private MutableCounterLong routerFailureStateStore; - @Metric("Failed requests due to read only mount point") - private MutableCounterLong routerFailureReadOnly; - @Metric("Failed requests due to locked path") - private MutableCounterLong routerFailureLocked; - @Metric("Failed requests due to safe mode") - private MutableCounterLong routerFailureSafemode; - - public FederationRPCMetrics(Configuration conf, RouterRpcServer rpcServer) { - this.rpcServer = rpcServer; - - registry.tag(SessionId, "RouterRPCSession"); - registry.tag(ProcessName, "Router"); - } - - public static FederationRPCMetrics create(Configuration conf, - RouterRpcServer rpcServer) { - MetricsSystem ms = DefaultMetricsSystem.instance(); - return ms.register(FederationRPCMetrics.class.getName(), - "HDFS Federation RPC Metrics", - new FederationRPCMetrics(conf, rpcServer)); - } - - /** - * Convert nanoseconds to milliseconds. - * @param ns Time in nanoseconds. - * @return Time in milliseconds. - */ - private static double toMs(double ns) { - return ns / 1000000; - } - - /** - * Reset the metrics system. - */ - public static void reset() { - MetricsSystem ms = DefaultMetricsSystem.instance(); - ms.unregisterSource(FederationRPCMetrics.class.getName()); - } - - public void incrProxyOpFailureStandby() { - proxyOpFailureStandby.incr(); - } - - @Override - public long getProxyOpFailureStandby() { - return proxyOpFailureStandby.value(); - } - - public void incrProxyOpFailureCommunicate() { - proxyOpFailureCommunicate.incr(); - } - - @Override - public long getProxyOpFailureCommunicate() { - return proxyOpFailureCommunicate.value(); - } - - - public void incrProxyOpNotImplemented() { - proxyOpNotImplemented.incr(); - } - - @Override - public long getProxyOpNotImplemented() { - return proxyOpNotImplemented.value(); - } - - public void incrProxyOpRetries() { - proxyOpRetries.incr(); - } - - @Override - public long getProxyOpRetries() { - return proxyOpRetries.value(); - } - - public void incrRouterFailureStateStore() { - routerFailureStateStore.incr(); - } - - @Override - public long getRouterFailureStateStoreOps() { - return routerFailureStateStore.value(); - } - - public void incrRouterFailureSafemode() { - routerFailureSafemode.incr(); - } - - @Override - public long getRouterFailureSafemodeOps() { - return routerFailureSafemode.value(); - } - - public void incrRouterFailureReadOnly() { - routerFailureReadOnly.incr(); - } - - @Override - public long getRouterFailureReadOnlyOps() { - return routerFailureReadOnly.value(); - } - - public void incrRouterFailureLocked() { - routerFailureLocked.incr(); - } - - @Override - public long getRouterFailureLockedOps() { - return routerFailureLocked.value(); - } - - @Override - public int getRpcServerCallQueue() { - return rpcServer.getServer().getCallQueueLen(); - } - - @Override - public int getRpcServerNumOpenConnections() { - return rpcServer.getServer().getNumOpenConnections(); - } - - @Override - public int getRpcClientNumConnections() { - return rpcServer.getRPCClient().getNumConnections(); - } - - @Override - public int getRpcClientNumActiveConnections() { - return rpcServer.getRPCClient().getNumActiveConnections(); - } - - @Override - public int getRpcClientNumCreatingConnections() { - return rpcServer.getRPCClient().getNumCreatingConnections(); - } - - @Override - public int getRpcClientNumConnectionPools() { - return rpcServer.getRPCClient().getNumConnectionPools(); - } - - @Override - public String getRpcClientConnections() { - return rpcServer.getRPCClient().getJSON(); - } - - /** - * Add the time to proxy an operation from the moment the Router sends it to - * the Namenode until it replied. - * @param time Proxy time of an operation in nanoseconds. - */ - public void addProxyTime(long time) { - proxy.add(time); - proxyOp.incr(); - } - - @Override - public double getProxyAvg() { - return toMs(proxy.lastStat().mean()); - } - - @Override - public long getProxyOps() { - return proxyOp.value(); - } - - /** - * Add the time to process a request in the Router from the time we receive - * the call until we send it to the Namenode. - * @param time Process time of an operation in nanoseconds. - */ - public void addProcessingTime(long time) { - processing.add(time); - processingOp.incr(); - } - - @Override - public double getProcessingAvg() { - return toMs(processing.lastStat().mean()); - } - - @Override - public long getProcessingOps() { - return processingOp.value(); - } -} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
