org.jgroups.util.Util.pickNext()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(164)

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

Util.pickNext介绍

[英]Returns the next min(N,list.size()) elements after obj
[中]返回obj之后的下一个min(N,list.size())元素

代码示例

代码示例来源:origin: wildfly/wildfly

protected Address determinePingDest() {
  if(pingable_mbrs == null || local_addr == null)
    return null;
  Address next=Util.pickNext(pingable_mbrs, local_addr);
  return Objects.equals(local_addr, next) ? null : next;
}

代码示例来源:origin: wildfly/wildfly

protected void handleView(View view) {
  view_size=view.size();
  Address tmp=Util.pickNext(view.getMembers(), local_addr);
  if(tmp != null && !tmp.equals(local_addr)) {
    next=tmp;
    if(log.isDebugEnabled())
      log.debug("next=" + next);
  }
}

代码示例来源:origin: wildfly/wildfly

protected void handleView(View view) {
  this.view=view;
  if(log.isDebugEnabled())
    log.debug("view=" + view);
  List<Address> members=view.getMembers();
  Address old_coord=coord;
  if(!members.isEmpty())
    coord=members.get(0);
  if(Objects.equals(coord, local_addr)) {
    List<Address> old_backups=backup_coords != null? new ArrayList<>(backup_coords) : null;
    backup_coords=new CopyOnWriteArrayList<>(Util.pickNext(members, local_addr, num_backups));
    // send the current values to all *new* backups
    List<Address> new_backups=Util.newElements(old_backups,backup_coords);
    for(Address new_backup: new_backups) {
      for(Map.Entry<String,VersionedValue> entry: counters.entrySet()) {
        UpdateRequest update=new UpdateRequest(entry.getKey(), entry.getValue().value, entry.getValue().version);
        sendRequest(new_backup, update);
      }
    }
  }
  else
    backup_coords=null;
  if(old_coord != null && coord != null && !old_coord.equals(coord) && local_addr.equals(coord)) {
    discard_requests=true; // set to false when the task is done
    startReconciliationTask();
  }
}

代码示例来源:origin: wildfly/wildfly

public void handleView(View view) {
  super.handleView(view);
  Address old_coord=coord;
  if(view.size() > 0) {
    coord=view.getCoord();
    is_coord=coord.equals(local_addr);
    log.debug("[%s] coord=%s, is_coord=%b", local_addr, coord, is_coord);
  }
  if(is_coord && num_backups > 0) {
    List<Address> new_backups=Util.pickNext(view.getMembers(), local_addr, num_backups);
    List<Address> copy_locks_list=null;
    synchronized(backups) {
      if(!backups.equals(new_backups)) {
        copy_locks_list=new ArrayList<>(new_backups);
        copy_locks_list.removeAll(backups);
        backups.clear();
        backups.addAll(new_backups);
      }
    }
    if(copy_locks_list != null && !copy_locks_list.isEmpty())
      copyLocksTo(copy_locks_list);
  }
  // For all non-acquired client locks, send the GRANT_LOCK request to the new coordinator (if changed)
  if(old_coord != null && !old_coord.equals(coord))
    client_lock_table.resendPendingLockRequests();
}

代码示例来源:origin: wildfly/wildfly

List<Address> new_backups=Util.pickNext(view.getMembers(), local_addr, num_backups);
List<Address> new_members=null;
synchronized(backups) {
List<Address> possiblebackups = Util.pickNext(view.getMembers(), 
  coord, num_backups);

代码示例来源:origin: org.jboss.eap/wildfly-client-all

protected Address determinePingDest() {
  if(pingable_mbrs == null || local_addr == null)
    return null;
  Address next=Util.pickNext(pingable_mbrs, local_addr);
  return Objects.equals(local_addr, next) ? null : next;
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

protected void handleView(View view) {
  this.view=view;
  if(log.isDebugEnabled())
    log.debug("view=" + view);
  List<Address> members=view.getMembers();
  Address old_coord=coord;
  if(!members.isEmpty())
    coord=members.get(0);
  if(Objects.equals(coord, local_addr)) {
    List<Address> old_backups=backup_coords != null? new ArrayList<>(backup_coords) : null;
    backup_coords=new CopyOnWriteArrayList<>(Util.pickNext(members, local_addr, num_backups));
    // send the current values to all *new* backups
    List<Address> new_backups=Util.newElements(old_backups,backup_coords);
    for(Address new_backup: new_backups) {
      for(Map.Entry<String,VersionedValue> entry: counters.entrySet()) {
        UpdateRequest update=new UpdateRequest(entry.getKey(), entry.getValue().value, entry.getValue().version);
        sendRequest(new_backup, update);
      }
    }
  }
  else
    backup_coords=null;
  if(old_coord != null && coord != null && !old_coord.equals(coord) && local_addr.equals(coord)) {
    discard_requests=true; // set to false when the task is done
    startReconciliationTask();
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

protected void handleView(View view) {
  view_size=view.size();
  Address tmp=Util.pickNext(view.getMembers(), local_addr);
  if(tmp != null && !tmp.equals(local_addr)) {
    next=tmp;
    if(log.isDebugEnabled())
      log.debug("next=" + next);
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public void handleView(View view) {
  super.handleView(view);
  Address old_coord=coord;
  if(view.size() > 0) {
    coord=view.getCoord();
    is_coord=coord.equals(local_addr);
    log.debug("[%s] coord=%s, is_coord=%b", local_addr, coord, is_coord);
  }
  if(is_coord && num_backups > 0) {
    List<Address> new_backups=Util.pickNext(view.getMembers(), local_addr, num_backups);
    List<Address> copy_locks_list=null;
    synchronized(backups) {
      if(!backups.equals(new_backups)) {
        copy_locks_list=new ArrayList<>(new_backups);
        copy_locks_list.removeAll(backups);
        backups.clear();
        backups.addAll(new_backups);
      }
    }
    if(copy_locks_list != null && !copy_locks_list.isEmpty())
      copyLocksTo(copy_locks_list);
  }
  // For all non-acquired client locks, send the GRANT_LOCK request to the new coordinator (if changed)
  if(old_coord != null && !old_coord.equals(coord))
    client_lock_table.resendPendingLockRequests();
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

List<Address> new_backups=Util.pickNext(view.getMembers(), local_addr, num_backups);
List<Address> new_members=null;
synchronized(backups) {
List<Address> possiblebackups = Util.pickNext(view.getMembers(), 
  coord, num_backups);

相关文章

Util类方法