Beispiel #1
0
        static void Generate1(synapse_client <data_processors.waypoints> client, string source, uint yy, uint mm, uint dd)
        {
            var contests = new ContestsType();

            var contest = new ContestType();

            contest.set_competition("Australian Racing");
            contest.set_contestNumber(1);
            contest.set_contestName(new TextType()).set_Value("Drink XXXX Responsibly Sprint");
            contest.set_sportCode(SportEnum.SportEnum_gp);
            contest.set_datasource(source);
            contest.set_startDate(new DateType()).set_Value(utils.EncodeDate(yy, mm, dd));
            ////
            var participant = new ParticipantType();

            participant.set_number("1");
            participant.set_barrier(new IntegerType()).set_Value(3);
            var entities = new EntitiesType();
            var horse    = entities.set_horse_element("horse", new HorseType());

            horse.set_name("Small Runner");
            horse.set_countryBorn(new TextType()).set_Value("AUS");
            var jockey = entities.set_jockey_element("jockey", new PersonType());

            jockey.set_name("S Clipperton");
            jockey.set_sid("S Clipperton");
            participant.set_entities(entities);
            contest.set_participants_element("1", participant);
            ////
            participant = new ParticipantType();
            participant.set_number("1A");
            participant.set_barrier(new IntegerType()).set_Value(2);
            entities = new EntitiesType();
            entities.set_horse_element("horse", new HorseType()).set_name("Medium Runner");
            participant.set_entities(entities);
            contest.set_participants_element("1A", participant);
            ////
            participant = new ParticipantType();
            participant.set_number("2");
            participant.set_barrier(new IntegerType()).set_Value(1);
            entities = new EntitiesType();
            entities.set_horse_element("horse", new HorseType()).set_name("Large Runner");
            participant.set_entities(entities);
            contest.set_participants_element("2", participant);
            //
            contests.set_contest_element(source + "|" + yy.ToString() + mm.ToString() + dd.ToString() + ";1000001", contest);

            var waypoints = new waypoints();
            var waypoint  = new waypoint();

            waypoint.set_timestamp(data_processors.federated_serialisation.utils.EncodeDateTime(DateTime.UtcNow));
            waypoint.set_tag("contests_1.example.csharp.1");
            waypoints.add_path_element(waypoint);
            client.publish("test." + source, contests, waypoints, false);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            try {
                var iterate_over = Convert.ToInt32(args[1]);
                System.Diagnostics.Stopwatch sw = null;

                {
                    var client = new synapse_client(new type_factory(), args[0]);
                    client.subscribe("test.compare_xml_with_thrift_a.leon", new DateTime(1970, 1, 2), null, true);

                    var i = -1;
                    sw = System.Diagnostics.Stopwatch.StartNew();
                    for (var msg_wrapper = client.next(); msg_wrapper != null && ++i != iterate_over; msg_wrapper = client.next())
                    {
                        if (msg_wrapper.msg.get_type_id() != imaginary_bet_pool.type_id)
                        {
                            throw new Exception("unexpected message");
                        }
                    }
                    sw.Stop();
                    Console.WriteLine("thrift done. each message processed in: " + sw.ElapsedMilliseconds / (double)iterate_over + "(ms)");
                    client.close();
                }

                {
                    var client = new data_processors.xml.synapse_client(new data_processors.xml.type_factory(), args[0]);
                    client.subscribe("test.compare_xml_with_thrift_b.leon", new DateTime(1970, 1, 2), null, true);

                    sw = System.Diagnostics.Stopwatch.StartNew();
                    var i = -1;
                    for (var msg_wrapper = client.next(); msg_wrapper != null && ++i != iterate_over; msg_wrapper = client.next())
                    {
                        if (msg_wrapper.msg.get_type_id() != imaginary_bet_pool_xml.type_id)
                        {
                            throw new Exception("unexpected message");
                        }
                    }
                    sw.Stop();
                    Console.WriteLine("xml done. each message processed in: " + sw.ElapsedMilliseconds / (double)iterate_over + "(ms)");
                    client.close();
                }

                Console.WriteLine("bye bye");
            } catch (Exception e) {
                Console.WriteLine("oops " + e.Message);
            }
        }
