Package com.hazelcast.nio

Examples of com.hazelcast.nio.BufferObjectDataInput


        if (portable == null) {
            throw new HazelcastSerializationException("Could not create Portable for class-id: " + dataClassId);
        }
        final DefaultPortableReader reader;
        final ClassDefinition cd;
        final BufferObjectDataInput bufferedIn = (BufferObjectDataInput) in;
        if (context.getVersion() == dataVersion) {
            cd = context.lookup(factoryId, dataClassId); // using context.version
            if (cd == null) {
                throw new HazelcastSerializationException("Could not find class-definition for " +
                        "factory-id: " + factoryId + ", class-id: " + dataClassId + ", version: " + dataVersion);
View Full Code Here


                return null;
            }
            try {
                final byte[] data = datagramPacketReceive.getData();
                final int offset = datagramPacketReceive.getOffset();
                final BufferObjectDataInput input = node.getSerializationService().createObjectDataInput(data);
                input.position(offset);

                final byte packetVersion = input.readByte();
                if (packetVersion != Packet.VERSION) {
                    logger.warning("Received a JoinRequest with a different packet version! This -> "
                            + Packet.VERSION + ", Incoming -> " + packetVersion
                            + ", Sender -> " + datagramPacketReceive.getAddress());
                    return null;
                }
                try {
                    return input.readObject();
                } finally {
                    input.close();
                }
            } catch (Exception e) {
                if (e instanceof EOFException || e instanceof HazelcastSerializationException) {
                    logger.warning("Received data format is invalid." +
                            " (An old version of Hazelcast may be running here.)", e);
View Full Code Here

        NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
        InternalPartitionServiceImpl partitionService = (InternalPartitionServiceImpl) nodeEngine.getPartitionService();
        SerializationService serializationService = nodeEngine.getSerializationService();
        int partitionId = getPartitionId();
        int replicaIndex = getReplicaIndex();
        BufferObjectDataInput in = null;
        try {
            if (data != null && data.length > 0) {
                logApplyReplicaSync(partitionId, replicaIndex);
                byte[] taskData = compressed ? IOUtil.decompress(data) : data;
                in = serializationService.createObjectDataInput(taskData);
                int size = in.readInt();
                for (int i = 0; i < size; i++) {
                    Operation op = (Operation) serializationService.readObject(in);
                    try {
                        ErrorLoggingResponseHandler responseHandler
                                = new ErrorLoggingResponseHandler(nodeEngine.getLogger(op.getClass()));
View Full Code Here

        partitionService.addActiveMigration(migrationInfo);
    }

    private void buildMigrationTasks() throws IOException {
        SerializationService serializationService = getNodeEngine().getSerializationService();
        BufferObjectDataInput in = serializationService.createObjectDataInput(toData());
        try {
            int size = in.readInt();
            tasks = new ArrayList<Operation>(size);
            for (int i = 0; i < size; i++) {
                Operation task = (Operation) serializationService.readObject(in);
                tasks.add(task);
            }
View Full Code Here

                return null;
            }
            try {
                final byte[] data = datagramPacketReceive.getData();
                final int offset = datagramPacketReceive.getOffset();
                final BufferObjectDataInput input = node.getSerializationService().createObjectDataInput(data);
                input.position(offset);

                final byte packetVersion = input.readByte();
                if (packetVersion != Packet.VERSION) {
                    logger.warning("Received a JoinRequest with a different packet version! This -> "
                            + Packet.VERSION + ", Incoming -> " + packetVersion
                            + ", Sender -> " + datagramPacketReceive.getAddress());
                    return null;
                }
                try {
                    return input.readObject();
                } finally {
                    input.close();
                }
            } catch (Exception e) {
                if (e instanceof EOFException || e instanceof HazelcastSerializationException) {
                    logger.warning("Received data format is invalid." +
                            " (An old version of Hazelcast may be running here.)", e);
View Full Code Here

        }
        return bytes;
    }

    public Object read(Data data) throws IOException {
        final BufferObjectDataInput in = service.createObjectDataInput(data);
        try {
            return serializer.read(in);
        } finally {
            IOUtil.closeResource(in);
        }
View Full Code Here

        out.writeData(data);
        byte[] bytes = out.toByteArray();
        byte[] header = ((PortableDataOutput) out).getPortableHeader();

        // emulate socket read by reading data from stream
        BufferObjectDataInput in = serializationService2.createObjectDataInput(new DefaultData(0, bytes, 0, header));
        data = in.readData();

        // read data
        Object object1 = serializationService2.toObject(data);

        // serialize new portable version
View Full Code Here

    public final PortableReader createPortableReader(Data data) throws IOException {
        if (!data.isPortable()) {
            throw new IllegalArgumentException();
        }
        BufferObjectDataInput in = createObjectDataInput(data);
        return portableSerializer.createReader(in);

    }
View Full Code Here

            service.push(out);
        }
    }

    public Object toObject(Data data) throws IOException {
        final BufferObjectDataInput in = service.createObjectDataInput(data);
        try {
            return serializer.read(in);
        } finally {
            IOUtil.closeResource(in);
        }
View Full Code Here

                return null;
            }
            try {
                final byte[] data = datagramPacketReceive.getData();
                final int offset = datagramPacketReceive.getOffset();
                final BufferObjectDataInput input = node.getSerializationService().createObjectDataInput(data);
                input.position(offset);

                final byte packetVersion = input.readByte();
                if (packetVersion != Packet.VERSION) {
                    logger.warning("Received a JoinRequest with a different packet version! This -> "
                            + Packet.VERSION + ", Incoming -> " + packetVersion
                            + ", Sender -> " + datagramPacketReceive.getAddress());
                    return null;
                }
                try {
                    return input.readObject();
                } finally {
                    input.close();
                }
            } catch (Exception e) {
                if (e instanceof EOFException || e instanceof HazelcastSerializationException) {
                    logger.warning("Received data format is invalid." +
                            " (An old version of Hazelcast may be running here.)", e);
View Full Code Here

TOP

Related Classes of com.hazelcast.nio.BufferObjectDataInput

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.