| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- package main
- import (
- "strconv"
- "time"
- "git.wecise.com/wecise/odbserver/odb"
- "gitee.com/wecisecode/util/logger"
- )
- // CGO_ENABLED=1 go run --ldflags '-linkmode external -extldflags "-static"' bulkevent.go
- // #cgo LDFLAGS: -L/opt/odbserver/sqlite -lsqlite -ldl
- // #include "/opt/odbserver/sqlite/sqlite.h"
- // #include <stdint.h>
- // #include <stdlib.h>
- // extern int64_t uhaha_seed;
- // extern int64_t uhaha_ts;
- // void uhaha_begin_reader();
- // void uhaha_end_reader();
- func main() {
- g, err := odb.New(&odb.Option{Cache: odb.CacheAll, Keyspace: "matrix", DisableInitialHostLookup: true}) // For aliyun
- //g, err := odb.New(&odb.Option{Cache:odb.CacheAll})
- if err != nil {
- logger.Fatal(err)
- }
- cstru := g.Class("/matrix/devops/alert_status")
- if rtn, _, err := g.Query(`select * from /matrix/devops/alert_status limit -1`); err == nil {
- for j, row := range rtn {
- delete(row, "id")
- for i := 1; i < 20; i++ {
- //row["serverserial"] = "hello2"+strconv.Itoa(j*20+i)
- logger.Warnf("serverserial => %d", (j+1)*900+i)
- row["serverserial"] = i*j + i + j
- row["type"] = i
- row["node"] = "wecise" + strconv.Itoa(i)
- if err := cstru.ID(g, row); err != nil {
- logger.Error(err)
- }
- if cqls, err := g.ObjectMap2Cql(cstru, row, false); err == nil {
- for i := 0; i < len(cqls); i++ {
- if err := cqls[i].Exec(); err != nil {
- logger.Error(err)
- }
- }
- }
- time.Sleep(100 * time.Millisecond)
- }
- }
- } else {
- logger.Error(err)
- }
- }
- /*
- [
- {
- "graph": {
- "nodes": [
- {
- "_icon": "linux",
- "class": "/matrix/entity/linux",
- "id": "linux:h2"
- },
- {
- "_icon": "cassandra",
- "class": "/matrix/entity/cassandra",
- "id": "cassandra:c1"
- },
- {
- "_icon": "biz",
- "class": "/matrix/entity/biz",
- "id": "biz:b1"
- },
- {
- "_icon": "linux",
- "class": "/matrix/entity/linux",
- "id": "linux:h1"
- }
- ],
- "edges": [
- {
- "class": "contain",
- "id": "biz:b1-linux:h1",
- "source": "biz:b1",
- "target": "linux:h1"
- },
- {
- "class": "contain",
- "id": "biz:b1-linux:h2",
- "source": "biz:b1",
- "target": "linux:h2"
- },
- {
- "class": "contain",
- "id": "linux:h1-cassandra:c1",
- "source": "linux:h1",
- "target": "cassandra:c1"
- }
- ],
- "paths": null,
- "pathtags": null
- }
- }
- ]
- */
|