Beispiel #3
0
 public void run(SslPolicyErrors?use_ssl, string synapse_host, int synapse_port, string topic_name, string seed_from_topic_name, bool tcp_no_delay, int so_rcvbuf, int so_sndbuf)
 {
     client = new synapse_client <DataProcessors.Waypoints.waypoints>(use_ssl, synapse_host, synapse_port, tcp_no_delay, so_rcvbuf, so_sndbuf, 30, 100000);
     client.subscribe(new ReaderWriterLockSlim(), new DataProcessors.Contests4.type_factory(), seed_from_topic_name, 1);
     for (var msg_wrapper = client.next(5000); msg_wrapper != null; msg_wrapper = client.next(5000))
     {
         if (msg_wrapper.type_name == "Contests" && msg_wrapper.non_delta_seen == true)
         {
             msg = new DataProcessors.Contests4.Contests();
             msg.set_from((DataProcessors.Contests4.Contests)msg_wrapper.msg);
             msg.set_dataprovider("here comes some unicode \u76F4 and back to ascii :)");
             Console.Error.WriteLine("seeded message size " + msg_wrapper.wire_size);
             break;
         }
     }
     client.close();
     client = null;
     if (msg == null)
     {
         throw new System.Exception("could not seed");
     }
     worker = new Thread(new ThreadStart(() => {
         Console.Error.WriteLine("synapse_publisher running...");
         try
         {
             client = new data_processors.synapse_client <DataProcessors.Waypoints.waypoints>(use_ssl, synapse_host, synapse_port, tcp_no_delay, so_rcvbuf, so_sndbuf, 30, 100000);
             for (uint i = 1; i != 10001 + 1; ++i)
             {
                 var p = new snd_ping();
                 p.published_timestamp = i;
                 p.local_timestamp     = DateTime.UtcNow;
                 p.msg_size            = (ulong)client.publish(topic_name, msg, null, false, null, 0, i);
                 stats.Enqueue(p);
             }
         } catch {
             error = true;
             Console.Error.WriteLine("synapse_publisher exception");
         } finally {
             if (client != null)
             {
                 client.close();
             }
         }
     }));
     worker.Start();
 }
