Example #1
0
 private ActivationId(UniqueKey key)
 {
     this.Key = key;
 }
Example #2
0
 internal static GrainId NewSystemTargetGrainIdByTypeCode(int typeData)
 {
     return(FindOrCreateGrainId(UniqueKey.NewSystemTargetKey(Guid.NewGuid(), typeData)));
 }
Example #3
0
 internal static GrainId GetSystemTargetGrainId(int typeData, string systemGrainId)
 {
     return(FindOrCreateGrainId(UniqueKey.NewSystemTargetKey(systemGrainId, typeData)));
 }
Example #4
0
 internal static GrainId NewClientId(Guid id, string clusterId = null)
 {
     return(FindOrCreateGrainId(UniqueKey.NewKey(id,
                                                 clusterId == null ? UniqueKey.Category.Client : UniqueKey.Category.GeoClient, 0, clusterId)));
 }
Example #5
0
 internal static GrainId GetSystemGrainId(Guid guid)
 {
     return(FindOrCreateGrainId(UniqueKey.NewKey(guid, UniqueKey.Category.SystemGrain)));
 }
Example #6
0
 internal static GrainId GetGrainId(long typeCode, string primaryKey)
 {
     return(FindOrCreateGrainId(UniqueKey.NewKey(0L,
                                                 UniqueKey.Category.KeyExtGrain,
                                                 typeCode, primaryKey)));
 }
Example #7
0
 private GrainId(UniqueKey key)
     : base(key)
 {
 }
Example #8
0
 internal static LegacyGrainId NewClientId(Guid id)
 {
     return(FindOrCreateGrainId(UniqueKey.NewKey(id, UniqueKey.Category.Client, 0)));
 }
Example #9
0
 // For testing only.
 internal static LegacyGrainId GetGrainIdForTesting(Guid guid)
 {
     return(FindOrCreateGrainId(UniqueKey.NewKey(guid)));
 }
Example #10
0
 private static LegacyGrainId FindOrCreateGrainId(UniqueKey key)
 {
     return(grainIdInternCache.FindOrCreate(key, k => new LegacyGrainId(k)));
 }
Example #11
0
 internal LegacyGrainId(UniqueKey key)
 {
     this.Key = key;
 }
Example #12
0
 internal static LegacyGrainId GetGrainServiceGrainId(int typeData, string systemGrainId)
 {
     return(FindOrCreateGrainId(UniqueKey.NewGrainServiceKey(systemGrainId, typeData)));
 }
Example #13
0
 internal static ActivationId GetActivationId(UniqueKey key)
 {
     return(legacyKeyInterner.FindOrCreate(key, k => new ActivationId(k)));
 }
Example #14
0
 public static ActivationId NewId()
 {
     return(GetActivationId(UniqueKey.NewKey()));
 }
Example #15
0
 internal GrainId(UniqueKey key)
     : base(key)
 {
 }
Example #16
0
 internal static LegacyGrainId GetSystemTargetGrainId(long typeData)
 {
     return(FindOrCreateGrainId(UniqueKey.NewEmptySystemTargetKey(typeData)));
 }
Example #17
0
 protected UniqueIdentifier(UniqueKey key)
 {
     Key = key;
 }
Example #18
0
 internal static GrainType GetGrainType(long typeCode, bool isKeyExt)
 {
     return(GetGrainType(isKeyExt
         ? UniqueKey.NewKey(0, UniqueKey.Category.KeyExtGrain, typeCode, "keyext")
         : UniqueKey.NewKey(0, UniqueKey.Category.Grain, typeCode)));
 }
Example #19
0
 internal static GrainId GetGrainServiceGrainId(short id, int typeData)
 {
     return(FindOrCreateGrainId(UniqueKey.NewGrainServiceKey(id, typeData)));
 }
Example #20
0
 private ActivationId(UniqueKey key)
     : base(key)
 {
 }
Example #21
0
 public static GrainId NewId()
 {
     return(FindOrCreateGrainId(UniqueKey.NewKey(Guid.NewGuid(), UniqueKey.Category.Grain)));
 }
Example #22
0
 public static ActivationId NewId()
 {
     return(FindOrCreate(UniqueKey.NewKey()));
 }
Example #23
0
 internal static GrainId GetGrainId(UniqueKey key)
 {
     return(FindOrCreateGrainId(key));
 }
Example #24
0
 internal static ActivationId GetActivationId(UniqueKey key)
 {
     return(FindOrCreate(key));
 }
Example #25
0
 // For testing only.
 internal static GrainId GetGrainIdForTesting(Guid guid)
 {
     return(FindOrCreateGrainId(UniqueKey.NewKey(guid, UniqueKey.Category.None)));
 }
Example #26
0
 private static ActivationId FindOrCreate(UniqueKey key)
 {
     return(interner.FindOrCreate(key, () => new ActivationId(key)));
 }
Example #27
0
 internal static GrainId GetSystemTargetGrainId(short systemGrainId)
 {
     return(FindOrCreateGrainId(UniqueKey.NewSystemTargetKey(systemGrainId)));
 }
Example #28
0
 public static GrainId NewClientAddressableGrainId()
 {
     return(FindOrCreateGrainId(UniqueKey.NewKey(Guid.NewGuid(), UniqueKey.Category.ClientAddressableObject)));
 }
Example #29
0
 internal static GrainId GetGrainId(long typeCode, Guid primaryKey, string keyExt = null)
 {
     return(FindOrCreateGrainId(UniqueKey.NewKey(primaryKey,
                                                 keyExt == null ? UniqueKey.Category.Grain : UniqueKey.Category.KeyExtGrain,
                                                 typeCode, keyExt)));
 }
Example #30
0
        private static unsafe LegacyGrainId FromGrainIdInternal(GrainId id)
        {
            var typeSpan = id.Type.AsSpan();
            int prefixLength;

            if (typeSpan.StartsWith(GrainTypePrefix.LegacyGrainPrefixBytes.Span))
            {
                prefixLength = GrainTypePrefix.LegacyGrainPrefixBytes.Length;
            }
            else
            {
                return(null);
            }

            ulong typeCodeData;
            var   typeCodeSlice = typeSpan.Slice(prefixLength);

            fixed(byte *typeCodeBytes = typeCodeSlice)
            {
                // TODO: noalloc
                var typeCodeString = Encoding.UTF8.GetString(typeCodeBytes, 16);

                if (!ulong.TryParse(typeCodeString, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out typeCodeData))
                {
                    return(null);
                }
            }

            ulong  n0, n1;
            string keyExt;
            var    keySpan = id.Key.Value.Span;

            fixed(byte *idBytes = keySpan)
            {
                const int fieldLength = 16;

                // TODO: noalloc
                var n0String = Encoding.UTF8.GetString(idBytes, fieldLength);

                if (!ulong.TryParse(n0String, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out n0))
                {
                    return(null);
                }

                // TODO: noalloc
                var n1String = Encoding.UTF8.GetString(idBytes + fieldLength, fieldLength);

                if (!ulong.TryParse(n1String, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out n1))
                {
                    return(null);
                }

                const int keySpanPrefixLength = fieldLength + fieldLength + 1;

                if (keySpan.Length > keySpanPrefixLength && idBytes[keySpanPrefixLength - 1] == (byte)'+')
                {
                    // Take every byte after the '+' and interpret it as UTF8
                    keyExt = Encoding.UTF8.GetString(idBytes + keySpanPrefixLength, keySpan.Length - keySpanPrefixLength);
                }
                else
                {
                    keyExt = default;
                }
            }

            return(new LegacyGrainId(UniqueKey.NewKey(n0, n1, typeCodeData, keyExt)));
        }