Example #1
0
 public Configuration()
 {
     IdentifierFactory  = new DefaultIdentifierFactory();
     ContentSerializer  = new JsonContentSerializer();
     IdGenerator        = new DefaultIdGenerator();
     IsolationLevel     = IsolationLevel.ReadCommitted;
     TablePrefix        = "";
     SessionPoolSize    = 16;
     QueryGatingEnabled = true;
 }
Example #2
0
 public Configuration()
 {
     IdentifierFactory  = new DefaultIdentifierFactory();
     ContentSerializer  = new JsonContentSerializer();
     IdGenerator        = new DefaultIdGenerator();
     IsolationLevel     = IsolationLevel.ReadCommitted;
     TablePrefix        = "";
     SessionPoolSize    = 16;
     QueryGatingEnabled = true;
     Logger             = NullLogger.Instance;
     ConcurrentTypes    = new HashSet <Type>();
 }
Example #3
0
 public Configuration()
 {
     IdentifierAccessorFactory = new PropertyAccessorFactory("Id");
     VersionAccessorFactory    = new PropertyAccessorFactory("Version");
     ContentSerializer         = new JsonContentSerializer();
     IdGenerator         = new DefaultIdGenerator();
     IsolationLevel      = IsolationLevel.ReadCommitted;
     TablePrefix         = "";
     CommandsPageSize    = 500;
     QueryGatingEnabled  = true;
     Logger              = NullLogger.Instance;
     ConcurrentTypes     = new HashSet <Type>();
     TableNameConvention = new DefaultTableNameConvention();
 }
Example #4
0
        private static void Go(IdGeneratorOptions options)
        {
            Count    = 0;
            testList = new List <GenTest>();

            // ++++++++++++++++++++++++++++++++
            if (single)
            {
                if (IdGen == null)
                {
                    IdGen = new DefaultIdGenerator(options);
                }

                if (outputLog)
                {
                    IdGen.GenIdActionAsync = (arg =>
                    {
                        if (arg.ActionType == 1)
                        {
                            Console.WriteLine($">>>> {arg.WorkerId}:开始:{DateTime.Now.ToString("mm:ss:fff")}, 周期次序:{arg.TermIndex}");
                        }
                        else if (arg.ActionType == 2)
                        {
                            Console.WriteLine($"<<<< {arg.WorkerId}:结束:{DateTime.Now.ToString("mm:ss:fff")},漂移 {arg.OverCostCountInOneTerm} 次,产生 {arg.GenCountInOneTerm} 个, 周期次序:{arg.TermIndex}");
                        }
                        if (arg.ActionType == 8)
                        {
                            Console.WriteLine($"---- {arg.WorkerId}:AA结束:{DateTime.Now.ToString("mm:ss:fff")},时间回拨");
                        }
                    });
                }

                for (int i = 1; i < workerCount + 1; i++)
                {
                    Console.WriteLine("Gen:" + i);
                    var test = new GenTest(IdGen, genIdCount, i);
                    testList.Add(test);
                    // test.GenId();
                    test.GenStart();
                }
            }
            else
            {
                for (int i = 1; i < workerCount + 1; i++)
                {
                    IdGeneratorOptions newOptions = new IdGeneratorOptions()
                    {
                        WorkerId          = (ushort)i, // workerId 不能设置为0
                        WorkerIdBitLength = options.WorkerIdBitLength,
                        SeqBitLength      = options.SeqBitLength,
                        MinSeqNumber      = options.MinSeqNumber,
                        MaxSeqNumber      = options.MaxSeqNumber,
                        Method            = options.Method,
                    };

                    Console.WriteLine("Gen:" + i);
                    var idGen2 = new DefaultIdGenerator(newOptions);
                    var test   = new GenTest(idGen2, genIdCount, i);

                    if (outputLog)
                    {
                        idGen2.GenIdActionAsync = (arg =>
                        {
                            Console.WriteLine($"{DateTime.Now.ToString("mm:ss:fff")} {arg.WorkerId} 漂移了 {arg.OverCostCountInOneTerm}, 顺序:{arg.TermIndex}");
                        });
                    }

                    testList.Add(test);
                    // test.GenId();
                    test.GenStart();
                }
            }

            while (Count < workerCount)
            {
                //Console.WriteLine("Count:" + Count);
                Thread.Sleep(1000);
            }
            //Console.WriteLine("Count:" + Count);

            if (!checkResult)
            {
                return;
            }

            var dupCount = 0;

            foreach (var id in testList[0].idList)
            {
                if (id == 0)
                {
                    Console.WriteLine("############### 错误的ID:" + id + "###########");
                }

                for (int j = 1; j < testList.Count; j++)
                {
                    if (testList[j].idList.Contains(id))
                    {
                        dupCount++;
                        Console.WriteLine("xxxxxxxxxx 重复的ID:" + id);
                    }
                }
            }

            if (dupCount > 0)
            {
                Console.WriteLine($"重复数量:{dupCount}");
            }
        }