当前位置: 首页>>代码示例>>Java>>正文


Java RequestSource.REQUEST_BY_USER_FORCED属性代码示例

本文整理汇总了Java中org.apache.hadoop.ha.HAServiceProtocol.RequestSource.REQUEST_BY_USER_FORCED属性的典型用法代码示例。如果您正苦于以下问题:Java RequestSource.REQUEST_BY_USER_FORCED属性的具体用法?Java RequestSource.REQUEST_BY_USER_FORCED怎么用?Java RequestSource.REQUEST_BY_USER_FORCED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.hadoop.ha.HAServiceProtocol.RequestSource的用法示例。


在下文中一共展示了RequestSource.REQUEST_BY_USER_FORCED属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkManualStateManagementOK

/**
 * Ensure that we are allowed to manually manage the HA state of the target
 * service. If automatic failover is configured, then the automatic
 * failover controllers should be doing state management, and it is generally
 * an error to use the HAAdmin command line to do so.
 * 
 * @param target the target to check
 * @return true if manual state management is allowed
 */
private boolean checkManualStateManagementOK(HAServiceTarget target) {
  if (target.isAutoFailoverEnabled()) {
    if (requestSource != RequestSource.REQUEST_BY_USER_FORCED) {
      errOut.println(
          "Automatic failover is enabled for " + target + "\n" +
          "Refusing to manually manage HA state, since it may cause\n" +
          "a split-brain scenario or other incorrect state.\n" +
          "If you are very sure you know what you are doing, please \n" +
          "specify the --" + FORCEMANUAL + " flag.");
      return false;
    } else {
      LOG.warn("Proceeding with manual HA state management even though\n" +
          "automatic failover is enabled for " + target);
      return true;
    }
  }
  return true;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:27,代码来源:HAAdmin.java

示例2: convert

private StateChangeRequestInfo convert(HAStateChangeRequestInfoProto proto) {
  RequestSource src;
  switch (proto.getReqSource()) {
  case REQUEST_BY_USER:
    src = RequestSource.REQUEST_BY_USER;
    break;
  case REQUEST_BY_USER_FORCED:
    src = RequestSource.REQUEST_BY_USER_FORCED;
    break;
  case REQUEST_BY_ZKFC:
    src = RequestSource.REQUEST_BY_ZKFC;
    break;
  default:
    LOG.warn("Unknown request source: " + proto.getReqSource());
    src = null;
  }
  
  return new StateChangeRequestInfo(src);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:19,代码来源:HAServiceProtocolServerSideTranslatorPB.java

示例3: checkManualStateManagementOK

/**
 * Ensure that we are allowed to manually manage the HA state of the target
 * service. If automatic failover is configured, then the automatic
 * failover controllers should be doing state management, and it is generally
 * an error to use the HAAdmin command line to do so.
 * 
 * @param target the target to check
 * @return true if manual state management is allowed
 */
private boolean checkManualStateManagementOK(HAServiceTarget target) {
  if (target.isAutoFailoverEnabled()) {
    if (requestSource != RequestSource.REQUEST_BY_USER_FORCED) {
      errOut.println(
          "Automatic failover is enabled for " + target + "\n" +
          "Refusing to manually manage HA state, since it may cause\n" +
          "a split-brain scenario or other incorrect state.\n" +
          "If you are very sure you know what you are doing, please \n" +
          "specify the " + FORCEMANUAL + " flag.");
      return false;
    } else {
      LOG.warn("Proceeding with manual HA state management even though\n" +
          "automatic failover is enabled for " + target);
      return true;
    }
  }
  return true;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:27,代码来源:HAAdmin.java

示例4: runCmd

protected int runCmd(String[] argv) throws Exception {
  if (argv.length < 1) {
    printUsage(errOut);
    return -1;
  }

  String cmd = argv[0];

  if (!cmd.startsWith("-")) {
    errOut.println("Bad command '" + cmd + "': expected command starting with '-'");
    printUsage(errOut);
    return -1;
  }
  
  if (!USAGE.containsKey(cmd)) {
    errOut.println(cmd.substring(1) + ": Unknown command");
    printUsage(errOut);
    return -1;
  }
  
  Options opts = new Options();

  // Add command-specific options
  if ("-failover".equals(cmd)) {
    addFailoverCliOpts(opts);
  }
  if("-transitionToActive".equals(cmd)) {
    addTransitionToActiveCliOpts(opts);
  }
  // Mutative commands take FORCEMANUAL option
  if ("-transitionToActive".equals(cmd) ||
      "-transitionToStandby".equals(cmd) ||
      "-failover".equals(cmd)) {
    opts.addOption(FORCEMANUAL, false,
        "force manual control even if auto-failover is enabled");
  }
       
  CommandLine cmdLine = parseOpts(cmd, opts, argv);
  if (cmdLine == null) {
    // error already printed
    return -1;
  }
  
  if (cmdLine.hasOption(FORCEMANUAL)) {
    if (!confirmForceManual()) {
      LOG.fatal("Aborted");
      return -1;
    }
    // Instruct the NNs to honor this request even if they're
    // configured for manual failover.
    requestSource = RequestSource.REQUEST_BY_USER_FORCED;
  }

  if ("-transitionToActive".equals(cmd)) {
    return transitionToActive(cmdLine);
  } else if ("-transitionToStandby".equals(cmd)) {
    return transitionToStandby(cmdLine);
  } else if ("-failover".equals(cmd)) {
    return failover(cmdLine);
  } else if ("-getServiceState".equals(cmd)) {
    return getServiceState(cmdLine);
  } else if ("-checkHealth".equals(cmd)) {
    return checkHealth(cmdLine);
  } else if ("-help".equals(cmd)) {
    return help(argv);
  } else {
    // we already checked command validity above, so getting here
    // would be a coding error
    throw new AssertionError("Should not get here, command: " + cmd);
  } 
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:71,代码来源:HAAdmin.java

示例5: runCmd

protected int runCmd(String[] argv) throws Exception {
  if (argv.length < 1) {
    printUsage(errOut);
    return -1;
  }

  String cmd = argv[0];

  if (!cmd.startsWith("-")) {
    errOut.println("Bad command '" + cmd + "': expected command starting with '-'");
    printUsage(errOut);
    return -1;
  }
  
  if (!USAGE.containsKey(cmd)) {
    errOut.println(cmd.substring(1) + ": Unknown command");
    printUsage(errOut);
    return -1;
  }
  
  Options opts = new Options();

  // Add command-specific options
  if ("-failover".equals(cmd)) {
    addFailoverCliOpts(opts);
  }
  // Mutative commands take FORCEMANUAL option
  if ("-transitionToActive".equals(cmd) ||
      "-transitionToStandby".equals(cmd) ||
      "-failover".equals(cmd)) {
    opts.addOption(FORCEMANUAL, false,
        "force manual control even if auto-failover is enabled");
  }
       
  CommandLine cmdLine = parseOpts(cmd, opts, argv);
  if (cmdLine == null) {
    // error already printed
    return -1;
  }
  
  if (cmdLine.hasOption(FORCEMANUAL)) {
    if (!confirmForceManual()) {
      LOG.fatal("Aborted");
      return -1;
    }
    // Instruct the NNs to honor this request even if they're
    // configured for manual failover.
    requestSource = RequestSource.REQUEST_BY_USER_FORCED;
  }

  if ("-transitionToActive".equals(cmd)) {
    return transitionToActive(cmdLine);
  } else if ("-transitionToStandby".equals(cmd)) {
    return transitionToStandby(cmdLine);
  } else if ("-failover".equals(cmd)) {
    return failover(cmdLine);
  } else if ("-getServiceState".equals(cmd)) {
    return getServiceState(cmdLine);
  } else if ("-checkHealth".equals(cmd)) {
    return checkHealth(cmdLine);
  } else if ("-help".equals(cmd)) {
    return help(argv);
  } else {
    // we already checked command validity above, so getting here
    // would be a coding error
    throw new AssertionError("Should not get here, command: " + cmd);
  } 
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:68,代码来源:HAAdmin.java


注:本文中的org.apache.hadoop.ha.HAServiceProtocol.RequestSource.REQUEST_BY_USER_FORCED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。