/** * Hedwig Console * * @param args arguments * @throws IOException * @throws InterruptedException */ public HedwigConsole(String[] args) throws IOException, InterruptedException { // Setup Terminal terminal = Terminal.setupTerminal(); HedwigCommands.init(); cl.parseOptions(args); if (cl.getCommand() == null) { inConsole = true; } else { inConsole = false; } org.apache.bookkeeper.conf.ClientConfiguration bkClientConf = new org.apache.bookkeeper.conf.ClientConfiguration(); ServerConfiguration hubServerConf = new ServerConfiguration(); String serverCfgFile = cl.getOption("server-cfg"); if (serverCfgFile != null) { try { hubServerConf.loadConf(new File(serverCfgFile).toURI().toURL()); } catch (ConfigurationException e) { throw new IOException(e); } try { bkClientConf.loadConf(new File(serverCfgFile).toURI().toURL()); } catch (ConfigurationException e) { throw new IOException(e); } } ClientConfiguration hubClientCfg = new ClientConfiguration(); String clientCfgFile = cl.getOption("client-cfg"); if (clientCfgFile != null) { try { hubClientCfg.loadConf(new File(clientCfgFile).toURI().toURL()); } catch (ConfigurationException e) { throw new IOException(e); } } printMessage("Connecting to zookeeper/bookkeeper using HedwigAdmin"); try { admin = new HedwigAdmin(bkClientConf, hubServerConf); admin.getZkHandle().register(new MyWatcher()); } catch (Exception e) { throw new IOException(e); } printMessage("Connecting to default hub server " + hubClientCfg.getDefaultServerHost()); hubClient = new HedwigClient(hubClientCfg); publisher = hubClient.getPublisher(); subscriber = hubClient.getSubscriber(); subscriber.addSubscriptionListener(new ConsoleSubscriptionListener()); // other parameters myRegion = hubServerConf.getMyRegion(); }
@Override @Before public void setUp() throws Exception { numServers = 1; super.setUp(); conf = new ClientConfiguration() { @Override public boolean isAutoSendConsumeMessageEnabled() { return false; } }; client = new HedwigClient(conf); publisher = client.getPublisher(); subscriber = client.getSubscriber(); }