From 80e181096d1318ef0d78c48ff4c5f6fea21d1051 Mon Sep 17 00:00:00 2001 From: YilunZhang39 Date: Wed, 31 Jul 2024 15:26:07 +0800 Subject: [PATCH] release_v3.00.0.1 --- README.md | 6 +-- dialer/behavior.go | 2 +- dialer/node.go | 2 +- test/dbConnection_test.go | 80 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a6d17e5..8ddc06d 100644 --- a/README.md +++ b/README.md @@ -237,7 +237,7 @@ func main() { 通过配置 BehaviorOptions 可以配置行为标识。可配置行为标识如下: - Priority:指定本任务优先级,可选范围为 0~8,默认为 8。 -- Parallelism:指定本任务并行度,可选范围为 0~64,默认为 8。 +- Parallelism:指定本任务并行度,可选范围为 0~64,默认为 64。 - FetchSize: 指定分块返回的块大小。 - LoadBalance: 指定是否开启负载均衡。 - EnableHighAvailability: 指定是否开启高可用。 @@ -1868,14 +1868,14 @@ NewTableFromStruct(obj interface{}) (*Table, error) 入参说明: -obj 可以为任意结构体对象,但是该结构体字段类型需要为数组,且字段带有以 `dolphindb` 开头的特定 tag,如 `dolphindb:"column:name,type:string"`。 +obj 可以为任意结构体对象,但是该结构体字段类型需要为数组,且字段带有以 `dolphindb` 开头的特定 tag,如 `dolphindb:"column:name;type:string"`。 其中,column 后为列名,type 后为列数据类型(通过 model.GetDataTypeString 获取)。字段类型需要跟列数据类型匹配。 示例: ```go type Example struct { - Name []string `dolphindb:"column:name,type:string"` + Name []string `dolphindb:"column:name;type:string"` } func main() { diff --git a/dialer/behavior.go b/dialer/behavior.go index 58862e0..0ea41c2 100644 --- a/dialer/behavior.go +++ b/dialer/behavior.go @@ -59,7 +59,7 @@ func (f *BehaviorOptions) GetPriority() int { // GetParallelism gets the parallelism of the task. func (f *BehaviorOptions) GetParallelism() int { if f.Parallelism == nil { - return 2 + return 64 } return *f.Parallelism } diff --git a/dialer/node.go b/dialer/node.go index d6d97df..96ca41e 100644 --- a/dialer/node.go +++ b/dialer/node.go @@ -280,7 +280,7 @@ func (c *conn) handleGetClusterPerfError(n *node, err error) error { } func (c *conn) connectNode(n *node) (bool, error) { - // fmt.Println("Connect to ", n.address) + fmt.Println("Connect to ", n.address) for !c.isClosed { err := c.connect(n.address) if err != nil { diff --git a/test/dbConnection_test.go b/test/dbConnection_test.go index 68ec275..be8c20d 100644 --- a/test/dbConnection_test.go +++ b/test/dbConnection_test.go @@ -442,3 +442,83 @@ func TestConnectionHighAvailability(t *testing.T) { }) } + +func TestConnectionParallel(t *testing.T) { + t.Parallel() + db, err := api.NewSimpleDolphinDBClient(context.TODO(), host3, "admin", "123456") + AssertNil(err) + db.RunScript("login(`admin,`123456);try{createUser(`test1, `123456)}catch(ex){};go;setMaxJobParallelism(`test1, 10);") + Convey("TestConnectionParallel_lt_MaxJobParallelism", t, func() { + + priority := 4 + parallel := 1 + opt := &dialer.BehaviorOptions{ + Priority: &priority, + Parallelism: ¶llel, + } + conn, err := api.NewDolphinDBClient(context.TODO(), host3, opt) + So(err, ShouldBeNil) + conn.Connect() + loginReq := &api.LoginRequest{ + UserID: "test1", + Password: "123456", + } + err = conn.Login(loginReq) + So(err, ShouldBeNil) + res, _ := conn.RunScript("getConsoleJobs()") + Println(res) + So(res.(*model.Table).GetColumnByName("parallelism").Get(0).Value().(int32), ShouldEqual, 1) + So(res.(*model.Table).GetColumnByName("priority").Get(0).Value().(int32), ShouldEqual, 4) + + conn.Close() + So(conn.IsClosed(), ShouldBeTrue) + }) + + Convey("TestConnectionParallel_gt_MaxJobParallelism", t, func() { + + priority := 4 + parallel := 11 + opt := &dialer.BehaviorOptions{ + Priority: &priority, + Parallelism: ¶llel, + } + conn, err := api.NewDolphinDBClient(context.TODO(), host3, opt) + So(err, ShouldBeNil) + conn.Connect() + loginReq := &api.LoginRequest{ + UserID: "test1", + Password: "123456", + } + err = conn.Login(loginReq) + So(err, ShouldBeNil) + res, _ := conn.RunScript("getConsoleJobs()") + Println(res) + So(res.(*model.Table).GetColumnByName("parallelism").Get(0).Value().(int32), ShouldEqual, 10) + So(res.(*model.Table).GetColumnByName("priority").Get(0).Value().(int32), ShouldEqual, 4) + + conn.Close() + So(conn.IsClosed(), ShouldBeTrue) + }) + + Convey("TestConnectionParallel_default", t, func() { + conn, err := api.NewDolphinDBClient(context.TODO(), host3, nil) + So(err, ShouldBeNil) + conn.Connect() + loginReq := &api.LoginRequest{ + UserID: "test1", + Password: "123456", + } + err = conn.Login(loginReq) + So(err, ShouldBeNil) + res, _ := conn.RunScript("getConsoleJobs()") + Println(res) + So(res.(*model.Table).GetColumnByName("parallelism").Get(0).Value().(int32), ShouldEqual, 10) + So(res.(*model.Table).GetColumnByName("priority").Get(0).Value().(int32), ShouldEqual, 4) + + conn.Close() + So(conn.IsClosed(), ShouldBeTrue) + }) + + db.Close() + AssertEqual(db.IsClosed(), true) +}