use of org.eclipse.ecf.provider.generic.gmm.Member in project ecf by eclipse.
the class ClientSOContainer method handleViewChangeMessage.
protected void handleViewChangeMessage(ContainerMessage mess) throws IOException {
if (!isConnected())
return;
final ContainerMessage.ViewChangeMessage vc = (ContainerMessage.ViewChangeMessage) mess.getData();
if (vc == null)
// $NON-NLS-1$
throw new IOException("view change message cannot be null");
final ID fromID = mess.getFromContainerID();
if (fromID == null || !fromID.equals(remoteServerID)) {
// $NON-NLS-1$ //$NON-NLS-2$
throw new IOException("view change message fromID=" + fromID + " is not from remoteServerID=" + remoteServerID);
}
final ID[] changeIDs = vc.getChangeIDs();
if (changeIDs == null) {
// do nothing if we've got no changes
} else {
for (int i = 0; i < changeIDs.length; i++) {
if (vc.isAdd()) {
boolean wasAdded = false;
synchronized (getGroupMembershipLock()) {
// known
if (groupManager.getMemberForID(changeIDs[i]) == null) {
wasAdded = true;
groupManager.addMember(new Member(changeIDs[i]));
}
}
// accomplished
if (wasAdded)
fireContainerEvent(new ContainerConnectedEvent(getID(), changeIDs[i]));
} else {
if (changeIDs[i].equals(getID())) {
// We've been ejected.
final ID serverID = remoteServerID;
synchronized (getGroupMembershipLock()) {
handleLeave(remoteServerID, connection);
}
// Notify listeners that we've been ejected
fireContainerEvent(new ContainerEjectedEvent(getID(), serverID, vc.getData()));
} else {
synchronized (getGroupMembershipLock()) {
groupManager.removeMember(changeIDs[i]);
}
// Notify listeners that another remote has gone away
fireContainerEvent(new ContainerDisconnectedEvent(getID(), changeIDs[i]));
}
}
}
}
}
use of org.eclipse.ecf.provider.generic.gmm.Member in project ecf by eclipse.
the class ServerSOContainer method forwardExcluding.
protected void forwardExcluding(ID from, ID excluding, ContainerMessage data) throws IOException {
if (excluding == null) {
queueContainerMessage(new ContainerMessage(from, null, getNextSequenceNumber(), data.getData()));
} else {
final Object[] ms = groupManager.getMembers();
for (int i = 0; i < ms.length; i++) {
final Member m = (Member) ms[i];
final ID oldID = m.getID();
if (!excluding.equals(oldID) && !from.equals(oldID)) {
final IAsynchConnection conn = (IAsynchConnection) m.getData();
if (conn != null) {
try {
conn.sendAsynch(oldID, serialize(new ContainerMessage(from, oldID, getNextSequenceNumber(), data.getData())));
} catch (final IOException e) {
traceStack(// $NON-NLS-1$
"Exception in forwardExcluding from " + from + " with oldID " + oldID, // $NON-NLS-1$
e);
}
}
}
}
}
}
Aggregations