private int transitionToObserver(final CommandLine cmd)
      throws IOException {
    String[] argv = cmd.getArgs();
    if (argv.length != 1) {
      errOut.println("transitionToObserver: incorrect number of arguments");
      printUsage(errOut, "-transitionToObserver", USAGE_DFS_MERGED);
      return -1;
    }

    HAServiceTarget target = resolveTarget(argv[0]);
    if (!checkSupportObserver(target)) {
      return -1;
    }
    if (!checkManualStateManagementOK(target)) {
      return -1;
    }
    try {
      HAServiceProtocol proto = target.getProxy(getConf(), 0);
      HAServiceProtocolHelper.transitionToObserver(proto, createReqInfo());
    } catch (ServiceFailedException e) {
      errOut.println("transitionToObserver failed! " + e.getLocalizedMessage());
      return -1;
    }
    return 0;
  }
@Test
  public void testTransitionToObserver() throws Exception {
    assertEquals(0, runTool("-transitionToObserver", "nn1"));
    Mockito.verify(mockProtocol).transitionToObserver(anyReqInfo());
  }