/** * Uses Storm config as returned by {@code Utils.readStormConfig()} * @param blobKey key of PMML model in Blobstore */ public ModelRunnerFromBlobStore(String blobKey, ModelOutputs modelOutputs) { this(blobKey, modelOutputs, Utils.readStormConfig()); }
/** * Constructor. * @param conf the configuration for storm. */ public HttpForwardingMetricsServer(Map<String, Object> conf) { this.conf = Utils.readStormConfig(); if (conf != null) { this.conf.putAll(conf); } }
/** * Returns PMML model from Blobstore. Uses Storm config as returned by {@code Utils.readStormConfig()} * @param blobKey key of PMML model in Blobstore */ public static InputStream getPmmlModelBlob(String blobKey) { return getPmmlModelBlob(blobKey, Utils.readStormConfig()); }
public static File getLogMetaDataFile(String fname) { String[] subStrings = fname.split(Pattern.quote(FILE_SEPARATOR)); // TODO: does this work well on windows? String id = subStrings[0]; Integer port = Integer.parseInt(subStrings[1]); return getLogMetaDataFile(Utils.readStormConfig(), id, port); }
public static void main(String[] args) { Map<String, Object> conf = Utils.readStormConfig(); System.exit(HealthChecker.healthCheck(conf)); }
/** * Creates a new {@link PMML} object representing the PMML model uploaded to the Blobstore with key specified as argument. * Uses Storm config as returned by {@code Utils.readStormConfig()} to get the Blobstore client */ public static PMML newPmml(String blobKey) throws JAXBException, SAXException, IOException { return newPmml(blobKey, Utils.readStormConfig()); }
public Map<String, Object> readStormConfigImpl() { Map<String, Object> conf = Utils.readStormConfig(); ConfigValidation.validateFields(conf); return conf; }
/** * Creates a new {@link Evaluator} object representing the PMML model uploaded to the Blobstore using the blob key specified as argument. * Uses Storm config as returned by {@code Utils.readStormConfig()} to get the Blobstore client */ public static Evaluator newEvaluator(String blobKey) throws IOException, JAXBException, SAXException { Objects.requireNonNull(blobKey); return newEvaluator(blobKey, Utils.readStormConfig()); }
public static ModelOutputs toDefaultStream(String blobKey) { return toDefaultStream(blobKey, Utils.readStormConfig()); }
public static void prepare() { Config conf = new Config(); conf.putAll(Utils.readStormConfig()); store = Utils.getClientBlobStore(conf); }
private LocalFsBlobStore initLocalFs() { LocalFsBlobStore store = new LocalFsBlobStore(); Map<String, Object> conf = Utils.readStormConfig(); conf.put(Config.STORM_LOCAL_DIR, baseFile.getAbsolutePath()); conf.put(Config.STORM_PRINCIPAL_TO_LOCAL_PLUGIN, "org.apache.storm.security.auth.DefaultPrincipalToLocal"); this.conf = conf; store.prepare(conf, null, null, null); return store; }
@Test public void defaultYamlTest() throws InvocationTargetException, NoSuchMethodException, NoSuchFieldException, InstantiationException, IllegalAccessException { Map<String, Object> conf = Utils.readStormConfig(); ConfigValidation.validateFields(conf); }
@Test(expected = KeyNotFoundException.class) public void testKeyNotFoundException() throws Exception { Map<String, Object> conf = Utils.readStormConfig(); String key1 = "key1"; conf.put(Config.STORM_LOCAL_DIR, "target"); LocalFsBlobStore bs = new LocalFsBlobStore(); LocalFsBlobStore spy = spy(bs); Mockito.doReturn(true).when(spy).checkForBlobOrDownload(key1); Mockito.doNothing().when(spy).checkForBlobUpdate(key1); spy.prepare(conf, null, null, null); spy.getBlob(key1, null); }
/** * allow cluster admin. */ @Test public void testAuthorizedLogUserAllowClusterAdmin() { Map<String, Object> stormConf = Utils.readStormConfig(); Map<String, Object> conf = new HashMap<>(stormConf); conf.put(NIMBUS_ADMINS, Collections.singletonList("alice")); ResourceAuthorizer authorizer = spy(new ResourceAuthorizer(conf)); doReturn(new ResourceAuthorizer.LogUserGroupWhitelist(Collections.emptySet(), Collections.emptySet())) .when(authorizer).getLogUserGroupWhitelist(anyString()); doReturn(Collections.emptySet()).when(authorizer).getUserGroups(anyString()); assertTrue(authorizer.isAuthorizedLogUser("alice", "non-blank-fname")); verifyStubMethodsAreCalledProperly(authorizer); }
/** * allow whitelisted topology user. */ @Test public void testAuthorizedLogUserAllowWhitelistedTopologyUser() { Map<String, Object> stormConf = Utils.readStormConfig(); Map<String, Object> conf = new HashMap<>(stormConf); ResourceAuthorizer authorizer = spy(new ResourceAuthorizer(conf)); doReturn(new ResourceAuthorizer.LogUserGroupWhitelist(Collections.singleton("alice"), Collections.emptySet())) .when(authorizer).getLogUserGroupWhitelist(anyString()); doReturn(Collections.emptySet()).when(authorizer).getUserGroups(anyString()); assertTrue(authorizer.isAuthorizedLogUser("alice", "non-blank-fname")); verifyStubMethodsAreCalledProperly(authorizer); }
@Test public void authorizationFailsWhenFilterConfigured() { Map<String, Object> stormConf = Utils.readStormConfig(); Map<String, Object> conf = new HashMap<>(stormConf); ResourceAuthorizer authorizer = spy(new ResourceAuthorizer(conf)); Mockito.when(authorizer.isAuthorizedLogUser(anyString(), anyString())).thenReturn(false); boolean authorized = authorizer.isUserAllowedToAccessFile("bob", "anyfile"); assertTrue(authorized); // no filter configured, allow anyone conf.put(DaemonConfig.LOGVIEWER_FILTER, "someFilter"); authorized = authorizer.isUserAllowedToAccessFile("bob", "anyfile"); assertFalse(authorized); // filter configured, should fail all users } }
public static void main(String[] args) throws Exception { Map<String, Object> conf = Utils.readStormConfig(); try (Supervisor supervisor = new Supervisor(conf, null, new StandaloneSupervisor(), new StormMetricsRegistry())) { supervisor.shutdownAllWorkers(null, null); } } }
private LogviewerLogSearchHandler getStubbedSearchHandler() { Map<String, Object> stormConf = Utils.readStormConfig(); LogviewerLogSearchHandler handler = new LogviewerLogSearchHandler(stormConf, topoPath, null, new ResourceAuthorizer(stormConf), new StormMetricsRegistry()); handler = spy(handler); doReturn(logFiles).when(handler).logsForPort(any(), any()); doAnswer(invocationOnMock -> { Object[] arguments = invocationOnMock.getArguments(); int fileOffset = (Integer) arguments[2]; String search = (String) arguments[4]; return new LogviewerLogSearchHandler.Matched(fileOffset, search, Collections.emptyList(), METRIC_SCANNED_FILES); }).when(handler).findNMatches(any(), anyInt(), anyInt(), anyInt(), any()); return handler; } }
private static LogviewerLogSearchHandler getSearchHandlerWithPort(int port) { Map<String, Object> stormConf = Utils.readStormConfig(); stormConf.put(DaemonConfig.LOGVIEWER_PORT, port); return new LogviewerLogSearchHandler(stormConf, null, null, new ResourceAuthorizer(stormConf), new StormMetricsRegistry()); }
private static LogviewerLogSearchHandler getSearchHandler() { Map<String, Object> stormConf = Utils.readStormConfig(); return new LogviewerLogSearchHandler(stormConf, null, null, new ResourceAuthorizer(stormConf), new StormMetricsRegistry()); }