1
0
mirror of synced 2025-12-17 02:28:12 +08:00

auto commit

This commit is contained in:
yitter
2021-04-04 02:02:06 +08:00
parent abea1071ee
commit 31e0f44b2a
5 changed files with 288 additions and 119 deletions

View File

@@ -25,12 +25,11 @@ namespace WInFormApp
public static extern long NextId2();
[DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)]
public static extern long RegisterWorkerId(string ip, int port, string password, int maxWorkerIdNumber);
public static extern IntPtr RegisterMany(string ip, int port, string password, int maxWorkerIdNumber, int idCount);
//public static extern ulong RegisterWorkerId2();
[DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)]
public static extern void UnRegisterWorkerId();
public static extern void UnRegister();
[DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)]
public static extern void SetWorkerId(uint workerId);
@@ -54,7 +53,12 @@ namespace WInFormApp
var ip = "localhost";
//txtIdList.Text += RegisterWorkerId(Encoding.UTF8.GetBytes(ip), 6379) + "\r\n";
txtIdList.Text += RegisterWorkerId(ip, 6379, "", 4) + "\r\n";
var ids = RegisterMany(ip, 6379, "", 4, 3);
//foreach (var id in ids)
//{
// txtIdList.Text += id;
//}
//txtIdList.Text += RegisterWorkerId() + "\r\n";
//txtIdList.Text += Test() + "\r\n";
@@ -69,7 +73,7 @@ namespace WInFormApp
{
try
{
UnRegisterWorkerId();
UnRegister();
txtIdList.Text += "LogOff";
}
catch (Exception ex)

View File

@@ -10,7 +10,6 @@ namespace Yitter.OrgSystem.TestA
{
class Program
{
// 测试参数默认配置下最佳性能是10W/s
static int genIdCount = 50000; // 计算ID数量如果要验证50W效率请将TopOverCostCount设置为20000或适当增加SeqBitLength
static short method = 1; // 1-漂移算法2-传统算法
@@ -25,10 +24,39 @@ namespace Yitter.OrgSystem.TestA
static int workerCount = 1;
//[DllImport("yitidgenc.dll", CallingConvention = CallingConvention.StdCall)]
//public static extern long NextId();
[DllImport("yitidgengo.dll", EntryPoint = "NextId", CallingConvention = CallingConvention.StdCall)]
public static extern long NextId2();
[DllImport("yitidgengo.so", EntryPoint = "NextId", CallingConvention = CallingConvention.StdCall)]
public static extern long NextId();
[DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)]
public static extern void SetWorkerId(uint workerId);
[DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int TestId();
[DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)]
public static extern long RegisterWorkerId(string ip, int port, string password, int maxWorkerIdNumber);
//public static extern ulong RegisterWorkerId2();
[DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)]
public static extern void UnRegisterWorkerId();
static void Main(string[] args)
{
Console.WriteLine("Hello World! C#");
RegisterWorkerId();
while (true)
{
Thread.Sleep(20000);
}
var options = new IdGeneratorOptions()
{
Method = method,
@@ -55,27 +83,19 @@ namespace Yitter.OrgSystem.TestA
while (true)
{
//RunSingle();
CallDll();
RunSingle();
//CallDll();
//Go(options);
Thread.Sleep(1000); // 每隔1秒执行一次Go
}
}
//[DllImport("yitidgenc.dll", CallingConvention = CallingConvention.StdCall)]
//public static extern long NextId();
[DllImport("yitidgengo.dll", EntryPoint = "NextId", CallingConvention = CallingConvention.StdCall)]
public static extern long NextId2();
[DllImport("yitidgengo.so", EntryPoint = "NextId", CallingConvention = CallingConvention.StdCall)]
public static extern long NextId();
[DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)]
public static extern void SetWorkerId(uint workerId);
[DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int TestId();
private static void RegisterWorkerId()
{
var workerId = RegisterWorkerId("118.178.140.203", 4037, "zhou@@myredis", 4);
Console.WriteLine("workerId" + workerId);
return;
}
private static void CallDll()
{