public async Task DoNotOverrideEntry() { var expected = new GrainAddress { ActivationId = ActivationId.NewId(), GrainId = GrainId.Parse("user/someraondomuser_" + Guid.NewGuid().ToString("N")), SiloAddress = SiloAddress.FromParsableString("10.0.23.12:1000@5678") }; var differentActivation = new GrainAddress { ActivationId = ActivationId.NewId(), GrainId = expected.GrainId, SiloAddress = SiloAddress.FromParsableString("10.0.23.12:1000@5678") }; var differentSilo = new GrainAddress { ActivationId = expected.ActivationId, GrainId = expected.GrainId, SiloAddress = SiloAddress.FromParsableString("10.0.23.14:1000@4583") }; Assert.Equal(expected, await this.grainDirectory.Register(expected)); Assert.Equal(expected, await this.grainDirectory.Register(differentActivation)); Assert.Equal(expected, await this.grainDirectory.Register(differentSilo)); Assert.Equal(expected, await this.grainDirectory.Lookup(expected.GrainId)); }
public static ActivationAddress ToActivationAddress(this GrainAddress addr) { return(ActivationAddress.GetAddress( SiloAddress.FromParsableString(addr.SiloAddress), GrainId.Parse(addr.GrainId), ActivationId.GetActivationId(UniqueKey.Parse(addr.ActivationId.AsSpan())))); }
public async Task RegisterLookupUnregisterLookup() { var expected = new GrainAddress { ActivationId = ActivationId.NewId(), GrainId = GrainId.Parse("user/someraondomuser_" + Guid.NewGuid().ToString("N")), SiloAddress = SiloAddress.FromParsableString("10.0.23.12:1000@5678") }; Assert.Equal(expected, await this.grainDirectory.Register(expected)); Assert.Equal(expected, await this.grainDirectory.Lookup(expected.GrainId)); await this.grainDirectory.Unregister(expected); Assert.Null(await this.grainDirectory.Lookup(expected.GrainId)); }
public async Task UnregisterMany() { const int N = 250; const int R = 40; // Create and insert N entries var addresses = new List <GrainAddress>(); for (var i = 0; i < N; i++) { var addr = new GrainAddress { ActivationId = ActivationId.NewId(), GrainId = GrainId.Parse("user/someraondomuser_" + Guid.NewGuid().ToString("N")), SiloAddress = SiloAddress.FromParsableString("10.0.23.12:1000@5678") }; addresses.Add(addr); await this.grainDirectory.Register(addr); } // Modify the Rth entry locally, to simulate another activation tentative by another silo var oldActivation = addresses[R].ActivationId; addresses[R].ActivationId = ActivationId.NewId(); // Batch unregister await this.grainDirectory.UnregisterMany(addresses); // Now we should only find the old Rth entry for (int i = 0; i < N; i++) { if (i == R) { var addr = await this.grainDirectory.Lookup(addresses[i].GrainId); Assert.NotNull(addr); Assert.Equal(oldActivation, addr.ActivationId); } else { Assert.Null(await this.grainDirectory.Lookup(addresses[i].GrainId)); } } }
public async Task DoNotDeleteDifferentActivationIdEntry() { var expected = new GrainAddress { ActivationId = ActivationId.NewId(), GrainId = GrainId.Parse("user/someraondomuser_" + Guid.NewGuid().ToString("N")), SiloAddress = SiloAddress.FromParsableString("10.0.23.12:1000@5678") }; var otherEntry = new GrainAddress { ActivationId = ActivationId.NewId(), GrainId = expected.GrainId, SiloAddress = SiloAddress.FromParsableString("10.0.23.12:1000@5678") }; Assert.Equal(expected, await this.grainDirectory.Register(expected)); await this.grainDirectory.Unregister(otherEntry); Assert.Equal(expected, await this.grainDirectory.Lookup(expected.GrainId)); }
private GrainId RoundTripGrainIdToParsable(GrainId input) { string str = input.ToString(); return(GrainId.Parse(str)); }
public async Task LookupNotFound() { Assert.Null(await this.grainDirectory.Lookup(GrainId.Parse("user/someraondomuser_" + Guid.NewGuid().ToString("N")))); }
internal static GrainId RowKeyToGrainId(string rowKey) => GrainId.Parse(HttpUtility.UrlDecode(rowKey, Encoding.UTF8));