@Override public IsMasterRunningResponse isMasterRunning(RpcController c, IsMasterRunningRequest req) throws ServiceException { try { master.checkServiceStarted(); return IsMasterRunningResponse.newBuilder().setIsMasterRunning( !master.isStopped()).build(); } catch (IOException e) { throw new ServiceException(e); } }
@Test public void testRPCException() throws IOException, InterruptedException, KeeperException { ServerName sm = master.getServerName(); boolean fakeZNodeDelete = false; for (int i = 0; i < 20; i++) { try { BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(sm, User.getCurrent(), 0); MasterProtos.MasterService.BlockingInterface stub = MasterProtos.MasterService.newBlockingStub(channel); assertTrue(stub.isMasterRunning(null, IsMasterRunningRequest.getDefaultInstance()) .getIsMasterRunning()); return; } catch (ServiceException ex) { IOException ie = ProtobufUtil.getRemoteException(ex); // No SocketTimeoutException here. RpcServer is already started after the construction of // HMaster. assertTrue(ie.getMessage().startsWith( "org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet")); LOG.info("Expected exception: ", ie); if (!fakeZNodeDelete) { testUtil.getZooKeeperWatcher().getRecoverableZooKeeper() .delete(testUtil.getZooKeeperWatcher().getMasterAddressZNode(), -1); fakeZNodeDelete = true; } } Thread.sleep(1000); } }
@Override public IsMasterRunningResponse isMasterRunning(RpcController c, IsMasterRunningRequest req) throws ServiceException { try { master.checkInitialized(); return IsMasterRunningResponse.newBuilder().setIsMasterRunning( !master.isStopped()).build(); } catch (IOException e) { throw new ServiceException(e); } }
@Test public void testRPCException() throws Exception { HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); TEST_UTIL.startMiniZKCluster(); Configuration conf = TEST_UTIL.getConfiguration(); conf.set(HConstants.MASTER_PORT, "0"); HMaster hm = new HMaster(conf); ServerName sm = hm.getServerName(); InetSocketAddress isa = new InetSocketAddress(sm.getHostname(), sm.getPort()); int i = 0; //retry the RPC a few times; we have seen SocketTimeoutExceptions if we //try to connect too soon. Retry on SocketTimeoutException. while (i < 20) { try { MasterMonitorProtocol inf = (MasterMonitorProtocol) HBaseClientRPC.getProxy( MasterMonitorProtocol.class, isa, conf, 100 * 10); inf.isMasterRunning(null, IsMasterRunningRequest.getDefaultInstance()); fail(); } catch (ServiceException ex) { IOException ie = ProtobufUtil.getRemoteException(ex); if (!(ie instanceof SocketTimeoutException)) { if(ie.getMessage().startsWith( "org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet")) { return; } } else { System.err.println("Got SocketTimeoutException. Will retry. "); } } catch (Throwable t) { fail("Unexpected throwable: " + t); } Thread.sleep(100); i++; } fail(); }
@Test public void testRPCException() throws Exception { HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); TEST_UTIL.startMiniZKCluster(); Configuration conf = TEST_UTIL.getConfiguration(); conf.set(HConstants.MASTER_PORT, "0"); CoordinatedStateManager cp = CoordinatedStateManagerFactory.getCoordinatedStateManager(conf); HMaster hm = new HMaster(conf, cp); ServerName sm = hm.getServerName(); RpcClient rpcClient = RpcClientFactory.createClient(conf, HConstants.CLUSTER_ID_DEFAULT); try { int i = 0; //retry the RPC a few times; we have seen SocketTimeoutExceptions if we //try to connect too soon. Retry on SocketTimeoutException. while (i < 20) { try { BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(sm, User.getCurrent(), 0); MasterProtos.MasterService.BlockingInterface stub = MasterProtos.MasterService.newBlockingStub(channel); stub.isMasterRunning(null, IsMasterRunningRequest.getDefaultInstance()); fail(); } catch (ServiceException ex) { IOException ie = ProtobufUtil.getRemoteException(ex); if (!(ie instanceof SocketTimeoutException)) { if (ie.getMessage().startsWith("org.apache.hadoop.hbase.ipc." + "ServerNotRunningYetException: Server is not running yet")) { // Done. Got the exception we wanted. System.out.println("Expected exception: " + ie.getMessage()); return; } else { throw ex; } } else { System.err.println("Got SocketTimeoutException. Will retry. "); } } catch (Throwable t) { fail("Unexpected throwable: " + t); } Thread.sleep(100); i++; } fail(); } finally { rpcClient.close(); } }
@Override public IsMasterRunningResponse isMasterRunning(RpcController c, IsMasterRunningRequest req) throws ServiceException { return IsMasterRunningResponse.newBuilder().setIsMasterRunning(isMasterRunning()).build(); }
@Test public void testRPCException() throws Exception { HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); TEST_UTIL.startMiniZKCluster(); Configuration conf = TEST_UTIL.getConfiguration(); conf.set(HConstants.MASTER_PORT, "0"); HMaster hm = new HMaster(conf); ServerName sm = hm.getServerName(); RpcClient rpcClient = new RpcClient(conf, HConstants.CLUSTER_ID_DEFAULT); try { int i = 0; //retry the RPC a few times; we have seen SocketTimeoutExceptions if we //try to connect too soon. Retry on SocketTimeoutException. while (i < 20) { try { BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(sm, User.getCurrent(), 0); MasterProtos.MasterService.BlockingInterface stub = MasterProtos.MasterService.newBlockingStub(channel); stub.isMasterRunning(null, IsMasterRunningRequest.getDefaultInstance()); fail(); } catch (ServiceException ex) { IOException ie = ProtobufUtil.getRemoteException(ex); if (!(ie instanceof SocketTimeoutException)) { if (ie.getMessage().startsWith("org.apache.hadoop.hbase.ipc." + "ServerNotRunningYetException: Server is not running yet")) { // Done. Got the exception we wanted. System.out.println("Expected exception: " + ie.getMessage()); return; } else { throw ex; } } else { System.err.println("Got SocketTimeoutException. Will retry. "); } } catch (Throwable t) { fail("Unexpected throwable: " + t); } Thread.sleep(100); i++; } fail(); } finally { rpcClient.stop(); } }
@Test public void testRPCException() throws Exception { HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); TEST_UTIL.startMiniZKCluster(); Configuration conf = TEST_UTIL.getConfiguration(); conf.set(HConstants.MASTER_PORT, "0"); CoordinatedStateManager cp = CoordinatedStateManagerFactory.getCoordinatedStateManager(conf); HMaster hm = new HMaster(conf, cp); ServerName sm = hm.getServerName(); RpcClient rpcClient = new RpcClient(conf, HConstants.CLUSTER_ID_DEFAULT); try { int i = 0; //retry the RPC a few times; we have seen SocketTimeoutExceptions if we //try to connect too soon. Retry on SocketTimeoutException. while (i < 20) { try { BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(sm, User.getCurrent(), 0); MasterProtos.MasterService.BlockingInterface stub = MasterProtos.MasterService.newBlockingStub(channel); stub.isMasterRunning(null, IsMasterRunningRequest.getDefaultInstance()); fail(); } catch (ServiceException ex) { IOException ie = ProtobufUtil.getRemoteException(ex); if (!(ie instanceof SocketTimeoutException)) { if (ie.getMessage().startsWith("org.apache.hadoop.hbase.ipc." + "ServerNotRunningYetException: Server is not running yet")) { // Done. Got the exception we wanted. System.out.println("Expected exception: " + ie.getMessage()); return; } else { throw ex; } } else { System.err.println("Got SocketTimeoutException. Will retry. "); } } catch (Throwable t) { fail("Unexpected throwable: " + t); } Thread.sleep(100); i++; } fail(); } finally { rpcClient.stop(); } }
public IsMasterRunningResponse isMasterRunning(RpcController c, IsMasterRunningRequest req) throws ServiceException { return IsMasterRunningResponse.newBuilder().setIsMasterRunning(isMasterRunning()).build(); }
/** * Creates a protocol buffer IsMasterRunningRequest * * @return a IsMasterRunningRequest */ public static IsMasterRunningRequest buildIsMasterRunningRequest() { return IsMasterRunningRequest.newBuilder().build(); }