• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang meta.Data类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/jportoles/influxdb092/meta.Data的典型用法代码示例。如果您正苦于以下问题:Golang Data类的具体用法?Golang Data怎么用?Golang Data使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Data类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestData_CreateRetentionPolicy

// Ensure a retention policy can be created.
func TestData_CreateRetentionPolicy(t *testing.T) {
	data := meta.Data{Nodes: []meta.NodeInfo{{ID: 1}, {ID: 2}}}
	if err := data.CreateDatabase("db0"); err != nil {
		t.Fatal(err)
	}

	// Create policy.
	if err := data.CreateRetentionPolicy("db0", &meta.RetentionPolicyInfo{
		Name:     "rp0",
		ReplicaN: 2,
		Duration: 4 * time.Hour,
	}); err != nil {
		t.Fatal(err)
	}

	// Verify policy exists.
	if !reflect.DeepEqual(data.Databases[0].RetentionPolicies, []meta.RetentionPolicyInfo{
		{
			Name:               "rp0",
			ReplicaN:           2,
			Duration:           4 * time.Hour,
			ShardGroupDuration: 1 * time.Hour,
		},
	}) {
		t.Fatalf("unexpected policies: %#v", data.Databases[0].RetentionPolicies)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:28,代码来源:data_test.go


示例2: TestData_CreateNode

// Ensure a node can be created.
func TestData_CreateNode(t *testing.T) {
	var data meta.Data
	if err := data.CreateNode("host0"); err != nil {
		t.Fatal(err)
	} else if !reflect.DeepEqual(data.Nodes, []meta.NodeInfo{{ID: 1, Host: "host0"}}) {
		t.Fatalf("unexpected node: %#v", data.Nodes[0])
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:9,代码来源:data_test.go


示例3: TestData_CreateDatabase

// Ensure a database can be created.
func TestData_CreateDatabase(t *testing.T) {
	var data meta.Data
	if err := data.CreateDatabase("db0"); err != nil {
		t.Fatal(err)
	} else if !reflect.DeepEqual(data.Databases, []meta.DatabaseInfo{{Name: "db0"}}) {
		t.Fatalf("unexpected databases: %#v", data.Databases)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:9,代码来源:data_test.go


示例4: TestData_CreateRetentionPolicy_ErrReplicationFactorMismatch

// Ensure that creating a policy with a replication factor that doesn't match
// the number of nodes in the cluster will return an error. This is a temporary
// restriction until v0.9.1 is released.
func TestData_CreateRetentionPolicy_ErrReplicationFactorMismatch(t *testing.T) {
	data := meta.Data{
		Nodes: []meta.NodeInfo{{ID: 1}, {ID: 2}, {ID: 3}},
	}
	if err := data.CreateRetentionPolicy("db0", &meta.RetentionPolicyInfo{Name: "rp0", ReplicaN: 2}); err != meta.ErrReplicationFactorMismatch {
		t.Fatalf("unexpected error: %s", err)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:11,代码来源:data_test.go


示例5: TestData_DropRetentionPolicy_ErrRetentionPolicyNotFound

// Ensure an error is returned when deleting a non-existent policy.
func TestData_DropRetentionPolicy_ErrRetentionPolicyNotFound(t *testing.T) {
	var data meta.Data
	if err := data.CreateDatabase("db0"); err != nil {
		t.Fatal(err)
	}
	if err := data.DropRetentionPolicy("db0", "rp0"); err != meta.ErrRetentionPolicyNotFound {
		t.Fatal(err)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:10,代码来源:data_test.go


示例6: TestData_CreateUser_ErrUserExists

// Ensure that creating the same user twice returns an error.
func TestData_CreateUser_ErrUserExists(t *testing.T) {
	var data meta.Data
	if err := data.CreateUser("susy", "", false); err != nil {
		t.Fatal(err)
	}
	if err := data.CreateUser("susy", "", false); err != meta.ErrUserExists {
		t.Fatal(err)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:10,代码来源:data_test.go


示例7: TestData_CreateDatabase_ErrDatabaseExists

// Ensure that creating an already existing database returns an error.
func TestData_CreateDatabase_ErrDatabaseExists(t *testing.T) {
	var data meta.Data
	if err := data.CreateDatabase("db0"); err != nil {
		t.Fatal(err)
	}
	if err := data.CreateDatabase("db0"); err != meta.ErrDatabaseExists {
		t.Fatalf("unexpected error: %s", err)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:10,代码来源:data_test.go


示例8: unpackMeta

// unpackMeta reads the metadata from the snapshot and initializes a raft
// cluster and replaces the root metadata.
func (cmd *Command) unpackMeta(mr *snapshot.MultiReader, sf snapshot.File, config *Config) error {
	// Read meta into buffer.
	var buf bytes.Buffer
	if _, err := io.CopyN(&buf, mr, sf.Size); err != nil {
		return fmt.Errorf("copy: %s", err)
	}

	// Unpack into metadata.
	var data meta.Data
	if err := data.UnmarshalBinary(buf.Bytes()); err != nil {
		return fmt.Errorf("unmarshal: %s", err)
	}

	// Copy meta config and remove peers so it starts in single mode.
	c := config.Meta
	c.Peers = nil

	// Initialize meta store.
	store := meta.NewStore(config.Meta)
	store.RaftListener = newNopListener()
	store.ExecListener = newNopListener()

	// Determine advertised address.
	_, port, err := net.SplitHostPort(config.Meta.BindAddress)
	if err != nil {
		return fmt.Errorf("split bind address: %s", err)
	}
	hostport := net.JoinHostPort(config.Meta.Hostname, port)

	// Resolve address.
	addr, err := net.ResolveTCPAddr("tcp", hostport)
	if err != nil {
		return fmt.Errorf("resolve tcp: addr=%s, err=%s", hostport, err)
	}
	store.Addr = addr

	// Open the meta store.
	if err := store.Open(); err != nil {
		return fmt.Errorf("open store: %s", err)
	}
	defer store.Close()

	// Wait for the store to be ready or error.
	select {
	case <-store.Ready():
	case err := <-store.Err():
		return err
	}

	// Force set the full metadata.
	if err := store.SetData(&data); err != nil {
		return fmt.Errorf("set data: %s", err)
	}

	return nil
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:58,代码来源:restore.go


示例9: TestData_CreateUser

// Ensure a user can be created.
func TestData_CreateUser(t *testing.T) {
	var data meta.Data
	if err := data.CreateUser("susy", "ABC123", true); err != nil {
		t.Fatal(err)
	} else if !reflect.DeepEqual(data.Users, []meta.UserInfo{
		{Name: "susy", Hash: "ABC123", Admin: true},
	}) {
		t.Fatalf("unexpected users: %#v", data.Users)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:11,代码来源:data_test.go


示例10: TestData_UpdateRetentionPolicy

// Ensure that a retention policy can be updated.
func TestData_UpdateRetentionPolicy(t *testing.T) {
	var data meta.Data
	if err := data.CreateDatabase("db0"); err != nil {
		t.Fatal(err)
	} else if err = data.CreateRetentionPolicy("db0", &meta.RetentionPolicyInfo{Name: "rp0"}); err != nil {
		t.Fatal(err)
	}

	// Update the policy.
	var rpu meta.RetentionPolicyUpdate
	rpu.SetName("rp1")
	rpu.SetDuration(10 * time.Hour)
	rpu.SetReplicaN(3)
	if err := data.UpdateRetentionPolicy("db0", "rp0", &rpu); err != nil {
		t.Fatal(err)
	}

	// Verify the policy was changed.
	if rpi, _ := data.RetentionPolicy("db0", "rp1"); !reflect.DeepEqual(rpi, &meta.RetentionPolicyInfo{
		Name:               "rp1",
		Duration:           10 * time.Hour,
		ShardGroupDuration: 604800000000000,
		ReplicaN:           3,
	}) {
		t.Fatalf("unexpected policy: %#v", rpi)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:28,代码来源:data_test.go


示例11: TestData_CreateContinuousQuery

// Ensure a continuous query can be created.
func TestData_CreateContinuousQuery(t *testing.T) {
	var data meta.Data
	if err := data.CreateDatabase("db0"); err != nil {
		t.Fatal(err)
	} else if err := data.CreateContinuousQuery("db0", "cq0", "SELECT count() FROM foo"); err != nil {
		t.Fatal(err)
	} else if !reflect.DeepEqual(data.Databases[0].ContinuousQueries, []meta.ContinuousQueryInfo{
		{Name: "cq0", Query: "SELECT count() FROM foo"},
	}) {
		t.Fatalf("unexpected queries: %#v", data.Databases[0].ContinuousQueries)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:13,代码来源:data_test.go


示例12: TestData_DropDatabase

// Ensure a database can be removed.
func TestData_DropDatabase(t *testing.T) {
	var data meta.Data
	for i := 0; i < 3; i++ {
		if err := data.CreateDatabase(fmt.Sprintf("db%d", i)); err != nil {
			t.Fatal(err)
		}
	}

	if err := data.DropDatabase("db1"); err != nil {
		t.Fatal(err)
	} else if !reflect.DeepEqual(data.Databases, []meta.DatabaseInfo{{Name: "db0"}, {Name: "db2"}}) {
		t.Fatalf("unexpected databases: %#v", data.Databases)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:15,代码来源:data_test.go


示例13: TestData_CreateRetentionPolicy_ErrRetentionPolicyExists

// Ensure that creating an already existing policy returns an error.
func TestData_CreateRetentionPolicy_ErrRetentionPolicyExists(t *testing.T) {
	var data meta.Data
	if err := data.CreateDatabase("db0"); err != nil {
		t.Fatal(err)
	} else if err = data.CreateRetentionPolicy("db0", &meta.RetentionPolicyInfo{Name: "rp0"}); err != nil {
		t.Fatal(err)
	}
	if err := data.CreateRetentionPolicy("db0", &meta.RetentionPolicyInfo{Name: "rp0"}); err != meta.ErrRetentionPolicyExists {
		t.Fatalf("unexpected error: %s", err)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:12,代码来源:data_test.go


示例14: TestData_RetentionPolicy

// Ensure that a retention policy can be retrieved.
func TestData_RetentionPolicy(t *testing.T) {
	var data meta.Data
	if err := data.CreateDatabase("db0"); err != nil {
		t.Fatal(err)
	} else if err = data.CreateRetentionPolicy("db0", &meta.RetentionPolicyInfo{Name: "rp0"}); err != nil {
		t.Fatal(err)
	} else if err = data.CreateRetentionPolicy("db0", &meta.RetentionPolicyInfo{Name: "rp1"}); err != nil {
		t.Fatal(err)
	}

	if rpi, err := data.RetentionPolicy("db0", "rp0"); err != nil {
		t.Fatal(err)
	} else if !reflect.DeepEqual(rpi, &meta.RetentionPolicyInfo{
		Name:               "rp0",
		ShardGroupDuration: 604800000000000,
	}) {
		t.Fatalf("unexpected value: %#v", rpi)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:20,代码来源:data_test.go


示例15: TestData_DeleteNode

// Ensure a node can be removed.
func TestData_DeleteNode(t *testing.T) {
	var data meta.Data
	if err := data.CreateNode("host0"); err != nil {
		t.Fatal(err)
	} else if err = data.CreateNode("host1"); err != nil {
		t.Fatal(err)
	} else if err := data.CreateNode("host2"); err != nil {
		t.Fatal(err)
	}

	if err := data.DeleteNode(1); err != nil {
		t.Fatal(err)
	} else if len(data.Nodes) != 2 {
		t.Fatalf("unexpected node count: %d", len(data.Nodes))
	} else if data.Nodes[0] != (meta.NodeInfo{ID: 2, Host: "host1"}) {
		t.Fatalf("unexpected node: %#v", data.Nodes[0])
	} else if data.Nodes[1] != (meta.NodeInfo{ID: 3, Host: "host2"}) {
		t.Fatalf("unexpected node: %#v", data.Nodes[1])
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:21,代码来源:data_test.go


示例16: TestData_DropRetentionPolicy

// Ensure a retention policy can be removed.
func TestData_DropRetentionPolicy(t *testing.T) {
	var data meta.Data
	if err := data.CreateDatabase("db0"); err != nil {
		t.Fatal(err)
	} else if err = data.CreateRetentionPolicy("db0", &meta.RetentionPolicyInfo{Name: "rp0"}); err != nil {
		t.Fatal(err)
	}

	if err := data.DropRetentionPolicy("db0", "rp0"); err != nil {
		t.Fatal(err)
	} else if len(data.Databases[0].RetentionPolicies) != 0 {
		t.Fatalf("unexpected policies: %#v", data.Databases[0].RetentionPolicies)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:15,代码来源:data_test.go


示例17: TestData_DropUser

// Ensure a user can be removed.
func TestData_DropUser(t *testing.T) {
	var data meta.Data
	if err := data.CreateUser("susy", "", false); err != nil {
		t.Fatal(err)
	} else if err := data.CreateUser("bob", "", false); err != nil {
		t.Fatal(err)
	}

	if err := data.DropUser("bob"); err != nil {
		t.Fatal(err)
	} else if !reflect.DeepEqual(data.Users, []meta.UserInfo{
		{Name: "susy"},
	}) {
		t.Fatalf("unexpected users: %#v", data.Users)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:17,代码来源:data_test.go


示例18: TestData_CreateShardGroup

// Ensure that a shard group can be created on a database for a given timestamp.
func TestData_CreateShardGroup(t *testing.T) {
	var data meta.Data
	if err := data.CreateNode("node0"); err != nil {
		t.Fatal(err)
	} else if err = data.CreateNode("node1"); err != nil {
		t.Fatal(err)
	} else if err = data.CreateDatabase("db0"); err != nil {
		t.Fatal(err)
	} else if err = data.CreateRetentionPolicy("db0", &meta.RetentionPolicyInfo{Name: "rp0", ReplicaN: 2, Duration: 1 * time.Hour}); err != nil {
		t.Fatal(err)
	}

	// Create shard group.
	if err := data.CreateShardGroup("db0", "rp0", time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)); err != nil {
		t.Fatal(err)
	}

	// Verify the shard group was created.
	if sgi, _ := data.ShardGroupByTimestamp("db0", "rp0", time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)); !reflect.DeepEqual(sgi, &meta.ShardGroupInfo{
		ID:        1,
		StartTime: time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC),
		EndTime:   time.Date(2000, time.January, 1, 1, 0, 0, 0, time.UTC),
		Shards: []meta.ShardInfo{
			{ID: 1, OwnerIDs: []uint64{1, 2}},
		},
	}) {
		t.Fatalf("unexpected shard group: %#v", sgi)
	} else if !sgi.Shards[0].OwnedBy(1) || !sgi.Shards[0].OwnedBy(2) || sgi.Shards[0].OwnedBy(3) {
		// Verify shard is correctly owned-by the node.
		t.Fatalf("new shard is not owned by correct node")
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:33,代码来源:data_test.go


示例19: TestData_RetentionPolicy_ErrDatabaseNotFound

// Ensure that retrieving a policy from a non-existent database returns an error.
func TestData_RetentionPolicy_ErrDatabaseNotFound(t *testing.T) {
	var data meta.Data
	if _, err := data.RetentionPolicy("db0", "rp0"); err != meta.ErrDatabaseNotFound {
		t.Fatal(err)
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:7,代码来源:data_test.go


示例20: TestData_DeleteShardGroup

// Ensure a shard group can be removed by ID.
func TestData_DeleteShardGroup(t *testing.T) {
	var data meta.Data
	if err := data.CreateNode("node0"); err != nil {
		t.Fatal(err)
	} else if err := data.CreateDatabase("db0"); err != nil {
		t.Fatal(err)
	} else if err = data.CreateRetentionPolicy("db0", &meta.RetentionPolicyInfo{Name: "rp0", ReplicaN: 1}); err != nil {
		t.Fatal(err)
	} else if err := data.CreateShardGroup("db0", "rp0", time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)); err != nil {
		t.Fatal(err)
	}

	if err := data.DeleteShardGroup("db0", "rp0", 1); err != nil {
		t.Fatal(err)
	}
	if sg := data.Databases[0].RetentionPolicies[0].ShardGroups[0]; !sg.Deleted() {
		t.Fatalf("shard group not correctly flagged as deleted")
	}
}
开发者ID:jportoles,项目名称:influxdb092,代码行数:20,代码来源:data_test.go



注:本文中的github.com/jportoles/influxdb092/meta.Data类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang tsdb.NewPoint函数代码示例发布时间:2022-05-23
下一篇:
Golang influxql.SelectStatement类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap