String fsURL = "hdfs://" + HConstants.LOCALHOST + ":" + dfsCluster.getNameNodePort(); confMap.put("fs.defaultFS", fsURL); confMap.put("hbase.rootdir", fsURL + "/hbase_test");
@Before public void setup() throws Exception { fs = dfsClusterRule.getDfscluster().getFileSystem(); hdfsURI = "hdfs://localhost:" + dfsClusterRule.getDfscluster().getNameNodePort() + "/"; }
@Before public void setup() throws Exception { fs = dfsClusterRule.getDfscluster().getFileSystem(); hdfsURI = "hdfs://localhost:" + dfsClusterRule.getDfscluster().getNameNodePort() + "/"; }
int namenodePort = cluster.getNameNodePort(); final Path walPath = AbstractFSWALProvider.getCurrentFileName(wal);
/** * @return Returns the port of the name node in the mini-cluster. */ public int getNameNodePort() { return cluster.getNameNodePort(); }
@Override public String getHDFSUri() { return "hdfs://localhost.localdomain:" + miniDFSCluster.getNameNodePort(); }
/** * Get the DFSClient. */ public DFSClient getDFSClient() throws IOException { InetSocketAddress nnAddr = new InetSocketAddress("localhost", cluster.getNameNodePort()); return new DFSClient(nnAddr, conf); }
/** * Get the DFSClient. */ public DFSClient getDFSClient() throws IOException { InetSocketAddress nnAddr = new InetSocketAddress("localhost", cluster.getNameNodePort()); return new DFSClient(nnAddr, conf); }
/** * Gets the rpc port used by the NameNode, because the caller * supplied port is not necessarily the actual port used. * Assumption: cluster has a single namenode */ public int getNameNodePort() { checkSingleNameNode(); return getNameNodePort(0); }
public static boolean allBlockReplicasCorrupt(MiniDFSCluster cluster, Path file, int blockNo) throws IOException { DFSClient client = new DFSClient(new InetSocketAddress("localhost", cluster.getNameNodePort()), cluster.getConfiguration()); LocatedBlocks blocks; try { blocks = client.getNamenode().getBlockLocations( file.toString(), 0, Long.MAX_VALUE); } finally { client.close(); } return blocks.get(blockNo).isCorrupt(); }
@Before public void setUp() throws Exception { this.baseDir = Files.createTempDirectory("test_hdfs").toFile().getAbsoluteFile(); this.hdfsCluster = HDFSClusterHelpers.createMiniDFSCluster(this.baseDir.getAbsolutePath()); this.adapterConfig = HDFSStorageConfig .builder() .with(HDFSStorageConfig.REPLICATION, 1) .with(HDFSStorageConfig.URL, String.format("hdfs://localhost:%d/", hdfsCluster.getNameNodePort())) .build(); }
@Before public void setUp() throws Exception { this.baseDir = Files.createTempDirectory("test_hdfs").toFile().getAbsoluteFile(); this.hdfsCluster = HDFSClusterHelpers.createMiniDFSCluster(this.baseDir.getAbsolutePath()); this.adapterConfig = HDFSStorageConfig .builder() .with(HDFSStorageConfig.REPLICATION, 1) .with(HDFSStorageConfig.URL, String.format("hdfs://localhost:%d/", hdfsCluster.getNameNodePort())) .build(); }
@Test public void testValidIdentifier() throws Exception { DFSAdmin admin = new DFSAdmin(config); String[] args = new String[]{"-refresh", "localhost:" + cluster.getNameNodePort(), "firstHandler"}; int exitCode = admin.run(args); assertEquals("DFSAdmin should succeed", 0, exitCode); Mockito.verify(firstHandler).handleRefresh("firstHandler", new String[]{}); // Second handler was never called Mockito.verify(secondHandler, Mockito.never()) .handleRefresh(Mockito.anyString(), Mockito.any(String[].class)); }
@Test public void testVariableArgs() throws Exception { DFSAdmin admin = new DFSAdmin(config); String[] args = new String[]{"-refresh", "localhost:" + cluster.getNameNodePort(), "secondHandler", "one"}; int exitCode = admin.run(args); assertEquals("DFSAdmin should return 2", 2, exitCode); exitCode = admin.run(new String[]{"-refresh", "localhost:" + cluster.getNameNodePort(), "secondHandler", "one", "two"}); assertEquals("DFSAdmin should now return 3", 3, exitCode); Mockito.verify(secondHandler).handleRefresh("secondHandler", new String[]{"one"}); Mockito.verify(secondHandler).handleRefresh("secondHandler", new String[]{"one", "two"}); }
public static boolean allBlockReplicasCorrupt(MiniDFSCluster cluster, Path file, int blockNo) throws IOException { DFSClient client = new DFSClient(new InetSocketAddress("localhost", cluster.getNameNodePort()), cluster.getConfiguration(0)); LocatedBlocks blocks; try { blocks = client.getNamenode().getBlockLocations( file.toString(), 0, Long.MAX_VALUE); } finally { client.close(); } return blocks.get(blockNo).isCorrupt(); }
@Test public void testInvalidIdentifier() throws Exception { DFSAdmin admin = new DFSAdmin(config); String [] args = new String[]{"-refresh", "localhost:" + cluster.getNameNodePort(), "unregisteredIdentity"}; int exitCode = admin.run(args); assertEquals("DFSAdmin should fail due to no handler registered", -1, exitCode); }
@Before public void startUpCluster() throws IOException { conf = new Configuration(); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(NUM_DATANODES).build(); fs = cluster.getFileSystem(); client = new DFSClient(new InetSocketAddress("localhost", cluster.getNameNodePort()), cluster.getConfiguration(0)); dn0 = cluster.getDataNodes().get(0); poolId = cluster.getNamesystem().getBlockPoolId(); dn0Reg = dn0.getDNRegistrationForBP(poolId); }
/** * Starts BookKeeper and HDFS MiniCluster. */ @Before public void setUp() throws Exception { super.setUp(); this.hdfsCluster = HDFSClusterHelpers.createMiniDFSCluster(getBaseDir().getAbsolutePath()); this.configBuilder.include(HDFSStorageConfig .builder() .with(HDFSStorageConfig.REPLICATION, 1) .with(HDFSStorageConfig.URL, String.format("hdfs://localhost:%d/", hdfsCluster.getNameNodePort()))); }
@Before public void setup() throws IOException { conf = new Configuration(); cluster = new MiniDFSCluster.Builder(conf) .nnTopology(MiniDFSNNTopology.simpleHATopology()).numDataNodes(0) .build(); tool = new DFSHAAdmin(); tool.setConf(conf); tool.setErrOut(new PrintStream(errOutBytes)); cluster.waitActive(); nn1Port = cluster.getNameNodePort(0); }
@Test public void testUnregistration() throws Exception { RefreshRegistry.defaultRegistry().unregisterAll("firstHandler"); // And now this should fail DFSAdmin admin = new DFSAdmin(config); String[] args = new String[]{"-refresh", "localhost:" + cluster.getNameNodePort(), "firstHandler"}; int exitCode = admin.run(args); assertEquals("DFSAdmin should return -1", -1, exitCode); }