当前位置: 首页>>代码示例>>Java>>正文


Java View.getMembers方法代码示例

本文整理汇总了Java中org.jgroups.View.getMembers方法的典型用法代码示例。如果您正苦于以下问题:Java View.getMembers方法的具体用法?Java View.getMembers怎么用?Java View.getMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jgroups.View的用法示例。


在下文中一共展示了View.getMembers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: viewAccepted

import org.jgroups.View; //导入方法依赖的package包/类
public void viewAccepted(View new_view) {
    nodes.clear();
    for(Address node: new_view.getMembers()) {
        int hash=Math.abs(node.hashCode() & (HASH_SPACE - 1));
        for(int i=hash; i < hash + HASH_SPACE; i++) {
            short new_index=(short)(i & (HASH_SPACE - 1));
            if(!nodes.containsKey(new_index)) {
                nodes.put(new_index, node);
                break;
            }
        }
    }

    if(log.isTraceEnabled()) {
        StringBuilder sb=new StringBuilder("node mappings:\n");
        for(Map.Entry<Short,Address> entry: nodes.entrySet()) {
            sb.append(entry.getKey() + ": " + entry.getValue()).append("\n");
        }
        log.trace(sb);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:22,代码来源:PartitionedHashMap.java

示例2: viewAccepted

import org.jgroups.View; //导入方法依赖的package包/类
@Override
public void viewAccepted(View newView) {
	if (newView.getMembers() != null) {
		synchronized (remoteMembers) {
			remoteMembers.removeAll(newView.getMembers());
			if (object instanceof ReplicatedObject<?> && !remoteMembers.isEmpty()) {
				HashSet<Serializable> dropped = new HashSet<Serializable>();
				for (Address address : remoteMembers) {
					dropped.add(new AddressWrapper(address));
				}
				((ReplicatedObject<?>)object).droppedMembers(dropped);
			}
			remoteMembers.clear();
			remoteMembers.addAll(newView.getMembers());
			remoteMembers.remove(this.disp.getChannel().getAddress());
		}
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:19,代码来源:JGroupsObjectReplicator.java

示例3: viewAccepted

import org.jgroups.View; //导入方法依赖的package包/类
@Override
public void viewAccepted(View view) {
    log.info("Members changed: {}", view.getMembers());
    synchronized (addresses) {
        addresses.clear();
        for (Address address: view.getMembers()) {
            System.out.println(address.getClass().getCanonicalName());
            addresses.put(address.toString(), address);
        }
    }
    try {
        log.trace("ViewId: {}", mapper.writeValueAsString(view));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:java-course-ee,项目名称:java-course-ee,代码行数:17,代码来源:NodeReceiverAdapter.java

示例4: print

import org.jgroups.View; //导入方法依赖的package包/类
static String print(View view) {
    StringBuilder sb=new StringBuilder();
    boolean first=true;
    sb.append(view.getClass().getSimpleName() + ": ").append(view.getViewId()).append(": ");
    for(Address mbr: view.getMembers()) {
        if(first)
            first=false;
        else
            sb.append(", ");
        sb.append(mbr);
    }
    return sb.toString();
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:14,代码来源:RelayDemoRpc.java

示例5: handleView

import org.jgroups.View; //导入方法依赖的package包/类
protected void handleView(View view) {
    List<Address> view_mbrs=view.getMembers();
    boolean is_pinger=false;
    members.clear();
    members.addAll(view_mbrs);
    Collection<InetAddress> current_hosts=null;
    synchronized(hosts) {
        hosts.clear();
        for(Address mbr: view_mbrs) {
            InetAddress key=getHostFor(mbr);
            if(key == null)
                continue;
            List<Address> mbrs=hosts.get(key);
            if(mbrs == null)
                hosts.put(key, mbrs=new ArrayList<>());
            mbrs.add(mbr);
        }
        is_pinger=isPinger(local_addr);
        current_hosts=new ArrayList<>(hosts.keySet());
    }

    if(suspected_mbrs.retainAll(view.getMembers()))
        has_suspected_mbrs=!suspected_mbrs.isEmpty();

    timestamps.keySet().retainAll(current_hosts);
    current_hosts.remove(local_host);
    for(InetAddress host: current_hosts)
        timestamps.putIfAbsent(host, getTimestamp());

    if(is_pinger)
        startPingerTask();
    else {
        stopPingerTask();
        timestamps.clear();
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:37,代码来源:FD_HOST.java

示例6: handleView

import org.jgroups.View; //导入方法依赖的package包/类
public void handleView(View view) {
    super.handleView(view);
    List<Address> members=view.getMembers();
    for(Map<Owner,ClientLock> map: client_lock_table.values()) {
        for(ClientLock lock: map.values())
            ((PeerLock)lock).retainAll(members);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:9,代码来源:PEER_LOCK.java

示例7: handleViewChange

import org.jgroups.View; //导入方法依赖的package包/类
private void handleViewChange(View view) {
    List<Address> new_mbrs=view.getMembers();
    List<Address> left_mbrs=Util.determineLeftMembers(members, new_mbrs);
    members.clear();
    members.addAll(new_mbrs);

    for(Address mbr: left_mbrs){
        // the new view doesn't contain the sender, it must have left,
        // hence we will clear all of itsfragmentation tables
        fragment_list.remove(mbr);
        if(log.isTraceEnabled())
            log.trace("[VIEW_CHANGE] removed " + mbr + " from fragmentation table");
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:15,代码来源:FRAG.java

示例8: handleViewChange

import org.jgroups.View; //导入方法依赖的package包/类
protected void handleViewChange(View view) {
    List<Address> new_mbrs=view.getMembers();
    List<Address> left_mbrs=Util.determineLeftMembers(members, new_mbrs);
    members.clear();
    members.addAll(new_mbrs);

    for(Address mbr: left_mbrs) {
        // the new view doesn't contain the sender, it must have left, hence we will clear its fragmentation tables
        fragment_list.remove(mbr);
        log.trace("%s: removed %s from fragmentation table", local_addr, mbr);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:13,代码来源:FRAG2.java

示例9: handleViewChange

import org.jgroups.View; //导入方法依赖的package包/类
private void handleViewChange(View view) {
    List<Address> members=view.getMembers();
    Set tmp=new LinkedHashSet(members);
    tmp.add(null); // for null destination (= mcast)
    sent.keySet().retainAll(tmp);
    received.keySet().retainAll(tmp);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:8,代码来源:STATS.java

示例10: viewChange

import org.jgroups.View; //导入方法依赖的package包/类
/**
 * Any member of 'membership' that is not in the new view is flagged as
 * SUSPECTED. Any member in the new view that is <em>not</em> in the
 * membership (ie, the set of responses expected for the current RPC) will
 * <em>not</em> be added to it. If we did this we might run into the
 * following problem:
 * <ul>
 * <li>Membership is {A,B}
 * <li>A sends a synchronous group RPC (which sleeps for 60 secs in the
 * invocation handler)
 * <li>C joins while A waits for responses from A and B
 * <li>If this would generate a new view {A,B,C} and if this expanded the
 * response set to {A,B,C}, A would wait forever on C's response because C
 * never received the request in the first place, therefore won't send a
 * response.
 * </ul>
 */
public void viewChange(View new_view) {
    if(new_view == null || requests == null || requests.isEmpty())
        return;

    List<Address> mbrs=new_view.getMembers();
    if(mbrs == null)
        return;

    boolean changed=false;

    lock.lock();
    try {
        for(Map.Entry<Address,Rsp<T>> entry: requests.entrySet()) {
            Address mbr=entry.getKey();
            // SiteAddresses are not checked as they might be in a different cluster
            if(!(mbr instanceof SiteAddress) && !mbrs.contains(mbr)) {
                Rsp<T> rsp=entry.getValue();
                if(rsp.setSuspected()) {
                    if(!(rsp.wasReceived() || rsp.wasUnreachable()))
                        num_received++;
                    changed=true;
                }
            }
        }
        if(changed)
            cond.signal(true);
    }
    finally {
        lock.unlock();
    }
    if(changed)
        checkCompletion(this);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:51,代码来源:GroupRequest.java

示例11: testMethodInvocationToNonExistingMembers

import org.jgroups.View; //导入方法依赖的package包/类
/**
 * Tests a method call to {A,B,C} where C left *before* the call. http://jira.jboss.com/jira/browse/JGRP-620
 */
public void testMethodInvocationToNonExistingMembers() throws Exception {

    final int timeout = 5 * 1000 ;

    // get the current membership, as seen by C
    View view=c.getView();
    List<Address> members=view.getMembers();
    System.out.println("list is " + members);

    // cause C to leave the group and close its channel
    System.out.println("closing c3");
    c.close();

    Util.sleep(1000);
    
    // make an RPC call using C's now outdated view of membership
    System.out.println("calling method foo() in " + members + " (view=" + b.getView() + ")");
    RspList<Object> rsps=disp1.callRemoteMethods(members, "foo", null, null, new RequestOptions(ResponseMode.GET_ALL, timeout));
    
    // all responses 
    System.out.println("responses:\n" + rsps);
    for(Map.Entry<Address,Rsp<Object>> entry: rsps.entrySet()) {
        Rsp rsp=entry.getValue();
        Util.assertTrue("response from " + entry.getKey() + " was not received", rsp.wasReceived());
        Util.assertFalse(rsp.wasSuspected());
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:31,代码来源:RpcDispatcherTest.java

示例12: viewAccepted

import org.jgroups.View; //导入方法依赖的package包/类
@Override
public void viewAccepted(View view)
{
    super.viewAccepted(view);
    
    for (Address address: view.getMembers())
    {
        System.out.println(address);
    }
    
    System.out.printf("Number of members %s\n", view.getMembers().size());
}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:13,代码来源:Group.java

示例13: viewAccepted

import org.jgroups.View; //导入方法依赖的package包/类
/**
 * This method is invoked by the cluster infrastructure whenever
 * a member joins or abandons the cluster group.
 *
 * @param membershipView Snapshot of members of the cluster.
 */
public void viewAccepted(View membershipView)
{
    synchronized(this)
    {
        Vector<Address> currentMemberList = membershipView.getMembers();
        handleArrivingMembers(currentMemberList);
        handleDepartedMembers(membershipView, currentMemberList);
    }
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:16,代码来源:ClusterMembershipListener.java

示例14: viewAccepted

import org.jgroups.View; //导入方法依赖的package包/类
@Override
        public void viewAccepted(View new_view) {
            Log.i(TAG, "** view: " + new_view);

            int peersNumber = new_view.size();
            if (peersNumber > 1) {
                List<Address> members = new_view.getMembers();
                peersIpAddress.clear();
                peers.clear();

                for (Address a : members) {
                    String addr = ((Object) a).toString();
                    Log.i(TAG, "members:" + addr);

//                    if (!addr.equalsIgnoreCase(localIpAddress)) {
                    peersIpAddress.add(a);
                    LanPlayer lanPlayer = new LanPlayer();
                    lanPlayer.setIp(addr);
                    lanPlayer.setUsername(channel.getName(a));
                    lanPlayer.setId(channel.getName(a));
                    peers.put(addr, lanPlayer);
//                    }
                }
            }
            LanUtils.sendUpdatePlayerInfoMsg();

        }
 
开发者ID:pjq,项目名称:pushup,代码行数:28,代码来源:PeersMgr.java

示例15: viewAccepted

import org.jgroups.View; //导入方法依赖的package包/类
@Override
public void viewAccepted(View view)
{
   if (trace)
   {
      log.tracef("java.net.preferIPv4Stack=%s", SecurityActions.getSystemProperty("java.net.preferIPv4Stack"));
      log.tracef("viewAccepted called w/ View=%s", view);
   }

   synchronized (this)
   {
      for (org.jgroups.Address physicalAddress : nodes.values())
      {
         if (physicalAddress != null && !view.containsMember(physicalAddress))
         {
            leave(physicalAddress);
         }
      }
      for (org.jgroups.Address address : view.getMembers())
      {
         if (channel != null && !channel.getAddress().equals(address) && !nodes.containsValue(address))
         {
            try
            {
               Set<org.ironjacamar.core.spi.workmanager.Address> logicalAddresses =
                  (Set<org.ironjacamar.core.spi.workmanager.Address>)sendMessage(address, Request.GET_WORKMANAGERS);

               if (logicalAddresses != null && !logicalAddresses.isEmpty())
               {
                  for (org.ironjacamar.core.spi.workmanager.Address logicalAddress : logicalAddresses)
                  {
                     join(logicalAddress, address);

                     Long shortRunning = getShortRunningFree(logicalAddress);
                     Long longRunning = getLongRunningFree(logicalAddress);
                  
                     localUpdateShortRunningFree(logicalAddress, shortRunning);
                     localUpdateLongRunningFree(logicalAddress, longRunning);
                  }
               }
            }
            catch (Throwable t)
            {
               log.error("ViewAccepted: " + t.getMessage(), t);
            }
         }
      }
   }
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:50,代码来源:JGroupsTransport.java


注:本文中的org.jgroups.View.getMembers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。