Merge branch 'release/UpdateRedisQueue_06'
This commit is contained in:
@@ -630,7 +630,9 @@ namespace IOB_UT_NEXT.Iob
|
||||
QueueAlarm = new DataQueue(codIob, "QueueAlarm", false, redisMan);
|
||||
// valutare se portare di nuovo in redis...
|
||||
QueueIN = new DataQueue(codIob, "QueueIN", useRedis, redisMan);
|
||||
QueueFLog = new DataQueue(codIob, "QueueFLog", useRedis, redisMan);
|
||||
// fix a NON redis
|
||||
QueueFLog = new DataQueue(codIob, "QueueFLog", false, redisMan);
|
||||
//QueueFLog = new DataQueue(codIob, "QueueFLog", useRedis, redisMan);
|
||||
QueueMessages = new DataQueue(codIob, "QueueMessages", false, redisMan);
|
||||
QueueRawTransf = new DataQueue(codIob, "QueueRawTransf", false, redisMan);
|
||||
QueueULog = new DataQueue(codIob, "QueueULog", false, redisMan);
|
||||
|
||||
+102
-66
@@ -29,6 +29,7 @@ namespace IOB_UT_NEXT
|
||||
/// <param name="codIob"></param>
|
||||
public RedisIobCache()
|
||||
{
|
||||
initRedisConn();
|
||||
initMemKeys();
|
||||
}
|
||||
|
||||
@@ -43,6 +44,7 @@ namespace IOB_UT_NEXT
|
||||
/// </param>
|
||||
public RedisIobCache(string codServer, string codIob, string tipoIob, int minDeltaS)
|
||||
{
|
||||
initRedisConn();
|
||||
// init dati di base...
|
||||
currCodIob = codIob;
|
||||
currIobType = tipoIob;
|
||||
@@ -116,41 +118,21 @@ namespace IOB_UT_NEXT
|
||||
{
|
||||
// init DB (sullo 0)
|
||||
answ = connRedis.GetDatabase();
|
||||
int dbNum = baseUtils.CRI("redisDb");
|
||||
// gestione override...
|
||||
if (baseUtils.CRI("redisDb") >= 0)
|
||||
if (dbNum >= 0)
|
||||
{
|
||||
// in questo caso uso il DB configurato in app.config...
|
||||
answ = connRedis.GetDatabase(baseUtils.CRI("redisDb"));
|
||||
answ = connRedis.GetDatabase(dbNum);
|
||||
}
|
||||
_currDB = answ;
|
||||
Logging.Instance.Info($"Apertura di un Redis Database: {dbNum}");
|
||||
}
|
||||
// restituisco oggetto DB
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto statico connessione redis
|
||||
/// </summary>
|
||||
public ConnectionMultiplexer connRedis
|
||||
{
|
||||
get
|
||||
{
|
||||
return lazyConnection.Value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto statico connessione redis
|
||||
/// </summary>
|
||||
public ConnectionMultiplexer connRedisAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
return lazyConnectionAdmin.Value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accesso all'oggetto stato IOB da esterno
|
||||
/// </summary>
|
||||
@@ -206,6 +188,7 @@ namespace IOB_UT_NEXT
|
||||
// init DB (sullo 0)
|
||||
answ = connRedis.GetSubscriber();
|
||||
_currSub = answ;
|
||||
Logging.Instance.Info($"Apertura di un Redis Message Subscriber");
|
||||
}
|
||||
// restituisco oggetto DB
|
||||
return answ;
|
||||
@@ -792,35 +775,6 @@ namespace IOB_UT_NEXT
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Incremento conteggio di un valore dentro una hash
|
||||
/// </summary>
|
||||
/// <param name="hashKey">chiave</param>
|
||||
/// <param name="hashField">valore con conteggio da tracciare</param>
|
||||
/// <param name="hashExpire">scadenza preimpostata hash datetime, se null NON scade</param>
|
||||
/// <returns></returns>
|
||||
public bool redIncrHashCount(string hashKey, string hashField, DateTime? hashExpire)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco se ci sia valore in redis...
|
||||
try
|
||||
{
|
||||
RedisKey chiave = hashKey;
|
||||
cache.HashIncrement(chiave, hashField, 1);
|
||||
if (hashExpire != null)
|
||||
{
|
||||
cache.KeyExpire(chiave, hashExpire);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Logging.Instance.Error($"redIncrHashCount {exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Incremento conteggio di un valore dentro una hash
|
||||
/// </summary>
|
||||
@@ -907,6 +861,18 @@ namespace IOB_UT_NEXT
|
||||
return cache.ListLeftPop(queueName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero list di TUTTI i valori in QUEUE (FIFO)
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <param name="maxElem">num max di elementi da recuperare</param>
|
||||
public List<RedisValue> redQueuePopAll(RedisKey queueName)
|
||||
{
|
||||
long nCount = cache.ListLength(queueName);
|
||||
List<RedisValue> listData = cache.ListRange(queueName, 0, nCount).ToList();
|
||||
return listData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero una list di valori in QUEUE (FIFO)
|
||||
/// </summary>
|
||||
@@ -920,18 +886,6 @@ namespace IOB_UT_NEXT
|
||||
return listData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero list di TUTTI i valori in QUEUE (FIFO)
|
||||
/// </summary>
|
||||
/// <param name="queueName"></param>
|
||||
/// <param name="maxElem">num max di elementi da recuperare</param>
|
||||
public List<RedisValue> redQueuePopAll(RedisKey queueName)
|
||||
{
|
||||
long nCount = cache.ListLength(queueName);
|
||||
List<RedisValue> listData = cache.ListRange(queueName, 0, nCount).ToList();
|
||||
return listData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scrittura valore in QUEUE (FIFO)
|
||||
/// </summary>
|
||||
@@ -1112,6 +1066,7 @@ namespace IOB_UT_NEXT
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salvataggio di una hash di valori in formato Dictionary
|
||||
/// </summary>
|
||||
@@ -1514,6 +1469,7 @@ namespace IOB_UT_NEXT
|
||||
/// </summary>
|
||||
private Dictionary<string, DateTime> LastKeySave = new Dictionary<string, DateTime>();
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Connessione lazy a redis...
|
||||
/// </summary>
|
||||
@@ -1540,7 +1496,8 @@ namespace IOB_UT_NEXT
|
||||
}
|
||||
|
||||
return ConnectionMultiplexer.Connect(RedisConnAdmin);
|
||||
});
|
||||
});
|
||||
#endif
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -1556,6 +1513,32 @@ namespace IOB_UT_NEXT
|
||||
/// </summary>
|
||||
private ISubscriber _currSub { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto statico connessione redis
|
||||
/// </summary>
|
||||
private ConnectionMultiplexer connRedis { get; set; }
|
||||
#if false
|
||||
{
|
||||
get
|
||||
{
|
||||
return lazyConnection.Value;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto statico connessione redis
|
||||
/// </summary>
|
||||
private ConnectionMultiplexer connRedisAdmin { get; set; }
|
||||
#if false
|
||||
{
|
||||
get
|
||||
{
|
||||
return lazyConnectionAdmin.Value;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
@@ -1591,6 +1574,59 @@ namespace IOB_UT_NEXT
|
||||
redIobChannel = $"IobChannel_{currCodIob}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Init oggetti connessione REDIS
|
||||
/// </summary>
|
||||
private void initRedisConn()
|
||||
{
|
||||
// init obj standard
|
||||
string RedisConn = baseUtils.CRS("RedisConn");
|
||||
if (string.IsNullOrEmpty(RedisConn))
|
||||
{
|
||||
RedisConn = "localhost,abortConnect=false,ssl=false";
|
||||
}
|
||||
connRedis = ConnectionMultiplexer.Connect(RedisConn);
|
||||
Logging.Instance.Info($"Apertura di un Redis Multiplexer");
|
||||
|
||||
// initi obj admin
|
||||
string RedisConnAdmin = baseUtils.CRS("RedisConnAdmin");
|
||||
if (string.IsNullOrEmpty(RedisConnAdmin))
|
||||
{
|
||||
RedisConnAdmin = "localhost,abortConnect=false,ssl=false,allowAdmin=true";
|
||||
}
|
||||
connRedisAdmin = ConnectionMultiplexer.Connect(RedisConnAdmin);
|
||||
Logging.Instance.Info($"Apertura di un Redis Multiplexer Admin");
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Incremento conteggio di un valore dentro una hash
|
||||
/// </summary>
|
||||
/// <param name="hashKey">chiave</param>
|
||||
/// <param name="hashField">valore con conteggio da tracciare</param>
|
||||
/// <param name="hashExpire">scadenza preimpostata hash datetime, se null NON scade</param>
|
||||
/// <returns></returns>
|
||||
public bool redIncrHashCount(string hashKey, string hashField, DateTime? hashExpire)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco se ci sia valore in redis...
|
||||
try
|
||||
{
|
||||
RedisKey chiave = hashKey;
|
||||
cache.HashIncrement(chiave, hashField, 1);
|
||||
if (hashExpire != null)
|
||||
{
|
||||
cache.KeyExpire(chiave, hashExpire);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Logging.Instance.Error($"redIncrHashCount {exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -5152,7 +5152,9 @@ namespace IOB_WIN_FORM.Iob
|
||||
bool useRedis = IOBConfFull.General.EnabRedisQue;
|
||||
QueueAlarm = new DataQueue(codIob, "QueueAlarm", false, redisMan);
|
||||
QueueIN = new DataQueue(codIob, "QueueIN", useRedis, redisMan);
|
||||
QueueFLog = new DataQueue(codIob, "QueueFLog", useRedis, redisMan);
|
||||
// no coda redis
|
||||
QueueFLog = new DataQueue(codIob, "QueueFLog", false, redisMan);
|
||||
//QueueFLog = new DataQueue(codIob, "QueueFLog", useRedis, redisMan);
|
||||
QueueMessages = new DataQueue(codIob, "QueueMessages", false, redisMan);
|
||||
QueueRawTransf = new DataQueue(codIob, "QueueRawTransf", false, redisMan);
|
||||
QueueULog = new DataQueue(codIob, "QueueULog", false, redisMan);
|
||||
@@ -5288,8 +5290,9 @@ namespace IOB_WIN_FORM.Iob
|
||||
listaValori = QueueFLog.ToList();
|
||||
// invio
|
||||
sendDataBlock(urlType.FLog, listaValori);
|
||||
// svuoto!
|
||||
QueueFLog = new DataQueue(IOBConfFull.General.FilenameIOB, "QueueFLog", IOBConfFull.General.EnabRedisQue, redisMan);
|
||||
// svuoto! NO redis
|
||||
QueueFLog = new DataQueue(IOBConfFull.General.FilenameIOB, "QueueFLog", false, redisMan);
|
||||
//QueueFLog = new DataQueue(IOBConfFull.General.FilenameIOB, "QueueFLog", IOBConfFull.General.EnabRedisQue, redisMan);
|
||||
lastWatchDog = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3315,8 +3315,9 @@ namespace IOB_WIN_FORM.Iob
|
||||
listaValori = QueueFLog.ToList();
|
||||
// invio
|
||||
sendDataBlock(urlType.FLog, listaValori);
|
||||
// svuoto!
|
||||
QueueFLog = new DataQueue(IOBConfFull.General.FilenameIOB, "QueueFLog", IOBConfFull.General.EnabRedisQue, redisMan);
|
||||
// svuoto! NO REDIS
|
||||
QueueFLog = new DataQueue(IOBConfFull.General.FilenameIOB, "QueueFLog", false, redisMan);
|
||||
//QueueFLog = new DataQueue(IOBConfFull.General.FilenameIOB, "QueueFLog", IOBConfFull.General.EnabRedisQue, redisMan);
|
||||
}
|
||||
}
|
||||
// HO FINITO invio di FLog...
|
||||
|
||||
@@ -20,3 +20,4 @@ CLI_INST=SteamWareSim
|
||||
STARTLIST=FTP_SONATEST
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
@@ -25,3 +25,4 @@ STARTLIST=SIMUL_01
|
||||
;STARTLIST=3024
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
@@ -32,3 +32,4 @@ CLI_INST=SteamWareSim
|
||||
STARTLIST=1042
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
@@ -19,3 +19,4 @@ STARTLIST=FTP-PING
|
||||
;STARTLIST=3024-PING
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
@@ -23,3 +23,4 @@ STARTLIST=3018
|
||||
;STARTLIST=3019
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
Reference in New Issue
Block a user