Package com.hazelcast.instance

Examples of com.hazelcast.instance.MemberImpl


    @Override
    public void dispatchEvent(Object event, Object listener) {
        TopicEvent topicEvent = (TopicEvent) event;
        Object msgObject = nodeEngine.toObject(topicEvent.data);
        ClusterService clusterService = nodeEngine.getClusterService();
        MemberImpl member = clusterService.getMember(topicEvent.publisherAddress);
        if (member == null) {
            if (logger.isLoggable(Level.INFO)) {
                logger.info("Dropping message " + msgObject + " from unknown address:" + topicEvent.publisherAddress);
            }
            return;
View Full Code Here


        final Address masterAddress = getMasterAddress();
        if (masterAddress == null) {
            logger.finest("Could not send MasterConfirmation, master is null!");
            return;
        }
        final MemberImpl masterMember = getMember(masterAddress);
        if (masterMember == null) {
            logger.finest("Could not send MasterConfirmation, master is null!");
            return;
        }
        if (logger.isFinestEnabled()) {
View Full Code Here

            }
            final Connection conn = node.connectionManager.getConnection(deadAddress);
            if (destroyConnection && conn != null) {
                node.connectionManager.destroyConnection(conn);
            }
            MemberImpl deadMember = getMember(deadAddress);
            if (deadMember != null) {
                removeMember(deadMember);
                logger.info(membersString());
            }
        } finally {
View Full Code Here

    private void assignNewMaster() {
        final Address oldMasterAddress = node.getMasterAddress();
        if (node.joined()) {
            final Collection<MemberImpl> members = getMemberList();
            MemberImpl newMaster = null;
            final int size = members.size();
            if (size > 1) {
                final Iterator<MemberImpl> iter = members.iterator();
                final MemberImpl member = iter.next();
                if (member.getAddress().equals(oldMasterAddress)) {
                    newMaster = iter.next();
                } else {
                    logger.severe("Old master " + oldMasterAddress
                            + " is dead but the first of member list is a different member " +
                            member + "!");
View Full Code Here

            }
        }
    }

    private boolean isJoinRequestFromAnExistingMember(JoinRequest joinRequest) {
        MemberImpl member = getMember(joinRequest.getAddress());
        if (member != null) {
            if (joinRequest.getUuid().equals(member.getUuid())) {
                if (logger.isFinestEnabled()) {
                    String message = "Ignoring join request, member already exists.. => " + joinRequest;
                    logger.finest(message);
                }
                // send members update back to node trying to join again...
                Operation op = new MemberInfoUpdateOperation(createMemberInfos(getMemberList(), true),
                        getClusterTime(), false);
                nodeEngine.getOperationService().send(op, member.getAddress());
                return true;
            }
            // If this node is master then remove old member and process join request.
            // If requesting address is equal to master node's address, that means master node
            // somehow disconnected and wants to join back.
            // So drop old member and process join request if this node becomes master.
            if (node.isMaster() || member.getAddress().equals(node.getMasterAddress())) {
                logger.warning("New join request has been received from an existing endpoint! => " + member
                        + " Removing old member and processing join request...");
                doRemoveAddress(member.getAddress(), false);
            }
        }
        return false;
    }
View Full Code Here

            Map<Address, MemberImpl> oldMemberMap = membersMapRef.get();

            if (oldMemberMap.size() == members.size()) {
                boolean same = true;
                for (MemberInfo memberInfo : members) {
                    MemberImpl member = oldMemberMap.get(memberInfo.getAddress());
                    if (member == null || !member.getUuid().equals(memberInfo.uuid)) {
                        same = false;
                        break;
                    }
                }
                if (same) {
                    logger.finest("No need to process member update...");
                    return;
                }
            }
            MemberImpl[] newMembers = new MemberImpl[members.size()];
            int k = 0;
            for (MemberInfo memberInfo : members) {
                MemberImpl member = oldMemberMap.get(memberInfo.address);
                if (member == null) {
                    member = createMember(memberInfo.address, memberInfo.uuid, thisAddress.getScopeId(), memberInfo.attributes);
                }
                newMembers[k++] = member;
                member.didRead();
            }
            setMembers(newMembers);
            if (!getMemberList().contains(thisMember)) {
                throw new HazelcastException("Member list doesn't contain local member!");
            }
View Full Code Here

        return true;
    }

    @Override
    public void connectionAdded(final Connection connection) {
        MemberImpl member = getMember(connection.getEndPoint());
        if (member != null) {
            member.didRead();
        }
    }
View Full Code Here

        try {
            Map<Address, MemberImpl> oldMemberMap = membersMapRef.get();
            final Map<Address, MemberImpl> memberMap = new LinkedHashMap<Address, MemberImpl>()// ! ORDERED !
            final Collection<MemberImpl> newMembers = new LinkedList<MemberImpl>();
            for (MemberImpl member : members) {
                MemberImpl currentMember = oldMemberMap.get(member.getAddress());
                if (currentMember == null) {
                    newMembers.add(member);
                    masterConfirmationTimes.put(member, Clock.currentTimeMillis());
                }
                memberMap.put(member.getAddress(), member);
            }
            setMembersRef(memberMap);

            if (!newMembers.isEmpty()) {
                Set<Member> eventMembers = new LinkedHashSet<Member>(oldMemberMap.values());
                if (newMembers.size() == 1) {
                    MemberImpl newMember = newMembers.iterator().next();
                    node.getPartitionService().memberAdded(newMember); // sync call
                    eventMembers.add(newMember);
                    sendMembershipEventNotifications(newMember, unmodifiableSet(eventMembers), true); // async events
                } else {
                    for (MemberImpl newMember : newMembers) {
View Full Code Here

        }
    }

    protected MemberImpl createMember(Address address, String nodeUuid, String ipV6ScopeId, Map<String, Object> attributes) {
        address.setScopeId(ipV6ScopeId);
        return new MemberImpl(address, thisAddress.equals(address), nodeUuid,
                (HazelcastInstanceImpl) nodeEngine.getHazelcastInstance(), attributes);
    }
View Full Code Here

        final String registrationId = service.addMembershipListener(new MembershipListener() {
            @Override
            public void memberAdded(MembershipEvent membershipEvent) {
                if (endpoint.live()) {
                    final MemberImpl member = (MemberImpl) membershipEvent.getMember();
                    endpoint.sendEvent(new ClientMembershipEvent(member, MembershipEvent.MEMBER_ADDED), getCallId());
                }
            }

            @Override
            public void memberRemoved(MembershipEvent membershipEvent) {
                if (endpoint.live()) {
                    final MemberImpl member = (MemberImpl) membershipEvent.getMember();
                    endpoint.sendEvent(new ClientMembershipEvent(member, MembershipEvent.MEMBER_REMOVED), getCallId());
                }
            }

            public void memberAttributeChanged(MemberAttributeEvent memberAttributeEvent) {
                if (endpoint.live()) {
                    final MemberImpl member = (MemberImpl) memberAttributeEvent.getMember();
                    final String uuid = member.getUuid();
                    final MemberAttributeOperationType op = memberAttributeEvent.getOperationType();
                    final String key = memberAttributeEvent.getKey();
                    final Object value = memberAttributeEvent.getValue();
                    final MemberAttributeChange memberAttributeChange = new MemberAttributeChange(uuid, op, key, value);
                    endpoint.sendEvent(new ClientMembershipEvent(member, memberAttributeChange), getCallId());
View Full Code Here

TOP

Related Classes of com.hazelcast.instance.MemberImpl

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.