示例#1
0
    public void _0_9_2_MultipleCommandPipeline(Disquuun disquuun)
    {
        WaitUntil("_0_9_2_MultipleCommandPipeline", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var infoCount  = 0;
        var addedJobId = string.Empty;
        var gotJobId   = "_";

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

        var jobData = new byte[100];

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

        disquuun.Pipeline(disquuun.Info());
        disquuun.Pipeline(disquuun.AddJob(queueId, jobData));
        disquuun.Pipeline(disquuun.GetJob(new string[] { queueId })).Execute(
            (command, data) => {
            switch (command)
            {
            case DisqueCommand.INFO: {
                lock (_0_9_2_MultipleCommandPipelineObject) {
                    infoCount++;
                }
                break;
            }

            case DisqueCommand.ADDJOB: {
                lock (_0_9_2_MultipleCommandPipelineObject) {
                    addedJobId = DisquuunDeserializer.AddJob(data);
                }
                break;
            }

            case DisqueCommand.GETJOB: {
                lock (_0_9_2_MultipleCommandPipelineObject) {
                    var gotJobDatas = DisquuunDeserializer.GetJob(data);
                    gotJobId        = gotJobDatas[0].jobId;
                    disquuun.FastAck(new string[] { gotJobId }).DEPRICATED_Sync();
                }
                break;
            }
            }
        }
            );

        WaitUntil("_0_9_2_MultipleCommandPipeline", () => (infoCount == 1 && !string.IsNullOrEmpty(addedJobId) && gotJobId == addedJobId), 5);
    }
示例#2
0
        public void Take_10byte_30sock_pipeline()
        {
            var waitHandle = new ManualResetEvent(false);

            for (var i = 0; i < 1; i++)
            {
                disquuun30.Pipeline(disquuun30.AddJob(qName, dataBytes1));
            }
            disquuun30.Pipeline().Execute((a, b) =>
            {
                waitHandle.Set();
            });
            waitHandle.WaitOne(Timeout.Infinite);
        }
示例#3
0
    public void _0_0_4_ReadmeSamplePipeline(Disquuun disquuun)
    {
        WaitUntil("_0_0_4_ReadmeSamplePipeline", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var fastacked = false;

        disquuun.Pipeline(
            disquuun.AddJob("my queue name", new byte[100]),
            disquuun.GetJob(new string[] { "my queue name" })
            ).Execute(
            (command, data) => {
            if (command != DisqueCommand.GETJOB)
            {
                return;
            }
            var jobs = DisquuunDeserializer.GetJob(data);

            var jobIds   = jobs.Select(jobData => jobData.jobId).ToArray();
            var jobDatas = jobs.Select(jobData => jobData.jobData).ToList();

            /*
             *      fast ack all.
             */
            disquuun.FastAck(jobIds).Async(
                (command2, data2) => {
                fastacked = true;
            }
                );
        }
            );

        WaitUntil("_0_0_4_ReadmeSamplePipeline", () => fastacked, 5);
    }
示例#4
0
    public void _0_9_1_MultiplePipeline(Disquuun disquuun)
    {
        WaitUntil("_0_9_1_MultiplePipeline", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var infoCount = 0;

        disquuun.Pipeline(disquuun.Info());
        disquuun.Pipeline(disquuun.Info());
        disquuun.Pipeline(disquuun.Info()).Execute(
            (command, data) => {
            lock (_0_9_1_MultiplePipelineObject) infoCount++;
        }
            );

        WaitUntil("_0_9_1_MultiplePipeline", () => (infoCount == 3), 5);
    }
        public void Publish(ConcurrentQueue <SendQueueRow> queue)
        {
            if (queue.Count == 0)
            {
                return;
            }

            while (queue.Count > 0)
            {
                SendQueueRow row;
                queue.TryDequeue(out row);
                disquuun.Pipeline(disquuun.AddJob(row.ConnectionId, row.Data, 0, "TTL", 60 * 10, "RETRY", 0));
            }

            disquuun.Pipeline().Execute((command, data) => { });
        }
示例#6
0
    public long _0_10_1_MultiplePipeline(Disquuun disquuun)
    {
        WaitUntil("_0_10_1_MultiplePipeline", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);
        var w = new Stopwatch();

        w.Start();

        var infoCount = 0;

        disquuun.Pipeline(disquuun.Info());
        disquuun.Pipeline(disquuun.Info());
        disquuun.Pipeline(disquuun.Info()).Execute(
            (command, data) =>
        {
            lock (_0_10_1_MultiplePipelineObject) infoCount++;
        }
            );

        WaitUntil("_0_10_1_MultiplePipeline", () => (infoCount == 3), 5);
        w.Stop();
        return(w.ElapsedMilliseconds);
    }
示例#7
0
    public void _0_9_Pipeline(Disquuun disquuun)
    {
        WaitUntil("_0_9_Pipeline", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var gotInfoCount = 0;

        disquuun.Pipeline(disquuun.Info(), disquuun.Info()).Execute(
            (command, data) => {
            lock (_0_9_PipelineObject) gotInfoCount++;
        }
            );

        WaitUntil("_0_9_Pipeline", () => (gotInfoCount == 2), 1);
    }
示例#8
0
    public void _0_8_Pipeline_Single(Disquuun disquuun)
    {
        WaitUntil("_0_8_Pipeline_Single", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var gotInfo = false;

        disquuun.Pipeline(disquuun.Info()).Execute(
            (command, data) => {
            gotInfo = true;
        }
            );

        WaitUntil("_0_8_Pipeline_Single", () => gotInfo, 1);
    }
示例#9
0
    public long _0_8_Pipeline_Single(Disquuun disquuun)
    {
        WaitUntil("_0_8_Pipeline_Single", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var gotInfo = false;
        var w       = new Stopwatch();

        w.Start();

        disquuun.Pipeline(disquuun.Info()).Execute(
            (command, data) =>
        {
            gotInfo = true;
        }
            );

        WaitUntil("_0_8_Pipeline_Single", () => gotInfo, 1);
        w.Stop();
        return(w.ElapsedMilliseconds);
    }
示例#10
0
    public void _7_1_1_GetJob1000byPipeline(Disquuun disquuun)
    {
        WaitUntil("_7_1_1_GetJob1000byPipeline", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var addingJobCount = 1000 * loadLevel;

        var connected = false;

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

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

        var addedCount = 0;

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

        for (var i = 0; i < addingJobCount; i++)
        {
            disquuun.Pipeline(disquuun.AddJob(queueId, new byte[10]));
        }

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


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

        var gotJobDataIds = new List <string>();


        var w = new Stopwatch();

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

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


        w.Stop();
        TestLogger.Log("_7_1_1_GetJob1000byPipeline w:" + w.ElapsedMilliseconds + " tick:" + w.ElapsedTicks);

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

        Assert("_7_1_1_GetJob1000byPipeline", addingJobCount, result, "result not match.");
        disquuun.Disconnect();
    }
示例#11
0
    public long _0_10_2_MultipleCommandPipeline(Disquuun disquuun)
    {
        WaitUntil("_0_10_2_MultipleCommandPipeline", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);
        var w = new Stopwatch();

        w.Start();

        var infoCount  = 0;
        var addedJobId = string.Empty;
        var gotJobId   = "_";

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


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

        disquuun.Pipeline(disquuun.Info());
        disquuun.Pipeline(disquuun.AddJob(queueId, data_100));
        disquuun.Pipeline(disquuun.GetJob(new string[] { queueId })).Execute(
            (command, data) =>
        {
            switch (command)
            {
            case DisqueCommand.INFO:
                {
                    lock (_0_10_2_MultipleCommandPipelineObject)
                    {
                        infoCount++;
                    }
                    break;
                }

            case DisqueCommand.ADDJOB:
                {
                    lock (_0_10_2_MultipleCommandPipelineObject)
                    {
                        addedJobId = DisquuunDeserializer.AddJob(data);
                    }
                    break;
                }

            case DisqueCommand.GETJOB:
                {
                    lock (_0_10_2_MultipleCommandPipelineObject)
                    {
                        var gotdata_100s = DisquuunDeserializer.GetJob(data);
                        gotJobId         = gotdata_100s[0].jobId;
                        disquuun.FastAck(new string[] { gotJobId }).DEPRICATED_Sync();
                    }
                    break;
                }
            }
        }
            );

        WaitUntil("_0_10_2_MultipleCommandPipeline", () => (infoCount == 1 && !string.IsNullOrEmpty(addedJobId) && gotJobId == addedJobId), 5);

        w.Stop();
        return(w.ElapsedMilliseconds);
    }
示例#12
0
    public void _7_0_1_AddJob1000byPipeline(Disquuun disquuun)
    {
        WaitUntil("_7_0_1_AddJob1000byPipeline", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var count = 1000 * loadLevel;

        var connectedCount = 0;

        disquuun = new Disquuun(DisquuunTests.TestDisqueHostStr, DisquuunTests.TestDisquePortNum, 1024, 100,
                                disquuunId => {
            connectedCount++;
        },
                                (info, e) => {
            TestLogger.Log("error, info:" + info + " e:" + e.Message);
        }
                                );



        WaitUntil("_7_0_1_AddJob1000byPipeline 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++)
        {
            disquuun.Pipeline(disquuun.AddJob(queueId, new byte[10]));
        }
        disquuun.Pipeline().Execute(
            (command, data) => {
            lock (_7_0_1_AddJob1000byPipelineObject) addedCount++;
        }
            );

        w.Stop();
        TestLogger.Log("_7_0_1_AddJob1000byPipeline w:" + w.ElapsedMilliseconds + " tick:" + w.ElapsedTicks);

        WaitUntil("_7_0_1_AddJob1000byPipeline 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 (_7_0_1_AddJob1000byPipelineObject) {
                    gotCount += fastackCount;
                }
            }
                );
        }
            );

        WaitUntil("_7_0_1_AddJob1000byPipeline 2", () => (gotCount == count), 10);
        disquuun.Disconnect();
    }
示例#13
0
    public void _0_9_4_MassiveCommandPipeline(Disquuun disquuun)
    {
        WaitUntil("_0_9_4_MassiveCommandPipeline", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var jobCount = 100000;

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

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

        var jobData = new byte[100];

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

        for (var i = 0; i < jobCount; i++)
        {
            disquuun.Pipeline(disquuun.AddJob(queueId, jobData));
        }
        disquuun.Pipeline(disquuun.Info());
        disquuun.Pipeline().Execute(
            (command, data) => {
            switch (command)
            {
            case DisqueCommand.INFO: {
                lock (_0_9_4_MassiveCommandPipelineObject) {
                    infoCount++;
                }
                break;
            }

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

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

        WaitUntil("_0_9_4_MassiveCommandPipeline 0", () => (infoCount == 1 && addedJobIds.Count == jobCount && gotJobIds.Count == jobCount), 20);

        var fastacked = false;

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

        WaitUntil("_0_9_4_MassiveCommandPipeline 1", () => fastacked, 5);
    }
示例#14
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);
    }
示例#15
0
    public long _8_2_0_GetJob1000byPipeline(Disquuun disquuun)
    {
        WaitUntil("_8_2_0_GetJob1000byPipeline 0", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5);

        var addingJobCount = 1000 * ratio;

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

        var addedCount = 0;

        for (var i = 0; i < addingJobCount; i++)
        {
            disquuun.Pipeline(disquuun.AddJob(queueId, data_10));
        }
        disquuun.Pipeline().Execute(
            (command, data) =>
        {
            lock (_8_2_GetJob1000byLoopLockObject) addedCount++;
        }
            );

        WaitUntil("_8_2_0_GetJob1000byPipeline 1", () => (addedCount == addingJobCount), 5);

        var gotJobDataIds = new List <string>();

        var w = new Stopwatch();

        w.Start();

        for (var i = 0; i < addingJobCount; i++)
        {
            disquuun.Pipeline(disquuun.GetJob(new string[] { queueId }, "count", addingJobCount));
        }
        disquuun.Pipeline().Execute(
            (command, data) =>
        {
            lock (_8_2_0_GetJob1000byPipelineObject)
            {
                var jobDatas = DisquuunDeserializer.GetJob(data);
                var jobIds   = jobDatas.Select(j => j.jobId).ToList();
                gotJobDataIds.AddRange(jobIds);

                if (gotJobDataIds.Count == addingJobCount)
                {
                    w.Stop();
                }
            }
        }
            );

        WaitUntil("_8_2_0_GetJob1000byPipeline 2", () => (gotJobDataIds.Count == addingJobCount), 30);
        WaitUntil("_8_2_0_GetJob1000byPipeline 3", () => (0 < disquuun.AvailableSocketNum()), 1);

        var fastackedCount = 0;

        disquuun.FastAck(gotJobDataIds.ToArray()).Async(
            (c, data) =>
        {
            fastackedCount = DisquuunDeserializer.FastAck(data);
        }
            );

        WaitUntil("_8_2_0_GetJob1000byPipeline 4", () => (addingJobCount == fastackedCount), 10);

        return(w.ElapsedMilliseconds);
    }
示例#16
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);
    }
示例#17
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);
    }