pull/1/head
wangshaoming 7 years ago
parent cba469867d
commit e2e7c35224
No known key found for this signature in database
GPG Key ID: 29F5223B4DB362B5
  1. 18
      scripts/nuget-hessian.sh
  2. 17
      src/DotXxlJob.Core/AdminClient.cs
  3. 3
      src/DotXxlJob.Core/Attributes/JobHandlerAttribute.cs
  4. 2
      src/DotXxlJob.Core/Internal/HessianSerializer.cs
  5. 11
      src/DotXxlJob.Core/Logger/JobLogger.cs

@ -0,0 +1,18 @@
set -ex
cd $(dirname $0)/../
artifactsFolder="./artifacts"
if [ -d $artifactsFolder ]; then
rm -R $artifactsFolder
fi
mkdir -p $artifactsFolder
dotnet build ./src/Hessian/Hessian.csproj -c Release
dotnet pack ./src/Hessian/Hessian.csproj -c Release -o ../../$artifactsFolder
dotnet nuget push ./$artifactsFolder/Hessian.*.nupkg -k $NUGET_KEY -s https://www.nuget.org

@ -1,14 +1,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.SymbolStore;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Hessian;
using DotXxlJob.Core.Config;
using DotXxlJob.Core.Model;
using Hessian;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -16,7 +15,7 @@ namespace DotXxlJob.Core
{
public class AdminClient
{
static readonly string MAPPING = "/api";
private static readonly string MAPPING = "/api";
private readonly XxlJobExecutorOptions _options;
private readonly IHttpClientFactory _clientFactory;
private readonly ILogger<AdminClient> _logger;
@ -29,7 +28,6 @@ namespace DotXxlJob.Core
, IHttpClientFactory clientFactory
, ILogger<AdminClient> logger)
{
Preconditions.CheckNotNull(optionsAccessor?.Value, "XxlJobExecutorOptions");
this._options = optionsAccessor?.Value;
@ -56,13 +54,11 @@ namespace DotXxlJob.Core
}
}
public Task<ReturnT> Callback(List<HandleCallbackParam> callbackParamList)
{
return InvokeRpcService("callback", new List<object> { new JavaClass { Name = Constants.JavaListFulName } }, callbackParamList);
}
public Task<ReturnT> Registry(RegistryParam registryParam)
{
return InvokeRpcService("registry", new List<object> { new JavaClass { Name = "com.xxl.job.core.biz.model.RegistryParam" } }, registryParam, true);
@ -79,7 +75,7 @@ namespace DotXxlJob.Core
var request = new RpcRequest {
RequestId = Guid.NewGuid().ToString("N"),
CreateMillisTime = DateTime.Now.GetTotalMilliseconds(),
AccessToken = this._options.AccessToken,
AccessToken = _options.AccessToken,
ClassName = "com.xxl.job.core.biz.AdminBiz",
MethodName = methodName,
ParameterTypes = parameterTypes,
@ -130,13 +126,10 @@ namespace DotXxlJob.Core
}
*/
res = HessianSerializer.DeserializeResponse(resStream);
}
catch (Exception ex)
{
this._logger.LogError(ex, "DeserializeResponse error:{errorMessage}", ex.Message);
}
if (res == null)
@ -160,7 +153,6 @@ namespace DotXxlJob.Core
{
return retList[0];
}
}
if (retList.Count > 0)
@ -169,7 +161,6 @@ namespace DotXxlJob.Core
}
}
throw new Exception("xxl-rpc server address not accessible.");
}
private async Task<Stream> DoPost(HttpClient client, AddressEntry address, byte[] postBuf)
@ -181,7 +172,5 @@ namespace DotXxlJob.Core
responseMessage.EnsureSuccessStatusCode();
return await responseMessage.Content.ReadAsStreamAsync();
}
}
}

@ -2,11 +2,12 @@ using System;
namespace DotXxlJob.Core
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class JobHandlerAttribute:Attribute
{
public JobHandlerAttribute(string name)
{
this.Name = name;
Name = name;
}
public string Name { get; }

@ -64,7 +64,7 @@ namespace DotXxlJob.Core
{
//没有数据可读了
}
catch (Exception)
catch
{
//TODO: do something?
}

@ -47,7 +47,16 @@ namespace DotXxlJob.Core
public void Log(string pattern, params object[] format)
{
var appendLog = string.Format(pattern, format);
string appendLog;
if (format == null || format.Length == 0)
{
appendLog = pattern;
}
else
{
appendLog = string.Format(pattern, format);
}
var callInfo = new StackTrace(true).GetFrame(1);
LogDetail(GetLogFileName(), callInfo, appendLog);
}

Loading…
Cancel
Save