ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [07/31] incubator-ignite git commit: #ignite-128: WIP.
Date Tue, 03 Feb 2015 14:18:34 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioListenerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioListenerAdapter.java b/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioListenerAdapter.java
deleted file mode 100644
index 805bded..0000000
--- a/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioListenerAdapter.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.client.router.impl;
-
-import org.apache.ignite.*;
-import org.apache.ignite.client.marshaller.*;
-import org.apache.ignite.client.marshaller.jdk.*;
-import org.apache.ignite.client.marshaller.optimized.*;
-import org.apache.ignite.internal.client.*;
-import org.apache.ignite.internal.processors.rest.client.message.*;
-import org.apache.ignite.internal.util.nio.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-
-import static org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.*;
-
-/**
- * Nio listener for the router. Extracts necessary meta information from messages
- * and delegates their delivery to underlying client.
- */
-abstract class GridTcpRouterNioListenerAdapter implements GridNioServerListener<GridClientMessage> {
-    /** Supported protocol versions. */
-    private static final Collection<Short> SUPP_VERS = new HashSet<>();
-
-    /**
-     */
-    static {
-        SUPP_VERS.add((short)1);
-    }
-
-    /** Logger. */
-    private final IgniteLogger log;
-
-    /** Client for grid access. */
-    private final GridRouterClientImpl client;
-
-    /** Marshallers map. */
-    protected final Map<Byte, GridClientMarshaller> marshMap;
-
-    /**
-     * @param log Logger.
-     * @param client Client for grid access.
-     */
-    @SuppressWarnings({"AbstractMethodCallInConstructor", "OverriddenMethodCallDuringObjectConstruction"})
-    GridTcpRouterNioListenerAdapter(IgniteLogger log, GridRouterClientImpl client) {
-        this.log = log;
-        this.client = client;
-
-        marshMap = new HashMap<>();
-
-        marshMap.put(GridClientOptimizedMarshaller.ID, new GridClientOptimizedMarshaller());
-        marshMap.put(GridClientJdkMarshaller.ID, new GridClientJdkMarshaller());
-
-        init();
-    }
-
-    /**
-     */
-    protected abstract void init();
-
-    /** {@inheritDoc} */
-    @Override public void onConnected(GridNioSession ses) {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onDisconnected(GridNioSession ses, @Nullable Exception e) {
-        if (e != null) {
-            if (e instanceof RuntimeException)
-                U.error(log, "Failed to process request from remote client: " + ses, e);
-            else
-                U.warn(log, "Closed client session due to exception [ses=" + ses + ", err=" + e.getMessage() + ']');
-        }
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("TypeMayBeWeakened")
-    @Override public void onMessage(final GridNioSession ses, final GridClientMessage msg) {
-        if (msg instanceof GridRouterRequest) {
-            GridRouterRequest routerMsg = (GridRouterRequest)msg;
-
-            final UUID clientId = routerMsg.clientId();
-            final long reqId = routerMsg.requestId();
-
-            try {
-                client.forwardMessage(routerMsg, routerMsg.destinationId(), ses.<Byte>meta(MARSHALLER_ID.ordinal()))
-                    .listenAsync(new GridClientFutureListener() {
-                        @Override public void onDone(GridClientFuture fut) {
-                            try {
-                                GridRouterResponse res = (GridRouterResponse)fut.get();
-                                // Restoring original request id, because it was overwritten by the client.
-                                res.requestId(reqId);
-
-                                ses.send(res);
-                            }
-                            catch (GridClientException e) {
-                                ses.send(makeFailureResponse(e, clientId, reqId));
-                            }
-                        }
-                    });
-            }
-            catch (GridClientException e) {
-                ses.send(makeFailureResponse(e, clientId, reqId));
-            }
-            catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
-
-                U.warn(
-                    log,
-                    "Message forwarding was interrupted (will ignore last message): " + e.getMessage(),
-                    "Message forwarding was interrupted.");
-            }
-        }
-        else if (msg instanceof GridClientHandshakeRequest) {
-            GridClientHandshakeRequest hs = (GridClientHandshakeRequest)msg;
-
-            short ver = hs.version();
-
-            if (!SUPP_VERS.contains(ver)) {
-                U.error(log, "Client protocol version is not supported [ses=" + ses +
-                    ", ver=" + ver +
-                    ", supported=" + SUPP_VERS + ']');
-
-                ses.close();
-            }
-            else {
-                byte marshId = hs.marshallerId();
-
-                GridClientMarshaller marsh = marshMap.get(marshId);
-
-                if (marsh == null) {
-                    U.error(log, "Client marshaller ID is invalid. Note that .NET and C++ clients " +
-                        "are supported only in enterprise edition [ses=" + ses + ", marshId=" + marshId + ']');
-
-                    ses.close();
-                }
-                else {
-                    ses.addMeta(MARSHALLER_ID.ordinal(), marshId);
-                    ses.addMeta(MARSHALLER.ordinal(), marsh);
-
-                    ses.send(GridClientHandshakeResponse.OK);
-                }
-            }
-        }
-        else if (msg instanceof GridClientPingPacket)
-            ses.send(GridClientPingPacket.PING_MESSAGE);
-        else
-            throw new IllegalArgumentException("Unsupported input message: " + msg);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onSessionWriteTimeout(GridNioSession ses) {
-        U.warn(log, "Closing NIO session because of write timeout.");
-
-        ses.close();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onSessionIdleTimeout(GridNioSession ses) {
-        U.warn(log, "Closing NIO session because of idle.");
-
-        ses.close();
-    }
-
-    /**
-     * Creates a failure response, based on the given exception.
-     *
-     * @param e Exception to extract failure report from.
-     * @param clientId Client id.
-     * @param reqId Request id.
-     * @return Failure response.
-     */
-    private GridClientResponse makeFailureResponse(GridClientException e, UUID clientId, Long reqId) {
-        U.error(log, "Failed to process message on router.", e);
-
-        GridClientResponse res = new GridClientResponse();
-
-        res.clientId(clientId);
-        res.requestId(reqId);
-        res.successStatus(GridClientResponse.STATUS_FAILED);
-        res.errorMessage("Failed to process message on router " +
-            "[exception=" + e.getClass().getSimpleName() + ", message=" + e.getMessage() + ']');
-
-        return res;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioListenerOsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioListenerOsImpl.java b/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioListenerOsImpl.java
deleted file mode 100644
index d27ac55..0000000
--- a/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioListenerOsImpl.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.client.router.impl;
-
-import org.apache.ignite.*;
-
-/**
- * Router NIO listener.
- */
-class GridTcpRouterNioListenerOsImpl extends GridTcpRouterNioListenerAdapter {
-    /**
-     * @param log Logger.
-     * @param client Client for grid access.
-     */
-    GridTcpRouterNioListenerOsImpl(IgniteLogger log, GridRouterClientImpl client) {
-        super(log, client);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void init() {
-        // No-op.
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioParser.java b/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioParser.java
deleted file mode 100644
index 231b0f5..0000000
--- a/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioParser.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.client.router.impl;
-
-import org.apache.ignite.*;
-import org.apache.ignite.client.marshaller.*;
-import org.apache.ignite.internal.processors.rest.client.message.*;
-import org.apache.ignite.internal.processors.rest.protocols.tcp.*;
-import org.apache.ignite.internal.util.nio.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-
-import java.io.*;
-import java.nio.*;
-
-import static org.apache.ignite.internal.processors.rest.protocols.tcp.GridMemcachedMessage.*;
-
-/**
- *
- */
-class GridTcpRouterNioParser extends GridTcpRestParser {
-    /** Number of received messages. */
-    private volatile long rcvCnt;
-
-    /** Number of sent messages. */
-    private volatile long sndCnt;
-
-    /** {@inheritDoc} */
-    @Override protected GridClientMessage parseClientMessage(GridNioSession ses, ParserState state) {
-        rcvCnt++;
-
-        return new GridRouterRequest(
-            state.buffer().toByteArray(),
-            state.header().reqId(),
-            state.header().clientId(),
-            state.header().destinationId());
-    }
-
-    /** {@inheritDoc} */
-    @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException {
-        sndCnt++;
-
-        if (msg instanceof GridRouterResponse) {
-            GridRouterResponse resp = (GridRouterResponse)msg;
-
-            ByteBuffer res = ByteBuffer.allocate(resp.body().length + 45);
-
-            res.put(IGNITE_REQ_FLAG);
-            res.putInt(resp.body().length + 40);
-            res.putLong(resp.requestId());
-            res.put(U.uuidToBytes(resp.clientId()));
-            res.put(U.uuidToBytes(resp.destinationId()));
-            res.put(resp.body());
-
-            res.flip();
-
-            return res;
-        }
-        else if (msg instanceof GridClientResponse) {
-            GridClientMarshaller marsh = marshaller(ses);
-
-            GridClientMessage clientMsg = (GridClientMessage)msg;
-
-            ByteBuffer res = marsh.marshal(msg, 45);
-
-            ByteBuffer slice = res.slice();
-
-            slice.put(IGNITE_REQ_FLAG);
-            slice.putInt(res.remaining() - 5);
-            slice.putLong(clientMsg.requestId());
-            slice.put(U.uuidToBytes(clientMsg.clientId()));
-            slice.put(U.uuidToBytes(clientMsg.destinationId()));
-
-            return res;
-        }
-        else if (msg instanceof GridClientPingPacket || msg instanceof GridClientHandshakeResponse)
-            return super.encode(ses, msg);
-        else
-            throw new IgniteCheckedException("Unsupported message: " + msg);
-    }
-
-    /**
-     * @return Number of received messages.
-     */
-    public long getReceivedCount() {
-        return rcvCnt;
-    }
-
-    /**
-     * @return Number of sent messages.
-     */
-    public long getSendCount() {
-        return sndCnt;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/client/ssl/GridSslBasicContextFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/client/ssl/GridSslBasicContextFactory.java b/modules/core/src/main/java/org/apache/ignite/client/ssl/GridSslBasicContextFactory.java
deleted file mode 100644
index b01ec2e..0000000
--- a/modules/core/src/main/java/org/apache/ignite/client/ssl/GridSslBasicContextFactory.java
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.client.ssl;
-
-import org.apache.ignite.internal.util.typedef.internal.*;
-
-import javax.net.ssl.*;
-import java.io.*;
-import java.security.*;
-import java.security.cert.*;
-import java.util.*;
-
-/**
- * Basic ssl context factory that provides ssl context configuration with specified key
- * and trust stores.
- * <p>
- * In some cases it is useful to disable certificate validation of client side (e.g. when connecting
- * to a server with self-signed certificate). This can be achieved by setting a disabled trust manager
- * to this factory, which can be obtained by {@link #getDisabledTrustManager()} method:
- * <pre>
- *     GridSslBasicContextFactory factory = new GridSslBasicContextFactory();
- *     factory.setTrustManagers(GridSslBasicContextFactory.getDisabledTrustManager());
- *     // Rest of initialization.
- * </pre>
- */
-public class GridSslBasicContextFactory implements GridSslContextFactory {
-    /** Default key store type. */
-    public static final String DFLT_STORE_TYPE = "JKS";
-
-    /** Default SSL protocol. */
-    public static final String DFLT_SSL_PROTOCOL = "TLS";
-
-    /** Default key manager algorithm. */
-    public static final String DFLT_KEY_ALGORITHM = "SunX509";
-
-    /** SSL protocol. */
-    private String proto = DFLT_SSL_PROTOCOL;
-
-    /** Key manager algorithm. */
-    private String keyAlgorithm = DFLT_KEY_ALGORITHM;
-
-    /** Key store type. */
-    private String keyStoreType = DFLT_STORE_TYPE;
-
-    /** Path to key store file */
-    private String keyStoreFilePath;
-
-    /** Key store password */
-    private char[] keyStorePwd;
-
-    /** Trust store type. */
-    private String trustStoreType = DFLT_STORE_TYPE;
-
-    /** Path to trust store. */
-    private String trustStoreFilePath;
-
-    /** Trust store password */
-    private char[] trustStorePwd;
-
-    /** Trust managers. */
-    private TrustManager[] trustMgrs;
-
-    /**
-     * Gets key store type used for context creation.
-     *
-     * @return Key store type.
-     */
-    public String getKeyStoreType() {
-        return keyStoreType;
-    }
-
-    /**
-     * Sets key store type used in context initialization. If not provided, {@link #DFLT_STORE_TYPE} will
-     * be used.
-     *
-     * @param keyStoreType Key store type.
-     */
-    public void setKeyStoreType(String keyStoreType) {
-        A.notNull(keyStoreType, "keyStoreType");
-
-        this.keyStoreType = keyStoreType;
-    }
-
-    /**
-     * Gets trust store type used for context creation.
-     *
-     * @return trust store type.
-     */
-    public String getTrustStoreType() {
-        return trustStoreType;
-    }
-
-    /**
-     * Sets trust store type used in context initialization. If not provided, {@link #DFLT_STORE_TYPE} will
-     * be used.
-     *
-     * @param trustStoreType Trust store type.
-     */
-    public void setTrustStoreType(String trustStoreType) {
-        A.notNull(trustStoreType, "trustStoreType");
-
-        this.trustStoreType = trustStoreType;
-    }
-
-    /**
-     * Gets protocol for secure transport.
-     *
-     * @return SSL protocol name.
-     */
-    public String getProtocol() {
-        return proto;
-    }
-
-    /**
-     * Sets protocol for secure transport. If not specified, {@link #DFLT_SSL_PROTOCOL} will be used.
-     *
-     * @param proto SSL protocol name.
-     */
-    public void setProtocol(String proto) {
-        A.notNull(proto, "proto");
-
-        this.proto = proto;
-    }
-
-    /**
-     * Gets algorithm that will be used to create a key manager. If not specified, {@link #DFLT_KEY_ALGORITHM}
-     * will be used.
-     *
-     * @return Key manager algorithm.
-     */
-    public String getKeyAlgorithm() {
-        return keyAlgorithm;
-    }
-
-    /**
-     * Sets key manager algorithm that will be used to create a key manager. Notice that in most cased default value
-     * suites well, however, on Android platform this value need to be set to <tt>X509<tt/>.
-     *
-     * @param keyAlgorithm Key algorithm name.
-     */
-    public void setKeyAlgorithm(String keyAlgorithm) {
-        A.notNull(keyAlgorithm, "keyAlgorithm");
-
-        this.keyAlgorithm = keyAlgorithm;
-    }
-
-    /**
-     * Gets path to the key store file.
-     *
-     * @return Path to key store file.
-     */
-    public String getKeyStoreFilePath() {
-        return keyStoreFilePath;
-    }
-
-    /**
-     * Sets path to the key store file. This is a mandatory parameter since
-     * ssl context could not be initialized without key manager.
-     *
-     * @param keyStoreFilePath Path to key store file.
-     */
-    public void setKeyStoreFilePath(String keyStoreFilePath) {
-        A.notNull(keyStoreFilePath, "keyStoreFilePath");
-
-        this.keyStoreFilePath = keyStoreFilePath;
-    }
-
-    /**
-     * Gets key store password.
-     *
-     * @return Key store password.
-     */
-    public char[] getKeyStorePassword() {
-        return keyStorePwd;
-    }
-
-    /**
-     * Sets key store password.
-     *
-     * @param keyStorePwd Key store password.
-     */
-    public void setKeyStorePassword(char[] keyStorePwd) {
-        A.notNull(keyStorePwd, "keyStorePwd");
-
-        this.keyStorePwd = keyStorePwd;
-    }
-
-    /**
-     * Gets path to the trust store file.
-     *
-     * @return Path to the trust store file.
-     */
-    public String getTrustStoreFilePath() {
-        return trustStoreFilePath;
-    }
-
-    /**
-     * Sets path to the trust store file. This is an optional parameter,
-     * however one of the {@code setTrustStoreFilePath(String)}, {@link #setTrustManagers(TrustManager[])}
-     * properties must be set.
-     *
-     * @param trustStoreFilePath Path to the trust store file.
-     */
-    public void setTrustStoreFilePath(String trustStoreFilePath) {
-        this.trustStoreFilePath = trustStoreFilePath;
-    }
-
-    /**
-     * Gets trust store password.
-     *
-     * @return Trust store password.
-     */
-    public char[] getTrustStorePassword() {
-        return trustStorePwd;
-    }
-
-    /**
-     * Sets trust store password.
-     *
-     * @param trustStorePwd Trust store password.
-     */
-    public void setTrustStorePassword(char[] trustStorePwd) {
-        this.trustStorePwd = trustStorePwd;
-    }
-
-    /**
-     * Gets pre-configured trust managers.
-     *
-     * @return Trust managers.
-     */
-    public TrustManager[] getTrustManagers() {
-        return trustMgrs;
-    }
-
-    /**
-     * Sets pre-configured trust managers. This is an optional parameter,
-     * however one of the {@link #setTrustStoreFilePath(String)}, {@code #setTrustManagers(TrustManager[])}
-     *
-     * @param trustMgrs Pre-configured trust managers.
-     */
-    public void setTrustManagers(TrustManager... trustMgrs) {
-        this.trustMgrs = trustMgrs;
-    }
-
-    /**
-     * Returns an instance of trust manager that will always succeed regardless of certificate provided.
-     *
-     * @return Trust manager instance.
-     */
-    public static TrustManager getDisabledTrustManager() {
-        return new DisabledX509TrustManager();
-    }
-
-    /** {@inheritDoc} */
-    @Override public SSLContext createSslContext() throws SSLException {
-        checkParameters();
-
-        try {
-            KeyManagerFactory keyMgrFactory = KeyManagerFactory.getInstance(keyAlgorithm);
-
-            KeyStore keyStore = loadKeyStore(keyStoreType, keyStoreFilePath, keyStorePwd);
-
-            keyMgrFactory.init(keyStore, keyStorePwd);
-
-            TrustManager[] mgrs = trustMgrs;
-
-            if (mgrs == null) {
-                TrustManagerFactory trustMgrFactory = TrustManagerFactory.getInstance(keyAlgorithm);
-
-                KeyStore trustStore = loadKeyStore(trustStoreType, trustStoreFilePath, trustStorePwd);
-
-                trustMgrFactory.init(trustStore);
-
-                mgrs = trustMgrFactory.getTrustManagers();
-            }
-
-            SSLContext ctx = SSLContext.getInstance(proto);
-
-            ctx.init(keyMgrFactory.getKeyManagers(), mgrs, null);
-
-            return ctx;
-        }
-        catch (GeneralSecurityException e) {
-            throw new SSLException("Failed to initialize SSL context " + parameters(), e);
-        }
-    }
-
-    /**
-     * Builds human-readable string with factory parameters.
-     *
-     * @return Parameters string.
-     */
-    private String parameters() {
-        StringBuilder buf = new StringBuilder("[keyStoreType=").append(keyStoreType);
-
-        buf.append(", proto=").append(proto).append(", keyStoreFile=").append(keyStoreFilePath);
-
-        if (trustMgrs != null)
-            buf.append(", trustMgrs=").append(Arrays.toString(trustMgrs));
-        else
-            buf.append(", trustStoreFile=").append(trustStoreFilePath);
-
-        buf.append(']');
-
-        return buf.toString();
-    }
-
-    /**
-     * Checks that all required parameters are set.
-     *
-     * @throws SSLException If any of required parameters is missing.
-     */
-    private void checkParameters() throws SSLException {
-        assert keyStoreType != null;
-        assert proto != null;
-
-        checkNullParameter(keyStoreFilePath, "keyStoreFilePath");
-        checkNullParameter(keyStorePwd, "keyStorePwd");
-
-        if (trustMgrs == null) {
-            if (trustStoreFilePath == null)
-                throw new SSLException("Failed to initialize SSL context (either trustStoreFilePath or " +
-                    "trustManagers must be provided)");
-            else
-                checkNullParameter(trustStorePwd, "trustStorePwd");
-        }
-    }
-
-    /**
-     * @param param Value.
-     * @param name Name.
-     * @throws SSLException If {@code null}.
-     */
-    private void checkNullParameter(Object param, String name) throws SSLException {
-        if (param == null)
-            throw new SSLException("Failed to initialize SSL context (parameter cannot be null): " + name);
-    }
-
-    /**
-     * By default, this method simply opens a raw file input stream. Subclasses may override this method
-     * if some specific location should be handled (this may be a case for Android users).
-     *
-     * @param filePath Path to the file.
-     * @return Opened input stream.
-     * @throws IOException If stream could not be opened.
-     */
-    protected InputStream openFileInputStream(String filePath) throws IOException {
-        return new FileInputStream(filePath);
-    }
-
-    /**
-     * Loads key store with configured parameters.
-     *
-     * @param keyStoreType Type of key store.
-     * @param storeFilePath Path to key store file.
-     * @param keyStorePwd Store password.
-     * @return Initialized key store.
-     * @throws SSLException If key store could not be initialized.
-     */
-    private KeyStore loadKeyStore(String keyStoreType, String storeFilePath, char[] keyStorePwd) throws SSLException {
-        InputStream input = null;
-
-        try {
-            KeyStore keyStore = KeyStore.getInstance(keyStoreType);
-
-            input = openFileInputStream(storeFilePath);
-
-            keyStore.load(input, keyStorePwd);
-
-            return keyStore;
-        }
-        catch (GeneralSecurityException e) {
-            throw new SSLException("Failed to initialize key store (security exception occurred) [type=" +
-                keyStoreType + ", keyStorePath=" + storeFilePath + ']', e);
-        }
-        catch (FileNotFoundException e) {
-            throw new SSLException("Failed to initialize key store (key store file was not found): [path=" +
-                storeFilePath + ", msg=" + e.getMessage() + ']');
-        }
-        catch (IOException e) {
-            throw new SSLException("Failed to initialize key store (I/O error occurred): " + storeFilePath, e);
-        }
-        finally {
-            if (input != null) {
-                try {
-                    input.close();
-                }
-                catch (IOException ignored) {
-                }
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    public String toString() {
-        return getClass().getSimpleName() + parameters();
-    }
-
-    /**
-     * Disabled trust manager, will skip all certificate checks.
-     */
-    private static class DisabledX509TrustManager implements X509TrustManager {
-        /** Empty certificate array. */
-        private static final X509Certificate[] CERTS = new X509Certificate[0];
-
-        /** {@inheritDoc} */
-        @Override public void checkClientTrusted(X509Certificate[] x509Certificates, String s)
-            throws CertificateException {
-            // No-op, all clients are trusted.
-        }
-
-        /** {@inheritDoc} */
-        @Override public void checkServerTrusted(X509Certificate[] x509Certificates, String s)
-            throws CertificateException {
-            // No-op, all servers are trusted.
-        }
-
-        /** {@inheritDoc} */
-        @Override public X509Certificate[] getAcceptedIssuers() {
-            return CERTS;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/client/ssl/GridSslContextFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/client/ssl/GridSslContextFactory.java b/modules/core/src/main/java/org/apache/ignite/client/ssl/GridSslContextFactory.java
deleted file mode 100644
index d226d01..0000000
--- a/modules/core/src/main/java/org/apache/ignite/client/ssl/GridSslContextFactory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.client.ssl;
-
-import javax.net.ssl.*;
-
-/**
- * This interface provides creation of SSL context both for server and client use.
- * <p>
- * Usually, it is enough to configure context from a particular key and trust stores, this functionality is provided
- * in {@link GridSslBasicContextFactory}.
- */
-public interface GridSslContextFactory {
-    /**
-     * Creates SSL context based on factory settings.
-     *
-     * @return Initialized SSL context.
-     * @throws SSLException If SSL context could not be created.
-     */
-    public SSLContext createSslContext() throws SSLException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/client/util/GridClientConsistentHash.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/client/util/GridClientConsistentHash.java b/modules/core/src/main/java/org/apache/ignite/client/util/GridClientConsistentHash.java
deleted file mode 100644
index 03ad5b3..0000000
--- a/modules/core/src/main/java/org/apache/ignite/client/util/GridClientConsistentHash.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.client.util;
-
-import org.apache.ignite.internal.client.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-import java.util.concurrent.locks.*;
-
-/**
- * Controls key to node affinity using consistent hash algorithm. This class is thread-safe
- * and does not have to be externally synchronized.
- * <p>
- * For a good explanation of what consistent hashing is, you can refer to
- * <a href="http://weblogs.java.net/blog/tomwhite/archive/2007/11/consistent_hash.html">Tom White's Blog</a>.
- */
-@SuppressWarnings("NullableProblems")
-public class GridClientConsistentHash<N> {
-    /** Prime number. */
-    private static final int PRIME = 15485857;
-
-    /** Random generator. */
-    private static final Random RAND = new Random();
-
-    /** Affinity seed. */
-    private final Object affSeed;
-
-    /** Map of hash assignments. */
-    private final NavigableMap<Integer, SortedSet<N>> circle = new TreeMap<>();
-
-    /** Read/write lock. */
-    private final ReadWriteLock rw = new ReentrantReadWriteLock();
-
-    /** Distinct nodes in the hash. */
-    private Collection<N> nodes = new HashSet<>();
-
-    /** Nodes comparator to resolve hash codes collisions. */
-    private Comparator<N> nodesComp;
-
-    /**
-     * Constructs consistent hash using empty affinity seed and {@code MD5} hasher function.
-     */
-    public GridClientConsistentHash() {
-        this(null, null);
-    }
-
-    /**
-     * Constructs consistent hash using given affinity seed and {@code MD5} hasher function.
-     *
-     * @param affSeed Affinity seed (will be used as key prefix for hashing).
-     */
-    public GridClientConsistentHash(Object affSeed) {
-        this(null, affSeed);
-    }
-
-    /**
-     * Constructs consistent hash using given affinity seed and hasher function.
-     *
-     * @param nodesComp Nodes comparator to resolve hash codes collisions.
-     *  If {@code null} natural order will be used.
-     * @param affSeed Affinity seed (will be used as key prefix for hashing).
-     */
-    public GridClientConsistentHash(Comparator<N> nodesComp, Object affSeed) {
-        this.nodesComp = nodesComp;
-        this.affSeed = affSeed == null ? new Integer(PRIME) : affSeed;
-    }
-
-    /**
-     * Adds nodes to consistent hash algorithm (if nodes are {@code null} or empty, then no-op).
-     *
-     * @param nodes Nodes to add.
-     * @param replicas Number of replicas for every node.
-     */
-    public void addNodes(Collection<N> nodes, int replicas) {
-        if (nodes == null || nodes.isEmpty())
-            return;
-
-        rw.writeLock().lock();
-
-        try {
-            for (N node : nodes)
-                addNode(node, replicas);
-        }
-        finally {
-            rw.writeLock().unlock();
-        }
-    }
-
-    /**
-     * Adds a node to consistent hash algorithm.
-     *
-     * @param node New node (if {@code null} then no-op).
-     * @param replicas Number of replicas for the node.
-     * @return {@code True} if node was added, {@code false} if it is {@code null} or
-     *      is already contained in the hash.
-     */
-    public boolean addNode(N node, int replicas) {
-        if (node == null)
-            return false;
-
-        long seed = affSeed.hashCode() * 31 + hash(node);
-
-        rw.writeLock().lock();
-
-        try {
-            if (!nodes.add(node))
-                return false;
-
-            int hash = hash(seed);
-
-            SortedSet<N> set = circle.get(hash);
-
-            if (set == null)
-                circle.put(hash, set = new TreeSet<>(nodesComp));
-
-            set.add(node);
-
-            for (int i = 1; i <= replicas; i++) {
-                seed = seed * affSeed.hashCode() + i;
-
-                hash = hash(seed);
-
-                set = circle.get(hash);
-
-                if (set == null)
-                    circle.put(hash, set = new TreeSet<>(nodesComp));
-
-                set.add(node);
-            }
-
-            return true;
-        }
-        finally {
-            rw.writeLock().unlock();
-        }
-    }
-
-    /**
-     * Removes a node and all of its replicas.
-     *
-     * @param node Node to remove (if {@code null}, then no-op).
-     * @return {@code True} if node was removed, {@code false} if node is {@code null} or
-     *      not present in hash.
-     */
-    public boolean removeNode(N node) {
-        if (node == null)
-            return false;
-
-        rw.writeLock().lock();
-
-        try {
-            if (!nodes.remove(node))
-                return false;
-
-            for (Iterator<SortedSet<N>> it = circle.values().iterator(); it.hasNext();) {
-                SortedSet<N> set = it.next();
-
-                if (!set.remove(node))
-                    continue;
-
-                if (set.isEmpty())
-                    it.remove();
-            }
-
-            return true;
-        }
-        finally {
-            rw.writeLock().unlock();
-        }
-    }
-
-    /**
-     * Gets number of distinct nodes, excluding replicas, in consistent hash.
-     *
-     * @return Number of distinct nodes, excluding replicas, in consistent hash.
-     */
-    public int count() {
-        rw.readLock().lock();
-
-        try {
-            return nodes.size();
-        }
-        finally {
-            rw.readLock().unlock();
-        }
-    }
-
-    /**
-     * Gets size of all nodes (including replicas) in consistent hash.
-     *
-     * @return Size of all nodes (including replicas) in consistent hash.
-     */
-    public int size() {
-        rw.readLock().lock();
-
-        try {
-            int size = 0;
-
-            for (SortedSet<N> set : circle.values())
-                size += set.size();
-
-            return size;
-        }
-        finally {
-            rw.readLock().unlock();
-        }
-    }
-
-    /**
-     * Checks if consistent hash has nodes added to it.
-     *
-     * @return {@code True} if consistent hash is empty, {@code false} otherwise.
-     */
-    public boolean isEmpty() {
-        return count() == 0;
-    }
-
-    /**
-     * Gets set of all distinct nodes in the consistent hash (in no particular order).
-     *
-     * @return Set of all distinct nodes in the consistent hash.
-     */
-    public Set<N> nodes() {
-        rw.readLock().lock();
-
-        try {
-            return new HashSet<>(nodes);
-        }
-        finally {
-            rw.readLock().unlock();
-        }
-    }
-
-    /**
-     * Picks a random node from consistent hash.
-     *
-     * @return Random node from consistent hash or {@code null} if there are no nodes.
-     */
-    public N random() {
-        return node(RAND.nextLong());
-    }
-
-    /**
-     * Gets node for a key.
-     *
-     * @param key Key.
-     * @return Node.
-     */
-    public N node(Object key) {
-        int hash = hash(key);
-
-        rw.readLock().lock();
-
-        try {
-            Map.Entry<Integer, SortedSet<N>> firstEntry = circle.firstEntry();
-
-            if (firstEntry == null)
-                return null;
-
-            Map.Entry<Integer, SortedSet<N>> tailEntry = circle.tailMap(hash, true).firstEntry();
-
-            // Get first node hash in the circle clock-wise.
-            return circle.get(tailEntry == null ? firstEntry.getKey() : tailEntry.getKey()).first();
-        }
-        finally {
-            rw.readLock().unlock();
-        }
-    }
-
-    /**
-     * Gets node for a given key.
-     *
-     * @param key Key to get node for.
-     * @param inc Optional inclusion set. Only nodes contained in this set may be returned.
-     *      If {@code null}, then all nodes may be included.
-     * @return Node for key, or {@code null} if node was not found.
-     */
-    public N node(Object key, Collection<N> inc) {
-        return node(key, inc, null);
-    }
-
-    /**
-     * Gets node for a given key.
-     *
-     * @param key Key to get node for.
-     * @param inc Optional inclusion set. Only nodes contained in this set may be returned.
-     *      If {@code null}, then all nodes may be included.
-     * @param exc Optional exclusion set. Only nodes not contained in this set may be returned.
-     *      If {@code null}, then all nodes may be returned.
-     * @return Node for key, or {@code null} if node was not found.
-     */
-    public N node(Object key, @Nullable final Collection<N> inc, @Nullable final Collection<N> exc) {
-        if (inc == null && exc == null)
-            return node(key);
-
-        return node(key, new GridClientPredicate<N>() {
-            @Override public boolean apply(N n) {
-                return (inc == null || inc.contains(n)) && (exc == null || !exc.contains(n));
-            }
-        });
-    }
-
-    /**
-     * Gets node for a given key.
-     *
-     * @param key Key to get node for.
-     * @param p Optional predicate for node filtering.
-     * @return Node for key, or {@code null} if node was not found.
-     */
-    public N node(Object key, GridClientPredicate<N>... p) {
-        if (p == null || p.length == 0)
-            return node(key);
-
-        int hash = hash(key);
-
-        rw.readLock().lock();
-
-        try {
-            final int size = nodes.size();
-
-            if (size == 0)
-                return null;
-
-            Set<N> failed = null;
-
-            // Move clock-wise starting from selected position 'hash'.
-            for (SortedSet<N> set : circle.tailMap(hash, true).values()) {
-                for (N n : set) {
-                    if (failed != null && failed.contains(n))
-                        continue;
-
-                    if (apply(p, n))
-                        return n;
-
-                    if (failed == null)
-                        failed = new HashSet<>();
-
-                    failed.add(n);
-
-                    if (failed.size() == size)
-                        return null;
-                }
-            }
-
-            //
-            // Copy-paste is used to escape several new objects creation.
-            //
-
-            // Wrap around moving clock-wise from the circle start.
-            for (SortedSet<N> set : circle.headMap(hash, false).values()) { // Circle head.
-                for (N n : set) {
-                    if (failed != null && failed.contains(n))
-                        continue;
-
-                    if (apply(p, n))
-                        return n;
-
-                    if (failed == null)
-                        failed = U.newHashSet(size);
-
-                    failed.add(n);
-
-                    if (failed.size() == size)
-                        return null;
-                }
-            }
-
-            return null;
-        }
-        finally {
-            rw.readLock().unlock();
-        }
-    }
-
-    /**
-     * Apply predicate to the node.
-     *
-     * @param p Predicate.
-     * @param n Node.
-     * @return {@code True} if filter passed or empty.
-     */
-    private boolean apply(GridClientPredicate<N>[] p, N n) {
-        if (p != null) {
-            for (GridClientPredicate<? super N> r : p) {
-                if (r != null && !r.apply(n))
-                    return false;
-            }
-        }
-
-        return true;
-    }
-
-    /**
-     * Gets hash code for a given object.
-     *
-     * @param o Object to get hash code for.
-     * @return Hash code.
-     */
-    public static int hash(Object o) {
-        int h = o == null ? 0 : o instanceof byte[] ? Arrays.hashCode((byte[])o) : o.hashCode();
-
-        // Spread bits to hash code.
-        h += (h <<  15) ^ 0xffffcd7d;
-        h ^= (h >>> 10);
-        h += (h <<   3);
-        h ^= (h >>>  6);
-        h += (h <<   2) + (h << 14);
-
-        return h ^ (h >>> 16);
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        StringBuilder sb = new StringBuilder(getClass().getSimpleName());
-
-        sb.append(" [affSeed=").append(affSeed).
-            append(", circle=").append(circle).
-            append(", nodesComp=").append(nodesComp).
-            append(", nodes=").append(nodes).append("]");
-
-        return sb.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/client/util/GridClientStripedLock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/client/util/GridClientStripedLock.java b/modules/core/src/main/java/org/apache/ignite/client/util/GridClientStripedLock.java
deleted file mode 100644
index af49c75..0000000
--- a/modules/core/src/main/java/org/apache/ignite/client/util/GridClientStripedLock.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.client.util;
-
-import java.util.concurrent.locks.*;
-
-/**
- * This is an utility class for 'splitting' locking of some
- * {@code int}- or {@code long}-keyed resources.
- *
- * Map {@code int} and {@code long} values to some number of locks,
- * and supply convenience methods to obtain and release these locks using key values.
- */
-public class GridClientStripedLock {
-    /** Array of underlying locks. */
-    private final Lock[] locks;
-
-    /**
-     * Creates new instance with the given concurrency level (number of locks).
-     *
-     * @param concurrencyLevel Concurrency level.
-     */
-    public GridClientStripedLock(int concurrencyLevel) {
-        locks = new Lock[concurrencyLevel];
-
-        for (int i = 0; i < concurrencyLevel; i++)
-            locks[i] = new ReentrantLock();
-    }
-
-    /**
-     * Gets concurrency level.
-     *
-     * @return Concurrency level.
-     */
-    public int concurrencyLevel() {
-        return locks.length;
-    }
-
-    /**
-     * Returns {@link Lock} object for the given key.
-     * @param key Key.
-     * @return Lock.
-     */
-    public Lock getLock(int key) {
-        return locks[GridClientUtils.safeAbs(key) % locks.length];
-    }
-
-    /**
-     * Returns {@link Lock} object for the given key.
-     * @param key Key.
-     * @return Lock.
-     */
-    public Lock getLock(long key) {
-        return locks[GridClientUtils.safeAbs((int)(key % locks.length))];
-    }
-
-    /**
-     * Returns lock for object.
-     *
-     * @param o Object.
-     * @return Lock.
-     */
-    public Lock getLock(Object o) {
-        return o == null ? locks[0] : getLock(o.hashCode());
-    }
-
-    /**
-     * Locks given key.
-     *
-     * @param key Key.
-     */
-    public void lock(int key) {
-        getLock(key).lock();
-    }
-
-    /**
-     * Unlocks given key.
-     *
-     * @param key Key.
-     */
-    public void unlock(int key) {
-        getLock(key).unlock();
-    }
-
-    /**
-     * Locks given key.
-     *
-     * @param key Key.
-     */
-    public void lock(long key) {
-        getLock(key).lock();
-    }
-
-    /**
-     * Unlocks given key.
-     *
-     * @param key Key.
-     */
-    public void unlock(long key) {
-        getLock(key).unlock();
-    }
-
-    /**
-     * Locks an object.
-     *
-     * @param o Object.
-     */
-    public void lock(Object o) {
-        getLock(o).lock();
-    }
-
-    /**
-     * Unlocks an object.
-     *
-     * @param o Object.
-     */
-    public void unlock(Object o) {
-        getLock(o).unlock();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/client/util/GridClientUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/client/util/GridClientUtils.java b/modules/core/src/main/java/org/apache/ignite/client/util/GridClientUtils.java
deleted file mode 100644
index b8e202a..0000000
--- a/modules/core/src/main/java/org/apache/ignite/client/util/GridClientUtils.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.client.util;
-
-import org.apache.ignite.internal.client.*;
-import org.jetbrains.annotations.*;
-
-import java.io.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.logging.*;
-
-/**
- * Java client utils.
- */
-public abstract class GridClientUtils {
-    /**
-     * Closes resource without reporting any error.
-     *
-     * @param closeable Resource to close.
-     */
-    public static void closeQuiet(@Nullable Closeable closeable) {
-        if (closeable != null) {
-            try {
-                closeable.close();
-            }
-            catch (IOException ignored) {
-                // No-op.
-            }
-        }
-    }
-
-    /**
-     * Creates a predicates that checks if given value is contained in collection c.
-     *
-     * @param c Collection to check.
-     * @param <T> Type of elements in collection.
-     * @return Predicate.
-     */
-    public static <T> GridClientPredicate<T> contains(final Collection<T> c) {
-        return new GridClientPredicate<T>() {
-            @Override public boolean apply(T t) {
-                return (!(c == null || c.isEmpty())) && c.contains(t);
-            }
-        };
-    }
-
-    /**
-     * Gets first element from given collection or returns {@code null} if the collection is empty.
-     *
-     * @param c A collection.
-     * @param <T> Type of the collection.
-     * @return Collections' first element or {@code null} in case if the collection is empty.
-     */
-    @Nullable public static <T> T first(@Nullable Iterable<? extends T> c) {
-        if (c == null)
-            return null;
-
-        Iterator<? extends T> it = c.iterator();
-
-        return it.hasNext() ? it.next() : null;
-    }
-
-    /**
-     * Applies filter and returns filtered collection of nodes.
-     *
-     * @param elements Nodes to be filtered.
-     * @param filters Filters to apply. Elements of this array are allowed to be {@code null}.
-     * @return Filtered collection.
-     */
-    public static <T> Collection<T> applyFilter(Iterable<? extends T> elements,
-        GridClientPredicate<? super T>... filters) {
-        assert filters != null;
-
-        Collection<T> res = new LinkedList<>();
-
-        for (T e : elements) {
-            boolean add = true;
-
-            for (GridClientPredicate<? super T> filter : filters)
-                if (filter != null && !filter.apply(e)) {
-                    add = false;
-
-                    break;
-                }
-
-            if (add)
-                res.add(e);
-        }
-
-        return res;
-    }
-
-    /**
-     * Checks if given REST protocol available for given node.
-     *
-     * @param node Node.
-     * @param p Protocol.
-     * @return {@code true} if protocol {@code p} available for {@code node},
-     *  {@code false} otherwise.
-     */
-    public static boolean restAvailable(GridClientNode node, GridClientProtocol p) {
-        return !node.availableAddresses(p, false).isEmpty();
-    }
-
-    /**
-     * Shutdowns given {@code ExecutorService} and wait for executor service to stop.
-     *
-     * @param owner The ExecutorService owner.
-     * @param exec ExecutorService to shutdown.
-     * @param log The logger to possible exceptions and warnings.
-     */
-    public static void shutdownNow(Class<?> owner, ExecutorService exec, Logger log) {
-        if (exec != null) {
-            List<Runnable> tasks = exec.shutdownNow();
-
-            if (!tasks.isEmpty())
-                log.warning("Runnable tasks outlived thread pool executor service [owner=" + getSimpleName(owner) +
-                    ", tasks=" + tasks + ']');
-
-            try {
-                exec.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
-            }
-            catch (InterruptedException ignored) {
-                log.warning("Got interrupted while waiting for executor service to stop.");
-
-                exec.shutdownNow();
-
-                // Preserve interrupt status.
-                Thread.currentThread().interrupt();
-            }
-        }
-    }
-
-    /**
-     * Gets simple class name taking care of empty names.
-     *
-     * @param cls Class to get the name for.
-     * @return Simple class name.
-     */
-    public static String getSimpleName(Class<?> cls) {
-        return cls.getSimpleName().isEmpty() ? cls.getName() : cls.getSimpleName();
-    }
-
-    /**
-     * Gets absolute value for integer. If integer is {@link Integer#MIN_VALUE}, then {@code 0} is returned.
-     *
-     * @param i Integer.
-     * @return Absolute value.
-     */
-    public static int safeAbs(int i) {
-        i = Math.abs(i);
-
-        return i < 0 ? 0 : i;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/client/util/GridConcurrentHashSet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/client/util/GridConcurrentHashSet.java b/modules/core/src/main/java/org/apache/ignite/client/util/GridConcurrentHashSet.java
deleted file mode 100644
index 1861e0e..0000000
--- a/modules/core/src/main/java/org/apache/ignite/client/util/GridConcurrentHashSet.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.client.util;
-
-import java.util.*;
-import java.util.concurrent.*;
-
-/**
- * Wrapper around concurrent map.
- */
-public class GridConcurrentHashSet<E> extends AbstractSet<E> {
-    /** Dummy value. */
-    protected static final Object VAL = Boolean.TRUE;
-
-    /** Base map. */
-    protected ConcurrentMap<E, Object> map;
-
-    /**
-     * Creates new set based on {@link ConcurrentHashMap}.
-     */
-    public GridConcurrentHashSet() {
-        this(new ConcurrentHashMap<E, Object>());
-    }
-
-    /**
-     * Creates new set based on the given map.
-     *
-     * @param map Map to be used for set implementation.
-     */
-    @SuppressWarnings({"unchecked"})
-    public GridConcurrentHashSet(ConcurrentMap<E, ?> map) {
-        this.map = (ConcurrentMap<E, Object>)map;
-    }
-
-    /**
-     * Gets wrapped map.
-     *
-     * @return Wrapped map.
-     */
-    @SuppressWarnings({"unchecked"})
-    protected final <T extends Map<E, Object>> T  map() {
-        return (T)map;
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public boolean add(E e) {
-        return map.put(e, VAL) == null;
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public Iterator<E> iterator() {
-        return map.keySet().iterator();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return map.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isEmpty() {
-        return map.isEmpty();
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings({"SuspiciousMethodCalls"})
-    @Override public boolean contains(Object o) {
-        return map.containsKey(o);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object[] toArray() {
-        return map.keySet().toArray();
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings({"SuspiciousToArrayCall"})
-    @Override public <T> T[] toArray(T[] a) {
-        return map.keySet().toArray(a);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean remove(Object o) {
-        return map.remove(o) != null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear() {
-        map.clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return map.keySet().toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectionConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectionConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectionConfiguration.java
index d85b036..b3af9fd 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectionConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectionConfiguration.java
@@ -17,7 +17,7 @@
 
 package org.apache.ignite.configuration;
 
-import org.apache.ignite.client.ssl.*;
+import org.apache.ignite.internal.client.ssl.*;
 import org.jetbrains.annotations.*;
 
 import java.net.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index 924f89c..62f35f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -21,6 +21,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.fs.*;
+import org.apache.ignite.internal.client.ssl.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.lifecycle.*;
 import org.apache.ignite.managed.*;
@@ -30,8 +31,6 @@ import org.apache.ignite.portables.*;
 import org.apache.ignite.spi.authentication.*;
 import org.apache.ignite.spi.indexing.*;
 import org.apache.ignite.streamer.*;
-import org.apache.ignite.client.ssl.*;
-import org.apache.ignite.interop.*;
 import org.apache.ignite.hadoop.*;
 import org.apache.ignite.internal.managers.eventstorage.*;
 import org.apache.ignite.plugin.security.*;
@@ -47,7 +46,6 @@ import org.apache.ignite.spi.loadbalancing.*;
 import org.apache.ignite.spi.securesession.*;
 import org.apache.ignite.spi.swapspace.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
 
 import javax.management.*;
 import java.lang.management.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientConfiguration.java
index c9d57f0..9eb9798 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientConfiguration.java
@@ -17,12 +17,12 @@
 
 package org.apache.ignite.internal.client;
 
+import org.apache.ignite.internal.client.ssl.*;
 import org.apache.ignite.portables.*;
 import org.apache.ignite.client.balancer.*;
 import org.apache.ignite.client.marshaller.*;
 import org.apache.ignite.client.marshaller.jdk.*;
 import org.apache.ignite.client.marshaller.optimized.*;
-import org.apache.ignite.client.ssl.*;
 import org.apache.ignite.plugin.security.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientPartitionAffinity.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientPartitionAffinity.java b/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientPartitionAffinity.java
index 7d209a5..a0fad61 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientPartitionAffinity.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientPartitionAffinity.java
@@ -17,7 +17,7 @@
 
 package org.apache.ignite.internal.client;
 
-import org.apache.ignite.client.util.*;
+import org.apache.ignite.internal.client.util.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 
 import java.util.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridRouterFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridRouterFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridRouterFactory.java
new file mode 100644
index 0000000..a2aaf3a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridRouterFactory.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.client.router;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.client.router.impl.*;
+import org.jetbrains.annotations.*;
+
+import java.util.*;
+import java.util.concurrent.*;
+
+/**
+ * This factory is responsible for router lifecycle management.
+ * All router should be started, accessed and stopped through this factory.
+ * <h1 class="header">Embedding router</h1>
+ * You can use {@link GridTcpRouterConfiguration} to set configuration parameters and pass them to
+ * {@link #startTcpRouter(GridTcpRouterConfiguration)}.
+ * <p>
+ * See {@link GridTcpRouter} for example on how to configure and start embedded router.
+ * <h1 class="header">Standalone router startup</h1>
+ * Alternatively you can run routers as a standalone processes by executing
+ * {@code IGNITE_HOME/bin/igniterouter.sh} or {@code IGNITE_HOME/bin/igniterouter.bat}.
+ * They both accept path to a configuration file as first command line argument.
+ * See {@code IGNITE_HOME/config/router/default-router.xml} for configuration example.
+ *
+ * @see GridTcpRouter
+ */
+public final class GridRouterFactory {
+    /** Map of running TCP routers. */
+    private static ConcurrentMap<UUID, GridTcpRouterImpl> tcpRouters =
+        new ConcurrentHashMap<>();
+
+    /**
+     * Ensure singleton,
+     */
+    private GridRouterFactory() {
+        // No-op.
+    }
+
+    /**
+     * Starts a TCP router with given configuration.
+     * <p>
+     * Starting router will be assigned a randomly generated UUID which can be obtained
+     * by {@link GridTcpRouter#id()} method. Later this instance could be obtained via
+     * {@link #tcpRouter} method.
+     *
+     * @param cfg Router configuration.
+     * @return Started router.
+     * @throws IgniteCheckedException If router start failed.
+     */
+    public static GridTcpRouter startTcpRouter(GridTcpRouterConfiguration cfg) throws IgniteCheckedException {
+        GridTcpRouterImpl router = new GridTcpRouterImpl(cfg);
+
+        router.start();
+
+        GridTcpRouterImpl old = tcpRouters.putIfAbsent(router.id(), router);
+
+        assert old == null : "UUIDs collision happens [tcpRouters=" + tcpRouters + ", router=" + router + ']';
+
+        return router;
+    }
+
+    /**
+     * Stops particular TCP router.
+     *
+     * @param tcpRouterId Id of the router to stop.
+     */
+    public static void stopTcpRouter(UUID tcpRouterId) {
+        GridTcpRouterImpl router = tcpRouters.remove(tcpRouterId);
+
+        if (router != null)
+            router.stop();
+    }
+
+    /**
+     * Returns TCP router with the given id.
+     *
+     * @param id Router Id.
+     * @return Router with the given id or {@code null} if router not found.
+     */
+    @Nullable public static GridTcpRouter tcpRouter(UUID id) {
+        return tcpRouters.get(id);
+    }
+
+    /**
+     * Returns collection of all currently running TCP routers.
+     *
+     * @return Collection of currently running {@link GridTcpRouter}s.
+     */
+    public static Collection<GridTcpRouter> allTcpRouters() {
+        return new ArrayList<GridTcpRouter>(tcpRouters.values());
+    }
+
+    /**
+     * Stops all currently active routers.
+     */
+    public static void stopAllRouters() {
+        for (Iterator<GridTcpRouterImpl> it = tcpRouters.values().iterator(); it.hasNext(); ) {
+            GridTcpRouterImpl router = it.next();
+
+            it.remove();
+
+            router.stop();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridTcpRouter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridTcpRouter.java b/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridTcpRouter.java
new file mode 100644
index 0000000..74909c7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridTcpRouter.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.client.router;
+
+import java.util.*;
+
+/**
+ * TCP router interface.
+ * <p>
+ * Router allows remote clients to connect to grid without direct access to
+ * the network where grid is running. It accepts requests on the same protocol
+ * as grid rest server and establish required connection to grid nodes
+ * to serve them.
+ * <p>
+ * Below is an example on how to start TCP router with non-default configuration.
+ * <pre name="code" class="java">
+ * GridTcpRouterConfiguration cfg =
+ *     new GridTcpRouterConfiguration();
+ *
+ * cfg.setHost("router.appdomain.com");
+ * cfg.setPort(11211);
+ *
+ * cfg.setServers(Arrays.asList(
+ *     "node1.appdomain.com:11211",
+ *     "node2.appdomain.com:11211"));
+ *
+ * GridRouterFactory.startTcpRouter(cfg);
+ * </pre>
+ * <p>
+ * Note that clients should be specifically configured in order to use router.
+ * Please refer to {@link org.apache.ignite.internal.client.GridClientConfiguration#getServers()} and
+ * {@link org.apache.ignite.internal.client.GridClientConfiguration#getRouters()} documentation for more details.
+ * <p>
+ * Instances of this interface are managed through {@link GridRouterFactory}.
+ *
+ * @see GridTcpRouterConfiguration
+ *
+ */
+public interface GridTcpRouter {
+    /**
+     * Returns router Id.
+     * <p>
+     * Unique router Ids are automatically generated on router startup.
+     * They are used to control router's lifecycle via {@link GridRouterFactory}.
+     *
+     * @see GridRouterFactory#tcpRouter(UUID)
+     * @see GridRouterFactory#stopTcpRouter(UUID)
+     * @return Router Id.
+     */
+    public UUID id();
+
+    /**
+     * Returns configuration used to start router.
+     *
+     * @see GridRouterFactory#startTcpRouter(GridTcpRouterConfiguration)
+     * @return Router configuration.
+     */
+    public GridTcpRouterConfiguration configuration();
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridTcpRouterConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridTcpRouterConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridTcpRouterConfiguration.java
new file mode 100644
index 0000000..e27cdb8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridTcpRouterConfiguration.java
@@ -0,0 +1,306 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.client.router;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.client.ssl.*;
+import org.apache.ignite.plugin.security.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.jetbrains.annotations.*;
+
+import java.net.*;
+import java.util.*;
+
+/**
+ * This class defines runtime configuration for TCP router.
+ * <p>
+ * Note that you should only set values
+ * that differ from defaults, as router will automatically pick default values
+ * for all values that are not set.
+ * <p>
+ * For more information about router configuration and startup refer to {@code GridRouterFactory}
+ * documentation.
+ */
+public class GridTcpRouterConfiguration {
+    /** Default servers to which router will try to connect. */
+    public static final Collection<String> DFLT_SERVERS =
+        Collections.singleton("127.0.0.1:" + IgniteConfiguration.DFLT_TCP_PORT);
+
+    /** Default TCP host for router to bind to. */
+    public static final String DFLT_TCP_HOST = "0.0.0.0";
+
+    /** Default TCP port. The next port number after Grid's default is used. */
+    public static final int DFLT_TCP_PORT = IgniteConfiguration.DFLT_TCP_PORT + 1;
+
+    /** Default port range. */
+    public static final int DFLT_PORT_RANGE = 0;
+
+    /** Default nodelay. */
+    public static final boolean DFLT_TCP_NODELAY = true;
+
+    /** Host. */
+    private String host = DFLT_TCP_HOST;
+
+    /** Port. */
+    private int port = DFLT_TCP_PORT;
+
+    /** Port range. */
+    @SuppressWarnings("RedundantFieldInitialization")
+    private int portRange = DFLT_PORT_RANGE;
+
+    /** No delay. */
+    private boolean noDelay = DFLT_TCP_NODELAY;
+
+    /** Idle timeout. */
+    private long idleTimeout = IgniteConfiguration.DFLT_REST_IDLE_TIMEOUT;
+
+    /** Client auth. */
+    private boolean sslClientAuth;
+
+    /** Ssl context factory. */
+    private GridSslContextFactory sslCtxFactory;
+
+    /** Collection of servers */
+    private Collection<String> srvrs = DFLT_SERVERS;
+
+    /** Logger. */
+    private IgniteLogger log;
+
+    /** Credentials. */
+    private GridSecurityCredentialsProvider credsProvider;
+
+    /**
+     * Gets TCP host or IP address for router to bind to.
+     * <p>
+     * If not defined, router will try to bind to all interfaces.
+     *
+     * @return TCP host.
+     */
+    public String getHost() {
+        return host;
+    }
+
+    /**
+     * Gets port for TCP binary protocol server.
+     * <p>
+     * Default is {@link #DFLT_TCP_PORT}.
+     *
+     * @return TCP port.
+     */
+    public int getPort() {
+        return port;
+    }
+
+    /**
+     * Gets port range for TCP binary protocol server. If port number returned from {@link #getPort()}
+     * is busy then ports withing this range will be tried.
+     * <p>
+     * Note: zero-range means only user-specified port will be used.
+     * <p>
+     * Default is {@link #DFLT_PORT_RANGE}.
+     *
+     * @return TCP port.
+     */
+    public int getPortRange() {
+        return portRange;
+    }
+
+    /**
+     * Gets flag indicating whether {@code TCP_NODELAY} option should be set for accepted client connections.
+     * Setting this option reduces network latency and should be set to {@code true} in majority of cases.
+     * For more information, see {@link Socket#setTcpNoDelay(boolean)}
+     * <p/>
+     * If not specified, default value is {@code true}.
+     *
+     * @return Whether {@code TCP_NODELAY} option should be enabled.
+     */
+    public boolean isNoDelay() {
+        return noDelay;
+    }
+
+    /**
+     * Gets timeout in milliseconds to consider connection idle. If no messages sent by client
+     * within this interval router closes idling connection.
+     * <p/>
+     * If not specified, default value is {@link org.apache.ignite.configuration.IgniteConfiguration#DFLT_REST_IDLE_TIMEOUT}.
+     *
+     * @return Idle timeout.
+     */
+    public long getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    /**
+     * Gets a flag indicating whether or not remote clients will be required to have
+     * a valid SSL certificate which validity will be verified with trust manager.
+     *
+     * @return Whether or not client authentication is required.
+     */
+    public boolean isSslClientAuth() {
+        return sslClientAuth;
+    }
+
+    /**
+     * Gets SSL context factory that will be used for creating a secure socket layer
+     * of both rest binary server and out coming connections.
+     *
+     * @return SslContextFactory instance.
+     * @see GridSslContextFactory
+     */
+    @Nullable public GridSslContextFactory getSslContextFactory() {
+        return sslCtxFactory;
+    }
+
+    /**
+     * Gets list of server addresses to which router should try to connect to.
+     * <p>
+     * Node that this list will be used only for initial grid connectivity.
+     * Once connected to the grid, router may establish connections to any grid node.
+     *
+     * @return List of server addresses.
+     */
+    public Collection<String> getServers() {
+        return srvrs;
+    }
+
+    /**
+     * Gets logger for the router instance.
+     * If no logger provided JDK logging will be used by router implementation.
+     *
+     * @return Logger or {@code null} if no logger provided by configuration.
+     */
+    public IgniteLogger getLogger() {
+        return log;
+    }
+
+    /**
+     * Gets credentials provider for grid access.
+     * <p>
+     * This credentials will be used only for initial connection and topology discovery
+     * by the router, not for client's request authorization.
+     *
+     * @return Credentials.
+     */
+    @Nullable public GridSecurityCredentialsProvider getSecurityCredentialsProvider() {
+        return credsProvider;
+    }
+
+    /**
+     * Sets host for router.
+     *
+     * @param host Host.
+     */
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    /**
+     * Sets port for router.
+     *
+     * @param port Port.
+     */
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    /**
+     * Sets port range router will be allowed to try.
+     * <p>
+     * Note: zero-range means only user-specified port will be used.
+     *
+     * @param portRange Port range.
+     * @see #DFLT_PORT_RANGE
+     */
+    public void setPortRange(int portRange) {
+        A.ensure(portRange >= 0, "portRange >= 0");
+
+        this.portRange = portRange;
+    }
+
+    /**
+     * Sets flag indicating whether {@code TCP_NODELAY} option should be set
+     * for accepted client connections.
+     *
+     * @param noDelay No delay.
+     */
+    public void setNoDelay(boolean noDelay) {
+        this.noDelay = noDelay;
+    }
+
+    /**
+     * Sets idle timeout.
+     *
+     * @param idleTimeout Idle timeout in milliseconds.
+     */
+    public void setIdleTimeout(long idleTimeout) {
+        this.idleTimeout = idleTimeout;
+    }
+
+    /**
+     * Sets flag indicating whether or not remote clients will be required to have
+     * a valid SSL certificate which validity will be verified with trust manager.
+     *
+     * @param sslClientAuth Ssl client auth.
+     */
+    public void setSslClientAuth(boolean sslClientAuth) {
+        this.sslClientAuth = sslClientAuth;
+    }
+
+    /**
+     * Sets SSL context factory that will be used for creating a secure socket layer
+     * of both rest binary server and out coming connections.
+     *
+     * @param sslCtxFactory Ssl context factory.
+     */
+    public void setSslContextFactory(GridSslContextFactory sslCtxFactory) {
+        this.sslCtxFactory = sslCtxFactory;
+    }
+
+    /**
+     * Sets list of server addresses where router's embedded client should connect.
+     *
+     * @param srvrs List of servers.
+     */
+    public void setServers(Collection<String> srvrs) {
+        this.srvrs = srvrs;
+    }
+
+    /**
+     * Sets logger for the router instance.
+     *
+     * @param log Logger.
+     */
+    public void setLogger(IgniteLogger log) {
+        this.log = log;
+    }
+
+    /**
+     * Sets credentials provider for grid access.
+     *
+     * @param credsProvider Credentials provider.
+     */
+    public void setSecurityCredentialsProvider(GridSecurityCredentialsProvider credsProvider) {
+        this.credsProvider = credsProvider;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(GridTcpRouterConfiguration.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b88a1012/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridTcpRouterMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridTcpRouterMBean.java b/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridTcpRouterMBean.java
new file mode 100644
index 0000000..f5dc44c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/router/GridTcpRouterMBean.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.client.router;
+
+import org.apache.ignite.mxbean.*;
+
+import java.util.*;
+
+/**
+ * MBean interface for TCP router.
+ */
+@IgniteMXBeanDescription("MBean for TCP router.")
+public interface GridTcpRouterMBean {
+    /**
+     * Gets host for TCP binary protocol server.
+     *
+     * @return TCP host.
+     */
+    @IgniteMXBeanDescription("Host for TCP binary protocol server.")
+    public String getHost();
+
+    /**
+     * Gets port for TCP binary protocol server.
+     *
+     * @return TCP port.
+     */
+    @IgniteMXBeanDescription("Port for TCP binary protocol server.")
+    public int getPort();
+
+    /**
+     * Gets a flag indicating whether or not remote clients will be required to have a valid SSL certificate which
+     * validity will be verified with trust manager.
+     *
+     * @return Whether or not client authentication is required.
+     */
+    @IgniteMXBeanDescription("Flag indicating whether or not SSL is enabled for incoming connections.")
+    public boolean isSslEnabled();
+
+    /**
+     * Gets a flag indicating whether or not remote clients will be required to have a valid SSL certificate which
+     * validity will be verified with trust manager.
+     *
+     * @return Whether or not client authentication is required.
+     */
+    @IgniteMXBeanDescription("Flag indicating whether or not remote clients are required to have a valid SSL certificate.")
+    public boolean isSslClientAuth();
+
+    /**
+     * Gets list of server addresses where router's embedded client should connect.
+     *
+     * @return List of server addresses.
+     */
+    @IgniteMXBeanDescription("Gets list of server addresses where router's embedded client should connect.")
+    public Collection<String> getServers();
+
+    /**
+     * Returns number of messages received by this router.
+     * Note that this parameter has approximate value.
+     *
+     * @return Number of messages received by this router.
+     */
+    @IgniteMXBeanDescription("Number of messages received by this router.")
+    public long getReceivedCount();
+
+    /**
+     * Returns number of responses returned by this router.
+     * Note that this parameter has approximate value.
+     *
+     * @return Number of responses returned by this router.
+     */
+    @IgniteMXBeanDescription("Number of responses returned by this router.")
+    public long getSendCount();
+}


Mime
View raw message