public String getClientString() { if (zkHost != null) return zkHost; if (zkProps == null) return null; // if the string wasn't passed as zkHost, then use the standalone server we started if (zkRun == null) return null; return "localhost:" + zkProps.getClientPortAddress().getPort(); }
public void start() { if (zkRun == null) return; zkThread = new Thread() { @Override public void run() { try { if (zkProps.getServers().size() > 1) { QuorumPeerMain zkServer = new QuorumPeerMain(); zkServer.runFromConfig(zkProps); } else { ServerConfig sc = new ServerConfig(); sc.readFrom(zkProps); ZooKeeperServerMain zkServer = new ZooKeeperServerMain(); zkServer.runFromConfig(sc); } log.info("ZooKeeper Server exited."); } catch (Exception e) { log.error("ZooKeeper Server ERROR", e); throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e); } } }; if (zkProps.getServers().size() > 1) { log.info( "STARTING EMBEDDED ENSEMBLE ZOOKEEPER SERVER at port " + zkProps.getClientPortAddress().getPort()); } else { log.info( "STARTING EMBEDDED STANDALONE ZOOKEEPER SERVER at port " + zkProps.getClientPortAddress().getPort()); } zkThread.setDaemon(true); zkThread.start(); try { Thread.sleep(500); // pause for ZooKeeper to start } catch (Exception e) { log.error("STARTING ZOOKEEPER", e); } }
public void parseConfig() { if (zkProps == null) { zkProps = new SolrZkServerProps(); // set default data dir // TODO: use something based on IP+port??? support ensemble all from same solr home? zkProps.setDataDir(dataHome); zkProps.zkRun = zkRun; zkProps.solrPort = Integer.toString(solrPort); } try { props = SolrZkServerProps.getProperties(confHome + '/' + "zoo.cfg"); SolrZkServerProps.injectServers(props, zkRun, zkHost); zkProps.parseProperties(props); if (zkProps.getClientPortAddress() == null) { zkProps.setClientPort(solrPort + 1000); } } catch (QuorumPeerConfig.ConfigException | IOException e) { if (zkRun != null) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e); } }
public Map<Long, QuorumPeer.QuorumServer> getServers() { return zkProps.getServers(); }