添加了很多日志
This commit is contained in:
parent
776b221b3d
commit
d328fcfdfb
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Debug",
|
||||||
"Microsoft": "Warning",
|
"Microsoft": "Warning",
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Debug",
|
||||||
"Microsoft": "Warning",
|
"Microsoft": "Debug",
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Debug"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*"
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine
|
||||||
}
|
}
|
||||||
public string GetPrintInfo()
|
public string GetPrintInfo()
|
||||||
{
|
{
|
||||||
return $"table route result:has different tail:{HasDifferentTail},current table:[{string.Join(",", ReplaceTables.Select(o => o.FullName))}]";
|
return $"(has different tail:{HasDifferentTail},current table:[{string.Join(",", ReplaceTables.Select(o => o.FullName))}])";
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !EFCORE2
|
#if !EFCORE2
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace ShardingCore.Sharding.ShardingExecutors
|
||||||
public TResult Execute<TResult>(IShardingDbContext shardingDbContext, Expression query)
|
public TResult Execute<TResult>(IShardingDbContext shardingDbContext, Expression query)
|
||||||
{
|
{
|
||||||
var compileParameter = new CompileParameter(shardingDbContext,query);
|
var compileParameter = new CompileParameter(shardingDbContext,query);
|
||||||
_logger.LogDebug(compileParameter.GetPrintInfo());
|
_logger.LogDebug($"compile parameter:{compileParameter.GetPrintInfo()}");
|
||||||
using (new CustomerQueryScope(compileParameter))
|
using (new CustomerQueryScope(compileParameter))
|
||||||
{
|
{
|
||||||
var queryCompilerContext = _queryCompilerContextFactory.Create(compileParameter);
|
var queryCompilerContext = _queryCompilerContextFactory.Create(compileParameter);
|
||||||
|
@ -42,7 +42,7 @@ namespace ShardingCore.Sharding.ShardingExecutors
|
||||||
CancellationToken cancellationToken = new CancellationToken())
|
CancellationToken cancellationToken = new CancellationToken())
|
||||||
{
|
{
|
||||||
var compileParameter = new CompileParameter(shardingDbContext,query);
|
var compileParameter = new CompileParameter(shardingDbContext,query);
|
||||||
_logger.LogDebug(compileParameter.GetPrintInfo());
|
_logger.LogDebug($"compile parameter:{compileParameter.GetPrintInfo()}");
|
||||||
|
|
||||||
using (new CustomerQueryScope(compileParameter))
|
using (new CustomerQueryScope(compileParameter))
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ namespace ShardingCore.Sharding.ShardingExecutors
|
||||||
public IAsyncEnumerable<TResult> ExecuteAsync<TResult>(IShardingDbContext shardingDbContext, Expression query)
|
public IAsyncEnumerable<TResult> ExecuteAsync<TResult>(IShardingDbContext shardingDbContext, Expression query)
|
||||||
{
|
{
|
||||||
var compileParameter = new CompileParameter(shardingDbContext,query);
|
var compileParameter = new CompileParameter(shardingDbContext,query);
|
||||||
_logger.LogDebug(compileParameter.GetPrintInfo());
|
_logger.LogDebug($"compile parameter:{compileParameter.GetPrintInfo()}");
|
||||||
using (new CustomerQueryScope(compileParameter))
|
using (new CustomerQueryScope(compileParameter))
|
||||||
{
|
{
|
||||||
var queryCompilerContext = _queryCompilerContextFactory.Create(compileParameter);
|
var queryCompilerContext = _queryCompilerContextFactory.Create(compileParameter);
|
||||||
|
@ -68,7 +68,7 @@ namespace ShardingCore.Sharding.ShardingExecutors
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var compileParameter = new CompileParameter(shardingDbContext,query);
|
var compileParameter = new CompileParameter(shardingDbContext,query);
|
||||||
_logger.LogDebug(compileParameter.GetPrintInfo());
|
_logger.LogDebug($"compile parameter:{compileParameter.GetPrintInfo()}");
|
||||||
using (new CustomerQueryScope(compileParameter))
|
using (new CustomerQueryScope(compileParameter))
|
||||||
{
|
{
|
||||||
var queryCompilerContext = _queryCompilerContextFactory.Create(compileParameter);
|
var queryCompilerContext = _queryCompilerContextFactory.Create(compileParameter);
|
||||||
|
|
|
@ -11,6 +11,8 @@ using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ShardingCore.Core;
|
||||||
#if EFCORE2
|
#if EFCORE2
|
||||||
using Microsoft.EntityFrameworkCore.Internal;
|
using Microsoft.EntityFrameworkCore.Internal;
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,6 +28,12 @@ namespace ShardingCore.Sharding.ShardingQueryExecutors
|
||||||
*/
|
*/
|
||||||
public class DefaultShardingQueryExecutor : IShardingQueryExecutor
|
public class DefaultShardingQueryExecutor : IShardingQueryExecutor
|
||||||
{
|
{
|
||||||
|
private readonly ILogger<DefaultShardingQueryExecutor> _logger;
|
||||||
|
|
||||||
|
public DefaultShardingQueryExecutor(ILogger<DefaultShardingQueryExecutor> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
public TResult Execute<TResult>(IMergeQueryCompilerContext mergeQueryCompilerContext)
|
public TResult Execute<TResult>(IMergeQueryCompilerContext mergeQueryCompilerContext)
|
||||||
{
|
{
|
||||||
|
@ -110,8 +118,18 @@ namespace ShardingCore.Sharding.ShardingQueryExecutors
|
||||||
|
|
||||||
var streamMergeContextMethod = streamMergeContextFactory.GetType().GetMethod(nameof(IStreamMergeContextFactory.Create));
|
var streamMergeContextMethod = streamMergeContextFactory.GetType().GetMethod(nameof(IStreamMergeContextFactory.Create));
|
||||||
if (streamMergeContextMethod == null)
|
if (streamMergeContextMethod == null)
|
||||||
throw new ShardingCoreException($"cant found IStreamMergeContextFactory method [{nameof(IStreamMergeContextFactory.Create)}]");
|
throw new ShardingCoreException($"cant found {nameof(IStreamMergeContextFactory)} method [{nameof(IStreamMergeContextFactory.Create)}]");
|
||||||
|
#if DEBUG
|
||||||
|
var streamMergeContext= streamMergeContextMethod.MakeGenericMethod(new Type[] { resultType }).Invoke(streamMergeContextFactory, new object[] { mergeQueryCompilerContext });
|
||||||
|
if (streamMergeContext is IPrint print)
|
||||||
|
{
|
||||||
|
_logger.LogDebug(print.GetPrintInfo());
|
||||||
|
}
|
||||||
|
return streamMergeContext;
|
||||||
|
#endif
|
||||||
|
#if !DEBUG
|
||||||
return streamMergeContextMethod.MakeGenericMethod(new Type[] { resultType }).Invoke(streamMergeContextFactory, new object[] { mergeQueryCompilerContext });
|
return streamMergeContextMethod.MakeGenericMethod(new Type[] { resultType }).Invoke(streamMergeContextFactory, new object[] { mergeQueryCompilerContext });
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
private TResult EnumerableExecute<TResult>(IMergeQueryCompilerContext mergeQueryCompilerContext)
|
private TResult EnumerableExecute<TResult>(IMergeQueryCompilerContext mergeQueryCompilerContext)
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace ShardingCore.Sharding.ShardingExecutors
|
||||||
var dataSourceRouteResult = dataSourceRouteRuleEngineFactory.Route(queryCombineResult.GetCombineQueryable(), compileParameter.GetShardingDbContext());
|
var dataSourceRouteResult = dataSourceRouteRuleEngineFactory.Route(queryCombineResult.GetCombineQueryable(), compileParameter.GetShardingDbContext());
|
||||||
_logger.LogDebug(dataSourceRouteResult.GetPrintInfo());
|
_logger.LogDebug(dataSourceRouteResult.GetPrintInfo());
|
||||||
var routeResults = tableRouteRuleEngineFactory.Route(queryCombineResult.GetCombineQueryable()).ToArray();
|
var routeResults = tableRouteRuleEngineFactory.Route(queryCombineResult.GetCombineQueryable()).ToArray();
|
||||||
_logger.LogDebug($"table route results:{string.Join(",",routeResults.Select(o=>o.GetPrintInfo()))}");
|
_logger.LogDebug($"table route results:{string.Join(","+Environment.NewLine,routeResults.Select(o=>o.GetPrintInfo()))}");
|
||||||
var mergeCombineCompilerContext = MergeQueryCompilerContext.Create(queryCompilerContext, queryCombineResult, dataSourceRouteResult,
|
var mergeCombineCompilerContext = MergeQueryCompilerContext.Create(queryCompilerContext, queryCombineResult, dataSourceRouteResult,
|
||||||
routeResults);
|
routeResults);
|
||||||
return mergeCombineCompilerContext;
|
return mergeCombineCompilerContext;
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace ShardingCore.Sharding
|
||||||
* @Date: Monday, 25 January 2021 11:38:27
|
* @Date: Monday, 25 January 2021 11:38:27
|
||||||
* @Email: 326308290@qq.com
|
* @Email: 326308290@qq.com
|
||||||
*/
|
*/
|
||||||
public class StreamMergeContext<TEntity> : ISeqQueryProvider, IDisposable
|
public class StreamMergeContext<TEntity> : ISeqQueryProvider, IDisposable,IPrint
|
||||||
#if !EFCORE2
|
#if !EFCORE2
|
||||||
, IAsyncDisposable
|
, IAsyncDisposable
|
||||||
#endif
|
#endif
|
||||||
|
@ -497,5 +497,11 @@ namespace ShardingCore.Sharding
|
||||||
{
|
{
|
||||||
return TableRouteResults.Length > GetMaxQueryConnectionsLimit();
|
return TableRouteResults.Length > GetMaxQueryConnectionsLimit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetPrintInfo()
|
||||||
|
{
|
||||||
|
return
|
||||||
|
$"stream merge context:[max query connections limit:{GetMaxQueryConnectionsLimit()}],[is use read write separation:{IsUseReadWriteSeparation()}],[is parallel query:{IsParallelQuery()}],[is not support sharding:{IsNotSupportSharding()}],[is sequence query:{IsSeqQuery()}],[can trip:{CanTrip()}],[is route not match:{IsRouteNotMatch()}],[throw if query route not match:{ThrowIfQueryRouteNotMatch()}],[is pagination query:{IsPaginationQuery()}],[has group query:{HasGroupQuery()}],[is merge query:{IsMergeQuery()}],[is single sharding entity query:{IsSingleShardingEntityQuery()}]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue