func UpdateAllIndex() { startTs := time.Now().Unix() updateAllIndex() endTs := time.Now().Unix() log.Printf("index, update all, startTs %s, time-consuming %d sec\n", proc.FmtUnixTs(startTs), endTs-startTs) // statistics proc.IndexUpdateAllCnt.Incr() proc.IndexUpdateAllCnt.PutOther("lastStartTs", proc.FmtUnixTs(startTs)) proc.IndexUpdateAllCnt.PutOther("lastTimeConsumingInSec", endTs-startTs) }
func collect() { if collectorSema.AvailablePermits() <= 0 { log.Println("collector.collect, concurrent not available") return } collectorSema.Acquire() defer collectorSema.Release() startTs := time.Now().Unix() _collect() endTs := time.Now().Unix() log.Printf("collect, startTs %s, time-consuming %d sec\n", proc.FmtUnixTs(startTs), endTs-startTs) // statistics proc.CollectorCronCnt.Incr() proc.CollectorCronCnt.PutOther("lastStartTs", proc.FmtUnixTs(startTs)) proc.CollectorCronCnt.PutOther("lastTimeConsumingInSec", endTs-startTs) }
// 索引的全量更新 func DeleteIndex() { // 阻止多个并发的访问,高并发时可能无效 if semaIndexDelete.AvailablePermits() <= 0 { log.Printf("deleteIndex, concurrent not avaiable") return } semaIndexDelete.Acquire() defer semaIndexDelete.Release() startTs := time.Now().Unix() deleteIndex() endTs := time.Now().Unix() log.Printf("deleteIndex, startTs %s, time-consuming %d sec\n", proc.FmtUnixTs(startTs), endTs-startTs) // statistics proc.IndexDeleteCnt.Incr() proc.IndexDeleteCnt.PutOther("lastStartTs", proc.FmtUnixTs(startTs)) proc.IndexDeleteCnt.PutOther("lastTimeConsumingInSec", endTs-startTs) }