Example usage for javax.net SocketFactory getClass

List of usage examples for javax.net SocketFactory getClass

Introduction

In this page you can find the example usage for javax.net SocketFactory getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

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();
    }
}