Package com.hazelcast.nio

Examples of com.hazelcast.nio.BufferObjectDataOutput


        if (p.getClassId() == 0) {
            throw new IllegalArgumentException("Portable class id cannot be zero!");
        }
        ClassDefinition cd = context.lookupOrRegisterClassDefinition(p);

        BufferObjectDataOutput bufferedOut = (BufferObjectDataOutput) out;
        DefaultPortableWriter writer = new DefaultPortableWriter(this, bufferedOut, cd);
        p.writePortable(writer);
        writer.end();
    }
View Full Code Here


        ClassDefinition createClassDefinition(byte[] compressedBinary) throws IOException {
            if (compressedBinary == null || compressedBinary.length == 0) {
                throw new IOException("Illegal class-definition binary! ");
            }
            final BufferObjectDataOutput out = serializationService.pop();
            final byte[] binary;
            try {
                decompress(compressedBinary, out);
                binary = out.toByteArray();
            } finally {
                serializationService.push(out);
            }
            final ClassDefinitionImpl cd = new ClassDefinitionImpl();
            cd.readData(serializationService.createObjectDataInput(binary));
View Full Code Here

            final ClassDefinitionImpl cdImpl = (ClassDefinitionImpl) cd;
            if (cdImpl.getVersion() < 0) {
                cdImpl.version = getVersion();
            }
            if (cdImpl.getBinary() == null) {
                final BufferObjectDataOutput out = serializationService.pop();
                try {
                    cdImpl.writeData(out);
                    final byte[] binary = out.toByteArray();
                    out.clear();
                    compress(binary, out);
                    cdImpl.setBinary(out.toByteArray());
                } catch (IOException e) {
                    throw new HazelcastSerializationException(e);
                } finally {
                    serializationService.push(out);
                }
View Full Code Here

    public void store(Long key, Data value) {
        if (enabled) {
            final Object actualValue;
            if (binary) {
                // WARNING: we can't pass original Data to the user
                BufferObjectDataOutput out = serializationService.createObjectDataOutput(value.totalSize());
                try {
                    value.writeData(out);
                    // buffer size is exactly equal to binary size, no need to copy array.
                    actualValue = out.getBuffer();
                } catch (IOException e) {
                    throw new HazelcastException(e);
                } finally {
                    IOUtil.closeResource(out);
                }
View Full Code Here

        if (enabled) {
            final Map<Long, Object> objectMap = new HashMap<Long, Object>(map.size());
            if (binary) {
                // WARNING: we can't pass original Data to the user
                // TODO: @mm - is there really an advantage of using binary storeAll? since we need to do array copy for each item.
                BufferObjectDataOutput out = serializationService.createObjectDataOutput(1024);
                try {
                    for (Map.Entry<Long, Data> entry : map.entrySet()) {
                        entry.getValue().writeData(out);
                        objectMap.put(entry.getKey(), out.toByteArray());
                        out.clear();
                    }
                } catch (IOException e) {
                    throw new HazelcastException(e);
                } finally {
                    IOUtil.closeResource(out);
View Full Code Here

        return null;
    }

    public void send(JoinMessage joinMessage) {
        if (!running) return;
        final BufferObjectDataOutput out = sendOutput;
        synchronized (sendLock) {
            try {
                out.writeByte(Packet.VERSION);
                out.writeObject(joinMessage);
                datagramPacketSend.setData(out.toByteArray());
                multicastSocket.send(datagramPacketSend);
                out.clear();
            } catch (IOException e) {
                logger.warning("You probably have too long Hazelcast configuration!", e);
            }
        }
    }
View Full Code Here

    private byte[] createReplicationData(List<Operation> tasks) throws IOException {
        byte[] data;
        NodeEngine nodeEngine = getNodeEngine();
        SerializationService serializationService = nodeEngine.getSerializationService();
        BufferObjectDataOutput out = serializationService.createObjectDataOutput(1024 * 32);
        try {
            out.writeInt(tasks.size());
            for (Operation task : tasks) {
                serializationService.writeObject(out, task);
            }
            data = out.toByteArray();
        } finally {
            closeResource(out);
        }
        return data;
    }
View Full Code Here

    private void spawnMigrationRequestTask(Address destination, long[] replicaVersions, Collection<Operation> tasks)
            throws IOException {
        NodeEngine nodeEngine = getNodeEngine();

        SerializationService serializationService = nodeEngine.getSerializationService();
        BufferObjectDataOutput out = createDataOutput(serializationService);

        out.writeInt(tasks.size());
        Iterator<Operation> iter = tasks.iterator();
        while (iter.hasNext()) {
            Operation task = iter.next();
            if (task instanceof NonThreadSafe) {
                serializationService.writeObject(out, task);
View Full Code Here

        }
        throw new HazelcastSerializationException(e);
    }

    BufferObjectDataOutput pop() {
        BufferObjectDataOutput out = outputPool.poll();
        if (out == null) {
            out = inputOutputFactory.createOutput(outputBufferSize, this);
        }
        return out;
    }
View Full Code Here

            cd.setBinary(compressedBinary);
            return register(cd);
        }

        private byte[] getClassDefBinary(byte[] compressedBinary) throws IOException {
            final BufferObjectDataOutput out = serializationService.pop();
            final byte[] binary;
            try {
                decompress(compressedBinary, out);
                binary = out.toByteArray();
            } finally {
                serializationService.push(out);
            }
            return binary;
        }
View Full Code Here

TOP

Related Classes of com.hazelcast.nio.BufferObjectDataOutput

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.