com.alibaba.dubbo.common.URL.getBackupAddress()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(70)

本文整理了Java中com.alibaba.dubbo.common.URL.getBackupAddress()方法的一些代码示例,展示了URL.getBackupAddress()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URL.getBackupAddress()方法的具体详情如下:
包路径:com.alibaba.dubbo.common.URL
类名称:URL
方法名:getBackupAddress

URL.getBackupAddress介绍

暂无

代码示例

代码示例来源:origin: com.alibaba/dubbo-common

public String getBackupAddress() {
  return getBackupAddress(0);
}

代码示例来源:origin: remoting/dubbox

public String getBackupAddress() {
  return getBackupAddress(0);
}

代码示例来源:origin: com.alibaba/dubbo

public String getBackupAddress() {
  return getBackupAddress(0);
}

代码示例来源:origin: remoting/dubbox

public String getBackupAddress() {
  return getBackupAddress(0);
}

代码示例来源:origin: com.alibaba/dubbo

public CuratorZookeeperClient(URL url) {
  super(url);
  try {
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
        .connectString(url.getBackupAddress())
        .retryPolicy(new RetryNTimes(1, 1000))
        .connectionTimeoutMs(5000);
    String authority = url.getAuthority();
    if (authority != null && authority.length() > 0) {
      builder = builder.authorization("digest", authority.getBytes());
    }
    client = builder.build();
    client.getConnectionStateListenable().addListener(new ConnectionStateListener() {
      @Override
      public void stateChanged(CuratorFramework client, ConnectionState state) {
        if (state == ConnectionState.LOST) {
          CuratorZookeeperClient.this.stateChanged(StateListener.DISCONNECTED);
        } else if (state == ConnectionState.CONNECTED) {
          CuratorZookeeperClient.this.stateChanged(StateListener.CONNECTED);
        } else if (state == ConnectionState.RECONNECTED) {
          CuratorZookeeperClient.this.stateChanged(StateListener.RECONNECTED);
        }
      }
    });
    client.start();
  } catch (Exception e) {
    throw new IllegalStateException(e.getMessage(), e);
  }
}

代码示例来源:origin: com.alibaba/dubbo-remoting-zookeeper

public CuratorZookeeperClient(URL url) {
  super(url);
  try {
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
        .connectString(url.getBackupAddress())
        .retryPolicy(new RetryNTimes(1, 1000))
        .connectionTimeoutMs(5000);
    String authority = url.getAuthority();
    if (authority != null && authority.length() > 0) {
      builder = builder.authorization("digest", authority.getBytes());
    }
    client = builder.build();
    client.getConnectionStateListenable().addListener(new ConnectionStateListener() {
      @Override
      public void stateChanged(CuratorFramework client, ConnectionState state) {
        if (state == ConnectionState.LOST) {
          CuratorZookeeperClient.this.stateChanged(StateListener.DISCONNECTED);
        } else if (state == ConnectionState.CONNECTED) {
          CuratorZookeeperClient.this.stateChanged(StateListener.CONNECTED);
        } else if (state == ConnectionState.RECONNECTED) {
          CuratorZookeeperClient.this.stateChanged(StateListener.RECONNECTED);
        }
      }
    });
    client.start();
  } catch (Exception e) {
    throw new IllegalStateException(e.getMessage(), e);
  }
}

代码示例来源:origin: net.jahhan/dubbo-remoting-zookeeper

