Package com.hazelcast.instance

Examples of com.hazelcast.instance.MemberImpl


    public void testMemberLeftException_usingMemberImpl() throws IOException, ClassNotFoundException {
        String uuid = UuidUtil.buildRandomUuidString();
        String host = "127.0.0.1";
        int port = 5000;

        Member member = new MemberImpl(new Address(host, port), false, uuid, null);

        testMemberLeftException(uuid, host, port, member);
    }
View Full Code Here


        out.writeObject(exception);

        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
        ObjectInputStream in = new ObjectInputStream(bin);
        MemberLeftException exception2 = (MemberLeftException) in.readObject();
        MemberImpl member2 = (MemberImpl) exception2.getMember();

        assertEquals(uuid, member2.getUuid());
        assertEquals(host, member2.getAddress().getHost());
        assertEquals(port, member2.getAddress().getPort());
    }
View Full Code Here

        public boolean write(SocketWritable socketWritable) {
            final Packet packet = (Packet) socketWritable;
            if (nodeEngine.getNode().isActive()) {
                Packet newPacket = readFromPacket(packet);
                MemberImpl member = nodeEngine.getClusterService().getMember(localEndpoint);
                if (member != null) {
                    member.didRead();
                }
                nodeEngine.handlePacket(newPacket);
                return true;
            }
            return false;
View Full Code Here

        List<HazelcastInstance> instanceList = buildInstances(3, 35701);
        final HazelcastInstance h1 = instanceList.get(0);
        final HazelcastInstance h2 = instanceList.get(1);
        final HazelcastInstance h3 = instanceList.get(2);

        final MemberImpl m1 = (MemberImpl) h1.getCluster().getLocalMember();
        final MemberImpl m2 = (MemberImpl) h2.getCluster().getLocalMember();
        final MemberImpl m3 = (MemberImpl) h3.getCluster().getLocalMember();

        // All three nodes join into one cluster
        assertEquals(3, h1.getCluster().getMembers().size());
        assertEquals(3, h2.getCluster().getMembers().size());
        assertEquals(3, h3.getCluster().getMembers().size());

        final Node n2 = TestUtil.getNode(h2);

        // Simulates node2 getting an out of order member list. That causes node2 to think it's the master.
        List<MemberInfo> members = new ArrayList<MemberInfo>();
        members.add(new MemberInfo(m2.getAddress(), m2.getUuid(), Collections. <String, Object> emptyMap()));
        members.add(new MemberInfo(m3.getAddress(), m3.getUuid(), Collections. <String, Object> emptyMap()));
        members.add(new MemberInfo(m1.getAddress(), m1.getUuid(), Collections. <String, Object> emptyMap()));
        n2.clusterService.updateMembers(members);
        n2.setMasterAddress(m2.getAddress());

        // Give the cluster some time to figure things out. The merge and heartbeat code should have kicked in by this point
View Full Code Here

        List<HazelcastInstance> instanceList = buildInstances(3, 45701);
        final HazelcastInstance h1 = instanceList.get(0);
        final HazelcastInstance h2 = instanceList.get(1);
        final HazelcastInstance h3 = instanceList.get(2);

        final MemberImpl m1 = (MemberImpl) h1.getCluster().getLocalMember();
        final MemberImpl m2 = (MemberImpl) h2.getCluster().getLocalMember();

        // All three nodes join into one cluster
        assertEquals(3, h1.getCluster().getMembers().size());
        assertEquals(3, h2.getCluster().getMembers().size());
        assertEquals(3, h3.getCluster().getMembers().size());

        final Node n2 = TestUtil.getNode(h2);
        // Simulates node2 getting an out of order member list. That causes node2 to think it's the master.
        List<MemberInfo> members = new ArrayList<MemberInfo>();
        members.add(new MemberInfo(m1.getAddress(), m1.getUuid(), Collections. <String, Object> emptyMap()));
        members.add(new MemberInfo(m2.getAddress(), m2.getUuid(), Collections. <String, Object> emptyMap()));
        n2.clusterService.updateMembers(members);

        // Give the cluster some time to figure things out. The merge and heartbeat code should have kicked in by this point
        Thread.sleep(30 * 1000);

 
View Full Code Here

        RuntimeException expectedException = new RuntimeException("example exception");
        when(transactionManagerService.pickBackupAddresses(anyInt()))
                .thenThrow(expectedException);

        NodeEngine nodeEngine = mock(NodeEngine.class);
        when(nodeEngine.getLocalMember()).thenReturn(new MemberImpl());
        when(nodeEngine.getLogger(TransactionImpl.class)).thenReturn(new DummyLogger());

        transaction = new TransactionImpl(transactionManagerService, nodeEngine, TransactionOptions.getDefault(), null);
        try {
            transaction.begin();
View Full Code Here

    }

    private Collection<Member> createMembers() throws UnknownHostException {
        Collection<Member> members = new HashSet<Member>();
        InetAddress fakeAddress = InetAddress.getLocalHost();
        members.add(new MemberImpl(new Address("192.192.0.1", fakeAddress, 5701), false));
        members.add(new MemberImpl(new Address("192.192.0.1", fakeAddress, 5702), false));
        members.add(new MemberImpl(new Address("192.168.3.101", fakeAddress, 5701), false));
        members.add(new MemberImpl(new Address("192.168.3.101", fakeAddress, 5702), false));
        members.add(new MemberImpl(new Address("172.16.5.11", fakeAddress, 5701), false));
        members.add(new MemberImpl(new Address("172.16.5.11", fakeAddress, 5702), false));
        members.add(new MemberImpl(new Address("172.123.0.13", fakeAddress, 5701), false));
        members.add(new MemberImpl(new Address("172.123.0.13", fakeAddress, 5702), false));
        members.add(new MemberImpl(new Address("www.hazelcast.com.tr", fakeAddress, 5701), false));
        members.add(new MemberImpl(new Address("www.hazelcast.com.tr", fakeAddress, 5702), false));
        members.add(new MemberImpl(new Address("jobs.hazelcast.com", fakeAddress, 5701), false));
        members.add(new MemberImpl(new Address("jobs.hazelcast.com", fakeAddress, 5702), false));
        members.add(new MemberImpl(new Address("www.hazelcast.org", fakeAddress, 5701), false));
        members.add(new MemberImpl(new Address("www.hazelcast.org", fakeAddress, 5702), false));
        members.add(new MemberImpl(new Address("download.hazelcast.org", fakeAddress, 5701), false));
        members.add(new MemberImpl(new Address("download.hazelcast.org", fakeAddress, 5702), false));
        return members;
    }
View Full Code Here

                }
                if ((float) partitionCount / memberCount > 2) {
                    if (previousMemberCount == 0) {
                        memberList = createMembers(memberCount, maxSameHostCount);
                    } else if (memberCount > previousMemberCount) {
                        MemberImpl last = (MemberImpl) memberList.get(previousMemberCount - 1);
                        List<Member> extra = createMembers(last, (memberCount - previousMemberCount), maxSameHostCount);
                        memberList.addAll(extra);
                    } else {
                        memberList = memberList.subList(0, memberCount);
                        shift(state, memberList);
View Full Code Here

                port = 5700;
                sameHostCount = rand.nextInt(maxSameHostCount) + 1;
            }
            count++;
            port++;
            MemberImpl m = new MemberImpl(new Address(InetAddress.getByAddress(new byte[]{ip[0], ip[1], ip[2], ip[3]})
                    , port), false);
            members.add(m);
            if (ip[3] == 255) {
                ip[2] = ++ip[2];
            }
View Full Code Here

                assertFalse("Duplicate owner of partition: " + partitionId,
                        set.contains(owner));
                set.add(owner);
                MemberGroup group = null;
                for (MemberGroup g : groups) {
                    if (g.hasMember(new MemberImpl(owner, true))) {
                        group = g;
                        break;
                    }
                }
                Assert.assertNotNull(group);
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.