Package com.hazelcast.cluster.client

Examples of com.hazelcast.cluster.client.ClientMembershipEvent


        };


        ctors[MEMBERSHIP_EVENT] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
            public IdentifiedDataSerializable createNew(Integer arg) {
                return new ClientMembershipEvent();
            }
        };


        return new ArrayDataSerializableFactory(ctors);
View Full Code Here


            final SerializationService serializationService = getSerializationService();
            while (!Thread.currentThread().isInterrupted()) {
                final Data clientResponseData = conn.read();
                final ClientResponse clientResponse = serializationService.toObject(clientResponseData);
                final Object eventObject = serializationService.toObject(clientResponse.getResponse());
                final ClientMembershipEvent event = (ClientMembershipEvent) eventObject;
                final MemberImpl member = (MemberImpl) event.getMember();
                boolean membersUpdated = false;
                if (event.getEventType() == MembershipEvent.MEMBER_ADDED) {
                    members.add(member);
                    membersUpdated = true;
                } else if (event.getEventType() == ClientMembershipEvent.MEMBER_REMOVED) {
                    members.remove(member);
                    membersUpdated = true;
//                    getConnectionManager().removeConnectionPool(member.getAddress()); //TODO
                } else if (event.getEventType() == ClientMembershipEvent.MEMBER_ATTRIBUTE_CHANGED) {
                    MemberAttributeChange memberAttributeChange = event.getMemberAttributeChange();
                    Map<Address, MemberImpl> memberMap = membersRef.get();
                    if (memberMap != null) {
                        for (MemberImpl target : memberMap.values()) {
                            if (target.getUuid().equals(memberAttributeChange.getUuid())) {
                                final MemberAttributeOperationType operationType = memberAttributeChange.getOperationType();
                                final String key = memberAttributeChange.getKey();
                                final Object value = memberAttributeChange.getValue();
                                target.updateAttribute(operationType, key, value);
                                MemberAttributeEvent memberAttributeEvent = new MemberAttributeEvent(
                                        client.getCluster(), target, operationType, key, value);
                                fireMemberAttributeEvent(memberAttributeEvent);
                                break;
                            }
                        }
                    }
                }

                if (membersUpdated) {
                    ((ClientPartitionServiceImpl) client.getClientPartitionService()).refreshPartitions();
                    updateMembersRef();
                    logger.info(membersString());
                    fireMembershipEvent(new MembershipEvent(client.getCluster(), member, event.getEventType(),
                            Collections.unmodifiableSet(new LinkedHashSet<Member>(members))));
                }
            }
        }
View Full Code Here

                    case HEARTBEAT:
                        return new HeartbeatOperation();
                    case CONFIG_CHECK:
                        return new ConfigCheck();
                    case MEMBERSHIP_EVENT:
                        return new ClientMembershipEvent();
                    default:
                        return null;
                }
            }
        };
View Full Code Here

        final SerializationService serializationService = clusterService.getSerializationService();
        while (!Thread.currentThread().isInterrupted()) {
            final Data clientResponseData = conn.read();
            final ClientResponse clientResponse = serializationService.toObject(clientResponseData);
            final Object eventObject = serializationService.toObject(clientResponse.getResponse());
            final ClientMembershipEvent event = (ClientMembershipEvent) eventObject;
            final MemberImpl member = (MemberImpl) event.getMember();
            boolean membersUpdated = false;
            if (event.getEventType() == MembershipEvent.MEMBER_ADDED) {
                members.add(member);
                membersUpdated = true;
            } else if (event.getEventType() == ClientMembershipEvent.MEMBER_REMOVED) {
                members.remove(member);
                membersUpdated = true;
//                    getConnectionManager().removeConnectionPool(member.getAddress()); //TODO
            } else if (event.getEventType() == ClientMembershipEvent.MEMBER_ATTRIBUTE_CHANGED) {
                MemberAttributeChange memberAttributeChange = event.getMemberAttributeChange();
                Map<Address, MemberImpl> memberMap = clusterService.getMembersRef();
                if (memberMap != null) {
                    for (MemberImpl target : memberMap.values()) {
                        if (target.getUuid().equals(memberAttributeChange.getUuid())) {
                            final MemberAttributeOperationType operationType = memberAttributeChange.getOperationType();
                            final String key = memberAttributeChange.getKey();
                            final Object value = memberAttributeChange.getValue();
                            target.updateAttribute(operationType, key, value);
                            MemberAttributeEvent memberAttributeEvent = new MemberAttributeEvent(
                                    client.getCluster(), target, operationType, key, value);
                            clusterService.fireMemberAttributeEvent(memberAttributeEvent);
                            break;
                        }
                    }
                }
            }

            if (membersUpdated) {
                ((ClientPartitionServiceImpl) client.getClientPartitionService()).refreshPartitions();
                updateMembersRef();
                LOGGER.info(clusterService.membersString());
                clusterService.fireMembershipEvent(new MembershipEvent(client.getCluster(), member, event.getEventType(),
                        Collections.unmodifiableSet(new LinkedHashSet<Member>(members))));
            }
        }
    }
View Full Code Here

        final SerializationService serializationService = clusterService.getSerializationService();
        while (!Thread.currentThread().isInterrupted()) {
            final Data clientResponseData = conn.read();
            final ClientResponse clientResponse = serializationService.toObject(clientResponseData);
            final Object eventObject = serializationService.toObject(clientResponse.getResponse());
            final ClientMembershipEvent event = (ClientMembershipEvent) eventObject;
            final MemberImpl member = (MemberImpl) event.getMember();
            boolean membersUpdated = false;
            if (event.getEventType() == MembershipEvent.MEMBER_ADDED) {
                members.add(member);
                membersUpdated = true;
            } else if (event.getEventType() == ClientMembershipEvent.MEMBER_REMOVED) {
                members.remove(member);
                membersUpdated = true;
                connectionManager.removeEndpoint(member.getAddress());
            } else if (event.getEventType() == ClientMembershipEvent.MEMBER_ATTRIBUTE_CHANGED) {
                MemberAttributeChange memberAttributeChange = event.getMemberAttributeChange();
                Map<Address, MemberImpl> memberMap = clusterService.getMembersRef();
                if (memberMap != null) {
                    for (MemberImpl target : memberMap.values()) {
                        if (target.getUuid().equals(memberAttributeChange.getUuid())) {
                            final MemberAttributeOperationType operationType = memberAttributeChange.getOperationType();
                            final String key = memberAttributeChange.getKey();
                            final Object value = memberAttributeChange.getValue();
                            target.updateAttribute(operationType, key, value);
                            MemberAttributeEvent memberAttributeEvent = new MemberAttributeEvent(
                                    client.getCluster(), target, operationType, key, value);
                            clusterService.fireMemberAttributeEvent(memberAttributeEvent);
                            break;
                        }
                    }
                }
            }

            if (membersUpdated) {
                ((ClientPartitionServiceImpl) client.getClientPartitionService()).refreshPartitions();
                updateMembersRef();
                LOGGER.info(clusterService.membersString());
                clusterService.fireMembershipEvent(new MembershipEvent(client.getCluster(), member, event.getEventType(),
                        Collections.unmodifiableSet(new LinkedHashSet<Member>(members))));
            }
        }
    }
View Full Code Here

                    case CONFIG_CHECK:
                        return new ConfigCheck();
                    case BIND_MESSAGE:
                        return new BindMessage();
                    case MEMBERSHIP_EVENT:
                        return new ClientMembershipEvent();
                    default:
                        return null;
                }
            }
        };
View Full Code Here

TOP

Related Classes of com.hazelcast.cluster.client.ClientMembershipEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.