/**
         * <summary>
         * Converts node bean to protocol message.</summary>
         *
         * <param name="node">Node bean to convert.</param>
         * <returns>Converted message.</returns>
         */
        private static GridClientNodeBean WrapNode(ProtoNodeBean node)
        {
            GridClientNodeBean bean = new GridClientNodeBean();

            bean.NodeId = WrapGuid(node.NodeId);

            bean.TcpPort      = node.TcpPort;
            bean.JettyPort    = node.JettyPort;
            bean.ConsistentId = WrapObject(node.ConsistentId);
            bean.ReplicaCount = node.ReplicaCount;

            bean.TcpAddresses.AddAll(node.TcpAddressList);
            bean.TcpHostNames.AddAll(node.TcpHostNameList);
            bean.JettyAddresses.AddAll(node.JettyAddressList);
            bean.JettyHostNames.AddAll(node.JettyHostNameList);

            if (node.HasCaches)
            {
                bean.Caches.AddAll <KeyValuePair <String, String> >(WrapMap <String, String>(node.Caches));
            }

            if (node.HasAttributes)
            {
                bean.Attributes.AddAll <KeyValuePair <String, Object> >(WrapMap <String, Object>(node.Attributes));
            }

            if (node.HasMetrics)
            {
                bean.Metrics.AddAll <KeyValuePair <String, Object> >(WrapMetrics(node.Metrics));
            }

            return(bean);
        }
        /**
         * <summary>
         * Creates client node instance from message.</summary>
         *
         * <param name="nodeBean">Node bean message.</param>
         * <returns>Created node.</returns>
         */
        private GridClientNodeImpl nodeBeanToNode(GridClientNodeBean nodeBean)
        {
            if (nodeBean == null)
            {
                return(null);
            }

            Guid nodeId = nodeBean.NodeId;

            GridClientNodeImpl node = new GridClientNodeImpl(nodeId);

            node.TcpAddresses.AddAll <String>(nodeBean.TcpAddresses);
            node.JettyAddresses.AddAll <String>(nodeBean.JettyAddresses);
            node.TcpPort      = nodeBean.TcpPort;
            node.ConsistentId = nodeBean.ConsistentId;
            node.HttpPort     = nodeBean.JettyPort;
            node.ReplicaCount = nodeBean.ReplicaCount;

            if (nodeBean.Caches != null && nodeBean.Caches.Count > 0)
            {
                node.Caches.AddAll <KeyValuePair <String, GridClientCacheMode> >(parseCacheModes(nodeBean.Caches));
            }

            if (nodeBean.Attributes != null && nodeBean.Attributes.Count > 0)
            {
                node.Attributes.AddAll <KeyValuePair <String, Object> >(nodeBean.Attributes);
            }

            if (nodeBean.Metrics != null && nodeBean.Metrics.Count > 0)
            {
                node.Metrics = parseNodeMetrics(nodeBean.Metrics);
            }

            return(node);
        }
        /**
         * <summary>
         * Converts node bean to protocol message.</summary>
         *
         * <param name="node">Node bean to convert.</param>
         * <returns>Converted message.</returns>
         */
        private static ProtoNodeBean WrapNode(GridClientNodeBean node)
        {
            ProtoNodeBean.Builder builder = ProtoNodeBean.CreateBuilder()
                                            .SetNodeId(WrapGuid(node.NodeId))
                                            .SetTcpPort(node.TcpPort)
                                            .SetJettyPort(node.JettyPort)
                                            .SetConsistentId(WrapObject(node.ConsistentId))
                                            .SetReplicaCount(node.ReplicaCount);

            if (node.TcpAddresses != null)
            {
                foreach (String addr in node.TcpAddresses)
                {
                    builder.AddTcpAddress(addr);
                }
            }

            if (node.TcpHostNames != null)
            {
                foreach (String addr in node.TcpHostNames)
                {
                    builder.AddTcpHostName(addr);
                }
            }

            if (node.JettyAddresses != null)
            {
                foreach (String addr in node.JettyAddresses)
                {
                    builder.AddJettyAddress(addr);
                }
            }

            if (node.JettyHostNames != null)
            {
                foreach (String addr in node.JettyHostNames)
                {
                    builder.AddJettyHostName(addr);
                }
            }

            if (node.Caches != null)
            {
                builder.SetCaches(WrapMap(node.Caches));
            }

            if (node.Attributes != null)
            {
                builder.SetAttributes(WrapMap(node.Attributes));
            }

            if (node.Metrics != null)
            {
                builder.SetMetrics(WrapMetrics(node.Metrics));
            }

            return(builder.Build());
        }