Example #1
0
        /// <summary>
        /// Writes the java task.
        /// </summary>
        private void WriteJavaTaskRequest(string taskName, object taskArg, ClientRequestContext ctx)
        {
            var writer = ctx.Writer;

            if (_clusterGroup != null)
            {
                var nodes = _clusterGroup.GetNodes();
                writer.WriteInt(nodes.Count);

                foreach (var node in nodes)
                {
                    writer.WriteGuid(node.Id);
                }
            }
            else
            {
                writer.WriteInt(0);
            }

            writer.WriteByte((byte)_flags);
            writer.WriteLong((long)_timeout.TotalMilliseconds);
            writer.WriteString(taskName);
            writer.WriteObject(taskArg);

            ctx.Socket.ExpectNotifications();
        }
Example #2
0
        public void TestClientForAttribute()
        {
            IClientClusterGroup clientPrj = _igniteClient.GetCluster().ForAttribute("my_attr", "value1");

            Assert.AreEqual(1, clientPrj.GetNodes().Count);

            var nodeId = _grid1.GetCluster().ForAttribute("my_attr", "value1").GetNodes().Single().Id;

            Assert.AreEqual(nodeId, clientPrj.GetNode().Id);
        }
Example #3
0
        /// <summary>
        /// Invokes the proxy method.
        /// </summary>
        private object InvokeProxyMethod(string serviceName, MethodBase method, object[] args,
                                         PlatformType platformType, IDictionary callAttrs)
        {
            return(_ignite.Socket.DoOutInOp(ClientOp.ServiceInvoke,
                                            ctx =>
            {
                var w = ctx.Writer;

                w.WriteString(serviceName);
                w.WriteByte(_serverKeepBinary ? (byte)ServiceFlags.KeepBinary : (byte)0);
                w.WriteLong((long)_timeout.TotalMilliseconds);

                if (_clusterGroup != null)
                {
                    var nodes = _clusterGroup.GetNodes();
                    if (nodes.Count == 0)
                    {
                        throw new IgniteClientException("Cluster group is empty");
                    }

                    w.WriteInt(nodes.Count);

                    foreach (var node in nodes)
                    {
                        BinaryUtils.WriteGuid(node.Id, ctx.Stream);
                    }
                }
                else
                {
                    w.WriteInt(0);
                }

                w.WriteString(method.Name);

                ServiceProxySerializer.WriteMethodArguments(w, null, args, platformType);

                if (ctx.Features.HasFeature(ClientBitmaskFeature.ServiceInvokeCtx))
                {
                    w.WriteDictionary(callAttrs);
                }
                else if (callAttrs != null)
                {
                    throw new IgniteClientException(
                        "Passing caller context to the service is not supported by the server");
                }
            },
                                            ctx =>
            {
                var reader = _keepBinary
                        ? ctx.Marshaller.StartUnmarshal(ctx.Stream, BinaryMode.ForceBinary)
                        : ctx.Reader;

                return reader.ReadObject <object>();
            }));
        }
Example #4
0
        public static void ClientClusterGroups()
        {
            var cfg = new IgniteClientConfiguration();
            //tag::client-cluster-groups[]
            IIgniteClient       client       = Ignition.StartClient(cfg);
            IClientClusterGroup serversInDc1 = client.GetCluster().ForServers().ForAttribute("dc", "dc1");

            foreach (IClientClusterNode node in serversInDc1.GetNodes())
            {
                Console.WriteLine($"Node ID: {node.Id}");
            }
            //end::client-cluster-groups[]
        }
Example #5
0
        /// <summary>
        /// Invokes the proxy method.
        /// </summary>
        private object InvokeProxyMethod(string serviceName, MethodBase method, object[] args)
        {
            return(_ignite.Socket.DoOutInOp(
                       ClientOp.ServiceInvoke,
                       ctx =>
            {
                var w = ctx.Writer;

                w.WriteString(serviceName);
                w.WriteByte(_serverKeepBinary ? (byte)ServiceFlags.KeepBinary : (byte)0);
                w.WriteLong((long)_timeout.TotalMilliseconds);

                if (_clusterGroup != null)
                {
                    var nodes = _clusterGroup.GetNodes();
                    if (nodes.Count == 0)
                    {
                        throw new IgniteClientException("Cluster group is empty");
                    }

                    w.WriteInt(nodes.Count);

                    foreach (var node in nodes)
                    {
                        BinaryUtils.WriteGuid(node.Id, ctx.Stream);
                    }
                }
                else
                {
                    w.WriteInt(0);
                }

                w.WriteString(method.Name);

                w.WriteInt(args.Length);
                foreach (var arg in args)
                {
                    w.WriteObjectDetached(arg);
                }
            },
                       ctx =>
            {
                var reader = _keepBinary
                        ? ctx.Marshaller.StartUnmarshal(ctx.Stream, BinaryMode.ForceBinary)
                        : ctx.Reader;

                return reader.ReadObject <object>();
            }));
        }