public int triggerBlockReport(String[] argv) throws IOException {
    List<String> args = new LinkedList<String>();
    for (int j = 1; j < argv.length; j++) {
      args.add(argv[j]);
    }
    // Block report to a specific namenode
    InetSocketAddress namenodeAddr = null;
    String nnHostPort = StringUtils.popOptionWithArgument("-namenode", args);
    if (nnHostPort != null) {
      namenodeAddr = NetUtils.createSocketAddr(nnHostPort);
    }

    boolean incremental = StringUtils.popOption("-incremental", args);
    String hostPort = StringUtils.popFirstNonOption(args);
    if (hostPort == null) {
      System.err.println("You must specify a host:port pair.");
      return 1;
    }
    if (!args.isEmpty()) {
      System.err.print("Can't understand arguments: " +
        Joiner.on(" ").join(args) + "\n");
      return 1;
    }
    ClientDatanodeProtocol dnProxy = getDataNodeProxy(hostPort);
    try {
      dnProxy.triggerBlockReport(
          new BlockReportOptions.Factory().
              setNamenodeAddr(namenodeAddr).
              setIncremental(incremental).
              build());
    } catch (IOException e) {
      System.err.println("triggerBlockReport error: " + e);
      return 1;
    }
    System.out.println("Triggering " +
        (incremental ? "an incremental " : "a full ") +
        "block report on " + hostPort +
        (namenodeAddr == null ? "" : " to namenode " + nnHostPort) +
        ".");
    return 0;
  }
@Test(timeout = 30000)
  public void testTriggerBlockReport() throws Exception {
    redirectStream();
    final DFSAdmin dfsAdmin = new DFSAdmin(conf);
    final DataNode dn = cluster.getDataNodes().get(0);
    final NameNode nn = cluster.getNameNode();

    final String dnAddr = String.format(
        "%s:%d",
        dn.getXferAddress().getHostString(),
        dn.getIpcPort());
    final String nnAddr = nn.getHostAndPort();
    resetStream();
    final List<String> outs = Lists.newArrayList();
    final int ret = ToolRunner.run(dfsAdmin,
        new String[]{"-triggerBlockReport", dnAddr, "-incremental", "-namenode", nnAddr});
    assertEquals(0, ret);

    scanIntoList(out, outs);
    assertEquals(1, outs.size());
    assertThat(outs.get(0),
        is(allOf(containsString("Triggering an incremental block report on "),
            containsString(" to namenode "))));
  }