コード例 #1
0
  public void startup() throws SenseiException {
    Message[] messages = {SenseiResultBPO.Result.getDefaultInstance()};

    ClientConfig config = new ClientConfig();
    config.setClusterName(_clusterName);
    config.setZooKeeperUrls(_zkurl);
    config.setResponseMessages(messages);

    config.setRouterFactory(_routerFactory);

    ClientBoostrapFactory bootstrapFactory = getClientBoostrapFactory();
    bootstrap = bootstrapFactory.getClientBootstrap(config);
    networkClient = bootstrap.getNetworkClient();
    Cluster cluster = bootstrap.getCluster();
    try {
      _broker = new SenseiBroker(cluster, networkClient, _reqRewriter);
    } catch (NorbertException ne) {
      log.info("shutting down bootstrap...");
      try {
        networkClient.close();
      } catch (ClusterShutdownException e) {
        log.info(e.getMessage(), e);
      } finally {
        bootstrap.shutdown();
      }
      throw new SenseiException(ne.getMessage(), ne);
    }
  }
コード例 #2
0
  public void shutdown() {
    try {
      log.info("shutting down client...");
      _broker.shutdown();
    } finally {
      log.info("shutting down bootstrap...");

      try {
        networkClient.close();
      } catch (ClusterShutdownException e) {
        log.error(e.getMessage(), e);
      } finally {
        bootstrap.shutdown();
      }
    }
  }