Package com.hazelcast.nio.serialization

Examples of com.hazelcast.nio.serialization.SerializationService


    @Override
    public Set query(String mapName, final Predicate predicate,
                     final IterationType iterationType, final boolean dataResult) {
        checkIfNotPagingPredicate(predicate);
        final NodeEngine nodeEngine = this.nodeEngine;
        final SerializationService serializationService = nodeEngine.getSerializationService();
        final Set<Integer> partitionIds = getAllPartitionIds(nodeEngine);
        final Set result = new QueryResultSet(serializationService, iterationType, dataResult);
        try {
            List<Future> futures = queryOnMembers(mapName, predicate, nodeEngine);
            addResultsOfPredicate(futures, result, partitionIds);
View Full Code Here


        assertEquals(0, queue.size());
    }

    private void fillQueue(WriteBehindQueue queue, int numberOfItems) {
        SerializationService ss1 = new DefaultSerializationServiceBuilder().build();
        final long storeTime = Clock.currentTimeMillis();
        for (int i = 0; i < numberOfItems; i++) {
            final DelayedEntry<Data, Object> e = DelayedEntry.createWithNullValue(ss1.toData(i), storeTime, i);
            queue.offer(e);
        }
    }
View Full Code Here

    protected void saveIndex(Record record) {
        Data dataKey = record.getKey();
        final IndexService indexService = mapContainer.getIndexService();
        if (indexService.hasIndex()) {
            SerializationService ss = mapServiceContext.getNodeEngine().getSerializationService();
            QueryableEntry queryableEntry = new QueryEntry(ss, dataKey, dataKey, record.getValue());
            indexService.saveEntryIndex(queryableEntry);
        }
    }
View Full Code Here

    }

    private Result processQueryEventFilter(EventFilter filter, EntryEventType eventType,
                                           final Data dataKey, Data dataOldValue, Data dataValue) {
        final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
        final SerializationService serializationService = nodeEngine.getSerializationService();
        Object testValue;
        if (eventType == EntryEventType.REMOVED || eventType == EntryEventType.EVICTED) {
            testValue = serializationService.toObject(dataOldValue);
        } else {
            testValue = serializationService.toObject(dataValue);
        }
        Object key = serializationService.toObject(dataKey);
        QueryEventFilter queryEventFilter = (QueryEventFilter) filter;
        QueryEntry entry = new QueryEntry(serializationService, dataKey, key, testValue);
        if (queryEventFilter.eval(entry)) {
            if (queryEventFilter.isIncludeValue()) {
                return Result.VALUE_INCLUDED;
View Full Code Here

     */
    public static <K, V> MapDataStore<K, V> createWriteBehindStore(MapContainer mapContainer, int partitionId,
                                                                   WriteBehindProcessor writeBehindProcessor) {
        final MapServiceContext mapServiceContext = mapContainer.getMapServiceContext();
        final MapStoreWrapper store = mapContainer.getStore();
        final SerializationService serializationService = mapServiceContext.getNodeEngine().getSerializationService();
        final int writeDelaySeconds = mapContainer.getMapConfig().getMapStoreConfig().getWriteDelaySeconds();
        final long writeDelayMillis = TimeUnit.SECONDS.toMillis(writeDelaySeconds);
        // TODO writeCoalescing should be configurable.
        boolean writeCoalescing = true;
        final WriteBehindStore mapDataStore
View Full Code Here

        }
    }

    private Object authenticate(ClientConnection connection, Credentials credentials, ClientPrincipal principal
            , boolean firstConnection) throws IOException {
        final SerializationService ss = getSerializationService();
        AuthenticationRequest auth = new AuthenticationRequest(credentials, principal);
        connection.init();
        auth.setOwnerConnection(firstConnection);
        //contains remoteAddress and principal
        SerializableCollection collectionWrapper;
        try {
            collectionWrapper = (SerializableCollection) sendAndReceive(auth, connection);
        } catch (Exception e) {
            throw new RetryableIOException(e);
        }
        final Iterator<Data> iter = collectionWrapper.iterator();
        if (iter.hasNext()) {
            final Data addressData = iter.next();
            final Address address = ss.toObject(addressData);
            connection.setRemoteEndpoint(address);
            if (iter.hasNext()) {
                final Data principalData = iter.next();
                return ss.toObject(principalData);
            }
        }
        throw new AuthenticationException();
    }
View Full Code Here

        throw new AuthenticationException();
    }

    @Override
    public Object sendAndReceive(ClientRequest request, ClientConnection connection) throws Exception {
        final SerializationService ss = client.getSerializationService();
        connection.write(ss.toData(request));
        final Data data = connection.read();
        ClientResponse clientResponse = ss.toObject(data);
        Object response = ss.toObject(clientResponse.getResponse());
        if (response instanceof Throwable) {
            Throwable t = (Throwable) response;
            ExceptionUtil.fixRemoteStackTrace(t, Thread.currentThread().getStackTrace());
            throw new Exception(t);
        }
View Full Code Here

    public Storage<DataRef> getNativeDataStorage() {
        throw new UnsupportedOperationException("Native memory feature is only available on Hazelcast Enterprise!");
    }

    public SerializationService createSerializationService() {
        SerializationService ss;
        try {
            Config config = node.getConfig();
            ClassLoader configClassLoader = node.getConfigClassLoader();

            HazelcastInstanceImpl hazelcastInstance = node.hazelcastInstance;
View Full Code Here

    }

    private void readPacket() {
        while (buffer.hasRemaining()) {
            if (packet == null) {
                final SerializationService ss = connection.getSerializationService();
                packet = new Packet(ss.getPortableContext());
            }
            boolean complete = packet.readFrom(buffer);
            if (complete) {
                packet.setConn(connection);
                connectionManager.handlePacket(packet);
View Full Code Here

    }

    private void sendInternal(ClientCallFuture future, ClientConnection connection, int partitionId) {
        connection.registerCallId(future);
        future.setConnection(connection);
        final SerializationService ss = client.getSerializationService();
        final ClientRequest request = future.getRequest();
        final Data data = ss.toData(request);
        Packet packet = new Packet(data, partitionId, ss.getPortableContext());
        if (!isAllowedToSendRequest(connection, request) || !connection.write(packet)) {
            final int callId = request.getCallId();
            connection.deRegisterCallId(callId);
            connection.deRegisterEventHandler(callId);
            future.notify(new TargetNotMemberException("Address : " + connection.getRemoteEndpoint()));
View Full Code Here

TOP

Related Classes of com.hazelcast.nio.serialization.SerializationService

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.