Esempio n. 1
0
    public long _8_1_2_GetJob1000byPipelines(Disquuun disquuun)
    {
        WaitUntil("_8_1_2_GetJob1000byPipelines", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var addingJobCount = 1000 * ratio;

        var connected = false;

        disquuun = new Disquuun(DisquuunTests.TestDisqueHostStr, DisquuunTests.TestDisquePortNum, 1024, 10,
                                disquuunId =>
        {
            connected = true;
        },
                                (info, e) =>
        {
            TestLogger.Log("error, info:" + info + " e:" + e.Message);
        },
                                (currentSocketCount, addSocket) =>
        {
            if (100 < currentSocketCount)
            {
                return;
            }
            addSocket(true, 1);
        }
                                );

        WaitUntil("_8_1_2_GetJob1000byPipelines", () => connected, 5);

        var addedCount = 0;

        var queueId = Guid.NewGuid().ToString();

        for (var i = 0; i < addingJobCount; i++)
        {
            disquuun.Pipeline(disquuun.AddJob(queueId, data_10));
        }

        disquuun.Pipeline().Execute(
            (command, data) =>
        {
            lock (_8_1_2_GetJob1000byPipelinesObject) addedCount++;
        }
            );


        WaitUntil("_8_1_2_GetJob1000byPipelines", () => (addedCount == addingJobCount), 10);

        var gotJobDataIds = new List <string>();


        var w = new Stopwatch();

        w.Start();
        for (var i = 0; i < addingJobCount; i++)
        {
            if (i == addingJobCount / 2)
            {
                disquuun.RevolvePipeline();
            }
            disquuun.Pipeline(disquuun.GetJob(new string[] { queueId }));
        }
        disquuun.Pipeline().Execute(
            (command, data) =>
        {
            lock (_8_1_2_GetJob1000byPipelinesObject)
            {
                var jobDatas = DisquuunDeserializer.GetJob(data);
                var jobIds   = jobDatas.Select(j => j.jobId).ToList();
                gotJobDataIds.AddRange(jobIds);
            }
        }
            );

        WaitUntil("_8_1_2_GetJob1000byPipelines", () => (gotJobDataIds.Count == addingJobCount), 10);

        w.Stop();

        var result = DisquuunDeserializer.FastAck(disquuun.FastAck(gotJobDataIds.ToArray()).DEPRICATED_Sync());

        Assert("_8_1_2_GetJob1000byPipelines", addingJobCount, result, "result not match.");
        disquuun.Disconnect();

        return(w.ElapsedMilliseconds);
    }
Esempio n. 2
0
    public long _0_10_5_Pipelines(Disquuun disquuun)
    {
        WaitUntil("_0_10_5_Pipelines", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);
        var w = new Stopwatch();

        w.Start();

        var jobCount = 100000;

        var infoCount   = 0;
        var addedJobIds = new List <string>();
        var gotJobIds   = new List <string>();

        var queueId = Guid.NewGuid().ToString();


        for (var i = 0; i < data_100.Length; i++)
        {
            data_100[i] = 1;
        }

        for (var i = 0; i < jobCount; i++)
        {
            if (i == jobCount / 2)
            {
                disquuun.RevolvePipeline();
            }
            disquuun.Pipeline(disquuun.AddJob(queueId, data_100));
        }

        disquuun.Pipeline(disquuun.Info());

        disquuun.Pipeline().Execute(
            (command, data) =>
        {
            lock (_0_10_5_PipelinesObject)
            {
                switch (command)
                {
                case DisqueCommand.INFO:
                    {
                        infoCount++;
                        break;
                    }

                case DisqueCommand.ADDJOB:
                    {
                        addedJobIds.Add(DisquuunDeserializer.AddJob(data));
                        break;
                    }
                }
            }
        }
            );

        WaitUntil("_0_10_5_Pipelines 0", () => (infoCount == 1 && addedJobIds.Count == jobCount), 10);

        disquuun.GetJob(new string[] { queueId }, "count", jobCount).Loop(
            (commnand, data) =>
        {
            lock (_0_10_5_PipelinesObject)
            {
                var data_100s = DisquuunDeserializer.GetJob(data).Select(j => j.jobId).ToList();
                gotJobIds.AddRange(data_100s);
                if (gotJobIds.Count != jobCount)
                {
                    return(true);
                }
                return(false);
            }
        }
            );

        WaitUntil("_0_10_5_Pipelines 1", () => (gotJobIds.Count == jobCount), 5);

        var fastacked = false;

        disquuun.FastAck(gotJobIds.ToArray()).Async(
            (command, data) =>
        {
            lock (_0_10_4_MassiveCommandPipelineObject) fastacked = true;
        }
            );

        WaitUntil("_0_10_5_Pipelines 2", () => fastacked, 5);

        w.Stop();
        return(w.ElapsedMilliseconds);
    }
Esempio n. 3
0
    public long _8_0_2_AddJob1000byPipelines(Disquuun disquuun)
    {
        WaitUntil("_8_0_2_AddJob1000byPipelines", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var count = 1000 * ratio;

        var connectedCount = 0;

        disquuun = new Disquuun(DisquuunTests.TestDisqueHostStr, DisquuunTests.TestDisquePortNum, 1024, 10,
                                disquuunId =>
        {
            connectedCount++;
        },
                                (info, e) =>
        {
            TestLogger.Log("error, info:" + info + " e:" + e.Message);
        },
                                (currentSocketCount, addSocket) =>
        {
            if (100 < currentSocketCount)
            {
                return;
            }
            addSocket(true, 1);
        }
                                );

        WaitUntil("_8_0_2_AddJob1000byPipelines 0", () => (connectedCount == 1), 5);

        var addedCount = 0;

        var queueId = Guid.NewGuid().ToString();

        var w = new Stopwatch();

        w.Start();
        for (var i = 0; i < count; i++)
        {
            if (i == count / 2)
            {
                disquuun.RevolvePipeline();
            }
            disquuun.Pipeline(disquuun.AddJob(queueId, data_10));
        }
        disquuun.Pipeline().Execute(
            (command, data) =>
        {
            lock (_8_0_2_AddJob1000byPipelinesObject) addedCount++;
        }
            );

        w.Stop();

        WaitUntil("_8_0_2_AddJob1000byPipelines 1", () => (addedCount == count), 100);

        var gotCount = 0;

        disquuun.GetJob(new string[] { queueId }, "count", count).Async(
            (command, data) =>
        {
            var jobDatas = DisquuunDeserializer.GetJob(data);
            var jobIds   = jobDatas.Select(j => j.jobId).ToArray();
            disquuun.FastAck(jobIds).Async(
                (c2, d2) =>
            {
                var fastackCount = DisquuunDeserializer.FastAck(d2);
                lock (_8_0_2_AddJob1000byPipelinesObject)
                {
                    gotCount += fastackCount;
                }
            }
                );
        }
            );

        WaitUntil("_8_0_2_AddJob1000byPipelines 2", () => (gotCount == count), 10);
        disquuun.Disconnect();

        return(w.ElapsedMilliseconds);
    }