public CuratorZookeeperClient(URL url) {
  super(url);
  try {
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
        .connectString(url.getBackupAddress())
        .retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000))
        .connectionTimeoutMs(5000);
    String authority = url.getAuthority();
    if (authority != null && authority.length() > 0) {
      builder = builder.authorization("digest", authority.getBytes());
    }
    client = builder.build();
    client.getConnectionStateListenable().addListener(new ConnectionStateListener() {
      public void stateChanged(CuratorFramework client, ConnectionState state) {
        if (state == ConnectionState.LOST) {
          CuratorZookeeperClient.this.stateChanged(StateListener.DISCONNECTED);
        } else if (state == ConnectionState.CONNECTED) {
          CuratorZookeeperClient.this.stateChanged(StateListener.CONNECTED);
        } else if (state == ConnectionState.RECONNECTED) {
          CuratorZookeeperClient.this.stateChanged(StateListener.RECONNECTED);
        }
      }
    });
    client.start();
  } catch (Exception e) {
    throw new IllegalStateException(e.getMessage(), e);
  }
}

代码示例来源:origin: com.alibaba/dubbo-remoting-zookeeper

public ZkclientZookeeperClient(URL url) {
  super(url);
  client = new ZkClientWrapper(url.getBackupAddress(), 30000);
  client.addListener(new IZkStateListener() {
    @Override
    public void handleStateChanged(KeeperState state) throws Exception {
      ZkclientZookeeperClient.this.state = state;
      if (state == KeeperState.Disconnected) {
        stateChanged(StateListener.DISCONNECTED);
      } else if (state == KeeperState.SyncConnected) {
        stateChanged(StateListener.CONNECTED);
      }
    }
    @Override
    public void handleNewSession() throws Exception {
      stateChanged(StateListener.RECONNECTED);
    }
  });
  client.start();
}

代码示例来源:origin: com.alibaba/dubbo

public ZkclientZookeeperClient(URL url) {
  super(url);
  client = new ZkClientWrapper(url.getBackupAddress(), 30000);
  client.addListener(new IZkStateListener() {
    @Override
    public void handleStateChanged(KeeperState state) throws Exception {
      ZkclientZookeeperClient.this.state = state;
      if (state == KeeperState.Disconnected) {
        stateChanged(StateListener.DISCONNECTED);
      } else if (state == KeeperState.SyncConnected) {
        stateChanged(StateListener.CONNECTED);
      }
    }
    @Override
    public void handleNewSession() throws Exception {
      stateChanged(StateListener.RECONNECTED);
    }
  });
  client.start();
}

代码示例来源:origin: remoting/dubbox

public CuratorZookeeperClient(URL url) {
  super(url);
  Builder builder = CuratorFrameworkFactory.builder()
      .connectString(url.getBackupAddress())
      .retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000))
      .connectionTimeoutMs(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_REGISTRY_CONNECT_TIMEOUT))
      .sessionTimeoutMs(url.getParameter(Constants.SESSION_TIMEOUT_KEY, Constants.DEFAULT_SESSION_TIMEOUT));
  String authority = url.getAuthority();
  if (authority != null && authority.length() > 0) {
    builder = builder.authorization("digest", authority.getBytes());
  }
  client = builder.build();
  client.getConnectionStateListenable().addListener(
      new ConnectionStateListener() {
        public void stateChanged(CuratorFramework client,
            ConnectionState state) {
          if (state == ConnectionState.LOST) {
            CuratorZookeeperClient.this
                .stateChanged(StateListener.DISCONNECTED);
          } else if (state == ConnectionState.CONNECTED) {
            CuratorZookeeperClient.this
                .stateChanged(StateListener.CONNECTED);
          } else if (state == ConnectionState.RECONNECTED) {
            CuratorZookeeperClient.this
                .stateChanged(StateListener.RECONNECTED);
          }
        }
      });
  client.start();
}

代码示例来源:origin: remoting/dubbox

