Ejemplo n.º 1
0
        public static GenericRecord CreateMessage()
        {
            // The first and only type in the list is the Message type.
            var recordSchema = (RecordSchema) MailResponder.Protocol.Types[0];
            var record = new GenericRecord(recordSchema);

            record.Add("to", "wife");
            record.Add("from", "husband");
            record.Add("body", "I love you!");

            return record;
        }
Ejemplo n.º 2
0
        public void TestSingleRpc()
        {
            Transceiver t = new LocalTransceiver(new TestResponder(protocol));
            var p = new GenericRecord(protocol.Messages["m"].Request);
            p.Add("x", "hello");
            var r = new GenericRequestor(t, protocol);

            for (int x = 0; x < 5; x++)
            {
                object request = r.Request("m", p);
                Assert.AreEqual("there", request);
            }
        }
Ejemplo n.º 3
0
        private string Send(GenericRecord message)
        {
            var request = new GenericRecord(MailResponder.Protocol.Messages["send"].Request);
            request.Add("message", message);

            var result = (string) proxy.Request("send", request);
            return result;
        }
Ejemplo n.º 4
0
        private static void FireAndForget(GenericRequestor proxy, GenericRecord genericRecord)
        {
            var request = new GenericRecord(MailResponder.Protocol.Messages["fireandforget"].Request);
            request.Add("message", genericRecord);

            proxy.Request("fireandforget", request);
        }
        // AVRO-625 [Test] 
        // Currently, SocketTransceiver does not permit out-of-order requests on a stateful connection.
        public void Test()
        {
            var waitLatch = new CountdownLatch(1);
            var simpleResponder = new SimpleResponder(waitLatch);
            server = new SocketServer("localhost", 0, simpleResponder);

            server.Start();

            int port = server.Port;

            transceiver = new SocketTransceiver("localhost", port);
            proxy = new GenericRequestor(transceiver, SimpleResponder.Protocol);

            // Step 1:
            proxy.GetRemote(); // force handshake

            new Thread(x =>
                           {
                               // Step 2a:
                               waitLatch.Wait();

                               var ack = new GenericRecord(SimpleResponder.Protocol.Messages["ack"].Request);
                               // Step 2b:
                               proxy.Request("ack", ack);

                           }).Start();


            /*
             * 3. Execute the Client.hello("wait") RPC, which will block until the
             *    Client.ack() call has completed in the background thread.
             */

            var request = new GenericRecord(SimpleResponder.Protocol.Messages["hello"].Request);
            request.Add("greeting", "wait");

            var response = (string)proxy.Request("hello", request);

            // 4. If control reaches here, both RPCs have executed concurrently
            Assert.AreEqual("wait", response); 
        }