change dma to dbm
This commit is contained in:
@@ -3,15 +3,15 @@ package args
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
|
||||||
"github.com/zuadi/tecamino-dbm/cert"
|
"github.com/tecamino/tecamino-dbm/cert"
|
||||||
"github.com/zuadi/tecamino-dbm/models"
|
"github.com/tecamino/tecamino-dbm/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Args struct {
|
type Args struct {
|
||||||
Port models.Port
|
Port models.Port
|
||||||
Cert cert.Cert
|
Cert cert.Cert
|
||||||
RootDir string
|
RootDir string
|
||||||
DMAFile string
|
DBMFile string
|
||||||
Debug bool
|
Debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ func Init() *Args {
|
|||||||
Https: *flag.Uint("https-port", 8101, "json server communication for http/wss"),
|
Https: *flag.Uint("https-port", 8101, "json server communication for http/wss"),
|
||||||
},
|
},
|
||||||
RootDir: *flag.String("workingDir", "./", "working directory"),
|
RootDir: *flag.String("workingDir", "./", "working directory"),
|
||||||
DMAFile: *flag.String("dma", "/test/test", "dma file name"),
|
DBMFile: *flag.String("dbm", "/test/test", "dbm file name"),
|
||||||
Debug: *flag.Bool("debug", false, "debug flag"),
|
Debug: *flag.Bool("debug", false, "debug flag"),
|
||||||
}
|
}
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@@ -44,7 +44,7 @@ func NewDbmHandler(a *args.Args) (*DBMHandler, error) {
|
|||||||
// Initialize dtabase manager handler
|
// Initialize dtabase manager handler
|
||||||
dmaHandler := DBMHandler{
|
dmaHandler := DBMHandler{
|
||||||
arg: a,
|
arg: a,
|
||||||
filePath: fmt.Sprintf("%s/%s.dma", a.RootDir, a.DMAFile),
|
filePath: fmt.Sprintf("%s/%s.dbm", a.RootDir, a.DBMFile),
|
||||||
Log: logger,
|
Log: logger,
|
||||||
Conns: serverModels.NewConnections(),
|
Conns: serverModels.NewConnections(),
|
||||||
}
|
}
|
||||||
|
@@ -7,12 +7,12 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zuadi/tecamino-dbm/args"
|
"github.com/tecamino/tecamino-dbm/args"
|
||||||
"github.com/zuadi/tecamino-dbm/cert"
|
"github.com/tecamino/tecamino-dbm/cert"
|
||||||
"github.com/zuadi/tecamino-dbm/dbm"
|
"github.com/tecamino/tecamino-dbm/dbm"
|
||||||
"github.com/zuadi/tecamino-dbm/models"
|
"github.com/tecamino/tecamino-dbm/models"
|
||||||
"github.com/zuadi/tecamino-dbm/server"
|
"github.com/tecamino/tecamino-dbm/server"
|
||||||
"github.com/zuadi/tecamino-dbm/utils"
|
"github.com/tecamino/tecamino-dbm/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateDps(t *testing.T) {
|
func TestCreateDps(t *testing.T) {
|
||||||
@@ -27,7 +27,7 @@ func TestCreateDps(t *testing.T) {
|
|||||||
KeyFile: "./cert/key.pem",
|
KeyFile: "./cert/key.pem",
|
||||||
},
|
},
|
||||||
RootDir: ".",
|
RootDir: ".",
|
||||||
DMAFile: "Test",
|
DBMFile: "Test",
|
||||||
Debug: false,
|
Debug: false,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -39,18 +39,18 @@ func TestCreateDps(t *testing.T) {
|
|||||||
ndps := utils.ListofA2ZZ()
|
ndps := utils.ListofA2ZZ()
|
||||||
l := len(ndps)
|
l := len(ndps)
|
||||||
s := time.Now()
|
s := time.Now()
|
||||||
for _, dp := range ndps {
|
// for _, dp := range ndps {
|
||||||
for i := 0; i < 100; i++ {
|
// for i := 0; i < 100; i++ {
|
||||||
err = dmaHandler.ImportDatapoints(&models.Datapoint{
|
// err = dmaHandler.ImportDatapoints(&models.Datapoint{
|
||||||
Path: fmt.Sprintf("Test:%s:%03d", dp, i),
|
// Path: fmt.Sprintf("Test:%s:%03d", dp, i),
|
||||||
Type: RandomType(),
|
// Type: models.RandomType(),
|
||||||
Value: rand.Int31(),
|
// Value: rand.Int31(),
|
||||||
})
|
// })
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
fmt.Printf("time used to create %d datapoints: %v\n", l*100, time.Since(s))
|
fmt.Printf("time used to create %d datapoints: %v\n", l*100, time.Since(s))
|
||||||
|
|
||||||
var m runtime.MemStats
|
var m runtime.MemStats
|
||||||
@@ -80,7 +80,7 @@ func TestQuery(t *testing.T) {
|
|||||||
KeyFile: "./cert/key.pem",
|
KeyFile: "./cert/key.pem",
|
||||||
},
|
},
|
||||||
RootDir: ".",
|
RootDir: ".",
|
||||||
DMAFile: "Test",
|
DBMFile: "Test",
|
||||||
Debug: false,
|
Debug: false,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -109,7 +109,7 @@ func TestUpdateDps(t *testing.T) {
|
|||||||
KeyFile: "./cert/key.pem",
|
KeyFile: "./cert/key.pem",
|
||||||
},
|
},
|
||||||
RootDir: ".",
|
RootDir: ".",
|
||||||
DMAFile: "Test",
|
DBMFile: "Test",
|
||||||
Debug: false,
|
Debug: false,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -121,17 +121,17 @@ func TestUpdateDps(t *testing.T) {
|
|||||||
ndps := utils.ListofA2ZZ()
|
ndps := utils.ListofA2ZZ()
|
||||||
l := len(ndps)
|
l := len(ndps)
|
||||||
s := time.Now()
|
s := time.Now()
|
||||||
for j, dp := range ndps {
|
// for j, dp := range ndps {
|
||||||
if j > 2 {
|
// if j > 2 {
|
||||||
break
|
// break
|
||||||
}
|
// }
|
||||||
for i := 0; i < 100; i++ {
|
// for i := 0; i < 100; i++ {
|
||||||
err = dmaHandler.UpdateDatapointValue(fmt.Sprintf("Test:%s:%03d", dp, i), rand.Int31())
|
// err = dmaHandler.UpdateDatapointValue(fmt.Sprintf("Test:%s:%03d", dp, i), rand.Int31())
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatal(err)
|
// t.Fatal(err)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
fmt.Printf("time used to update %d datapoints: %v\n", l*100, time.Since(s))
|
fmt.Printf("time used to update %d datapoints: %v\n", l*100, time.Since(s))
|
||||||
|
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
|
Reference in New Issue
Block a user