Package com.hazelcast.nio

Examples of com.hazelcast.nio.BufferObjectDataOutput


        return serializer.read(in);
    }

    @SuppressWarnings("unchecked")
    public Data toData(Object object, int partitionHash) throws IOException {
        final BufferObjectDataOutput out = service.pop();
        try {
            serializer.write(out, object);
            byte[] header = null;
            if (out instanceof PortableDataOutput) {
                header = ((PortableDataOutput) out).getPortableHeader();
            }
            return new DefaultData(serializer.getTypeId(), out.toByteArray(), partitionHash, header);
        } finally {
            service.push(out);
        }
    }
View Full Code Here


        }
        final Object actualValue;
        if (binary) {
            // WARNING: we can't pass original Data to the user
            int size = QuickMath.normalize(value.dataSize(), BUFFER_SIZE_FACTOR);
            BufferObjectDataOutput out = serializationService.createObjectDataOutput(size);
            try {
                out.writeData(value);
                actualValue = out.toByteArray();
            } catch (IOException e) {
                throw new HazelcastException(e);
            } finally {
                IOUtil.closeResource(out);
            }
View Full Code Here

        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(OUTPUT_SIZE);
            try {
                for (Map.Entry<Long, Data> entry : map.entrySet()) {
                    out.writeData(entry.getValue());
                    objectMap.put(entry.getKey(), out.toByteArray());
                    out.clear();
                }
            } catch (IOException e) {
                throw new HazelcastException(e);
            } finally {
                IOUtil.closeResource(out);
View Full Code Here

                }
            }
        }

        private byte[] toClassDefinitionBinary(ClassDefinition cd) throws IOException {
            BufferObjectDataOutput out = serializationService.pop();
            try {
                writeClassDefinition(cd, out);
                byte[] binary = out.toByteArray();
                out.clear();
                compress(binary, out);
                return out.toByteArray();
            } finally {
                serializationService.push(out);
            }
        }
View Full Code Here

            if (compressedBinary == null || compressedBinary.length == 0) {
                throw new IOException("Illegal class-definition binary! ");
            }

            BufferObjectDataOutput out = serializationService.pop();
            byte[] binary;
            try {
                decompress(compressedBinary, out);
                binary = out.toByteArray();
            } finally {
                serializationService.push(out);
            }

            ClassDefinitionImpl cd = readClassDefinition(serializationService.createObjectDataInput(binary));
View Full Code Here

    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

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.