Examples of MainMemoryEntry


Examples of co.paralleluniverse.galaxy.server.MainMemoryEntry

                monitor.addObjectServed();
                store.write(id, msg.getNode(), 1, new byte[0], null);
                send(Message.PUTX(msg, id, new short[0], 1, null));
                return true;
            } else if ((owner = store.casOwner(id, SERVER, msg.getNode())) == msg.getNode()) { // if owner is server, then transfer ownership
                MainMemoryEntry entry = store.read(id);
                if (LOG.isDebugEnabled())
                    LOG.debug("Owner of line {} is now node {} (previously owned by server)", hex(id), msg.getNode());
                monitor.addOwnerWrite();
                monitor.addObjectServed();
                send(Message.PUTX(msg, id, new short[0], entry.version, ByteBuffer.wrap(entry.data)));
View Full Code Here

Examples of co.paralleluniverse.galaxy.server.MainMemoryEntry

                rs = getLine.executeQuery();
                rs.next();
                final long version = rs.getLong(1);
                final byte[] data = rs.getBytes(2);
                conn.commit();
                return new MainMemoryEntry(version, data);
            } finally {
                if (rs != null)
                    rs.close();
            }
        } catch (SQLException e) {
View Full Code Here

Examples of co.paralleluniverse.galaxy.server.MainMemoryEntry

        if (LOG.isDebugEnabled())
            LOG.debug("WRITE " + hex(id) + " ver: " + version + " data: " + (data != null ? "(" + data.length + " bytes)" : "null"));

        final DatabaseEntry key = new DatabaseEntry(Longs.toByteArray(id));
        final DatabaseEntry dbEntry = new DatabaseEntry();
        entryBinding.objectToEntry(new MainMemoryEntry(version, data), dbEntry);

        mainStore.put((Transaction) txn, key, dbEntry);
        // try to write owner, but only if nonexistent (i.e will happen at first put only)
        ownerDirectory.putNoOverwrite((Transaction) txn, key, new DatabaseEntry(Shorts.toByteArray(owner)));
    }
View Full Code Here

Examples of co.paralleluniverse.galaxy.server.MainMemoryEntry

    @Override
    public MainMemoryEntry read(long id) {
        final DatabaseEntry dbEntry = new DatabaseEntry();
        OperationStatus status = mainStore.get(null, new DatabaseEntry(Longs.toByteArray(id)), dbEntry, LockMode.READ_COMMITTED);
        if (status == OperationStatus.SUCCESS) {
            final MainMemoryEntry entry = entryBinding.entryToObject(dbEntry);
            return entry;
        } else
            return null;
    }
View Full Code Here

Examples of co.paralleluniverse.galaxy.server.MainMemoryEntry

        final DatabaseEntry value = new DatabaseEntry();
        final Cursor cursor = mainStore.openCursor(null, CursorConfig.DEFAULT);
        try {
            while (cursor.getNext(key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
                long id = Longs.fromByteArray(key.getData());
                final MainMemoryEntry entry = entryBinding.entryToObject(value);
                ps.println("Id : " + hex(id) + " version: " + entry.version + " data: (" + entry.data.length + " bytes).");
            }
        } finally {
            cursor.close();
        }
View Full Code Here

Examples of co.paralleluniverse.galaxy.server.MainMemoryEntry

            final long version = in.readLong();
            //final int dataLength = in.readUnsignedShort();
            final int dataLength = in.getBufferLength() - in.getBufferOffset();
            final byte[] data = new byte[dataLength];
            in.readFast(data);
            return new MainMemoryEntry(version, data);
        }
View Full Code Here

Examples of co.paralleluniverse.galaxy.server.MainMemoryEntry

        if (LOG.isDebugEnabled())
            LOG.debug("WRITE " + hex(id) + " ver: " + version + " data: " + (data != null ? "(" + data.length + " bytes)" : "null"));

        final DatabaseEntry key = new DatabaseEntry(Longs.toByteArray(id));
        final DatabaseEntry dbEntry = new DatabaseEntry();
        entryBinding.objectToEntry(new MainMemoryEntry(version, data), dbEntry);

        mainStore.put((Transaction) txn, key, dbEntry);
        // try to write owner, but only if nonexistent (i.e will happen at first put only)
        ownerDirectory.putNoOverwrite((Transaction) txn, key, new DatabaseEntry(Shorts.toByteArray(owner)));
    }
View Full Code Here

Examples of co.paralleluniverse.galaxy.server.MainMemoryEntry

    @Override
    public MainMemoryEntry read(long id) {
        final DatabaseEntry dbEntry = new DatabaseEntry();
        OperationStatus status = mainStore.get(null, new DatabaseEntry(Longs.toByteArray(id)), dbEntry, LockMode.READ_COMMITTED);
        if (status == OperationStatus.SUCCESS) {
            final MainMemoryEntry entry = entryBinding.entryToObject(dbEntry);
            return entry;
        } else
            return null;
    }
View Full Code Here

Examples of co.paralleluniverse.galaxy.server.MainMemoryEntry

        final DatabaseEntry value = new DatabaseEntry();
        final Cursor cursor = mainStore.openCursor(null, CursorConfig.DEFAULT);
        try {
            while (cursor.getNext(key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
                long id = Longs.fromByteArray(key.getData());
                final MainMemoryEntry entry = entryBinding.entryToObject(value);
                ps.println("Id : " + hex(id) + " version: " + entry.version + " data: (" + entry.data.length + " bytes).");
            }
        } finally {
            cursor.close();
        }
View Full Code Here

Examples of co.paralleluniverse.galaxy.server.MainMemoryEntry

            final long version = in.readLong();
            //final int dataLength = in.readUnsignedShort();
            final int dataLength = in.getBufferLength() - in.getBufferOffset();
            final byte[] data = new byte[dataLength];
            in.readFast(data);
            return new MainMemoryEntry(version, data);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.