You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2012/09/27 00:55:16 UTC
svn commit: r1390763 [3/3] - in
/hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common:
./ src/ src/contrib/bash-tab-completion/ src/main/bin/ src/main/docs/
src/main/docs/src/documentation/content/xdocs/ src/main/java/ src/main/j...
Modified: hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestMultipleProtocolServer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestMultipleProtocolServer.java?rev=1390763&r1=1390762&r2=1390763&view=diff
==============================================================================
--- hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestMultipleProtocolServer.java (original)
+++ hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestMultipleProtocolServer.java Wed Sep 26 22:55:00 2012
@@ -175,8 +175,9 @@ public class TestMultipleProtocolServer
@Before
public void setUp() throws Exception {
// create a server with two handlers
- server = RPC.getServer(Foo0.class,
- new Foo0Impl(), ADDRESS, 0, 2, false, conf, null);
+ server = new RPC.Builder(conf).setProtocol(Foo0.class)
+ .setInstance(new Foo0Impl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(2).setVerbose(false).build();
server.addProtocol(RPC.RpcKind.RPC_WRITABLE, Foo1.class, new Foo1Impl());
server.addProtocol(RPC.RpcKind.RPC_WRITABLE, Bar.class, new BarImpl());
server.addProtocol(RPC.RpcKind.RPC_WRITABLE, Mixin.class, new BarImpl());
@@ -263,8 +264,9 @@ public class TestMultipleProtocolServer
@Test(expected=IOException.class)
public void testIncorrectServerCreation() throws IOException {
- RPC.getServer(Foo1.class,
- new Foo0Impl(), ADDRESS, 0, 2, false, conf, null);
+ new RPC.Builder(conf).setProtocol(Foo1.class).setInstance(new Foo0Impl())
+ .setBindAddress(ADDRESS).setPort(0).setNumHandlers(2).setVerbose(false)
+ .build();
}
// Now test a PB service - a server hosts both PB and Writable Rpcs.
Modified: hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestProtoBufRpc.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestProtoBufRpc.java?rev=1390763&r1=1390762&r2=1390763&view=diff
==============================================================================
--- hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestProtoBufRpc.java (original)
+++ hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestProtoBufRpc.java Wed Sep 26 22:55:00 2012
@@ -113,7 +113,8 @@ public class TestProtoBufRpc {
.newReflectiveBlockingService(serverImpl);
// Get RPC server for server side implementation
- server = RPC.getServer(TestRpcService.class, service, ADDRESS, PORT, conf);
+ server = new RPC.Builder(conf).setProtocol(TestRpcService.class)
+ .setInstance(service).setBindAddress(ADDRESS).setPort(PORT).build();
addr = NetUtils.getConnectAddress(server);
// now the second protocol
Modified: hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java?rev=1390763&r1=1390762&r2=1390763&view=diff
==============================================================================
--- hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java (original)
+++ hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java Wed Sep 26 22:55:00 2012
@@ -314,8 +314,9 @@ public class TestRPC {
@Test
public void testConfRpc() throws Exception {
- Server server = RPC.getServer(TestProtocol.class,
- new TestImpl(), ADDRESS, 0, 1, false, conf, null);
+ Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(1).setVerbose(false).build();
// Just one handler
int confQ = conf.getInt(
CommonConfigurationKeys.IPC_SERVER_HANDLER_QUEUE_SIZE_KEY,
@@ -328,8 +329,11 @@ public class TestRPC {
assertEquals(confReaders, server.getNumReaders());
server.stop();
- server = RPC.getServer(TestProtocol.class,
- new TestImpl(), ADDRESS, 0, 1, 3, 200, false, conf, null);
+ server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(1).setnumReaders(3).setQueueSizePerHandler(200)
+ .setVerbose(false).build();
+
assertEquals(3, server.getNumReaders());
assertEquals(200, server.getMaxQueueSize());
server.stop();
@@ -337,8 +341,8 @@ public class TestRPC {
@Test
public void testProxyAddress() throws Exception {
- Server server = RPC.getServer(TestProtocol.class,
- new TestImpl(), ADDRESS, 0, conf);
+ Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0).build();
TestProtocol proxy = null;
try {
@@ -362,8 +366,10 @@ public class TestRPC {
public void testSlowRpc() throws Exception {
System.out.println("Testing Slow RPC");
// create a server with two handlers
- Server server = RPC.getServer(TestProtocol.class,
- new TestImpl(), ADDRESS, 0, 2, false, conf, null);
+ Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(2).setVerbose(false).build();
+
TestProtocol proxy = null;
try {
@@ -409,8 +415,8 @@ public class TestRPC {
}
private void testCallsInternal(Configuration conf) throws Exception {
- Server server = RPC.getServer(TestProtocol.class,
- new TestImpl(), ADDRESS, 0, conf);
+ Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0).build();
TestProtocol proxy = null;
try {
server.start();
@@ -528,8 +534,9 @@ public class TestRPC {
}
private void doRPCs(Configuration conf, boolean expectFailure) throws Exception {
- Server server = RPC.getServer(TestProtocol.class,
- new TestImpl(), ADDRESS, 0, 5, true, conf, null);
+ Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(5).setVerbose(true).build();
server.refreshServiceAcl(conf, new TestPolicyProvider());
@@ -573,8 +580,9 @@ public class TestRPC {
@Test
public void testServerAddress() throws IOException {
- Server server = RPC.getServer(TestProtocol.class,
- new TestImpl(), ADDRESS, 0, 5, true, conf, null);
+ Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(5).setVerbose(true).build();
InetSocketAddress bindAddr = null;
try {
bindAddr = NetUtils.getConnectAddress(server);
@@ -668,8 +676,9 @@ public class TestRPC {
@Test
public void testErrorMsgForInsecureClient() throws Exception {
- final Server server = RPC.getServer(TestProtocol.class,
- new TestImpl(), ADDRESS, 0, 5, true, conf, null);
+ final Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(5).setVerbose(true).build();
server.enableSecurity();
server.start();
boolean succeeded = false;
@@ -693,8 +702,10 @@ public class TestRPC {
conf.setInt(CommonConfigurationKeys.IPC_SERVER_RPC_READ_THREADS_KEY, 2);
- final Server multiServer = RPC.getServer(TestProtocol.class,
- new TestImpl(), ADDRESS, 0, 5, true, conf, null);
+ final Server multiServer = new RPC.Builder(conf)
+ .setProtocol(TestProtocol.class).setInstance(new TestImpl())
+ .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
+ .build();
multiServer.enableSecurity();
multiServer.start();
succeeded = false;
@@ -748,8 +759,9 @@ public class TestRPC {
assertEquals("Expect no Reader threads running before test",
0, threadsBefore);
- final Server server = RPC.getServer(TestProtocol.class,
- new TestImpl(), ADDRESS, 0, 5, true, conf, null);
+ final Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(5).setVerbose(true).build();
server.start();
try {
int threadsRunning = countThreads("Server$Listener$Reader");
@@ -762,6 +774,42 @@ public class TestRPC {
0, threadsAfter);
}
+ @Test
+ public void testRPCBuilder() throws Exception {
+ // Test mandatory field conf
+ try {
+ new RPC.Builder(null).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(5).setVerbose(true).build();
+ fail("Didn't throw HadoopIllegalArgumentException");
+ } catch (Exception e) {
+ if (!(e instanceof HadoopIllegalArgumentException)) {
+ fail("Expecting HadoopIllegalArgumentException but caught " + e);
+ }
+ }
+ // Test mandatory field protocol
+ try {
+ new RPC.Builder(conf).setInstance(new TestImpl()).setBindAddress(ADDRESS)
+ .setPort(0).setNumHandlers(5).setVerbose(true).build();
+ fail("Didn't throw HadoopIllegalArgumentException");
+ } catch (Exception e) {
+ if (!(e instanceof HadoopIllegalArgumentException)) {
+ fail("Expecting HadoopIllegalArgumentException but caught " + e);
+ }
+ }
+ // Test mandatory field instance
+ try {
+ new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5)
+ .setVerbose(true).build();
+ fail("Didn't throw HadoopIllegalArgumentException");
+ } catch (Exception e) {
+ if (!(e instanceof HadoopIllegalArgumentException)) {
+ fail("Expecting HadoopIllegalArgumentException but caught " + e);
+ }
+ }
+ }
+
public static void main(String[] args) throws Exception {
new TestRPC().testCallsInternal(conf);
Modified: hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPCCompatibility.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPCCompatibility.java?rev=1390763&r1=1390762&r2=1390763&view=diff
==============================================================================
--- hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPCCompatibility.java (original)
+++ hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPCCompatibility.java Wed Sep 26 22:55:00 2012
@@ -131,8 +131,9 @@ public class TestRPCCompatibility {
public void testVersion0ClientVersion1Server() throws Exception {
// create a server with two handlers
TestImpl1 impl = new TestImpl1();
- server = RPC.getServer(TestProtocol1.class,
- impl, ADDRESS, 0, 2, false, conf, null);
+ server = new RPC.Builder(conf).setProtocol(TestProtocol1.class)
+ .setInstance(impl).setBindAddress(ADDRESS).setPort(0).setNumHandlers(2)
+ .setVerbose(false).build();
server.addProtocol(RPC.RpcKind.RPC_WRITABLE, TestProtocol0.class, impl);
server.start();
addr = NetUtils.getConnectAddress(server);
@@ -147,8 +148,9 @@ public class TestRPCCompatibility {
@Test // old client vs new server
public void testVersion1ClientVersion0Server() throws Exception {
// create a server with two handlers
- server = RPC.getServer(TestProtocol0.class,
- new TestImpl0(), ADDRESS, 0, 2, false, conf, null);
+ server = new RPC.Builder(conf).setProtocol(TestProtocol0.class)
+ .setInstance(new TestImpl0()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(2).setVerbose(false).build();
server.start();
addr = NetUtils.getConnectAddress(server);
@@ -198,8 +200,9 @@ System.out.println("echo int is NOT supp
public void testVersion2ClientVersion1Server() throws Exception {
// create a server with two handlers
TestImpl1 impl = new TestImpl1();
- server = RPC.getServer(TestProtocol1.class,
- impl, ADDRESS, 0, 2, false, conf, null);
+ server = new RPC.Builder(conf).setProtocol(TestProtocol1.class)
+ .setInstance(impl).setBindAddress(ADDRESS).setPort(0).setNumHandlers(2)
+ .setVerbose(false).build();
server.addProtocol(RPC.RpcKind.RPC_WRITABLE, TestProtocol0.class, impl);
server.start();
addr = NetUtils.getConnectAddress(server);
@@ -219,8 +222,9 @@ System.out.println("echo int is NOT supp
ProtocolSignature.resetCache();
// create a server with two handlers
TestImpl2 impl = new TestImpl2();
- server = RPC.getServer(TestProtocol2.class,
- impl, ADDRESS, 0, 2, false, conf, null);
+ server = new RPC.Builder(conf).setProtocol(TestProtocol2.class)
+ .setInstance(impl).setBindAddress(ADDRESS).setPort(0).setNumHandlers(2)
+ .setVerbose(false).build();
server.addProtocol(RPC.RpcKind.RPC_WRITABLE, TestProtocol0.class, impl);
server.start();
addr = NetUtils.getConnectAddress(server);
@@ -290,8 +294,9 @@ System.out.println("echo int is NOT supp
@Test
public void testVersionMismatch() throws IOException {
- server = RPC.getServer(TestProtocol2.class, new TestImpl2(), ADDRESS, 0, 2,
- false, conf, null);
+ server = new RPC.Builder(conf).setProtocol(TestProtocol2.class)
+ .setInstance(new TestImpl2()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(2).setVerbose(false).build();
server.start();
addr = NetUtils.getConnectAddress(server);
@@ -308,8 +313,9 @@ System.out.println("echo int is NOT supp
@Test
public void testIsMethodSupported() throws IOException {
- server = RPC.getServer(TestProtocol2.class, new TestImpl2(), ADDRESS, 0, 2,
- false, conf, null);
+ server = new RPC.Builder(conf).setProtocol(TestProtocol2.class)
+ .setInstance(new TestImpl2()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(2).setVerbose(false).build();
server.start();
addr = NetUtils.getConnectAddress(server);
@@ -332,8 +338,9 @@ System.out.println("echo int is NOT supp
@Test
public void testProtocolMetaInfoSSTranslatorPB() throws Exception {
TestImpl1 impl = new TestImpl1();
- server = RPC.getServer(TestProtocol1.class, impl, ADDRESS, 0, 2, false,
- conf, null);
+ server = new RPC.Builder(conf).setProtocol(TestProtocol1.class)
+ .setInstance(impl).setBindAddress(ADDRESS).setPort(0).setNumHandlers(2)
+ .setVerbose(false).build();
server.addProtocol(RPC.RpcKind.RPC_WRITABLE, TestProtocol0.class, impl);
server.start();
Modified: hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestSaslRPC.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestSaslRPC.java?rev=1390763&r1=1390762&r2=1390763&view=diff
==============================================================================
--- hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestSaslRPC.java (original)
+++ hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestSaslRPC.java Wed Sep 26 22:55:00 2012
@@ -112,7 +112,7 @@ public class TestSaslRPC {
}
@Override
public UserGroupInformation getUser() {
- if ("".equals(realUser.toString())) {
+ if (realUser.toString().isEmpty()) {
return UserGroupInformation.createRemoteUser(tokenid.toString());
} else {
UserGroupInformation realUgi = UserGroupInformation
@@ -235,9 +235,11 @@ public class TestSaslRPC {
@Test
public void testDigestRpc() throws Exception {
TestTokenSecretManager sm = new TestTokenSecretManager();
- final Server server = RPC.getServer(TestSaslProtocol.class,
- new TestSaslImpl(), ADDRESS, 0, 5, true, conf, sm);
-
+ final Server server = new RPC.Builder(conf)
+ .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
+ .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
+ .setSecretManager(sm).build();
+
doDigestRpc(server, sm);
}
@@ -246,9 +248,10 @@ public class TestSaslRPC {
TestTokenSecretManager sm = new TestTokenSecretManager();
try {
SecurityUtil.setSecurityInfoProviders(new CustomSecurityInfo());
- final Server server = RPC.getServer(TestSaslProtocol.class,
- new TestSaslImpl(), ADDRESS, 0, 5,
- true, conf, sm);
+ final Server server = new RPC.Builder(conf)
+ .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
+ .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5)
+ .setVerbose(true).setSecretManager(sm).build();
doDigestRpc(server, sm);
} finally {
SecurityUtil.setSecurityInfoProviders(new SecurityInfo[0]);
@@ -257,8 +260,9 @@ public class TestSaslRPC {
@Test
public void testSecureToInsecureRpc() throws Exception {
- Server server = RPC.getServer(TestSaslProtocol.class,
- new TestSaslImpl(), ADDRESS, 0, 5, true, conf, null);
+ Server server = new RPC.Builder(conf).setProtocol(TestSaslProtocol.class)
+ .setInstance(new TestSaslImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(5).setVerbose(true).build();
server.disableSecurity();
TestTokenSecretManager sm = new TestTokenSecretManager();
doDigestRpc(server, sm);
@@ -267,8 +271,10 @@ public class TestSaslRPC {
@Test
public void testErrorMessage() throws Exception {
BadTokenSecretManager sm = new BadTokenSecretManager();
- final Server server = RPC.getServer(TestSaslProtocol.class,
- new TestSaslImpl(), ADDRESS, 0, 5, true, conf, sm);
+ final Server server = new RPC.Builder(conf)
+ .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
+ .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
+ .setSecretManager(sm).build();
boolean succeeded = false;
try {
@@ -355,8 +361,10 @@ public class TestSaslRPC {
@Test
public void testPerConnectionConf() throws Exception {
TestTokenSecretManager sm = new TestTokenSecretManager();
- final Server server = RPC.getServer(TestSaslProtocol.class,
- new TestSaslImpl(), ADDRESS, 0, 5, true, conf, sm);
+ final Server server = new RPC.Builder(conf)
+ .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
+ .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
+ .setSecretManager(sm).build();
server.start();
final UserGroupInformation current = UserGroupInformation.getCurrentUser();
final InetSocketAddress addr = NetUtils.getConnectAddress(server);
@@ -418,8 +426,10 @@ public class TestSaslRPC {
UserGroupInformation current = UserGroupInformation.getCurrentUser();
System.out.println("UGI: " + current);
- Server server = RPC.getServer(TestSaslProtocol.class, new TestSaslImpl(),
- ADDRESS, 0, 5, true, newConf, null);
+ Server server = new RPC.Builder(newConf)
+ .setProtocol(TestSaslProtocol.class).setInstance(new TestSaslImpl())
+ .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true)
+ .build();
TestSaslProtocol proxy = null;
server.start();
@@ -441,8 +451,9 @@ public class TestSaslRPC {
@Test
public void testDigestAuthMethod() throws Exception {
TestTokenSecretManager sm = new TestTokenSecretManager();
- Server server = RPC.getServer(TestSaslProtocol.class,
- new TestSaslImpl(), ADDRESS, 0, 5, true, conf, sm);
+ Server server = new RPC.Builder(conf).setProtocol(TestSaslProtocol.class)
+ .setInstance(new TestSaslImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(5).setVerbose(true).setSecretManager(sm).build();
server.start();
final UserGroupInformation current = UserGroupInformation.getCurrentUser();
Modified: hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestDoAsEffectiveUser.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestDoAsEffectiveUser.java?rev=1390763&r1=1390762&r2=1390763&view=diff
==============================================================================
--- hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestDoAsEffectiveUser.java (original)
+++ hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestDoAsEffectiveUser.java Wed Sep 26 22:55:00 2012
@@ -155,8 +155,9 @@ public class TestDoAsEffectiveUser {
conf.setStrings(ProxyUsers
.getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME), "group1");
configureSuperUserIPAddresses(conf, REAL_USER_SHORT_NAME);
- Server server = RPC.getServer(TestProtocol.class, new TestImpl(), ADDRESS,
- 0, 5, true, conf, null);
+ Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(5).setVerbose(true).build();
refreshConf(conf);
try {
@@ -197,8 +198,9 @@ public class TestDoAsEffectiveUser {
configureSuperUserIPAddresses(conf, REAL_USER_SHORT_NAME);
conf.setStrings(ProxyUsers.getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME),
"group1");
- Server server = RPC.getServer(TestProtocol.class, new TestImpl(), ADDRESS,
- 0, 2, false, conf, null);
+ Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(2).setVerbose(false).build();
refreshConf(conf);
try {
@@ -244,8 +246,9 @@ public class TestDoAsEffectiveUser {
"20.20.20.20"); //Authorized IP address
conf.setStrings(ProxyUsers.getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME),
"group1");
- Server server = RPC.getServer(TestProtocol.class, new TestImpl(), ADDRESS,
- 0, 2, false, conf, null);
+ Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(2).setVerbose(false).build();
refreshConf(conf);
@@ -286,8 +289,9 @@ public class TestDoAsEffectiveUser {
final Configuration conf = new Configuration();
conf.setStrings(ProxyUsers
.getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME), "group1");
- Server server = RPC.getServer(TestProtocol.class, new TestImpl(), ADDRESS,
- 0, 2, false, conf, null);
+ Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(2).setVerbose(false).build();
try {
server.start();
@@ -325,8 +329,9 @@ public class TestDoAsEffectiveUser {
public void testRealUserGroupNotSpecified() throws IOException {
final Configuration conf = new Configuration();
configureSuperUserIPAddresses(conf, REAL_USER_SHORT_NAME);
- Server server = RPC.getServer(TestProtocol.class, new TestImpl(), ADDRESS,
- 0, 2, false, conf, null);
+ Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(2).setVerbose(false).build();
try {
server.start();
@@ -366,9 +371,9 @@ public class TestDoAsEffectiveUser {
configureSuperUserIPAddresses(conf, REAL_USER_SHORT_NAME);
conf.setStrings(ProxyUsers.getProxySuperuserGroupConfKey(REAL_USER_SHORT_NAME),
"group3");
- Server server = RPC.getServer(TestProtocol.class, new TestImpl(), ADDRESS,
- 0, 2, false, conf, null);
-
+ Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
+ .setInstance(new TestImpl()).setBindAddress(ADDRESS).setPort(0)
+ .setNumHandlers(2).setVerbose(false).build();
try {
server.start();
@@ -414,8 +419,9 @@ public class TestDoAsEffectiveUser {
conf
.set(CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
UserGroupInformation.setConfiguration(conf);
- final Server server = RPC.getServer(TestProtocol.class, new TestImpl(),
- ADDRESS, 0, 5, true, conf, sm);
+ 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();
@@ -468,8 +474,10 @@ public class TestDoAsEffectiveUser {
newConf.set(CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION,
"kerberos");
UserGroupInformation.setConfiguration(newConf);
- final Server server = RPC.getServer(TestProtocol.class, new TestImpl(),
- ADDRESS, 0, 5, true, newConf, sm);
+ 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();
Modified: hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUserGroupInformation.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUserGroupInformation.java?rev=1390763&r1=1390762&r2=1390763&view=diff
==============================================================================
--- hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUserGroupInformation.java (original)
+++ hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestUserGroupInformation.java Wed Sep 26 22:55:00 2012
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.lang.reflect.Method;
import java.security.PrivilegedExceptionAction;
import java.util.Collection;
import java.util.LinkedHashSet;
@@ -49,6 +50,7 @@ public class TestUserGroupInformation {
final private static String GROUP3_NAME = "group3";
final private static String[] GROUP_NAMES =
new String[]{GROUP1_NAME, GROUP2_NAME, GROUP3_NAME};
+ private static Configuration conf;
/**
* UGI should not use the default security conf, else it will collide
@@ -68,7 +70,7 @@ public class TestUserGroupInformation {
/** configure ugi */
@BeforeClass
public static void setup() {
- Configuration conf = new Configuration();
+ conf = new Configuration();
conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTH_TO_LOCAL,
"RULE:[2:$1@$0](.*@HADOOP.APACHE.ORG)s/@.*//" +
"RULE:[1:$1@$0](.*@HADOOP.APACHE.ORG)s/@.*//"
@@ -537,4 +539,39 @@ public class TestUserGroupInformation {
}
});
}
+
+ /** Test hasSufficientTimeElapsed method */
+ @Test
+ public void testHasSufficientTimeElapsed() throws Exception {
+ // Make hasSufficientTimeElapsed public
+ Method method = UserGroupInformation.class
+ .getDeclaredMethod("hasSufficientTimeElapsed", long.class);
+ method.setAccessible(true);
+
+ UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
+ User user = ugi.getSubject().getPrincipals(User.class).iterator().next();
+ long now = System.currentTimeMillis();
+
+ // Using default relogin time (1 minute)
+ user.setLastLogin(now - 2 * 60 * 1000); // 2 minutes before "now"
+ assertTrue((Boolean)method.invoke(ugi, now));
+ user.setLastLogin(now - 30 * 1000); // 30 seconds before "now"
+ assertFalse((Boolean)method.invoke(ugi, now));
+
+ // Using relogin time of 10 minutes
+ Configuration conf2 = new Configuration(conf);
+ conf2.setLong(
+ CommonConfigurationKeysPublic.HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN,
+ 10 * 60);
+ UserGroupInformation.setConfiguration(conf2);
+ user.setLastLogin(now - 15 * 60 * 1000); // 15 minutes before "now"
+ assertTrue((Boolean)method.invoke(ugi, now));
+ user.setLastLogin(now - 6 * 60 * 1000); // 6 minutes before "now"
+ assertFalse((Boolean)method.invoke(ugi, now));
+ // Restore original conf to UGI
+ UserGroupInformation.setConfiguration(conf);
+
+ // Restore hasSufficientTimElapsed back to private
+ method.setAccessible(false);
+ }
}
Modified: hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestStringUtils.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestStringUtils.java?rev=1390763&r1=1390762&r2=1390763&view=diff
==============================================================================
--- hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestStringUtils.java (original)
+++ hadoop/common/branches/branch-trunk-win/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestStringUtils.java Wed Sep 26 22:55:00 2012
@@ -231,7 +231,8 @@ public class TestStringUtils extends Uni
assertArrayEquals(expectedArray, StringUtils.getTrimmedStrings(pathologicalDirList2));
assertArrayEquals(emptyArray, StringUtils.getTrimmedStrings(emptyList1));
- assertArrayEquals(emptyArray, StringUtils.getTrimmedStrings(emptyList2));
+ String[] estring = StringUtils.getTrimmedStrings(emptyList2);
+ assertArrayEquals(emptyArray, estring);
}
@Test