Browse Source

Used IAbpDistributedLock instead of IDistributedLockProvider

pull/85/head
malik masis 4 years ago
parent
commit
ea4333a13b
  1. 10
      services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/DbMigrations/AdministrationServiceDatabaseMigrationEventHandler.cs
  2. 14
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/CatalogServiceDatabaseMigrationEventHandler.cs
  3. 5
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServiceDatabaseMigrationEventHandler.cs
  4. 6
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationEventHandler.cs
  5. 12
      services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationEventHandler.cs
  6. 5
      shared/EShopOnAbp.Shared.Hosting.Microservices/DbMigrations/EfCore/DatabaseEfCoreMigrationEventHandler.cs
  7. 8
      shared/EShopOnAbp.Shared.Hosting.Microservices/DbMigrations/MongoDb/DatabaseMongoDbMigrationEventHandler.cs

10
services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/DbMigrations/AdministrationServiceDatabaseMigrationEventHandler.cs

@ -1,12 +1,12 @@
using EShopOnAbp.AdministrationService.EntityFrameworkCore;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.EfCore;
using Medallion.Threading;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement;
@ -29,7 +29,7 @@ namespace EShopOnAbp.AdministrationService.DbMigrations
IPermissionDefinitionManager permissionDefinitionManager,
IPermissionDataSeeder permissionDataSeeder,
IDistributedEventBus distributedEventBus,
IDistributedLockProvider distributedLockProvider
IAbpDistributedLock distributedLockProvider
) : base(
currentTenant,
unitOfWorkManager,
@ -67,11 +67,11 @@ namespace EShopOnAbp.AdministrationService.DbMigrations
{
try
{
Logger.LogInformation("AdministrationService - Before Acquire");
Logger.LogInformation("AdministrationService - Before Acquire and Migration and Seed Data");
await using (var handle = await DistributedLockProvider.AcquireLockAsync(DatabaseName))
await using (var handle = await DistributedLockProvider.TryAcquireAsync(DatabaseName))
{
if(handle != null)
if (handle != null)
{
await MigrateDatabaseSchemaAsync(eventData.Id);
Logger.LogInformation("Starting AdministrationService DataSeeder...");

14
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/CatalogServiceDatabaseMigrationEventHandler.cs

@ -1,10 +1,10 @@
using System;
using System.Threading.Tasks;
using EShopOnAbp.CatalogService.MongoDB;
using EShopOnAbp.CatalogService.MongoDB;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.MongoDb;
using Medallion.Threading;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
@ -21,7 +21,7 @@ namespace EShopOnAbp.CatalogService.DbMigrations
ITenantStore tenantStore,
IDistributedEventBus distributedEventBus,
IServiceProvider serviceProvider,
IDistributedLockProvider distributedLockProvider
IAbpDistributedLock distributedLockProvider
) : base(
currentTenant,
unitOfWorkManager,
@ -47,9 +47,9 @@ namespace EShopOnAbp.CatalogService.DbMigrations
try
{
Logger.LogInformation("CatalogService - Before Acquire ");
Logger.LogInformation("CatalogService - Before Acquire and MigrateDatabaseSchemaAsync");
await using (var handle = await DistributedLockProvider.AcquireLockAsync(DatabaseName))
await using (var handle = await DistributedLockProvider.TryAcquireAsync(DatabaseName))
{
if (handle != null)
{

5
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServiceDatabaseMigrationEventHandler.cs

@ -12,6 +12,7 @@ using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
using Medallion.Threading;
using Microsoft.Extensions.Logging;
using Volo.Abp.DistributedLocking;
namespace EShopOnAbp.IdentityService.DbMigrations
{
@ -32,7 +33,7 @@ namespace EShopOnAbp.IdentityService.DbMigrations
IdentityServerDataSeeder identityServerDataSeeder,
IDistributedEventBus distributedEventBus,
ILocalEventBus localEventBus,
IDistributedLockProvider distributedLockProvider
IAbpDistributedLock distributedLockProvider
) : base(
currentTenant,
unitOfWorkManager,
@ -57,7 +58,7 @@ namespace EShopOnAbp.IdentityService.DbMigrations
{
Logger.LogInformation("IdentityService - Before Acquire ");
await using (var handle = await DistributedLockProvider.AcquireLockAsync(DatabaseName))
await using (var handle = await DistributedLockProvider.TryAcquireAsync(DatabaseName))
{
if (handle != null)
{

6
services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationEventHandler.cs

@ -1,10 +1,10 @@
using EShopOnAbp.OrderingService.EntityFrameworkCore;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.EfCore;
using Medallion.Threading;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
@ -23,7 +23,7 @@ namespace EShopOnAbp.OrderingService.DbMigrations
ITenantStore tenantStore,
IDistributedEventBus distributedEventBus,
IDataSeeder dataSeeder,
IDistributedLockProvider distributedLockProvider)
IAbpDistributedLock distributedLockProvider)
: base(
currentTenant,
unitOfWorkManager,
@ -53,7 +53,7 @@ namespace EShopOnAbp.OrderingService.DbMigrations
{
Logger.LogInformation("OrderingService - Before Acquire ");
await using (var handle = await DistributedLockProvider.AcquireLockAsync(DatabaseName))
await using (var handle = await DistributedLockProvider.TryAcquireAsync(DatabaseName))
{
if (handle != null)
{

12
services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationEventHandler.cs

@ -1,13 +1,13 @@
using EShopOnAbp.PaymentService.EntityFrameworkCore;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.EfCore;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.EfCore;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
using Medallion.Threading;
using Microsoft.Extensions.Logging;
namespace EShopOnAbp.PaymentService.DbMigrations
{
@ -20,7 +20,7 @@ namespace EShopOnAbp.PaymentService.DbMigrations
IUnitOfWorkManager unitOfWorkManager,
ITenantStore tenantStore,
IDistributedEventBus distributedEventBus,
IDistributedLockProvider distributedLockProvider)
IAbpDistributedLock distributedLockProvider)
: base(
currentTenant,
unitOfWorkManager,
@ -45,9 +45,9 @@ namespace EShopOnAbp.PaymentService.DbMigrations
try
{
Logger.LogInformation("PaymentService - Before Acquire ");
Logger.LogInformation("PaymentService - Before Acquire and MigrateDatabaseSchemaAsync");
await using (var handle = await DistributedLockProvider.AcquireLockAsync(DatabaseName))
await using (var handle = await DistributedLockProvider.TryAcquireAsync(DatabaseName))
{
if (handle != null)
{

5
shared/EShopOnAbp.Shared.Hosting.Microservices/DbMigrations/EfCore/DatabaseEfCoreMigrationEventHandler.cs

@ -10,6 +10,7 @@ using Microsoft.Extensions.Logging.Abstractions;
using Serilog;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EventBus.Distributed;
@ -30,7 +31,7 @@ public abstract class DatabaseEfCoreMigrationEventHandler<TDbContext> : Database
protected IDistributedEventBus DistributedEventBus { get; }
protected ILogger<DatabaseEfCoreMigrationEventHandler<TDbContext>> Logger { get; set; }
protected string DatabaseName { get; }
protected IDistributedLockProvider DistributedLockProvider { get; }
protected IAbpDistributedLock DistributedLockProvider { get; }
protected DatabaseEfCoreMigrationEventHandler(
ICurrentTenant currentTenant,
@ -38,7 +39,7 @@ public abstract class DatabaseEfCoreMigrationEventHandler<TDbContext> : Database
ITenantStore tenantStore,
IDistributedEventBus distributedEventBus,
string databaseName,
IDistributedLockProvider distributedLockProvider
IAbpDistributedLock distributedLockProvider
)
{
CurrentTenant = currentTenant;

8
shared/EShopOnAbp.Shared.Hosting.Microservices/DbMigrations/MongoDb/DatabaseMongoDbMigrationEventHandler.cs

@ -1,5 +1,4 @@
using Medallion.Threading;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using MongoDB.Driver;
@ -8,6 +7,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MongoDB;
@ -29,7 +29,7 @@ public abstract class DatabaseMongoDbMigrationEventHandler<TDbContext> : Databas
protected ILogger<DatabaseMongoDbMigrationEventHandler<TDbContext>> Logger { get; set; }
protected IServiceProvider ServiceProvider { get; }
protected string DatabaseName { get; }
protected IDistributedLockProvider DistributedLockProvider { get; }
protected IAbpDistributedLock DistributedLockProvider { get; }
protected DatabaseMongoDbMigrationEventHandler(
@ -39,7 +39,7 @@ public abstract class DatabaseMongoDbMigrationEventHandler<TDbContext> : Databas
IDistributedEventBus distributedEventBus,
string databaseName,
IServiceProvider serviceProvider,
IDistributedLockProvider distributedLockProvider
IAbpDistributedLock distributedLockProvider
)
{
CurrentTenant = currentTenant;

Loading…
Cancel
Save