Java Code Examples for org.apache.hadoop.hdfs.server.namenode.NameNode#getRpcServer()
The following examples show how to use
org.apache.hadoop.hdfs.server.namenode.NameNode#getRpcServer() .
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: NamenodeWebHdfsMethods.java From hadoop with Apache License 2.0 | 5 votes |
private static NamenodeProtocols getRPCServer(NameNode namenode) throws IOException { final NamenodeProtocols np = namenode.getRpcServer(); if (np == null) { throw new RetriableException("Namenode is in startup mode"); } return np; }
Example 2
Source File: TestWebHDFS.java From hadoop with Apache License 2.0 | 5 votes |
/** * Make sure a RetriableException is thrown when rpcServer is null in * NamenodeWebHdfsMethods. */ @Test public void testRaceWhileNNStartup() throws Exception { MiniDFSCluster cluster = null; final Configuration conf = WebHdfsTestUtil.createConf(); try { cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build(); cluster.waitActive(); final NameNode namenode = cluster.getNameNode(); final NamenodeProtocols rpcServer = namenode.getRpcServer(); Whitebox.setInternalState(namenode, "rpcServer", null); final Path foo = new Path("/foo"); final FileSystem webHdfs = WebHdfsTestUtil.getWebHdfsFileSystem(conf, WebHdfsFileSystem.SCHEME); try { webHdfs.mkdirs(foo); fail("Expected RetriableException"); } catch (RetriableException e) { GenericTestUtils.assertExceptionContains("Namenode is in startup mode", e); } Whitebox.setInternalState(namenode, "rpcServer", rpcServer); } finally { if (cluster != null) { cluster.shutdown(); } } }
Example 3
Source File: NamenodeWebHdfsMethods.java From big-c with Apache License 2.0 | 5 votes |
private static NamenodeProtocols getRPCServer(NameNode namenode) throws IOException { final NamenodeProtocols np = namenode.getRpcServer(); if (np == null) { throw new RetriableException("Namenode is in startup mode"); } return np; }
Example 4
Source File: TestWebHDFS.java From big-c with Apache License 2.0 | 5 votes |
/** * Make sure a RetriableException is thrown when rpcServer is null in * NamenodeWebHdfsMethods. */ @Test public void testRaceWhileNNStartup() throws Exception { MiniDFSCluster cluster = null; final Configuration conf = WebHdfsTestUtil.createConf(); try { cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build(); cluster.waitActive(); final NameNode namenode = cluster.getNameNode(); final NamenodeProtocols rpcServer = namenode.getRpcServer(); Whitebox.setInternalState(namenode, "rpcServer", null); final Path foo = new Path("/foo"); final FileSystem webHdfs = WebHdfsTestUtil.getWebHdfsFileSystem(conf, WebHdfsFileSystem.SCHEME); try { webHdfs.mkdirs(foo); fail("Expected RetriableException"); } catch (RetriableException e) { GenericTestUtils.assertExceptionContains("Namenode is in startup mode", e); } Whitebox.setInternalState(namenode, "rpcServer", rpcServer); } finally { if (cluster != null) { cluster.shutdown(); } } }
Example 5
Source File: TestWebHDFSForHA.java From hadoop with Apache License 2.0 | 4 votes |
/** * Make sure the WebHdfsFileSystem will retry based on RetriableException when * rpcServer is null in NamenodeWebHdfsMethods while NameNode starts up. */ @Test (timeout=120000) public void testRetryWhileNNStartup() throws Exception { final Configuration conf = DFSTestUtil.newHAConfiguration(LOGICAL_NAME); MiniDFSCluster cluster = null; final Map<String, Boolean> resultMap = new HashMap<String, Boolean>(); try { cluster = new MiniDFSCluster.Builder(conf).nnTopology(topo) .numDataNodes(0).build(); HATestUtil.setFailoverConfigurations(cluster, conf, LOGICAL_NAME); cluster.waitActive(); cluster.transitionToActive(0); final NameNode namenode = cluster.getNameNode(0); final NamenodeProtocols rpcServer = namenode.getRpcServer(); Whitebox.setInternalState(namenode, "rpcServer", null); new Thread() { @Override public void run() { boolean result = false; FileSystem fs = null; try { fs = FileSystem.get(WEBHDFS_URI, conf); final Path dir = new Path("/test"); result = fs.mkdirs(dir); } catch (IOException e) { result = false; } finally { IOUtils.cleanup(null, fs); } synchronized (TestWebHDFSForHA.this) { resultMap.put("mkdirs", result); TestWebHDFSForHA.this.notifyAll(); } } }.start(); Thread.sleep(1000); Whitebox.setInternalState(namenode, "rpcServer", rpcServer); synchronized (this) { while (!resultMap.containsKey("mkdirs")) { this.wait(); } Assert.assertTrue(resultMap.get("mkdirs")); } } finally { if (cluster != null) { cluster.shutdown(); } } }
Example 6
Source File: TestWebHDFSForHA.java From big-c with Apache License 2.0 | 4 votes |
/** * Make sure the WebHdfsFileSystem will retry based on RetriableException when * rpcServer is null in NamenodeWebHdfsMethods while NameNode starts up. */ @Test (timeout=120000) public void testRetryWhileNNStartup() throws Exception { final Configuration conf = DFSTestUtil.newHAConfiguration(LOGICAL_NAME); MiniDFSCluster cluster = null; final Map<String, Boolean> resultMap = new HashMap<String, Boolean>(); try { cluster = new MiniDFSCluster.Builder(conf).nnTopology(topo) .numDataNodes(0).build(); HATestUtil.setFailoverConfigurations(cluster, conf, LOGICAL_NAME); cluster.waitActive(); cluster.transitionToActive(0); final NameNode namenode = cluster.getNameNode(0); final NamenodeProtocols rpcServer = namenode.getRpcServer(); Whitebox.setInternalState(namenode, "rpcServer", null); new Thread() { @Override public void run() { boolean result = false; FileSystem fs = null; try { fs = FileSystem.get(WEBHDFS_URI, conf); final Path dir = new Path("/test"); result = fs.mkdirs(dir); } catch (IOException e) { result = false; } finally { IOUtils.cleanup(null, fs); } synchronized (TestWebHDFSForHA.this) { resultMap.put("mkdirs", result); TestWebHDFSForHA.this.notifyAll(); } } }.start(); Thread.sleep(1000); Whitebox.setInternalState(namenode, "rpcServer", rpcServer); synchronized (this) { while (!resultMap.containsKey("mkdirs")) { this.wait(); } Assert.assertTrue(resultMap.get("mkdirs")); } } finally { if (cluster != null) { cluster.shutdown(); } } }