public void Thread_DataLog(IChannelHandlerContext context, byte[] Data) { try { long _id = Data.DeserializeProtobuf <long>(); using (var t = Datalog.dbEngine.GetTransaction()) { var _row = t.SelectForwardStartFrom <long, byte[]>(Datalog._Ratel_log, _id, false).Take(2); foreach (var item in _row) { var data = new RatelMessagePack() { command = Command.Execute_Command_DataLog, Data = item.Value, conf_key = Ratel.YamlConfig.ServerConfSetting.serverSettingModel.Key, }; var _byte = data.SerializeProtobuf(); var _unpooled = Unpooled.WrappedBuffer(_byte); context.WriteAndFlushAsync(_unpooled); } } } catch (Exception ex) { } }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="command"></param> private void GetLogSend(IChannelHandlerContext context, string command) { long id = Get_Log_Record(); var _pack = new RatelMessagePack() { command = command, Data = id.SerializeProtobuf(), conf_key = Ratel.YamlConfig.ServerConfSetting.serverSettingModel.Key, }; var upooled = Unpooled.WrappedBuffer(_pack.SerializeProtobuf()); context.WriteAndFlushAsync(upooled); }
public void RunThread() { _thread1 = new Thread(() => { while (true) { Thread.Sleep(1000 * 3); foreach (var item in Ratel.Node.ClustersNode.node .Where(x => x.Value.me == false && x.Value.ConnectionStatus == false)) { string[] _ip = item.Value.host.Split(':'); ClustersNode(_ip[0], int.Parse(_ip[1])); } } }); _thread2 = new Thread(() => { while (true) { Thread.Sleep(1000 * 3); foreach (var item in Ratel.Node.ClustersNode.node.Where(x => x.Value.me == false && x.Value.channel != null && x.Value.master == true)) { var data = new RatelMessagePack() { command = Command.Thread_DataLog, Data = CommandImpl.Get_Log_Id().SerializeProtobuf(), conf_key = Ratel.YamlConfig.ServerConfSetting.serverSettingModel.Key, }; var _byte = data.SerializeProtobuf(); var _unpooled = Helios.Buffers.Unpooled.WrappedBuffer(_byte); item.Value.channel.WriteAndFlushAsync(_unpooled); } } }); _thread1.IsBackground = true; _thread2.IsBackground = true; _thread1.Start(); _thread2.Start(); }