RpcServer.CurCall.set(call); try { if (!this.rpcServer.isStarted()) { InetSocketAddress address = rpcServer.getListenerAddress(); throw new ServerNotRunningYetException("Server " + (address != null ? address : "(channel closed)") + " is not running yet"); resultPair = this.rpcServer.call(call, this.status); } catch (TimeoutIOException e){ RpcServer.LOG.warn("Can not complete this request in time, drop it: " + call); RpcServer.CurCall.set(null); if (resultPair != null) { this.rpcServer.addCallSize(call.getSize() * -1); sucessful = true; this.status.pause("Waiting for a call"); } catch (OutOfMemoryError e) { if (this.rpcServer.getErrorHandler() != null) { if (this.rpcServer.getErrorHandler().checkOOME(e)) { RpcServer.LOG.info(Thread.currentThread().getName() + ": exiting on OutOfMemoryError"); return; InetSocketAddress address = rpcServer.getListenerAddress(); RpcServer.LOG.warn(Thread.currentThread().getName() + ": caught a ClosedChannelException, " + "this means that the server " + (address != null ? address : "(channel closed)") + } finally { if (!sucessful) {
@Before public void setupBasicMocks() throws IOException, ServiceException { rs = Mockito.mock(HRegionServer.class); rpcServices = Mockito.mock(RSRpcServices.class); rpcServer = Mockito.mock(RpcServerInterface.class); Mockito.doReturn(HBaseConfiguration.create()) .when(rs).getConfiguration(); Mockito.doReturn(rpcServices).when(rs).getRSRpcServices(); Mockito.doReturn(rpcServer).when(rs).getRpcServer(); Mockito.doReturn(fakeResponse).when(rpcServices).getServerInfo( (RpcController)Mockito.any(), (GetServerInfoRequest)Mockito.any()); // Fake ZKW ZKWatcher zkw = Mockito.mock(ZKWatcher.class); Mockito.doReturn("fakequorum").when(zkw).getQuorum(); Mockito.doReturn(zkw).when(rs).getZooKeeper(); // Fake BlockCache LOG.warn("The " + HConstants.HFILE_BLOCK_CACHE_SIZE_KEY + " is set to 0"); Mockito.doReturn(Optional.empty()).when(rs).getBlockCache(); // Fake MasterAddressTracker MasterAddressTracker mat = Mockito.mock(MasterAddressTracker.class); Mockito.doReturn(fakeMasterAddress).when(mat).getMasterAddress(); Mockito.doReturn(mat).when(rs).getMasterAddressTracker(); MetricsRegionServer rms = Mockito.mock(MetricsRegionServer.class); Mockito.doReturn(new MetricsRegionServerWrapperStub()).when(rms).getRegionServerWrapper(); Mockito.doReturn(rms).when(rs).getRegionServerMetrics(); MetricsHBaseServer ms = Mockito.mock(MetricsHBaseServer.class); Mockito.doReturn(new MetricsHBaseServerWrapperStub()).when(ms).getHBaseServerWrapper(); Mockito.doReturn(ms).when(rpcServer).getMetrics(); }
@VisibleForTesting public RpcScheduler getRpcScheduler() { return rpcServer.getScheduler(); } }
InetSocketAddress address = rpcServer.getListenerAddress(); call.setResponse(null, null, CALL_DROPPED_EXCEPTION, "Call dropped, server " + (address != null ? address : "(channel closed)") + " is overloaded, please retry."); call.sendResponseIfReady(); } catch (ClosedChannelException cce) { InetSocketAddress address = rpcServer.getListenerAddress(); RpcServer.LOG.warn(Thread.currentThread().getName() + ": caught a ClosedChannelException, " + "this means that the server " + (address != null ? address : "(channel closed)") + } finally { if (!sucessful) { this.rpcServer.addCallSize(call.getSize() * -1);
rpcServer.setRsRpcServices(this); scannerLeaseTimeoutPeriod = rs.conf.getInt( HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, DEFAULT_REGION_SERVER_RPC_MINIMUM_SCAN_TIME_LIMIT_DELTA); InetSocketAddress address = rpcServer.getListenerAddress(); if (address == null) { throw new IOException("Listener channel is closed"); rpcServer.setErrorHandler(this); rs.setName(name);
Lists.newArrayList(new RpcServer.BlockingServiceAndInterface((BlockingService) SERVICE, null)), isa, serverConf, new FifoRpcScheduler(serverConf, 1)); rpcServer.start(); try (RpcClient rpcClient = RpcClientFactory.createClient(clientConf, HConstants.DEFAULT_CLUSTER_ID.toString())) { BlockingInterface stub = newBlockingStub(rpcClient, rpcServer.getListenerAddress(), clientUser); TestThread th1 = new TestThread(stub); rpcServer.stop();
void stop() { if (accessChecker != null) { accessChecker.stop(); } closeAllScanners(); rpcServer.stop(); }
@Before public void setUp() throws IOException { // Setup server for both protocols this.conf = HBaseConfiguration.create(); this.conf.set(RpcServerFactory.CUSTOM_RPC_SERVER_IMPL_CONF_KEY, rpcServerImpl); Logger log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer"); log.setLevel(Level.DEBUG); log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer.trace"); log.setLevel(Level.TRACE); // Create server side implementation // Get RPC server for server side implementation this.server = RpcServerFactory.createRpcServer(null, "testrpc", Lists.newArrayList(new RpcServer.BlockingServiceAndInterface(SERVICE, null)), new InetSocketAddress(ADDRESS, PORT), conf, new FifoRpcScheduler(conf, 10)); InetSocketAddress address = server.getListenerAddress(); if (address == null) { throw new IOException("Listener channel is closed"); } this.isa = address; this.server.start(); }
this.rpcServer = RpcServerFactory.createRpcServer(this, "tokenServer", sai, initialIsa, conf, new FifoRpcScheduler(conf, 1)); InetSocketAddress address = rpcServer.getListenerAddress(); if (address == null) { throw new IOException("Listener channel is closed");
void start(ZKWatcher zkWatcher) { if (AccessChecker.isAuthorizationSupported(getConfiguration())) { accessChecker = new AccessChecker(getConfiguration(), zkWatcher); } this.scannerIdGenerator = new ScannerIdGenerator(this.regionServer.serverName); rpcServer.start(); }
DEFAULT_REGION_SERVER_RPC_MINIMUM_SCAN_TIME_LIMIT_DELTA); InetSocketAddress address = rpcServer.getListenerAddress(); if (address == null) { throw new IOException("Listener channel is closed"); rpcServer.setErrorHandler(this); rs.setName(name);
/** * Does nothing but exercise a {@link CallRunner} outside of {@link RpcServer} context. */ @Test public void testSimpleCall() { RpcServerInterface mockRpcServer = Mockito.mock(RpcServerInterface.class); Mockito.when(mockRpcServer.isStarted()).thenReturn(true); ServerCall mockCall = Mockito.mock(ServerCall.class); CallRunner cr = new CallRunner(mockRpcServer, mockCall); cr.setStatus(new MonitoredRPCHandlerImpl()); cr.run(); } }
/** * On construction, adds the size of this call to the running count of outstanding call sizes. * Presumption is that we are put on a queue while we wait on an executor to run us. During this * time we occupy heap. */ // The constructor is shutdown so only RpcServer in this class can make one of these. CallRunner(final RpcServerInterface rpcServer, final RpcCall call) { this.call = call; this.rpcServer = rpcServer; // Add size of the call to queue size. if (call != null && rpcServer != null) { this.rpcServer.addCallSize(call.getSize()); } }
Lists.newArrayList(new RpcServer.BlockingServiceAndInterface((BlockingService) SERVICE, null)), isa, serverConf, new FifoRpcScheduler(serverConf, 1)); rpcServer.start(); try (RpcClient rpcClient = RpcClientFactory.createClient(clientConf, HConstants.DEFAULT_CLUSTER_ID.toString())) { BlockingInterface stub = newBlockingStub(rpcClient, rpcServer.getListenerAddress(), clientUser); TestThread th1 = new TestThread(stub); rpcServer.stop();
@After public void tearDown() throws Exception { server.stop(); }
@Before public void setUp() throws IOException { // Setup server for both protocols this.conf = HBaseConfiguration.create(); this.conf.set(RpcServerFactory.CUSTOM_RPC_SERVER_IMPL_CONF_KEY, rpcServerImpl); Logger log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer"); log.setLevel(Level.DEBUG); log = Logger.getLogger("org.apache.hadoop.ipc.HBaseServer.trace"); log.setLevel(Level.TRACE); // Create server side implementation // Get RPC server for server side implementation this.server = RpcServerFactory.createRpcServer(null, "testrpc", Lists.newArrayList(new RpcServer.BlockingServiceAndInterface(SERVICE, null)), new InetSocketAddress(ADDRESS, PORT), conf, new FifoRpcScheduler(conf, 10)); InetSocketAddress address = server.getListenerAddress(); if (address == null) { throw new IOException("Listener channel is closed"); } this.isa = address; this.server.start(); }
retry = false; assertEquals("Master RPC port is incorrect", masterPort, cluster.getMaster().getRpcServer().getListenerAddress().getPort()); assertEquals("Master info port is incorrect", masterInfoPort, cluster.getMaster().getInfoServer().getPort()); assertEquals("RS RPC port is incorrect", rsPort, cluster.getRegionServer(0).getRpcServer().getListenerAddress().getPort()); assertEquals("RS info port is incorrect", rsInfoPort, cluster.getRegionServer(0).getInfoServer().getPort());
private void initialize() throws IOException { // ZK configuration must _not_ have hbase.security.authentication or it will require SASL auth Configuration zkConf = new Configuration(conf); zkConf.set(User.HBASE_SECURITY_CONF_KEY, "simple"); this.zookeeper = new ZKWatcher(zkConf, TokenServer.class.getSimpleName(), this, true); this.rpcServer.start(); // Mock up region coprocessor environment RegionCoprocessorEnvironment mockRegionCpEnv = mock(RegionCoprocessorEnvironment.class, Mockito.withSettings().extraInterfaces(HasRegionServerServices.class)); when(mockRegionCpEnv.getConfiguration()).thenReturn(conf); when(mockRegionCpEnv.getClassLoader()).then( (var1) -> Thread.currentThread().getContextClassLoader()); RegionServerServices mockRss = mock(RegionServerServices.class); when(mockRss.getRpcServer()).thenReturn(rpcServer); when(((HasRegionServerServices) mockRegionCpEnv).getRegionServerServices()) .thenReturn(mockRss); super.start(mockRegionCpEnv); started = true; }
/** * Does nothing but exercise a {@link CallRunner} outside of {@link RpcServer} context. */ @Test public void testSimpleCall() { RpcServerInterface mockRpcServer = Mockito.mock(RpcServerInterface.class); Mockito.when(mockRpcServer.isStarted()).thenReturn(true); ServerCall mockCall = Mockito.mock(ServerCall.class); CallRunner cr = new CallRunner(mockRpcServer, mockCall); cr.setStatus(new MonitoredRPCHandlerImpl()); cr.run(); } }
/** * On construction, adds the size of this call to the running count of outstanding call sizes. * Presumption is that we are put on a queue while we wait on an executor to run us. During this * time we occupy heap. */ // The constructor is shutdown so only RpcServer in this class can make one of these. CallRunner(final RpcServerInterface rpcServer, final Call call) { this.call = call; this.rpcServer = rpcServer; // Add size of the call to queue size. this.rpcServer.addCallSize(call.getSize()); }