示例#1
0
  @Autowired
  public UrlTokenMonitor(
      ZooKeeperConnection connection,
      ControllerPaths controllerPaths,
      ObjectSerializer objectSerializer,
      UrlTokenDictionary tokenDictionary,
      UrlTokenRepository tokenRepository) {
    ZooKeeperTreeConsistentCallback cb =
        new ZooKeeperTreeConsistentCallback() {
          @Override
          public void treeConsistent(ZooKeeperTreeNode oldRoot, ZooKeeperTreeNode newRoot) {
            onTokenTreeChanged(newRoot);
          }
        };
    this.objectSerializer = objectSerializer;
    this.tokenDictionary = tokenDictionary;
    this.tokenRepository = tokenRepository;

    String nodePath = controllerPaths.getUrlTokens();
    this.tokenNodeWatcher = new ZooKeeperTreeWatcher(connection, 0, nodePath, cb);

    this.tokenChangeListeners = Sets.newHashSet();
    this.previousTokenDtos = Sets.newHashSet();
    this.tokensInitialized = false;
  }
示例#2
0
 /**
  * Constructs a new FailoverMonitor with injected dependencies.
  *
  * @param connection the ZooKeeper connection
  * @param controllerPaths controller paths
  */
 @Autowired
 public FailoverMonitor(ZooKeeperConnection connection, ControllerPaths controllerPaths) {
   this.connection = connection;
   this.masterElection = new ZooKeeperElection(connection, controllerPaths.getMaster());
   this.failoverListeners = Sets.newHashSet();
   this.failoverState = FailoverState.UNKNOWN;
 }