Package com.hazelcast.nio

Examples of com.hazelcast.nio.Connection


        return send(packet, target, null);
    }

    private boolean send(Packet packet, Address target, SendTask sendTask) {
        ConnectionManager connectionManager = node.getConnectionManager();
        Connection connection = connectionManager.getConnection(target);
        if (connection != null) {
            return send(packet, connection);
        }

        if (sendTask == null) {
View Full Code Here


            endpoint.destroy();
        } catch (LoginException e) {
            LOGGER.warning(e);
        }

        final Connection connection = endpoint.getConnection();
        if (closeImmediately) {
            try {
                connection.close();
            } catch (Throwable e) {
                LOGGER.warning("While closing client connection: " + connection, e);
            }
        } else {
            nodeEngine.getExecutionService().schedule(new Runnable() {
                public void run() {
                    if (connection.live()) {
                        try {
                            connection.close();
                        } catch (Throwable e) {
                            LOGGER.warning("While closing client connection: " + e.toString());
                        }
                    }
                }
View Full Code Here

        final String memberUuid = clientEngine.getLocalMember().getUuid();
        for (ClientEndpoint clientEndpoint : clientEndpointManager.getEndpoints()) {
            if (clientEndpoint.isFirstConnection()) {
                continue;
            }
            final Connection connection = clientEndpoint.getConnection();
            final long lastTimePackageReceived = connection.lastReadTime();
            final long timeoutInMillis = TimeUnit.SECONDS.toMillis(heartbeatTimeoutSeconds);
            final long currentTimeInMillis = Clock.currentTimeMillis();
            if (lastTimePackageReceived + timeoutInMillis < currentTimeInMillis) {
                if (memberUuid.equals(clientEndpoint.getPrincipal().getOwnerUuid())) {
                    logger.log(Level.WARNING, "Client heartbeat is timed out , closing connection to " + connection);
                    connection.close();
                }
            }
        }
    }
View Full Code Here

            if (targetAddress.equals(node.getThisAddress()) || isLocalAddress(targetAddress)) {
                node.setAsMaster();
                return;
            }
            long joinStartTime = Clock.currentTimeMillis();
            Connection connection;
            while (node.isActive() && !node.joined() && (Clock.currentTimeMillis() - joinStartTime < maxJoinMillis)) {
                connection = node.connectionManager.getOrConnect(targetAddress);
                if (connection == null) {
                    //noinspection BusyWait
                    Thread.sleep(2000L);
View Full Code Here

                }
                if (logger.isFinestEnabled()) {
                    logger.finest("We are going to try to connect to each address" + colPossibleAddresses);
                }
                for (Address possibleAddress : colPossibleAddresses) {
                    final Connection conn = node.connectionManager.getOrConnect(possibleAddress);
                    if (conn != null) {
                        foundConnection = true;
                        if (logger.isFinestEnabled()) {
                            logger.finest("Found a connection and sending join request to " + possibleAddress);
                        }
View Full Code Here

                //noinspection BusyWait
                Thread.sleep(1500);
            } catch (InterruptedException e) {
                return;
            }
            final Connection conn = node.connectionManager.getConnection(possibleAddress);
            if (conn != null) {
                final JoinRequest response = node.clusterService.checkJoinInfo(possibleAddress);
                if (response != null && shouldMerge(response)) {
                    logger.warning(node.getThisAddress() + " is merging [tcp/ip] to " + possibleAddress);
                    setTargetAddress(possibleAddress);
View Full Code Here

        }
    }

    protected final boolean isValid() {
        final ClusterServiceImpl clusterService = getService();
        final Connection conn = getConnection();
        final Address masterAddress = conn != null ? conn.getEndPoint() : null;
        boolean isLocal = conn == null;
        return isLocal
                || (masterAddress != null && masterAddress.equals(clusterService.getMasterAddress()));
    }
View Full Code Here

        }
        return false;
    }

    private boolean checkAlreadyConnected(TcpIpConnection connection, Address remoteEndPoint) {
        final Connection existingConnection = connectionsMap.get(remoteEndPoint);
        if (existingConnection != null && existingConnection.live()) {
            if (existingConnection != connection) {
                if (logger.isFinestEnabled()) {
                    log(Level.FINEST, existingConnection + " is already bound to " + remoteEndPoint
                            + ", new one is " + connection);
                }
View Full Code Here

        return getOrConnect(address, false);
    }

    @Override
    public Connection getOrConnect(final Address address, final boolean silent) {
        Connection connection = connectionsMap.get(address);
        if (connection == null && live) {
            if (connectionsInProgress.add(address)) {
                ioService.shouldConnectTo(address);
                ioService.executeAsync(new SocketConnector(this, address, silent));
            }
View Full Code Here

        }
        activeConnections.remove(connection);
        final Address endPoint = connection.getEndPoint();
        if (endPoint != null) {
            connectionsInProgress.remove(endPoint);
            final Connection existingConn = connectionsMap.get(endPoint);
            if (existingConn == connection && live) {
                connectionsMap.remove(endPoint);
                ioService.getEventService().executeEventCallback(new StripedRunnable() {
                    @Override
                    public void run() {
View Full Code Here

TOP

Related Classes of com.hazelcast.nio.Connection

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.