コード例 #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
  @Before
  public void setUp() {
    // load the spring application context
    String confDirName = System.getProperty("test.conf.dir");
    File confDir = null;
    if (confDirName == null) confDir = new File("test/conf");
    else confDir = new File(confDirName);

    ApplicationContext testSpringCtx =
        new FileSystemXmlApplicationContext(
            "file:" + new File(confDir, SENSEI_TEST_CONF_FILE).getAbsolutePath());
    networkClient = (SenseiNetworkClient) testSpringCtx.getBean("network-client");
    networkClient.registerRequest(
        SenseiRequestBPO.Request.getDefaultInstance(), SenseiResultBPO.Result.getDefaultInstance());
    clusterClient = (ClusterClient) testSpringCtx.getBean("cluster-client");
    requestRewriter = (SenseiRequestScatterRewriter) testSpringCtx.getBean("request-rewriter");
    routerFactory =
        (PartitionedLoadBalancerFactory<Integer>) testSpringCtx.getBean("router-factory");
    networkServer1 = (NetworkServer) testSpringCtx.getBean("network-server-1");
    networkServer2 = (NetworkServer) testSpringCtx.getBean("network-server-2");
  }