Package co.paralleluniverse.galaxy.core.Message

Examples of co.paralleluniverse.galaxy.core.Message.BACKUP_PACKET


        testSerialize(Message.BACKUPACK((short) rand.nextInt(), rand.nextLong(), rand.nextLong()));
    }

    @Test
    public void testBACKUPACK_PACKETSer() {
        final BACKUP_PACKET m1 = Message.BACKUP_PACKET(rand.nextLong(), Arrays.asList(
                Message.BACKUP(rand.nextLong(), rand.nextLong(), randomBuffer(100)),
                Message.BACKUP(rand.nextLong(), rand.nextLong(), randomBuffer(45)),
                Message.BACKUP(rand.nextLong(), rand.nextLong(), randomBuffer(70))));

        byte[] array = m1.toByteArray();
        final BACKUP_PACKET m2 = (BACKUP_PACKET) Message.fromByteArray(array);

        assertThat(m2.getId(), equalTo(m1.getId()));
        assertThat(m2.getBackups().size(), equalTo(m1.getBackups().size()));
        for (int i = 0; i < m1.getBackups().size(); i++)
            assertThat(m2.getBackups().get(i), deepEqualTo(m1.getBackups().get(i)));

        final ByteBuffer[] buffers = m1.toByteBuffers();
        final BACKUP_PACKET m3 = (BACKUP_PACKET) Message.fromByteBuffer(combine(buffers));

        assertThat(m3.getId(), equalTo(m1.getId()));
        assertThat(m3.getBackups().size(), equalTo(m1.getBackups().size()));
        for (int i = 0; i < m1.getBackups().size(); i++)
            assertThat(m3.getBackups().get(i), deepEqualTo(m1.getBackups().get(i)));
    }
View Full Code Here


                } finally {
                    currentBackupsLock.unlock();
                }
            }

            final BACKUP_PACKET packet = flush1();
            if (packet != null)
                send(packet);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
View Full Code Here

            if (lastSent == null) {
                shouldFlush = false;
                this.lastFlush = System.nanoTime();
                if (currentBackups.isEmpty())
                    return null;
                final BACKUP_PACKET packet;
                packet = Message.BACKUP_PACKET(nextId, currentBackups.values());
                nextId++;
                lastSent = packet;
                currentBackups.clear();
                return packet;
View Full Code Here

        cache.receive(Message.INVACK(getCluster().getMyNodeId(), id));
    }

    private void ack(boolean server) {
        LOG.debug("Ack {}", server ? "server" : "slaves");
        BACKUP_PACKET packet = null;
        final BACKUP_PACKET _lastSent;
        currentBackupsLock.lock();
        try {
            if (server && awaitSlaves) {
                awaitServer = false;
                return;
            }
            if (!server && awaitServer) {
                awaitSlaves = false;
                return;
            }
            _lastSent = lastSent;
            lastSent = null;
            awaitServer = false;
            awaitSlaves = false;
            if (shouldFlush)
                packet = flush1();
        } finally {
            currentBackupsLock.unlock();
        }

        for (BACKUP backup : _lastSent.getBackups())
            cache.receive(Message.BACKUPACK((short) 0, backup.getLine(), backup.getVersion()).setIncoming());
        if (packet != null)
            send(packet);
    }
View Full Code Here

TOP

Related Classes of co.paralleluniverse.galaxy.core.Message.BACKUP_PACKET

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.