public static void withConfiguredClient(WithNimbus cb, Map conf) throws Exception { ReqContext context = ReqContext.context(); Principal principal = context.principal(); String user = principal == null ? null : principal.getName(); try (NimbusClient client = getConfiguredClientAs(conf, user);) { cb.run(client.getClient()); } }
/** * Execute cb with a configured nimbus client that will be closed once cb returns. * @param cb the callback to send to nimbus. * @param conf the conf to use instead of reading the global storm conf. * @throws Exception on any kind of error. */ public static void withConfiguredClient(WithNimbus cb, Map<String, Object> conf) throws Exception { try (NimbusClient client = getConfiguredClientAs(conf, null)) { cb.run(client.getClient()); } }