Beispiel #4
0
        public static void Main(string[] args)
        {
            try
            {
                var iterate_over  = Convert.ToInt32(args[2]);
                var total_runners = Convert.ToInt32(args[1]);
                ++total_runners;
                System.Diagnostics.Stopwatch sw = null;
                Random rnd = null;



                {
                    rnd = new Random();
                    var client = new synapse_client(new type_factory(), args[0]);

                    // Custom message creation
                    sw = System.Diagnostics.Stopwatch.StartNew();
                    for (int i = 0; i != iterate_over; ++i)
                    {
                        var bet_pool = new imaginary_bet_pool();
                        bet_pool.set_xid("11-06-2008;Hong+Kong;1;1208%3AHK;quartet;1;4.1;150;50;b");
                        bet_pool.set_sid("optionally set sid value:x12:1251:777");
                        if (bet_pool.get_description() == null)
                        {
                            bet_pool.set_description("sample description of a message for the betting pool(s)");
                        }

                        // build some sample combos
                        for (byte a = 1; a != total_runners; ++a)
                        {
                            for (byte b = 1; b != total_runners - 1; ++b)
                            {
                                for (byte c = 1; c != total_runners - 2; ++c)
                                {
                                    for (byte d = 1; d != total_runners - 3; ++d)
                                    {
                                        bet_pool.set_combinations_element(new byte[] { a, b, c, d }, i * .01);
                                    }
                                }
                            }
                        }
                        bet_pool.set_When(client.timestamp_now());
                        client.publish("test.compare_xml_with_thrift_a.leon", bet_pool, false);
                    }
                    sw.Stop();
                    Console.WriteLine("thrift done. each message processed in: " + sw.ElapsedMilliseconds / (double)iterate_over + "(ms); message-rate: " + iterate_over / (sw.ElapsedMilliseconds * 0.001) + ", message size: " + client.stream.Length + ", participating runners: " + (total_runners - 1) + ", averaged over: " + iterate_over + " transactions");
                    client.close();
                }
                //  System.Threading.Thread.Sleep(10000);
                {
                    rnd = new Random();
                    var client = new data_processors.xml.synapse_client(new data_processors.xml.type_factory(), args[0]);
                    sw = System.Diagnostics.Stopwatch.StartNew();
                    for (int i = 0; i != iterate_over; ++i)
                    {
                        var bet_pool = new imaginary_bet_pool_xml();
                        bet_pool.xid          = "11-06-2008;Hong+Kong;1;1208%3AHK;quartet;1;4.1;150;50;b";
                        bet_pool.sid          = "optionally set sid value:x12:1251:777";
                        bet_pool.description  = "sample description of a message for the betting pool(s)";
                        bet_pool.combinations = new List <c>();
                        int blag = 0;
                        // build some sample combos
                        for (byte a = 1; a != total_runners; ++a)
                        {
                            for (byte b = 1; b != total_runners - 1; ++b)
                            {
                                for (byte c = 1; c != total_runners - 2; ++c)
                                {
                                    for (byte d = 1; d != total_runners - 3; ++d)
                                    {
                                        var combo = new c();
                                        //combo.r = a.ToString() + "," + b.ToString() + "," + c.ToString() + "," + d.ToString();
                                        combo.r = ++blag;
                                        combo.p = (double)i * .01;
                                        bet_pool.combinations.Add(combo);
                                    }
                                }
                            }
                        }
                        bet_pool.When = client.timestamp_now();
                        client.publish("test.compare_xml_with_thrift_b.leon", bet_pool);
                    }
                    sw.Stop();
                    Console.WriteLine("xml done. each message processed in: " + sw.ElapsedMilliseconds / (double)iterate_over + "(ms); message-rate: " + iterate_over / (sw.ElapsedMilliseconds * 0.001) + ", message size: " + client.stream.Length + ", participating runners: " + (total_runners - 1) + ", averaged over: " + iterate_over + " transactions");
                    client.close();
                }
                Console.WriteLine("bye bye");
            }
            catch (Exception e)
            {
                Console.WriteLine("oops " + e.Message);
            }
        }
