public static void InitializeDefaultPartitionKeys(short partitionCount, short eventHubPartitionCount) { if (ScaledEntityPartitionResolver.DefaultPartitionKeys == null) { ScaledEntityPartitionResolver.DefaultPartitionKeys = ScaledEntityPartitionResolver.GeneratePartitionKeys(partitionCount); } if (ScaledEntityPartitionResolver.DefaultEventHubPartitionKeys == null) { ScaledEntityPartitionResolver.DefaultEventHubPartitionKeys = ScaledEntityPartitionResolver.GeneratePartitionKeys(eventHubPartitionCount); } }
public static short ResolveToEntityLogicalPartition(string value, short entityPartitionCount) { uint num; uint num1; if (value == null) { return(0); } ScaledEntityPartitionResolver.ComputeHash(Encoding.ASCII.GetBytes(value.ToUpper(CultureInfo.InvariantCulture)), 0, 0, out num, out num1); long num2 = (long)(num ^ num1); return((short)Math.Abs(num2 % (long)entityPartitionCount)); }
public static string[] GeneratePartitionKeys(short partitionCount) { string[] strArrays = new string[partitionCount]; int num = 0; int num1 = 0; while (num1 < partitionCount) { string str = num.ToString(CultureInfo.InvariantCulture); short entityLogicalPartition = ScaledEntityPartitionResolver.ResolveToEntityLogicalPartition(str, partitionCount); if (strArrays[entityLogicalPartition] == null) { strArrays[entityLogicalPartition] = str; num1++; } num++; } return(strArrays); }
public static bool MapsToSingleLogicalPartition(string[] values, short partitionCount) { bool flag = true; if ((int)values.Length > 0) { short entityLogicalPartition = ScaledEntityPartitionResolver.ResolveToEntityLogicalPartition(values[0], partitionCount); int num = 1; while (num < (int)values.Length) { if (ScaledEntityPartitionResolver.ResolveToEntityLogicalPartition(values[num], partitionCount) == entityLogicalPartition) { num++; } else { flag = false; break; } } } return(flag); }
public static bool MapsToSingleLogicalPartition(long[] sequenceNumbers) { bool flag = true; if ((int)sequenceNumbers.Length > 0) { short entityLogicalPartition = ScaledEntityPartitionResolver.SequenceNumberToEntityLogicalPartition(sequenceNumbers[0]); int num = 1; while (num < (int)sequenceNumbers.Length) { if (ScaledEntityPartitionResolver.SequenceNumberToEntityLogicalPartition(sequenceNumbers[num]) == entityLogicalPartition) { num++; } else { flag = false; break; } } } return(flag); }
public static bool MapsToSingleLogicalPartition(Guid[] lockTokens) { bool flag = true; if ((int)lockTokens.Length > 0) { short entityLogicalPartition = ScaledEntityPartitionResolver.LockTokenToEntityLogicalPartition(lockTokens[0]); int num = 1; while (num < (int)lockTokens.Length) { if (ScaledEntityPartitionResolver.LockTokenToEntityLogicalPartition(lockTokens[num]) == entityLogicalPartition) { num++; } else { flag = false; break; } } } return(flag); }