diff --git a/Directory.Build.props b/Directory.Build.props index 3330dae..ff4346d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 2.0* + 2.3.* - \ No newline at end of file + diff --git a/NuClear.CodeStyle.DotSettings b/NuClear.CodeStyle.DotSettings index d3f16cf..1bc5785 100644 --- a/NuClear.CodeStyle.DotSettings +++ b/NuClear.CodeStyle.DotSettings @@ -153,6 +153,7 @@ True True True + True True True True diff --git a/Orleans.Clustering.Cassandra.sln b/Orleans.Clustering.Cassandra.sln index 4fc2e70..b905985 100644 --- a/Orleans.Clustering.Cassandra.sln +++ b/Orleans.Clustering.Cassandra.sln @@ -1,14 +1,18 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orleans.Clustering.Cassandra", "src/Orleans.Clustering.Cassandra/Orleans.Clustering.Cassandra.csproj", "{715DE586-77D5-48B1-AB5F-C3FE4E2FA1FD}" +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29025.244 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Clustering.Cassandra", "src\Orleans.Clustering.Cassandra\Orleans.Clustering.Cassandra.csproj", "{715DE586-77D5-48B1-AB5F-C3FE4E2FA1FD}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{91B10093-470D-4C12-A7A6-E1388E89937E}" -ProjectSection(SolutionItems) = preProject - build\build.ps1 = build\build.ps1 - build\build.cmd = build\build.cmd - appveyor.yml = appveyor.yml - Directory.Build.props = Directory.Build.props -EndProjectSection + ProjectSection(SolutionItems) = preProject + appveyor.yml = appveyor.yml + build\build.cmd = build\build.cmd + build\build.ps1 = build\build.ps1 + Directory.Build.props = Directory.Build.props + global.json = global.json + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,4 +25,10 @@ Global {715DE586-77D5-48B1-AB5F-C3FE4E2FA1FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {715DE586-77D5-48B1-AB5F-C3FE4E2FA1FD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {695ED350-2363-49F5-B682-38A3FD4DCCA3} + EndGlobalSection EndGlobal diff --git a/global.json b/global.json new file mode 100644 index 0000000..71273c2 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "2.1.400" + } +} diff --git a/src/Orleans.Clustering.Cassandra/ClusteringExtensions.cs b/src/Orleans.Clustering.Cassandra/ClusteringExtensions.cs index bd162a3..76b396a 100644 --- a/src/Orleans.Clustering.Cassandra/ClusteringExtensions.cs +++ b/src/Orleans.Clustering.Cassandra/ClusteringExtensions.cs @@ -2,10 +2,10 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Orleans.Clustering.Cassandra.Membership; using Orleans.Clustering.Cassandra.Options; -using Orleans.Configuration; using Orleans.Hosting; using Orleans.Messaging; @@ -65,4 +65,4 @@ public static IServiceCollection UseCassandraGatewayListProvider( return services.AddSingleton(); } } -} \ No newline at end of file +} diff --git a/src/Orleans.Clustering.Cassandra/Membership/CassandraMembershipTable.cs b/src/Orleans.Clustering.Cassandra/Membership/CassandraMembershipTable.cs index 6773e13..b6d3833 100644 --- a/src/Orleans.Clustering.Cassandra/Membership/CassandraMembershipTable.cs +++ b/src/Orleans.Clustering.Cassandra/Membership/CassandraMembershipTable.cs @@ -118,6 +118,31 @@ public async Task DeleteMembershipTableEntries(string clusterId) } } + public async Task CleanupDefunctSiloEntries(DateTimeOffset beforeDate) + { + try + { + var data = await _dataTable + .Where(x => x.ClusterId == _clusterId && x.Timestamp < beforeDate && x.Status == (int)SiloStatus.Dead) + .AllowFiltering() + .SetConsistencyLevel(DefaultConsistencyLevel) + .ExecuteAsync(); + + var batch = _mapper.CreateBatch().WithOptions(x => x.SetConsistencyLevel(DefaultConsistencyLevel)); + foreach (var item in data) + { + batch.Delete(item); + } + + await _mapper.ExecuteAsync(batch); + } + catch (DriverException) + { + _logger.LogWarning("Cassandra driver error occured while cleaning up defunct Silo entries for cluster {clusterId}.", _clusterId); + throw; + } + } + public async Task ReadRow(SiloAddress key) { try diff --git a/src/Orleans.Clustering.Cassandra/Orleans.Clustering.Cassandra.csproj b/src/Orleans.Clustering.Cassandra/Orleans.Clustering.Cassandra.csproj index cdc2517..aa4cfa8 100644 --- a/src/Orleans.Clustering.Cassandra/Orleans.Clustering.Cassandra.csproj +++ b/src/Orleans.Clustering.Cassandra/Orleans.Clustering.Cassandra.csproj @@ -3,8 +3,8 @@ netstandard2.0 - + - \ No newline at end of file +