Beispiel #5
0
        static void Generate2(synapse_client <data_processors.waypoints> client)
        {
            var contests_20150401 = new ContestsType();
            var contests_20150402 = new ContestsType();

            var qt_contest1 = new ContestType();

            qt_contest1.set_competition("Australian Racing");
            qt_contest1.set_contestNumber(1);
            qt_contest1.set_contestName(new TextType()).set_Value("Drink XXXX Responsibly Sprint");
            qt_contest1.set_sportCode(SportEnum.SportEnum_gp);
            qt_contest1.set_datasource("qt");
            qt_contest1.set_startDate(new DateType()).set_Value(utils.EncodeDate(2015, 04, 01));
            ////
            var participant = new ParticipantType();

            participant.set_number("1");
            participant.set_barrier(new IntegerType()).set_Value(3);
            var entities = new EntitiesType();
            var horse    = entities.set_horse_element("horse", new HorseType());

            horse.set_name("Small Runner");
            horse.set_countryBorn(new TextType()).set_Value("AUS");
            var jockey = entities.set_jockey_element("jockey", new PersonType());

            jockey.set_name("S Clipperton");
            jockey.set_sid("S Clipperton");
            participant.set_entities(entities);
            qt_contest1.set_participants_element("1", participant);
            ////
            participant = new ParticipantType();
            participant.set_number("1A");
            participant.set_barrier(new IntegerType()).set_Value(2);
            entities = new EntitiesType();
            entities.set_horse_element("horse", new HorseType()).set_name("Medium Runner");
            participant.set_entities(entities);
            qt_contest1.set_participants_element("1A", participant);
            ////
            participant = new ParticipantType();
            participant.set_number("2");
            participant.set_barrier(new IntegerType()).set_Value(1);
            entities = new EntitiesType();
            entities.set_horse_element("horse", new HorseType()).set_name("Large Runner");
            participant.set_entities(entities);
            qt_contest1.set_participants_element("2", participant);
            //
            contests_20150401.set_contest_element("qt|20150401;1000001", qt_contest1);
            client.publish("test.qt", contests_20150401, null, false, Encoding.ASCII.GetBytes("contests_20150401"));

            ////////////////////////////////////////////////////////////////
            qt_contest1 = new ContestType();
            qt_contest1.set_competition("Australian Racing");
            qt_contest1.set_contestNumber(1);
            qt_contest1.set_contestName(new TextType()).set_Value("Drink XXXX Responsibly Sprint");
            qt_contest1.set_sportCode(SportEnum.SportEnum_gp);
            qt_contest1.set_datasource("qt");
            qt_contest1.set_startDate(new DateType()).set_Value(utils.EncodeDate(2015, 04, 02));
            ////
            participant = new ParticipantType();
            participant.set_number("1");
            participant.set_barrier(new IntegerType()).set_Value(3);
            entities = new EntitiesType();
            horse    = entities.set_horse_element("horse", new HorseType());
            horse.set_name("Small Runner");
            horse.set_countryBorn(new TextType()).set_Value("AUS");
            jockey = entities.set_jockey_element("jockey", new PersonType());
            jockey.set_name("S Clipperton");
            jockey.set_sid("S Clipperton");
            participant.set_entities(entities);
            qt_contest1.set_participants_element("1", participant);
            ////
            participant = new ParticipantType();
            participant.set_number("1A");
            participant.set_barrier(new IntegerType()).set_Value(2);
            entities = new EntitiesType();
            entities.set_horse_element("horse", new HorseType()).set_name("Medium Runner");
            participant.set_entities(entities);
            qt_contest1.set_participants_element("1A", participant);
            ////
            participant = new ParticipantType();
            participant.set_number("2");
            participant.set_barrier(new IntegerType()).set_Value(1);
            entities = new EntitiesType();
            entities.set_horse_element("horse", new HorseType()).set_name("Large Runner");
            participant.set_entities(entities);
            qt_contest1.set_participants_element("2", participant);
            //
            contests_20150402.set_contest_element("qt|20150402;1000001", qt_contest1);
            client.publish("test.qt", contests_20150402, null, false, Encoding.ASCII.GetBytes("contests_20150402"));
            ////////////////////////////////////////////////////////////////

            ////// Jockey change - publish delta /////
            var a_contest = contests_20150401.get_contest_element("qt|20150401;1000001");

            if (a_contest != null)
            {
                var a_participant = a_contest.get_participants_element("1");
                if (a_participant != null)
                {
                    var a_entities = a_participant.get_entities();
                    if (a_entities != null)
                    {
                        var a_jockey = a_entities.get_jockey_element("jockey");
                        if (a_jockey != null)
                        {
                            a_jockey.set_name("D J Browne");
                            a_jockey.set_sid("4317");
                        }
                        else
                        {
                            Console.WriteLine("Jockey not found!");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Entities not found!");
                    }
                }
                else
                {
                    Console.WriteLine("Participant 1 not found!");
                }
            }
            else
            {
                Console.WriteLine("Contest not found!");
            }
            client.publish("test.qt", contests_20150401, null, true, Encoding.ASCII.GetBytes("contests_20150401"));

            ///////////////////////////////////////////////////////////////

            ///// Jockey change - publish delta /////
            a_contest = contests_20150402.get_contest_element("qt|20150402;1000001");
            if (a_contest != null)
            {
                var a_participant = a_contest.get_participants_element("1");
                if (a_participant != null)
                {
                    var a_entities = a_participant.get_entities();
                    if (a_entities != null)
                    {
                        var a_jockey = a_entities.get_jockey_element("jockey");
                        if (a_jockey != null)
                        {
                            a_jockey.set_name("D J Browne");
                            a_jockey.set_sid("4317");
                        }
                        else
                        {
                            Console.WriteLine("Jockey not found!");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Entities not found!");
                    }
                }
                else
                {
                    Console.WriteLine("Participant 1 not found!");
                }
            }
            else
            {
                Console.WriteLine("Contest not found!");
            }
            client.publish("test.qt", contests_20150402, null, true, Encoding.ASCII.GetBytes("contests_20150402"));
        }