mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Allow objects without checksum
This commit is contained in:
parent
1cf47757ab
commit
702fdfe93b
3 changed files with 30 additions and 21 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
type ObjectInformation struct {
|
||||
ObjectType string
|
||||
RedisKey string
|
||||
HasChecksum bool
|
||||
Factory connection.RowFactory
|
||||
BulkInsertStmt *connection.BulkInsertStmt
|
||||
BulkDeleteStmt *connection.BulkDeleteStmt
|
||||
|
|
|
|||
|
|
@ -149,25 +149,27 @@ func Operator(super *supervisor.Supervisor, chHA chan int, objectInformation *co
|
|||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
benchmarc := utils.NewBenchmark()
|
||||
wgUpdate.Add(len(update))
|
||||
if (objectInformation.HasChecksum) {
|
||||
go func() {
|
||||
benchmarc := utils.NewBenchmark()
|
||||
wgUpdate.Add(len(update))
|
||||
|
||||
// Provide the UpdateCompWorker with IDs to compare
|
||||
chUpdateComp <- update
|
||||
// Provide the UpdateCompWorker with IDs to compare
|
||||
chUpdateComp <- update
|
||||
|
||||
// Wait for all IDs to be update in MySQL
|
||||
kill := waitOrKill(wgUpdate, done)
|
||||
benchmarc.Stop()
|
||||
if !kill {
|
||||
log.WithFields(log.Fields{
|
||||
"type": objectInformation.ObjectType,
|
||||
"count": atomic.LoadUint32(updateCounter),
|
||||
"benchmark": benchmarc.String(),
|
||||
"action": "update",
|
||||
}).Infof("Updated %v %ss in %v", atomic.LoadUint32(updateCounter), objectInformation.ObjectType, benchmarc.String())
|
||||
}
|
||||
}()
|
||||
// Wait for all IDs to be update in MySQL
|
||||
kill := waitOrKill(wgUpdate, done)
|
||||
benchmarc.Stop()
|
||||
if !kill {
|
||||
log.WithFields(log.Fields{
|
||||
"type": objectInformation.ObjectType,
|
||||
"count": atomic.LoadUint32(updateCounter),
|
||||
"benchmark": benchmarc.String(),
|
||||
"action": "update",
|
||||
}).Infof("Updated %v %ss in %v", atomic.LoadUint32(updateCounter), objectInformation.ObjectType, benchmarc.String())
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -191,7 +193,7 @@ func GetDelta(super *supervisor.Supervisor, objectInformation *configobject.Obje
|
|||
go func() {
|
||||
defer wg.Done()
|
||||
var err error
|
||||
res, err := super.Rdbw.HKeys(fmt.Sprintf("icinga:checksum:%s", objectInformation.RedisKey)).Result()
|
||||
res, err := super.Rdbw.HKeys(fmt.Sprintf("icinga:config:%s", objectInformation.RedisKey)).Result()
|
||||
if err != nil {
|
||||
super.ChErr <- err
|
||||
return
|
||||
|
|
@ -226,16 +228,21 @@ func InsertPrepWorker(super *supervisor.Supervisor, objectInformation *configobj
|
|||
ChBack: chInsertBack,
|
||||
}
|
||||
for i, key := range chunk.Keys {
|
||||
if chunk.Configs[i] == nil || chunk.Checksums[i] == nil {
|
||||
if chunk.Configs[i] == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
pkg := jsondecoder.JsonDecodePackage{
|
||||
Id: key,
|
||||
ChecksumsRaw: chunk.Checksums[i].(string),
|
||||
ConfigRaw: chunk.Configs[i].(string),
|
||||
ConfigRaw: chunk.Configs[i].(string),
|
||||
Factory: objectInformation.Factory,
|
||||
ObjectType: objectInformation.ObjectType,
|
||||
}
|
||||
|
||||
if chunk.Checksums[i] != nil {
|
||||
pkg.ChecksumsRaw = chunk.Checksums[i].(string)
|
||||
}
|
||||
|
||||
pkgs.Packages = append(pkgs.Packages, pkg)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ func init() {
|
|||
ObjectType: "host",
|
||||
RedisKey: "host",
|
||||
Factory: NewHost,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt("host", Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt("host"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt("host", Fields),
|
||||
|
|
|
|||
Loading…
Reference in a new issue