List of usage examples for javax.net SocketFactory getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.apache.hadoop.hdfs.server.datanode.TestDataNodeTcpNoDelay.java
@Test public void testTcpNoDelayEnabled() throws Exception { Configuration testConf = new Configuration(baseConf); // here we do not have to config TCP_NDELAY settings, since they should be // active by default testConf.set(HADOOP_RPC_SOCKET_FACTORY_CLASS_DEFAULT_KEY, SocketFactoryWrapper.class.getName()); SocketFactory defaultFactory = NetUtils.getDefaultSocketFactory(testConf); LOG.info("Socket factory is " + defaultFactory.getClass().getName()); MiniDFSCluster dfsCluster = new MiniDFSCluster.Builder(testConf).numDataNodes(3).build(); dfsCluster.waitActive();// w w w . j ava 2 s . c o m DistributedFileSystem dfs = dfsCluster.getFileSystem(); try { createData(dfs); transferBlock(dfs); // check that TCP_NODELAY has been set on all sockets assertTrue(SocketFactoryWrapper.wasTcpNoDelayActive()); } finally { SocketFactoryWrapper.reset(); dfsCluster.shutdown(); } }
From source file:org.apache.hadoop.hdfs.server.datanode.TestDataNodeTcpNoDelay.java
@Test public void testTcpNoDelayDisabled() throws Exception { Configuration testConf = new Configuration(baseConf); // disable TCP_NODELAY in settings setTcpNoDelay(testConf, false);// www . j a v a2 s .c o m testConf.set(HADOOP_RPC_SOCKET_FACTORY_CLASS_DEFAULT_KEY, SocketFactoryWrapper.class.getName()); SocketFactory defaultFactory = NetUtils.getDefaultSocketFactory(testConf); LOG.info("Socket factory is " + defaultFactory.getClass().getName()); MiniDFSCluster dfsCluster = new MiniDFSCluster.Builder(testConf).numDataNodes(3).build(); dfsCluster.waitActive(); DistributedFileSystem dfs = dfsCluster.getFileSystem(); try { createData(dfs); transferBlock(dfs); // we can only check that TCP_NODELAY was disabled on some sockets, // since part of the client write path always enables TCP_NODELAY // by necessity assertFalse(SocketFactoryWrapper.wasTcpNoDelayActive()); } finally { SocketFactoryWrapper.reset(); dfsCluster.shutdown(); } }