Java Code Examples for org.apache.hadoop.ipc.Server#start()
The following examples show how to use
org.apache.hadoop.ipc.Server#start() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DummyHAService.java From big-c with Apache License 2.0 | 6 votes |
private InetSocketAddress startAndGetRPCServerAddress(InetSocketAddress serverAddress) { Configuration conf = new Configuration(); try { RPC.setProtocolEngine(conf, HAServiceProtocolPB.class, ProtobufRpcEngine.class); HAServiceProtocolServerSideTranslatorPB haServiceProtocolXlator = new HAServiceProtocolServerSideTranslatorPB(new MockHAProtocolImpl()); BlockingService haPbService = HAServiceProtocolService .newReflectiveBlockingService(haServiceProtocolXlator); Server server = new RPC.Builder(conf) .setProtocol(HAServiceProtocolPB.class) .setInstance(haPbService) .setBindAddress(serverAddress.getHostName()) .setPort(serverAddress.getPort()).build(); server.start(); return NetUtils.getConnectAddress(server); } catch (IOException e) { return null; } }
Example 2
Source File: TestRPCFactories.java From hadoop with Apache License 2.0 | 6 votes |
private void testPbServerFactory() { InetSocketAddress addr = new InetSocketAddress(0); Configuration conf = new Configuration(); ApplicationMasterProtocol instance = new AMRMProtocolTestImpl(); Server server = null; try { server = RpcServerFactoryPBImpl.get().getServer( ApplicationMasterProtocol.class, instance, addr, conf, null, 1); server.start(); } catch (YarnRuntimeException e) { e.printStackTrace(); Assert.fail("Failed to create server"); } finally { if (server != null) { server.stop(); } } }
Example 3
Source File: TestInterDatanodeProtocol.java From hadoop with Apache License 2.0 | 6 votes |
/** Test to verify that InterDatanode RPC timesout as expected when * the server DN does not respond. */ @Test(expected=SocketTimeoutException.class) public void testInterDNProtocolTimeout() throws Throwable { final Server server = new TestServer(1, true); server.start(); final InetSocketAddress addr = NetUtils.getConnectAddress(server); DatanodeID fakeDnId = DFSTestUtil.getLocalDatanodeID(addr.getPort()); DatanodeInfo dInfo = new DatanodeInfo(fakeDnId); InterDatanodeProtocol proxy = null; try { proxy = DataNode.createInterDataNodeProtocolProxy( dInfo, conf, 500, false); proxy.initReplicaRecovery(new RecoveringBlock( new ExtendedBlock("bpid", 1), null, 100)); fail ("Expected SocketTimeoutException exception, but did not get."); } finally { if (proxy != null) { RPC.stopProxy(proxy); } server.stop(); } }
Example 4
Source File: TestClientToAMTokens.java From hadoop with Apache License 2.0 | 6 votes |
@Override protected void serviceStart() throws Exception { Configuration conf = getConfig(); Server server; try { secretMgr = new ClientToAMTokenSecretManager( this.appAttemptId, secretKey); server = new RPC.Builder(conf) .setProtocol(CustomProtocol.class) .setNumHandlers(1) .setSecretManager(secretMgr) .setInstance(this).build(); } catch (Exception e) { throw new YarnRuntimeException(e); } server.start(); this.address = NetUtils.getConnectAddress(server); super.serviceStart(); }
Example 5
Source File: TestNMAuditLogger.java From big-c with Apache License 2.0 | 6 votes |
/** * Test {@link NMAuditLogger} with IP set. */ @Test public void testNMAuditLoggerWithIP() throws Exception { Configuration conf = new Configuration(); // start the IPC server Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class) .setInstance(new MyTestRPCServer()).setBindAddress("0.0.0.0") .setPort(0).setNumHandlers(5).setVerbose(true).build(); server.start(); InetSocketAddress addr = NetUtils.getConnectAddress(server); // Make a client connection and test the audit log TestProtocol proxy = (TestProtocol)RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); // Start the testcase proxy.ping(); server.stop(); }
Example 6
Source File: TestRPCFactories.java From hadoop with Apache License 2.0 | 6 votes |
private void testPbServerFactory() { InetSocketAddress addr = new InetSocketAddress(0); Configuration conf = new Configuration(); MRClientProtocol instance = new MRClientProtocolTestImpl(); Server server = null; try { server = RpcServerFactoryPBImpl.get().getServer( MRClientProtocol.class, instance, addr, conf, null, 1); server.start(); } catch (YarnRuntimeException e) { e.printStackTrace(); Assert.fail("Failed to crete server"); } finally { server.stop(); } }
Example 7
Source File: TFApplicationRpcServer.java From TensorFlowOnYARN with Apache License 2.0 | 5 votes |
@Override public void run() { Configuration conf = new Configuration(); YarnRPC rpc = YarnRPC.create(conf); InetSocketAddress address = new InetSocketAddress(rpcAddress, rpcPort); Server server = rpc.getServer( TensorFlowCluster.class, this, address, conf, null, conf.getInt(YarnConfiguration.RM_RESOURCE_TRACKER_CLIENT_THREAD_COUNT, YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_CLIENT_THREAD_COUNT)); server.start(); }
Example 8
Source File: TestDFSClientRetries.java From big-c with Apache License 2.0 | 5 votes |
/** Test that timeout occurs when DN does not respond to RPC. * Start up a server and ask it to sleep for n seconds. Make an * RPC to the server and set rpcTimeout to less than n and ensure * that socketTimeoutException is obtained */ @Test public void testClientDNProtocolTimeout() throws IOException { final Server server = new TestServer(1, true); server.start(); final InetSocketAddress addr = NetUtils.getConnectAddress(server); DatanodeID fakeDnId = DFSTestUtil.getLocalDatanodeID(addr.getPort()); ExtendedBlock b = new ExtendedBlock("fake-pool", new Block(12345L)); LocatedBlock fakeBlock = new LocatedBlock(b, new DatanodeInfo[0]); ClientDatanodeProtocol proxy = null; try { proxy = DFSUtil.createClientDatanodeProtocolProxy( fakeDnId, conf, 500, false, fakeBlock); proxy.getReplicaVisibleLength(new ExtendedBlock("bpid", 1)); fail ("Did not get expected exception: SocketTimeoutException"); } catch (SocketTimeoutException e) { LOG.info("Got the expected Exception: SocketTimeoutException"); } finally { if (proxy != null) { RPC.stopProxy(proxy); } server.stop(); } }
Example 9
Source File: TestDoAsEffectiveUser.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void testRealUserGroupNotSpecified() throws IOException { final Configuration conf = new Configuration(); configureSuperUserIPAddresses(conf, REAL_USER_SHORT_NAME); Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class) .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0) .setNumHandlers(2).setVerbose(false).build(); try { server.start(); final InetSocketAddress addr = NetUtils.getConnectAddress(server); UserGroupInformation realUserUgi = UserGroupInformation .createRemoteUser(REAL_USER_NAME); UserGroupInformation proxyUserUgi = UserGroupInformation .createProxyUserForTesting(PROXY_USER_NAME, realUserUgi, GROUP_NAMES); String retVal = proxyUserUgi .doAs(new PrivilegedExceptionAction<String>() { @Override public String run() throws IOException { proxy = (TestProtocol) RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); String ret = proxy.aMethod(); return ret; } }); Assert.fail("The RPC must have failed " + retVal); } catch (Exception e) { e.printStackTrace(); } finally { server.stop(); if (proxy != null) { RPC.stopProxy(proxy); } } }
Example 10
Source File: TestDoAsEffectiveUser.java From hadoop with Apache License 2.0 | 5 votes |
@Test(timeout=4000) public void testRealUserSetup() throws IOException { final Configuration conf = new Configuration(); conf.setStrings(DefaultImpersonationProvider.getTestProvider(). getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME), "group1"); configureSuperUserIPAddresses(conf, REAL_USER_SHORT_NAME); Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class) .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0) .setNumHandlers(5).setVerbose(true).build(); refreshConf(conf); try { server.start(); UserGroupInformation realUserUgi = UserGroupInformation .createRemoteUser(REAL_USER_NAME); checkRemoteUgi(server, realUserUgi, conf); UserGroupInformation proxyUserUgi = UserGroupInformation.createProxyUserForTesting( PROXY_USER_NAME, realUserUgi, GROUP_NAMES); checkRemoteUgi(server, proxyUserUgi, conf); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } finally { server.stop(); if (proxy != null) { RPC.stopProxy(proxy); } } }
Example 11
Source File: TestDFSClientRetries.java From hadoop with Apache License 2.0 | 5 votes |
/** Test that timeout occurs when DN does not respond to RPC. * Start up a server and ask it to sleep for n seconds. Make an * RPC to the server and set rpcTimeout to less than n and ensure * that socketTimeoutException is obtained */ @Test public void testClientDNProtocolTimeout() throws IOException { final Server server = new TestServer(1, true); server.start(); final InetSocketAddress addr = NetUtils.getConnectAddress(server); DatanodeID fakeDnId = DFSTestUtil.getLocalDatanodeID(addr.getPort()); ExtendedBlock b = new ExtendedBlock("fake-pool", new Block(12345L)); LocatedBlock fakeBlock = new LocatedBlock(b, new DatanodeInfo[0]); ClientDatanodeProtocol proxy = null; try { proxy = DFSUtil.createClientDatanodeProtocolProxy( fakeDnId, conf, 500, false, fakeBlock); proxy.getReplicaVisibleLength(new ExtendedBlock("bpid", 1)); fail ("Did not get expected exception: SocketTimeoutException"); } catch (SocketTimeoutException e) { LOG.info("Got the expected Exception: SocketTimeoutException"); } finally { if (proxy != null) { RPC.stopProxy(proxy); } server.stop(); } }
Example 12
Source File: TestDoAsEffectiveUser.java From big-c with Apache License 2.0 | 5 votes |
@Test(timeout=4000) public void testRealUserAuthorizationSuccess() throws IOException { final Configuration conf = new Configuration(); configureSuperUserIPAddresses(conf, REAL_USER_SHORT_NAME); conf.setStrings(DefaultImpersonationProvider.getTestProvider(). getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME), "group1"); Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class) .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0) .setNumHandlers(2).setVerbose(false).build(); refreshConf(conf); try { server.start(); UserGroupInformation realUserUgi = UserGroupInformation .createRemoteUser(REAL_USER_NAME); checkRemoteUgi(server, realUserUgi, conf); UserGroupInformation proxyUserUgi = UserGroupInformation .createProxyUserForTesting(PROXY_USER_NAME, realUserUgi, GROUP_NAMES); checkRemoteUgi(server, proxyUserUgi, conf); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } finally { server.stop(); if (proxy != null) { RPC.stopProxy(proxy); } } }
Example 13
Source File: TestDoAsEffectiveUser.java From big-c with Apache License 2.0 | 4 votes |
@Test public void testRealUserGroupAuthorizationFailure() throws IOException { final Configuration conf = new Configuration(); configureSuperUserIPAddresses(conf, REAL_USER_SHORT_NAME); conf.setStrings(DefaultImpersonationProvider.getTestProvider(). getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME), "group3"); Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class) .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0) .setNumHandlers(2).setVerbose(false).build(); refreshConf(conf); try { server.start(); final InetSocketAddress addr = NetUtils.getConnectAddress(server); UserGroupInformation realUserUgi = UserGroupInformation .createRemoteUser(REAL_USER_NAME); UserGroupInformation proxyUserUgi = UserGroupInformation .createProxyUserForTesting(PROXY_USER_NAME, realUserUgi, GROUP_NAMES); String retVal = proxyUserUgi .doAs(new PrivilegedExceptionAction<String>() { @Override public String run() throws IOException { proxy = RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); String ret = proxy.aMethod(); return ret; } }); Assert.fail("The RPC must have failed " + retVal); } catch (Exception e) { e.printStackTrace(); } finally { server.stop(); if (proxy != null) { RPC.stopProxy(proxy); } } }
Example 14
Source File: TestClientProtocolWithDelegationToken.java From hadoop with Apache License 2.0 | 4 votes |
@Test public void testDelegationTokenRpc() throws Exception { ClientProtocol mockNN = mock(ClientProtocol.class); FSNamesystem mockNameSys = mock(FSNamesystem.class); DelegationTokenSecretManager sm = new DelegationTokenSecretManager( DFSConfigKeys.DFS_NAMENODE_DELEGATION_KEY_UPDATE_INTERVAL_DEFAULT, DFSConfigKeys.DFS_NAMENODE_DELEGATION_KEY_UPDATE_INTERVAL_DEFAULT, DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_DEFAULT, 3600000, mockNameSys); sm.startThreads(); final Server server = new RPC.Builder(conf) .setProtocol(ClientProtocol.class).setInstance(mockNN) .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true) .setSecretManager(sm).build(); server.start(); final UserGroupInformation current = UserGroupInformation.getCurrentUser(); final InetSocketAddress addr = NetUtils.getConnectAddress(server); String user = current.getUserName(); Text owner = new Text(user); DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(owner, owner, null); Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>( dtId, sm); SecurityUtil.setTokenService(token, addr); LOG.info("Service for token is " + token.getService()); current.addToken(token); current.doAs(new PrivilegedExceptionAction<Object>() { @Override public Object run() throws Exception { ClientProtocol proxy = null; try { proxy = RPC.getProxy(ClientProtocol.class, ClientProtocol.versionID, addr, conf); proxy.getServerDefaults(); } finally { server.stop(); if (proxy != null) { RPC.stopProxy(proxy); } } return null; } }); }
Example 15
Source File: TestDoAsEffectiveUser.java From big-c with Apache License 2.0 | 4 votes |
@Test public void testProxyWithToken() throws Exception { final Configuration conf = new Configuration(masterConf); TestTokenSecretManager sm = new TestTokenSecretManager(); SecurityUtil.setAuthenticationMethod(AuthenticationMethod.KERBEROS, conf); UserGroupInformation.setConfiguration(conf); final Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class) .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0) .setNumHandlers(5).setVerbose(true).setSecretManager(sm).build(); server.start(); final UserGroupInformation current = UserGroupInformation .createRemoteUser(REAL_USER_NAME); final InetSocketAddress addr = NetUtils.getConnectAddress(server); TestTokenIdentifier tokenId = new TestTokenIdentifier(new Text(current .getUserName()), new Text("SomeSuperUser")); Token<TestTokenIdentifier> token = new Token<TestTokenIdentifier>(tokenId, sm); SecurityUtil.setTokenService(token, addr); UserGroupInformation proxyUserUgi = UserGroupInformation .createProxyUserForTesting(PROXY_USER_NAME, current, GROUP_NAMES); proxyUserUgi.addToken(token); refreshConf(conf); String retVal = proxyUserUgi.doAs(new PrivilegedExceptionAction<String>() { @Override public String run() throws Exception { try { proxy = RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); String ret = proxy.aMethod(); return ret; } catch (Exception e) { e.printStackTrace(); throw e; } finally { server.stop(); if (proxy != null) { RPC.stopProxy(proxy); } } } }); //The user returned by server must be the one in the token. Assert.assertEquals(REAL_USER_NAME + " (auth:TOKEN) via SomeSuperUser (auth:SIMPLE)", retVal); }
Example 16
Source File: TestDoAsEffectiveUser.java From hadoop with Apache License 2.0 | 4 votes |
@Test public void testRealUserIPNotSpecified() throws IOException { final Configuration conf = new Configuration(); conf.setStrings(DefaultImpersonationProvider.getTestProvider(). getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME), "group1"); Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class) .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0) .setNumHandlers(2).setVerbose(false).build(); refreshConf(conf); try { server.start(); final InetSocketAddress addr = NetUtils.getConnectAddress(server); UserGroupInformation realUserUgi = UserGroupInformation .createRemoteUser(REAL_USER_NAME); UserGroupInformation proxyUserUgi = UserGroupInformation .createProxyUserForTesting(PROXY_USER_NAME, realUserUgi, GROUP_NAMES); String retVal = proxyUserUgi .doAs(new PrivilegedExceptionAction<String>() { @Override public String run() throws IOException { proxy = RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); String ret = proxy.aMethod(); return ret; } }); Assert.fail("The RPC must have failed " + retVal); } catch (Exception e) { e.printStackTrace(); } finally { server.stop(); if (proxy != null) { RPC.stopProxy(proxy); } } }
Example 17
Source File: TestDoAsEffectiveUser.java From big-c with Apache License 2.0 | 4 votes |
@Test public void testTokenBySuperUser() throws Exception { TestTokenSecretManager sm = new TestTokenSecretManager(); final Configuration newConf = new Configuration(masterConf); SecurityUtil.setAuthenticationMethod(AuthenticationMethod.KERBEROS, newConf); UserGroupInformation.setConfiguration(newConf); final Server server = new RPC.Builder(newConf) .setProtocol(TestProtocol.class).setInstance(new TestImpl()) .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true) .setSecretManager(sm).build(); server.start(); final UserGroupInformation current = UserGroupInformation .createUserForTesting(REAL_USER_NAME, GROUP_NAMES); refreshConf(newConf); final InetSocketAddress addr = NetUtils.getConnectAddress(server); TestTokenIdentifier tokenId = new TestTokenIdentifier(new Text(current .getUserName()), new Text("SomeSuperUser")); Token<TestTokenIdentifier> token = new Token<TestTokenIdentifier>(tokenId, sm); SecurityUtil.setTokenService(token, addr); current.addToken(token); String retVal = current.doAs(new PrivilegedExceptionAction<String>() { @Override public String run() throws Exception { try { proxy = RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, newConf); String ret = proxy.aMethod(); return ret; } catch (Exception e) { e.printStackTrace(); throw e; } finally { server.stop(); if (proxy != null) { RPC.stopProxy(proxy); } } } }); String expected = REAL_USER_NAME + " (auth:TOKEN) via SomeSuperUser (auth:SIMPLE)"; Assert.assertEquals(retVal + "!=" + expected, expected, retVal); }
Example 18
Source File: TestClientProtocolWithDelegationToken.java From big-c with Apache License 2.0 | 4 votes |
@Test public void testDelegationTokenRpc() throws Exception { ClientProtocol mockNN = mock(ClientProtocol.class); FSNamesystem mockNameSys = mock(FSNamesystem.class); DelegationTokenSecretManager sm = new DelegationTokenSecretManager( DFSConfigKeys.DFS_NAMENODE_DELEGATION_KEY_UPDATE_INTERVAL_DEFAULT, DFSConfigKeys.DFS_NAMENODE_DELEGATION_KEY_UPDATE_INTERVAL_DEFAULT, DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_DEFAULT, 3600000, mockNameSys); sm.startThreads(); final Server server = new RPC.Builder(conf) .setProtocol(ClientProtocol.class).setInstance(mockNN) .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true) .setSecretManager(sm).build(); server.start(); final UserGroupInformation current = UserGroupInformation.getCurrentUser(); final InetSocketAddress addr = NetUtils.getConnectAddress(server); String user = current.getUserName(); Text owner = new Text(user); DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(owner, owner, null); Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>( dtId, sm); SecurityUtil.setTokenService(token, addr); LOG.info("Service for token is " + token.getService()); current.addToken(token); current.doAs(new PrivilegedExceptionAction<Object>() { @Override public Object run() throws Exception { ClientProtocol proxy = null; try { proxy = RPC.getProxy(ClientProtocol.class, ClientProtocol.versionID, addr, conf); proxy.getServerDefaults(); } finally { server.stop(); if (proxy != null) { RPC.stopProxy(proxy); } } return null; } }); }
Example 19
Source File: TestDoAsEffectiveUser.java From big-c with Apache License 2.0 | 4 votes |
@Test public void testRealUserIPNotSpecified() throws IOException { final Configuration conf = new Configuration(); conf.setStrings(DefaultImpersonationProvider.getTestProvider(). getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME), "group1"); Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class) .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0) .setNumHandlers(2).setVerbose(false).build(); refreshConf(conf); try { server.start(); final InetSocketAddress addr = NetUtils.getConnectAddress(server); UserGroupInformation realUserUgi = UserGroupInformation .createRemoteUser(REAL_USER_NAME); UserGroupInformation proxyUserUgi = UserGroupInformation .createProxyUserForTesting(PROXY_USER_NAME, realUserUgi, GROUP_NAMES); String retVal = proxyUserUgi .doAs(new PrivilegedExceptionAction<String>() { @Override public String run() throws IOException { proxy = RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); String ret = proxy.aMethod(); return ret; } }); Assert.fail("The RPC must have failed " + retVal); } catch (Exception e) { e.printStackTrace(); } finally { server.stop(); if (proxy != null) { RPC.stopProxy(proxy); } } }
Example 20
Source File: TestDoAsEffectiveUser.java From hadoop with Apache License 2.0 | 4 votes |
@Test public void testProxyWithToken() throws Exception { final Configuration conf = new Configuration(masterConf); TestTokenSecretManager sm = new TestTokenSecretManager(); SecurityUtil.setAuthenticationMethod(AuthenticationMethod.KERBEROS, conf); UserGroupInformation.setConfiguration(conf); final Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class) .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0) .setNumHandlers(5).setVerbose(true).setSecretManager(sm).build(); server.start(); final UserGroupInformation current = UserGroupInformation .createRemoteUser(REAL_USER_NAME); final InetSocketAddress addr = NetUtils.getConnectAddress(server); TestTokenIdentifier tokenId = new TestTokenIdentifier(new Text(current .getUserName()), new Text("SomeSuperUser")); Token<TestTokenIdentifier> token = new Token<TestTokenIdentifier>(tokenId, sm); SecurityUtil.setTokenService(token, addr); UserGroupInformation proxyUserUgi = UserGroupInformation .createProxyUserForTesting(PROXY_USER_NAME, current, GROUP_NAMES); proxyUserUgi.addToken(token); refreshConf(conf); String retVal = proxyUserUgi.doAs(new PrivilegedExceptionAction<String>() { @Override public String run() throws Exception { try { proxy = RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); String ret = proxy.aMethod(); return ret; } catch (Exception e) { e.printStackTrace(); throw e; } finally { server.stop(); if (proxy != null) { RPC.stopProxy(proxy); } } } }); //The user returned by server must be the one in the token. Assert.assertEquals(REAL_USER_NAME + " (auth:TOKEN) via SomeSuperUser (auth:SIMPLE)", retVal); }