private Supervisor(ISupervisor iSupervisor, StormMetricsRegistry metricsRegistry) throws IOException, IllegalAccessException, InstantiationException, ClassNotFoundException { this(ConfigUtils.readStormConfig(), null, iSupervisor, metricsRegistry); }
/** * Execute cb with a configured nimbus client that will be closed once cb returns. * @param cb the callback to send to nimbus. * @throws Exception on any kind of error. */ public static void withConfiguredClient(WithNimbus cb) throws Exception { withConfiguredClient(cb, ConfigUtils.readStormConfig()); }
public static void main(String[] args) throws Exception { Map<String, Object> conf = ConfigUtils.readStormConfig(); boolean fixUp = false; for (String arg : args) { String a = arg.toLowerCase(); if ("-f".equals(a) || "--fixup".equals(a)) { fixUp = true; } else { throw new IllegalArgumentException("Unsupported argument " + arg + " only -f or --fixup is supported."); } } verifyAcls(conf, fixUp); } }
public static ILocalAssignmentsBackend getDefault() { ILocalAssignmentsBackend backend = new InMemoryAssignmentBackend(); backend.prepare(ConfigUtils.readStormConfig()); return backend; } }
public static void withConfiguredClient(WithBlobstore withBlobstore) throws Exception { Map<String, Object> conf = ConfigUtils.readStormConfig(); try (ClientBlobStore blobStore = Utils.getClientBlobStore(conf)) { withBlobstore.run(blobStore); } }
public static Nimbus launch(INimbus inimbus) throws Exception { Map<String, Object> conf = Utils.merge(ConfigUtils.readStormConfig(), ConfigUtils.readYamlConfig("storm-cluster-auth.yaml", false)); boolean fixupAcl = (boolean) conf.get(DaemonConfig.STORM_NIMBUS_ZOOKEEPER_ACLS_FIXUP); boolean checkAcl = fixupAcl || (boolean) conf.get(DaemonConfig.STORM_NIMBUS_ZOOKEEPER_ACLS_CHECK); if (checkAcl) { AclEnforcement.verifyAcls(conf, fixupAcl); } return launchServer(conf, inimbus); }
public static void main(String[] args) throws Exception { SysOutOverSLF4J.sendSystemOutAndErrToSLF4J(); Map<String, Object> conf = ConfigUtils.readStormConfig(); Object port = conf.get(Config.STORM_ZOOKEEPER_PORT); String localPath = (String) conf.get(DaemonConfig.DEV_ZOOKEEPER_PATH); Utils.forceDelete(localPath); Zookeeper.mkInprocessZookeeper(localPath, ObjectReader.getInt(port)); } }
/** * Creates a LocalDRPC with the specified metrics registry. * @param metricsRegistry The registry */ public LocalDRPC(StormMetricsRegistry metricsRegistry) { Map<String, Object> conf = ConfigUtils.readStormConfig(); drpc = new DRPC(metricsRegistry, conf); serviceId = ServiceRegistry.registerService(new DRPCThrift(drpc)); }
public static void main(String[] args) throws Exception { Preconditions.checkArgument(args.length == 5, "Illegal number of arguments. Expected: 5, Actual: " + args.length); String stormId = args[0]; String assignmentId = args[1]; String supervisorPort = args[2]; String portStr = args[3]; String workerId = args[4]; Map<String, Object> conf = ConfigUtils.readStormConfig(); Utils.setupDefaultUncaughtExceptionHandler(); StormCommon.validateDistributedMode(conf); Worker worker = new Worker(conf, null, stormId, assignmentId, Integer.parseInt(supervisorPort), Integer.parseInt(portStr), workerId); worker.start(); Utils.addShutdownHookWithForceKillIn1Sec(worker::shutdown); }
@Test public void testSchedulerStrategyWhitelist() { Map<String, Object> config = ConfigUtils.readStormConfig(); String allowed = DefaultResourceAwareStrategy.class.getName(); config.put(Config.NIMBUS_SCHEDULER_STRATEGY_CLASS_WHITELIST, Arrays.asList(allowed)); Object sched = ReflectionUtils.newSchedulerStrategyInstance(allowed, config); assertEquals(sched.getClass().getName(), allowed); }
@Test(expected = RuntimeException.class) public void getTransportPluginThrowsRunimeTest() { Map<String, Object> conf = ConfigUtils.readStormConfig(); conf.put(Config.STORM_THRIFT_TRANSPORT_PLUGIN, "null.invalid"); ClientAuthUtils.getTransportPlugin(ThriftConnectionType.NIMBUS, conf, null); }
@Test public void testSchedulerStrategyEmptyWhitelist() { Map<String, Object> config = ConfigUtils.readStormConfig(); String allowed = DefaultResourceAwareStrategy.class.getName(); Object sched = ReflectionUtils.newSchedulerStrategyInstance(allowed, config); assertEquals(sched.getClass().getName(), allowed); }
@Test public void testSchedulerStrategyWhitelistException() { Map<String, Object> config = ConfigUtils.readStormConfig(); String allowed = "org.apache.storm.scheduler.resource.strategies.scheduling.SomeNonExistantStrategy"; String notAllowed = DefaultResourceAwareStrategy.class.getName(); config.put(Config.NIMBUS_SCHEDULER_STRATEGY_CLASS_WHITELIST, Arrays.asList(allowed)); Assertions.assertThrows(DisallowedStrategyException.class, () -> ReflectionUtils.newSchedulerStrategyInstance(notAllowed, config)); }
public static void main(String[] args) { SysOutOverSLF4J.sendSystemOutAndErrToSLF4J(); Map<String, Object> conf = ConfigUtils.overrideLoginConfigWithSystemProperty(ConfigUtils.readStormConfig()); StormMetricsRegistry metricsRegistry = new StormMetricsRegistry(); final Pacemaker serverHandler = new Pacemaker(conf, metricsRegistry); serverHandler.launchServer(); metricsRegistry.startMetricsReporters(conf); Utils.addShutdownHookWithForceKillIn1Sec(metricsRegistry::stopMetricsReporters); }
public void getConfiguredClientThrowsRuntimeExceptionOnBadArgsTest() throws TTransportException { Map<String, Object> config = ConfigUtils.readStormConfig(); config.put(Config.STORM_NIMBUS_RETRY_TIMES, 0); try { new NimbusClient(config, "", 65535); Assert.fail("Expected exception to be thrown"); } catch (RuntimeException e) { Assert.assertTrue( "Cause is not TTransportException " + e, Utils.exceptionCauseIsInstanceOf(TTransportException.class, e)); } }
@Test public void shellBaseGroupsMappingTest() throws Exception { Map<String, Object> clusterConf = ConfigUtils.readStormConfig(); ShellBasedGroupsMapping groups = new ShellBasedGroupsMapping(); groups.prepare(clusterConf); String userName = System.getProperty("user.name"); assertTrue(groups.getGroups(userName).size() >= 0); assertEquals(0, groups.getGroups("userDoesNotExist").size()); assertEquals(0, groups.getGroups(null).size()); }
@Test public void positiveWhitelistAuthroizationTest() { SimpleWhitelistAuthorizer auth = new SimpleWhitelistAuthorizer(); Map<String, Object> conf = ConfigUtils.readStormConfig(); conf.put(SimpleWhitelistAuthorizer.WHITELIST_USERS_CONF, Arrays.asList("user")); auth.prepare(conf); ReqContext context = new ReqContext(mkSubject("user")); assertTrue(auth.permit(context, "activate", conf)); }
@Test public void getDefaultZkAclsSecureServerConf() { Map<String, Object> conf = ConfigUtils.readStormConfig(); conf.put(Config.STORM_ZOOKEEPER_AUTH_SCHEME, "digest"); conf.put(Config.STORM_ZOOKEEPER_AUTH_PAYLOAD, "storm:thisisapoorpassword"); conf.put(Config.STORM_PRINCIPAL_TO_LOCAL_PLUGIN, DefaultPrincipalToLocal.class.getName()); conf.put(Config.NIMBUS_THRIFT_PORT, 6666); assertNull(DaemonType.UNKNOWN.getDefaultZkAcls(conf)); assertNull(DaemonType.PACEMAKER.getDefaultZkAcls(conf)); assertEquals(DaemonType.NIMBUS_SUPERVISOR_ZK_ACLS, DaemonType.SUPERVISOR.getDefaultZkAcls(conf)); assertEquals(DaemonType.NIMBUS_SUPERVISOR_ZK_ACLS, DaemonType.NIMBUS.getDefaultZkAcls(conf)); assertNull(DaemonType.WORKER.getDefaultZkAcls(conf)); }
@Test public void negativeWhitelistAuthroizationTest() { SimpleWhitelistAuthorizer auth = new SimpleWhitelistAuthorizer(); Map<String, Object> conf = ConfigUtils.readStormConfig(); auth.prepare(conf); ReqContext context = new ReqContext(mkSubject("user")); assertFalse(auth.permit(context, "activate", conf)); }
@Test public void getDefaultZkAclsDefaultConf() { Map<String, Object> conf = ConfigUtils.readStormConfig(); assertNull(DaemonType.UNKNOWN.getDefaultZkAcls(conf)); assertNull(DaemonType.PACEMAKER.getDefaultZkAcls(conf)); assertNull(DaemonType.SUPERVISOR.getDefaultZkAcls(conf)); assertNull(DaemonType.NIMBUS.getDefaultZkAcls(conf)); assertNull(DaemonType.WORKER.getDefaultZkAcls(conf)); }