public CuratorZookeeperClient(URL url) {
  super(url);
  Builder builder = CuratorFrameworkFactory.builder()
      .connectString(url.getBackupAddress())
      .retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000))
      .connectionTimeoutMs(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_REGISTRY_CONNECT_TIMEOUT))
      .sessionTimeoutMs(url.getParameter(Constants.SESSION_TIMEOUT_KEY, Constants.DEFAULT_SESSION_TIMEOUT));
  String authority = url.getAuthority();
  if (authority != null && authority.length() > 0) {
    builder = builder.authorization("digest", authority.getBytes());
  }
  client = builder.build();
  client.getConnectionStateListenable().addListener(
      new ConnectionStateListener() {
        public void stateChanged(CuratorFramework client,
            ConnectionState state) {
          if (state == ConnectionState.LOST) {
            CuratorZookeeperClient.this
                .stateChanged(StateListener.DISCONNECTED);
          } else if (state == ConnectionState.CONNECTED) {
            CuratorZookeeperClient.this
                .stateChanged(StateListener.CONNECTED);
          } else if (state == ConnectionState.RECONNECTED) {
            CuratorZookeeperClient.this
                .stateChanged(StateListener.RECONNECTED);
          }
        }
      });
  client.start();
}

代码示例来源:origin: net.jahhan/dubbo-remoting-zookeeper

public ZkclientZookeeperClient(URL url) {
  super(url);
  client = new ZkClient(url.getBackupAddress(),
      url.getParameter(Constants.SESSION_TIMEOUT_KEY, Constants.DEFAULT_SESSION_TIMEOUT),
      url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_REGISTRY_CONNECT_TIMEOUT));
  client.subscribeStateChanges(new IZkStateListener() {
    public void handleStateChanged(KeeperState state) throws Exception {
      ZkclientZookeeperClient.this.state = state;
      if (state == KeeperState.Disconnected) {
        stateChanged(StateListener.DISCONNECTED);
      } else if (state == KeeperState.SyncConnected) {
        stateChanged(StateListener.CONNECTED);
      }
    }
    public void handleNewSession() throws Exception {
      stateChanged(StateListener.RECONNECTED);
    }
  });
}

代码示例来源:origin: hutai123/dubbox

public ZkclientZookeeperClient(URL url) {
  super(url);
  client = new ZkClient(
      url.getBackupAddress(),
      url.getParameter(Constants.SESSION_TIMEOUT_KEY, Constants.DEFAULT_SESSION_TIMEOUT),
      url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_REGISTRY_CONNECT_TIMEOUT));
  client.subscribeStateChanges(new IZkStateListener() {
    public void handleStateChanged(KeeperState state) throws Exception {
      ZkclientZookeeperClient.this.state = state;
      if (state == KeeperState.Disconnected) {
        stateChanged(StateListener.DISCONNECTED);
      } else if (state == KeeperState.SyncConnected) {
        stateChanged(StateListener.CONNECTED);
      }
    }
    public void handleNewSession() throws Exception {
      stateChanged(StateListener.RECONNECTED);
    }
    //@Override
    public void handleSessionEstablishmentError(Throwable error) throws Exception {
      //TODO list...
      logger.error("zookeeper connection error!", error);
      throw new Exception(error);
    }
  });
}

代码示例来源:origin: hutai123/dubbox

public ZkclientZookeeperClient(URL url) {
  super(url);
  client = new ZkClient(
      url.getBackupAddress(),
      url.getParameter(Constants.SESSION_TIMEOUT_KEY, Constants.DEFAULT_SESSION_TIMEOUT),
      url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_REGISTRY_CONNECT_TIMEOUT));
  client.subscribeStateChanges(new IZkStateListener() {
    public void handleStateChanged(KeeperState state) throws Exception {
      ZkclientZookeeperClient.this.state = state;
      if (state == KeeperState.Disconnected) {
        stateChanged(StateListener.DISCONNECTED);
      } else if (state == KeeperState.SyncConnected) {
        stateChanged(StateListener.CONNECTED);
      }
    }
    public void handleNewSession() throws Exception {
      stateChanged(StateListener.RECONNECTED);
    }
    //@Override
    public void handleSessionEstablishmentError(Throwable error) throws Exception {
      //TODO list...
      logger.error("zookeeper connection error!", error);
      throw new Exception(error);
    }
  });
}

相关文章

微信公众号

最新文章

更多