public MockLeaderElector(boolean isLeader, String host, int port) { this.isLeader = isLeader; this.leaderAddress = new NimbusInfo(host, port, true); }
public static NimbusInfo parse(String nimbusInfo) { Matcher m = HOST_PORT_PATTERN.matcher(nimbusInfo); if (!m.matches()) { throw new RuntimeException("nimbusInfo should have format of host:port, invalid string " + nimbusInfo); } return new NimbusInfo(m.group(1), Integer.valueOf(m.group(2)), false); }
public static NimbusInfo fromConf(Map<String, Object> conf) { try { String host = InetAddress.getLocalHost().getCanonicalHostName(); if (conf.containsKey(Config.STORM_LOCAL_HOSTNAME)) { host = (String) conf.get(Config.STORM_LOCAL_HOSTNAME); LOG.info("Overriding nimbus host to storm.local.hostname -> {}", host); } else { LOG.info("Nimbus figures out its name to {}", host); } int port = ObjectReader.getInt(conf.get(Config.NIMBUS_THRIFT_PORT), 6627); return new NimbusInfo(host, port, false); } catch (UnknownHostException e) { throw new RuntimeException("Something wrong with network/dns config, host cant figure out its name", e); } }
private LocalFsBlobStore initLocalFs() { LocalFsBlobStore store = new LocalFsBlobStore(); // Spy object that tries to mock the real object store LocalFsBlobStore spy = spy(store); Mockito.doNothing().when(spy).checkForBlobUpdate("test"); Mockito.doNothing().when(spy).checkForBlobUpdate("other"); Mockito.doNothing().when(spy).checkForBlobUpdate("test-empty-subject-WE"); Mockito.doNothing().when(spy).checkForBlobUpdate("test-empty-subject-DEF"); Mockito.doNothing().when(spy).checkForBlobUpdate("test-empty-acls"); Map<String, Object> conf = Utils.readStormConfig(); conf.put(Config.STORM_ZOOKEEPER_PORT, zk.getPort()); conf.put(Config.STORM_LOCAL_DIR, baseFile.getAbsolutePath()); conf.put(Config.STORM_PRINCIPAL_TO_LOCAL_PLUGIN,"org.apache.storm.security.auth.DefaultPrincipalToLocal"); NimbusInfo nimbusInfo = new NimbusInfo("localhost", 0, false); spy.prepare(conf, null, nimbusInfo, null); return spy; }
public static NimbusInfo parse(String nimbusInfo) { String[] hostAndPort = nimbusInfo.split(DELIM); if(hostAndPort != null && hostAndPort.length == 2) { return new NimbusInfo(hostAndPort[0], Integer.parseInt(hostAndPort[1]), false); } else { throw new RuntimeException("nimbusInfo should have format of host:port, invalid string " + nimbusInfo); } }
public static NimbusInfo fromConf(Map conf) { try { String host = InetAddress.getLocalHost().getCanonicalHostName(); if (conf.containsKey(Config.STORM_LOCAL_HOSTNAME)) { host = conf.get(Config.STORM_LOCAL_HOSTNAME).toString(); LOG.info("Overriding nimbus host to storm.local.hostname -> {}", host); } else { LOG.info("Nimbus figures out its name to {}", host); } int port = Integer.parseInt(conf.get(Config.NIMBUS_THRIFT_PORT).toString()); return new NimbusInfo(host, port, false); } catch (UnknownHostException e) { throw new RuntimeException("Something wrong with network/dns config, host cant figure out its name", e); } }