org.jgroups.View Java Examples

The following examples show how to use org.jgroups.View. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UniTimeClusterDiscovery.java    From unitime with Apache License 2.0 6 votes vote down vote up
protected void handleView(View new_view, View old_view, boolean coord_changed) {
    if(is_coord) {
        if(clear_table_on_view_change)
            clearTable();
        else if(old_view != null && new_view != null) {
            Address[][] diff=View.diff(old_view, new_view);
            Address[] left_mbrs=diff[1];
            for(Address left_mbr : left_mbrs)
                if(left_mbr != null && !new_view.containsMember(left_mbr))
                    remove(left_mbr);
        }
    }
    if(coord_changed || clear_table_on_view_change)
        writeOwnInformation(); // write immediately
    if(info_writer_max_writes_after_view > 0)
        startInfoWriter(); // and / or write in the background
}
 
Example #2
Source File: NO_DUPES.java    From jgroups-raft with Apache License 2.0 6 votes vote down vote up
/**
 * @return True if the message should be passed up, false if it should be discarded
 */
protected boolean handleGmsHeader(GMS.GmsHeader hdr, Address sender) {
    switch(hdr.getType()) {
        case GMS.GmsHeader.JOIN_REQ:
        case GMS.GmsHeader.JOIN_REQ_WITH_STATE_TRANSFER:
            Address joiner=hdr.getMember();
            if(!(joiner instanceof ExtendedUUID)) {
                log.debug("joiner %s needs to have an ExtendedUUID but has a %s", sender, joiner.getClass().getSimpleName());
                break;
            }
            View v=view;
            if(contains(v, (ExtendedUUID)joiner)) {
                String msg=String.format("join of %s rejected as it would create a view with duplicate members (current view: %s)", joiner, v);
                log.warn(msg);
                sendJoinRejectedMessageTo(sender, msg);
                return false;
            }
            break;
        case GMS.GmsHeader.MERGE_REQ:
            // to be done later when we know how to handle merges in jgroups-raft
            break;
    }
    return true;
}
 
Example #3
Source File: CounterServiceDemo.java    From jgroups-raft with Apache License 2.0 6 votes vote down vote up
void start(String props, String name, long repl_timeout, boolean allow_dirty_reads, boolean follower) throws Exception {
    ch=new JChannel(props).name(name);
    counter_service=new CounterService(ch).raftId(name).replTimeout(repl_timeout).allowDirtyReads(allow_dirty_reads);
    if(follower)
        disableElections(ch);
    ch.setReceiver(new ReceiverAdapter() {
        public void viewAccepted(View view) {
            System.out.println("-- view: " + view);
        }
    });

    try {
        ch.connect("cntrs");
        loop();
    }
    finally {
        Util.close(ch);
    }
}
 
Example #4
Source File: SolverServerImplementation.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void viewAccepted(View view) {
	sLog.info("viewAccepted(" + view + ")");
	if (view instanceof MergeView) {
		reset();
	}
}
 
Example #5
Source File: NO_DUPES.java    From jgroups-raft with Apache License 2.0 5 votes vote down vote up
protected static boolean contains(View v, ExtendedUUID joiner) {
    byte[] raft_id=joiner.get(RAFT.raft_id_key);
    for(Address addr: v) {
        if(addr instanceof ExtendedUUID) {
            ExtendedUUID uuid=(ExtendedUUID)addr;
            byte[] tmp=uuid.get(RAFT.raft_id_key);
            // compare byte[] buffers to avoid the cost of deserialization
            if(Arrays.equals(raft_id, tmp))
                return true;
        }
    }
    return false;
}
 
Example #6
Source File: ClusterMembershipListener.java    From flex-blazeds with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example #7
Source File: ClusterMembershipListener.java    From flex-blazeds with Apache License 2.0 5 votes vote down vote up
private void handleDepartedMembers(View membershipView, Vector<Address> currentMemberList)
    {
        for (Address member : members)
        {
            if (!membershipView.containsMember(member))
            {
//                cluster.removeClusterNode(member);
                zombies.remove(member);
            }
        }
        members = currentMemberList;
    }
 
Example #8
Source File: JavaGroupsCache.java    From commons-jcs with Apache License 2.0 4 votes vote down vote up
public void viewAccepted( View view )
{
    log.info( "View Changed: " + String.valueOf( view ) );
}
 
Example #9
Source File: JGroupsTransport.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void viewAccepted(View view)
{
   if (log.isTraceEnabled())
   {
      log.tracef("java.net.preferIPv4Stack=%s", SecurityActions.getSystemProperty("java.net.preferIPv4Stack"));
      log.tracef("viewAccepted called w/ View=%s", view);
      log.tracef("viewAccepted called w/ physicalAdresses=%s", nodes.values());
      log.tracef("viewAccepted called w/ members=%s", view.getMembers());
      log.tracef("viewAccepted called w/ channels=%s", channel);

   }

   synchronized (this)
   {
      List<org.jgroups.Address> physicalAddresses = new ArrayList<org.jgroups.Address>(nodes.values().size());
      physicalAddresses.addAll(nodes.values());
      for (org.jgroups.Address physicalAddress : physicalAddresses)
      {
         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.jboss.jca.core.spi.workmanager.Address> logicalAddresses =
                  (Set<org.jboss.jca.core.spi.workmanager.Address>)sendMessage(address, Request.GET_WORKMANAGERS);

               if (logicalAddresses != null && logicalAddresses.size() > 0)
               {
                  for (org.jboss.jca.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);
            }
         }
      }
   }
}
 
Example #10
Source File: JGroupsTransport.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
@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);
            }
         }
      }
   }
}
 
Example #11
Source File: ChatManagerImpl.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void viewAccepted(View arg0) {
}
 
Example #12
Source File: PCServiceEntityProvider.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void viewAccepted(View arg0) {
}
 
Example #13
Source File: NodeReceiverAdapter.java    From java-course-ee with MIT License 4 votes vote down vote up
@Override
public void viewAccepted(View view) {
    log.info("Members has been changed: " + view.getMembers());
}
 
Example #14
Source File: ReplicatedStateMachineDemo.java    From jgroups-raft with Apache License 2.0 4 votes vote down vote up
@Override
public void viewAccepted(View view) {
    System.out.println("-- view change: " + view);
}
 
Example #15
Source File: ChatManagerImpl.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void viewAccepted(View arg0) {
}
 
Example #16
Source File: PCServiceEntityProvider.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void viewAccepted(View arg0) {
}
 
Example #17
Source File: ReplicatedMapNotificationAdapter.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void viewChange(View view, List mbrs_joined, List mbrs_left) {}
 
Example #18
Source File: JvmStateReceiverAdapter.java    From jwala with Apache License 2.0 4 votes vote down vote up
@Override
public void viewAccepted(View view) {
    LOGGER.debug("JGroups coordinator cluster VIEW: {}", view.toString());
}