ClientService.Interface getRegionServerStub(ServerName serverName) throws IOException { return CollectionUtils.computeIfAbsentEx(rsStubs, getStubKey(ClientService.Interface.class.getSimpleName(), serverName, hostnameCanChange), () -> createRegionServerStub(serverName)); }
AdminService.Interface getAdminStub(ServerName serverName) throws IOException { return CollectionUtils.computeIfAbsentEx(adminSubs, getStubKey(AdminService.Interface.class.getSimpleName(), serverName, hostnameCanChange), () -> createAdminServerStub(serverName)); }
@Override public AdminProtos.AdminService.BlockingInterface getAdmin(ServerName serverName) throws IOException { checkClosed(); if (isDeadServer(serverName)) { throw new RegionServerStoppedException(serverName + " is dead."); } String key = getStubKey(AdminProtos.AdminService.BlockingInterface.class.getName(), serverName, this.hostnamesCanChange); return (AdminProtos.AdminService.BlockingInterface) computeIfAbsentEx(stubs, key, () -> { BlockingRpcChannel channel = this.rpcClient.createBlockingRpcChannel(serverName, user, rpcTimeout); return AdminProtos.AdminService.newBlockingStub(channel); }); }
@Override public BlockingInterface getClient(ServerName serverName) throws IOException { checkClosed(); if (isDeadServer(serverName)) { throw new RegionServerStoppedException(serverName + " is dead."); } String key = getStubKey(ClientProtos.ClientService.BlockingInterface.class.getName(), serverName, this.hostnamesCanChange); return (ClientProtos.ClientService.BlockingInterface) computeIfAbsentEx(stubs, key, () -> { BlockingRpcChannel channel = this.rpcClient.createBlockingRpcChannel(serverName, user, rpcTimeout); return ClientProtos.ClientService.newBlockingStub(channel); }); }
@Override public Hbck getHbck(ServerName masterServer) throws IOException { checkClosed(); if (isDeadServer(masterServer)) { throw new RegionServerStoppedException(masterServer + " is dead."); } String key = getStubKey(MasterProtos.HbckService.BlockingInterface.class.getName(), masterServer, this.hostnamesCanChange); return new HBaseHbck(this, (MasterProtos.HbckService.BlockingInterface) computeIfAbsentEx(stubs, key, () -> { BlockingRpcChannel channel = this.rpcClient.createBlockingRpcChannel(masterServer, user, rpcTimeout); return MasterProtos.HbckService.newBlockingStub(channel); })); }
/** * Create a stub. Try once only. It is not typed because there is no common type to protobuf * services nor their interfaces. Let the caller do appropriate casting. * @return A stub for master services. */ private MasterProtos.MasterService.BlockingInterface makeStubNoRetries() throws IOException, KeeperException { ServerName sn = get(registry.getMasterAddress()); if (sn == null) { String msg = "ZooKeeper available but no active master location found"; LOG.info(msg); throw new MasterNotRunningException(msg); } if (isDeadServer(sn)) { throw new MasterNotRunningException(sn + " is dead."); } // Use the security info interface name as our stub key String key = getStubKey(MasterProtos.MasterService.getDescriptor().getName(), sn, hostnamesCanChange); MasterProtos.MasterService.BlockingInterface stub = (MasterProtos.MasterService.BlockingInterface) computeIfAbsentEx(stubs, key, () -> { BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(sn, user, rpcTimeout); return MasterProtos.MasterService.newBlockingStub(channel); }); isMasterRunning(stub); return stub; }
AdminService.Interface getAdminStub(ServerName serverName) throws IOException { ServerName vhostSN = detectVServerName(serverName); return CollectionUtils.computeIfAbsentEx(adminSubs, getStubKey(AdminService.Interface.class.getSimpleName(), vhostSN, hostnameCanChange), () -> createAdminServerStub(vhostSN)); }
ClientService.Interface getRegionServerStub(ServerName serverName) throws IOException { ServerName vhostSN = detectVServerName(serverName); return CollectionUtils.computeIfAbsentEx(rsStubs, getStubKey(ClientService.Interface.class.getSimpleName(), vhostSN, hostnameCanChange), () -> createRegionServerStub(vhostSN)); }
@Override public BlockingInterface getClient(ServerName serverName) throws IOException { checkClosed(); if (isDeadServer(serverName)) { throw new RegionServerStoppedException(serverName + " is dead."); } ServerName vhostSN = detectVServerName(serverName); String key = getStubKey(ClientProtos.ClientService.BlockingInterface.class.getName(), vhostSN, this.hostnamesCanChange); return (ClientProtos.ClientService.BlockingInterface) computeIfAbsentEx(stubs, key, () -> { BlockingRpcChannel channel = this.rpcClient.createBlockingRpcChannel(vhostSN, user, rpcTimeout); return ClientProtos.ClientService.newBlockingStub(channel); }); }
@Override public AdminProtos.AdminService.BlockingInterface getAdmin(ServerName serverName) throws IOException { checkClosed(); if (isDeadServer(serverName)) { throw new RegionServerStoppedException(serverName + " is dead."); } ServerName vhostSN = detectVServerName(serverName); String key = getStubKey(AdminProtos.AdminService.BlockingInterface.class.getName(), vhostSN, this.hostnamesCanChange); return (AdminProtos.AdminService.BlockingInterface) computeIfAbsentEx(stubs, key, () -> { BlockingRpcChannel channel = this.rpcClient.createBlockingRpcChannel(vhostSN, user, rpcTimeout); return AdminProtos.AdminService.newBlockingStub(channel); }); }
/** * Create a stub. Try once only. It is not typed because there is no common type to protobuf * services nor their interfaces. Let the caller do appropriate casting. * @return A stub for master services. */ private MasterProtos.MasterService.BlockingInterface makeStubNoRetries() throws IOException, KeeperException { ServerName sn = get(registry.getMasterAddress()); if (sn == null) { String msg = "ZooKeeper available but no active master location found"; LOG.info(msg); throw new MasterNotRunningException(msg); } if (isDeadServer(sn)) { throw new MasterNotRunningException(sn + " is dead."); } // Use the security info interface name as our stub key ServerName vhostSN = detectVServerName(sn); String key = getStubKey(MasterProtos.MasterService.getDescriptor().getName(), vhostSN, hostnamesCanChange); MasterProtos.MasterService.BlockingInterface stub = (MasterProtos.MasterService.BlockingInterface) computeIfAbsentEx(stubs, key, () -> { BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(vhostSN, user, rpcTimeout); return MasterProtos.MasterService.newBlockingStub(channel); }); isMasterRunning(stub); return stub; }