コード例 #1
0
ファイル: Session.java プロジェクト: ptolemeza/java-driver
 @Override
 public void onDown(Host host) {
   // Note that with well behaved balancing policy (that ignore dead nodes), the removePool call
   // is not necessary
   // since updateCreatedPools should take care of it. But better protect against non well
   // behaving policies.
   removePool(host);
   updateCreatedPools();
 }
コード例 #2
0
ファイル: Session.java プロジェクト: ptolemeza/java-driver
    /*
     * When the set of live nodes change, the loadbalancer will change his
     * mind on host distances. It might change it on the node that came/left
     * but also on other nodes (for instance, if a node dies, another
     * previously ignored node may be now considered).
     *
     * This method ensures that all hosts for which a pool should exist
     * have one, and hosts that shouldn't don't.
     */
    private void updateCreatedPools() {
      for (Host h : cluster.getMetadata().allHosts()) {
        HostDistance dist = loadBalancingPolicy().distance(h);
        HostConnectionPool pool = pools.get(h);

        if (pool == null) {
          if (dist != HostDistance.IGNORED && h.getMonitor().isUp()) addOrRenewPool(h);
        } else if (dist != pool.hostDistance) {
          if (dist == HostDistance.IGNORED) {
            removePool(h);
          } else {
            pool.hostDistance = dist;
          }
        }
      }
    }
コード例 #3
0
ファイル: Session.java プロジェクト: ptolemeza/java-driver
 @Override
 public void onRemove(Host host) {
   removePool(host);
   updateCreatedPools();
 }