Package org.apache.hadoop.hdfs.tools

Examples of org.apache.hadoop.hdfs.tools.DFSAdmin.run()


  @Test
  public void testInvalidCommand() throws Exception {
    DFSAdmin admin = new DFSAdmin(config);
    String [] args = new String[]{"-refresh", "nn"};
    int exitCode = admin.run(args);
    assertEquals("DFSAdmin should fail due to bad args", -1, exitCode);
  }

  @Test
  public void testInvalidIdentifier() throws Exception {
View Full Code Here


  @Test
  public void testInvalidIdentifier() throws Exception {
    DFSAdmin admin = new DFSAdmin(config);
    String [] args = new String[]{"-refresh", "localhost:" + NNPort, "unregisteredIdentity"};
    int exitCode = admin.run(args);
    assertEquals("DFSAdmin should fail due to no handler registered", -1, exitCode);
  }

  @Test
  public void testValidIdentifier() throws Exception {
View Full Code Here

  @Test
  public void testValidIdentifier() throws Exception {
    DFSAdmin admin = new DFSAdmin(config);
    String[] args = new String[]{"-refresh", "localhost:" + NNPort, "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())
View Full Code Here

  @Test
  public void testVariableArgs() throws Exception {
    DFSAdmin admin = new DFSAdmin(config);
    String[] args = new String[]{"-refresh", "localhost:" + NNPort, "secondHandler", "one"};
    int exitCode = admin.run(args);
    assertEquals("DFSAdmin should return 2", 2, exitCode);

    exitCode = admin.run(new String[]{"-refresh", "localhost:" + NNPort, "secondHandler", "one", "two"});
    assertEquals("DFSAdmin should now return 3", 3, exitCode);
View Full Code Here

    DFSAdmin admin = new DFSAdmin(config);
    String[] args = new String[]{"-refresh", "localhost:" + NNPort, "secondHandler", "one"};
    int exitCode = admin.run(args);
    assertEquals("DFSAdmin should return 2", 2, exitCode);

    exitCode = admin.run(new String[]{"-refresh", "localhost:" + NNPort, "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"});
  }
View Full Code Here

    RefreshRegistry.defaultRegistry().unregisterAll("firstHandler");

    // And now this should fail
    DFSAdmin admin = new DFSAdmin(config);
    String[] args = new String[]{"-refresh", "localhost:" + NNPort, "firstHandler"};
    int exitCode = admin.run(args);
    assertEquals("DFSAdmin should return -1", -1, exitCode);
  }

  @Test
  public void testUnregistrationReturnValue() {
View Full Code Here

    RefreshRegistry.defaultRegistry().register("sharedId", secondHandler);

    // this should trigger both
    DFSAdmin admin = new DFSAdmin(config);
    String[] args = new String[]{"-refresh", "localhost:" + NNPort, "sharedId", "one"};
    int exitCode = admin.run(args);
    assertEquals(-1, exitCode); // -1 because one of the responses is unregistered

    // verify we called both
    Mockito.verify(firstHandler).handleRefresh("sharedId", new String[]{"one"});
    Mockito.verify(secondHandler).handleRefresh("sharedId", new String[]{"one"});
View Full Code Here

    RefreshRegistry.defaultRegistry().register("shared", handlerTwo);

    // We refresh both
    DFSAdmin admin = new DFSAdmin(config);
    String[] args = new String[]{"-refresh", "localhost:" + NNPort, "shared"};
    int exitCode = admin.run(args);
    assertEquals(-1, exitCode); // We get -1 because of our logic for melding non-zero return codes

    // Verify we called both
    Mockito.verify(handlerOne).handleRefresh("shared", new String[]{});
    Mockito.verify(handlerTwo).handleRefresh("shared", new String[]{});
View Full Code Here

    RefreshRegistry.defaultRegistry().register("exceptional", exceptionalHandler);
    RefreshRegistry.defaultRegistry().register("exceptional", otherExceptionalHandler);

    DFSAdmin admin = new DFSAdmin(config);
    String[] args = new String[]{"-refresh", "localhost:" + NNPort, "exceptional"};
    int exitCode = admin.run(args);
    assertEquals(-1, exitCode); // Exceptions result in a -1

    Mockito.verify(exceptionalHandler).handleRefresh("exceptional", new String[]{});
    Mockito.verify(otherExceptionalHandler).handleRefresh("exceptional", new String[]{});
View Full Code Here

    g2.toArray(str_groups);
    System.out.println(Arrays.toString(str_groups));
    for(int i=0; i<g2.size(); i++) {
      assertEquals("Should be same group ", g1.get(i), g2.get(i));
    }
    admin.run(args);
    System.out.println("third attempt(after refresh command), should be different:");
    List<String> g3 = groups.getGroups(user);
    g3.toArray(str_groups);
    System.out.println(Arrays.toString(str_groups));
    for(int i=0; i<g3.size(); i++) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.