public static NodeFencer create(Configuration conf, String confKey) throws BadFencingConfigurationException { String confStr = conf.get(confKey); if (confStr == null) { return null; } return new NodeFencer(conf, confStr); }
private void doFence(HAServiceTarget target) { LOG.info("Should fence: " + target); boolean gracefulWorked = new FailoverController(conf, RequestSource.REQUEST_BY_ZKFC).tryGracefulFence(target); if (gracefulWorked) { // It's possible that it's in standby but just about to go into active, // no? Is there some race here? LOG.info("Successfully transitioned " + target + " to standby " + "state without fencing"); return; } try { target.checkFencingConfigured(); } catch (BadFencingConfigurationException e) { LOG.error("Couldn't fence old active " + target, e); recordActiveAttempt(new ActiveAttemptRecord(false, "Unable to fence old active")); throw new RuntimeException(e); } if (!target.getFencer().fence(target)) { throw new RuntimeException("Unable to fence " + target); } }
private static FenceMethodWithArg parseMethod(Configuration conf, String line) throws BadFencingConfigurationException { Matcher m; if ((m = CLASS_WITH_ARGUMENT.matcher(line)).matches()) { String className = m.group(1); String arg = m.group(2); return createFenceMethod(conf, className, arg); } else if ((m = CLASS_WITHOUT_ARGUMENT.matcher(line)).matches()) { String className = m.group(1); return createFenceMethod(conf, className, null); } else { throw new BadFencingConfigurationException( "Unable to parse line: '" + line + "'"); } }
NodeFencer(Configuration conf, String spec) throws BadFencingConfigurationException { this.methods = parseMethods(conf, spec); }
private static List<FenceMethodWithArg> parseMethods(Configuration conf, String spec) throws BadFencingConfigurationException { String[] lines = spec.split("\\s*\n\\s*"); List<FenceMethodWithArg> methods = Lists.newArrayList(); for (String line : lines) { line = HASH_COMMENT_RE.matcher(line).replaceAll(""); line = line.trim(); if (!line.isEmpty()) { methods.add(parseMethod(conf, line)); } } return methods; }
this.fencer = NodeFencer.create(targetConf, DFSConfigKeys.DFS_HA_FENCE_METHODS_KEY); } catch (BadFencingConfigurationException e) {
NodeFencer(Configuration conf, String spec) throws BadFencingConfigurationException { this.methods = parseMethods(conf, spec); }
private static List<FenceMethodWithArg> parseMethods(Configuration conf, String spec) throws BadFencingConfigurationException { String[] lines = spec.split("\\s*\n\\s*"); List<FenceMethodWithArg> methods = Lists.newArrayList(); for (String line : lines) { line = HASH_COMMENT_RE.matcher(line).replaceAll(""); line = line.trim(); if (!line.isEmpty()) { methods.add(parseMethod(conf, line)); } } return methods; }
DummyHAService(HAServiceState state, InetSocketAddress address, boolean testWithProtoBufRPC) { this.state = state; this.testWithProtoBufRPC = testWithProtoBufRPC; if (testWithProtoBufRPC) { this.address = startAndGetRPCServerAddress(address); } else { this.address = address; } Configuration conf = new Configuration(); this.proxy = makeMock(conf, HA_HM_RPC_TIMEOUT_DEFAULT); try { conf.set(DUMMY_FENCE_KEY, DummyFencer.class.getName()); this.fencer = Mockito.spy( NodeFencer.create(conf, DUMMY_FENCE_KEY)); } catch (BadFencingConfigurationException e) { throw new RuntimeException(e); } synchronized (instances) { instances.add(this); this.index = instances.size(); } }
if (!fromSvc.getFencer().fence(fromSvc)) { throw new FailoverFailedException("Unable to fence " + fromSvc + ". Fencing failed.");
public static NodeFencer create(Configuration conf, String confKey) throws BadFencingConfigurationException { String confStr = conf.get(confKey); if (confStr == null) { return null; } return new NodeFencer(conf, confStr); }
NodeFencer(Configuration conf, String spec) throws BadFencingConfigurationException { this.methods = parseMethods(conf, spec); }
private static List<FenceMethodWithArg> parseMethods(Configuration conf, String spec) throws BadFencingConfigurationException { String[] lines = spec.split("\\s*\n\\s*"); List<FenceMethodWithArg> methods = Lists.newArrayList(); for (String line : lines) { line = HASH_COMMENT_RE.matcher(line).replaceAll(""); line = line.trim(); if (!line.isEmpty()) { methods.add(parseMethod(conf, line)); } } return methods; }
private static FenceMethodWithArg parseMethod(Configuration conf, String line) throws BadFencingConfigurationException { Matcher m; if ((m = CLASS_WITH_ARGUMENT.matcher(line)).matches()) { String className = m.group(1); String arg = m.group(2); return createFenceMethod(conf, className, arg); } else if ((m = CLASS_WITHOUT_ARGUMENT.matcher(line)).matches()) { String className = m.group(1); return createFenceMethod(conf, className, null); } else { throw new BadFencingConfigurationException( "Unable to parse line: '" + line + "'"); } }
DummyHAService(HAServiceState state, InetSocketAddress address, boolean testWithProtoBufRPC) { this.state = state; this.testWithProtoBufRPC = testWithProtoBufRPC; if (testWithProtoBufRPC) { this.address = startAndGetRPCServerAddress(address); } else { this.address = address; } Configuration conf = new Configuration(); this.proxy = makeMock(conf, HA_HM_RPC_TIMEOUT_DEFAULT); try { conf.set(DUMMY_FENCE_KEY, DummyFencer.class.getName()); this.fencer = Mockito.spy( NodeFencer.create(conf, DUMMY_FENCE_KEY)); } catch (BadFencingConfigurationException e) { throw new RuntimeException(e); } synchronized (instances) { instances.add(this); this.index = instances.size(); } }
private void doFence(HAServiceTarget target) { LOG.info("Should fence: " + target); boolean gracefulWorked = new FailoverController(conf, RequestSource.REQUEST_BY_ZKFC).tryGracefulFence(target); if (gracefulWorked) { // It's possible that it's in standby but just about to go into active, // no? Is there some race here? LOG.info("Successfully transitioned " + target + " to standby " + "state without fencing"); return; } try { target.checkFencingConfigured(); } catch (BadFencingConfigurationException e) { LOG.error("Couldn't fence old active " + target, e); recordActiveAttempt(new ActiveAttemptRecord(false, "Unable to fence old active")); throw new RuntimeException(e); } if (!target.getFencer().fence(target)) { throw new RuntimeException("Unable to fence " + target); } }
public static NodeFencer create(Configuration conf, String confKey) throws BadFencingConfigurationException { String confStr = conf.get(confKey); if (confStr == null) { return null; } return new NodeFencer(conf, confStr); }
NodeFencer(Configuration conf, String spec) throws BadFencingConfigurationException { this.methods = parseMethods(conf, spec); }
private static List<FenceMethodWithArg> parseMethods(Configuration conf, String spec) throws BadFencingConfigurationException { String[] lines = spec.split("\\s*\n\\s*"); List<FenceMethodWithArg> methods = Lists.newArrayList(); for (String line : lines) { line = HASH_COMMENT_RE.matcher(line).replaceAll(""); line = line.trim(); if (!line.isEmpty()) { methods.add(parseMethod(conf, line)); } } return methods; }
private static FenceMethodWithArg parseMethod(Configuration conf, String line) throws BadFencingConfigurationException { Matcher m; if ((m = CLASS_WITH_ARGUMENT.matcher(line)).matches()) { String className = m.group(1); String arg = m.group(2); return createFenceMethod(conf, className, arg); } else if ((m = CLASS_WITHOUT_ARGUMENT.matcher(line)).matches()) { String className = m.group(1); return createFenceMethod(conf, className, null); } else { throw new BadFencingConfigurationException( "Unable to parse line: '" + line + "'"); } }