Package com.hazelcast.client.spi.impl

Examples of com.hazelcast.client.spi.impl.ClientInvocationServiceImpl


    final <T> T invoke(ClientRequest request) {
        if (request instanceof BaseTransactionRequest) {
            ((BaseTransactionRequest) request).setTxnId(proxy.getTxnId());
            ((BaseTransactionRequest) request).setClientThreadId(Thread.currentThread().getId());
        }
        final ClientInvocationServiceImpl invocationService = (ClientInvocationServiceImpl)proxy.getClient().getInvocationService();
        final SerializationService ss = proxy.getClient().getSerializationService();
        try {
            final Future f = invocationService.send(request, proxy.getConnection());
            return ss.toObject(f.get()) ;
        } catch (Exception e) {
            throw ExceptionUtil.rethrow(e);
        }
    }
View Full Code Here


            lb = new RoundRobinLB();
        }
        loadBalancer = lb;
        connectionManager = new ClientConnectionManagerImpl(this, loadBalancer);
        clusterService = new ClientClusterServiceImpl(this);
        invocationService = new ClientInvocationServiceImpl(this);
        userContext = new ConcurrentHashMap<String, Object>();
        proxyManager.init(config);
        partitionService = new ClientPartitionServiceImpl(this);
    }
View Full Code Here

    public static String listen(ClientContext context, ClientRequest request, Object key, EventHandler handler) {
        //TODO callback
        final Future future;
        try {
            final ClientInvocationServiceImpl invocationService =getClientInvocationService(context);

            if (key == null) {
                future = invocationService.invokeOnRandomTarget(request, handler);
            } else {
                future = invocationService.invokeOnKeyOwner(request, key, handler);
            }
            String registrationId = context.getSerializationService().toObject(future.get());
            invocationService.registerListener(registrationId, request.getCallId());
            return registrationId;
        } catch (Exception e) {
            throw ExceptionUtil.rethrow(e);
        }
    }
View Full Code Here

    }

    public static boolean stopListening(ClientContext context,
                                        BaseClientRemoveListenerRequest request, String registrationId) {
        try {
            ClientInvocationServiceImpl invocationService = getClientInvocationService(context);
            registrationId = invocationService.deRegisterListener(registrationId);
            if (registrationId == null) {
                return false;
            }
            request.setRegistrationId(registrationId);
            final Future<Boolean> future = invocationService.invokeOnRandomTarget(request);
            return (Boolean) context.getSerializationService().toObject(future.get());
        } catch (Exception e) {
            throw ExceptionUtil.rethrow(e);
        }
    }
View Full Code Here

        return null;
    }

    public Xid[] recover() {
        final SerializationService serializationService = client.getSerializationService();
        final ClientInvocationServiceImpl invocationService = (ClientInvocationServiceImpl) client.getInvocationService();
        final Xid[] empty = new Xid[0];
        try {
            final ClientConnection connection = connect();
            if (connection == null) {
                return empty;
            }
            final RecoverAllTransactionsRequest request = new RecoverAllTransactionsRequest();
            final ICompletableFuture<SerializableCollection> future = invocationService.send(request, connection);
            final SerializableCollection collectionWrapper = serializationService.toObject(future.get());

            for (Data data : collectionWrapper) {
                final SerializableXID xid = serializationService.toObject(data);
                recoveredTransactions.put(xid, connection);
View Full Code Here

                xid.getGlobalTransactionId(), xid.getBranchQualifier());
        final ClientConnection connection = recoveredTransactions.remove(sXid);
        if (connection == null) {
            return false;
        }
        final ClientInvocationServiceImpl invocationService = (ClientInvocationServiceImpl) client.getInvocationService();
        final RecoverTransactionRequest request = new RecoverTransactionRequest(sXid, commit);
        try {
            final ICompletableFuture future = invocationService.send(request, connection);
            future.get();
        } catch (Exception e) {
            ExceptionUtil.rethrow(e);
        }
        return true;
View Full Code Here

        if (request instanceof BaseTransactionRequest) {
            ((BaseTransactionRequest) request).setTxnId(txnId);
            ((BaseTransactionRequest) request).setClientThreadId(threadId);
        }
        final SerializationService ss = client.getSerializationService();
        final ClientInvocationServiceImpl invocationService = (ClientInvocationServiceImpl)client.getInvocationService();
        try {
            final Future f = invocationService.send(request, connection);
            return ss.toObject(f.get()) ;
        } catch (Exception e) {
            throw ExceptionUtil.rethrow(e);
        }
    }
View Full Code Here

        if (request instanceof BaseTransactionRequest) {
            ((BaseTransactionRequest) request).setTxnId(txnId);
            ((BaseTransactionRequest) request).setClientThreadId(threadId);
        }
        final SerializationService ss = client.getSerializationService();
        final ClientInvocationServiceImpl invocationService = (ClientInvocationServiceImpl) client.getInvocationService();
        try {
            final Future f = invocationService.send(request, connection);
            return ss.toObject(f.get());
        } catch (Exception e) {
            throw ExceptionUtil.rethrow(e);
        }
    }
View Full Code Here

        return null;
    }

    public Xid[] recover() {
        final SerializationService serializationService = client.getSerializationService();
        final ClientInvocationServiceImpl invocationService = (ClientInvocationServiceImpl) client.getInvocationService();
        final Xid[] empty = new Xid[0];
        try {
            final ClientConnection connection = connect();
            if (connection == null) {
                return empty;
            }
            final RecoverAllTransactionsRequest request = new RecoverAllTransactionsRequest();
            final ICompletableFuture<SerializableCollection> future = invocationService.send(request, connection);
            final SerializableCollection collectionWrapper = serializationService.toObject(future.get());

            for (Data data : collectionWrapper) {
                final SerializableXID xid = serializationService.toObject(data);
                recoveredTransactions.put(xid, connection);
View Full Code Here

                xid.getGlobalTransactionId(), xid.getBranchQualifier());
        final ClientConnection connection = recoveredTransactions.remove(sXid);
        if (connection == null) {
            return false;
        }
        final ClientInvocationServiceImpl invocationService = (ClientInvocationServiceImpl) client.getInvocationService();
        final RecoverTransactionRequest request = new RecoverTransactionRequest(sXid, commit);
        try {
            final ICompletableFuture future = invocationService.send(request, connection);
            future.get();
        } catch (Exception e) {
            ExceptionUtil.rethrow(e);
        }
        return true;
View Full Code Here

TOP

Related Classes of com.hazelcast.client.spi.impl.ClientInvocationServiceImpl

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.