本文整理汇总了Golang中github.com/nathanielc/morgoth/Godeps/_workspace/src/github.com/influxdb/influxdb/meta.Data.RetentionPolicy方法的典型用法代码示例。如果您正苦于以下问题:Golang Data.RetentionPolicy方法的具体用法?Golang Data.RetentionPolicy怎么用?Golang Data.RetentionPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/nathanielc/morgoth/Godeps/_workspace/src/github.com/influxdb/influxdb/meta.Data
的用法示例。
在下文中一共展示了Data.RetentionPolicy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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)
}
}
示例2: TestData_ShardGroupExpiredDeleted
// Ensure that a shard group is correctly detected as expired.
func TestData_ShardGroupExpiredDeleted(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 groups.
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.CreateShardGroup("db0", "rp0", time.Date(2001, time.January, 1, 0, 0, 0, 0, time.UTC)); err != nil {
t.Fatal(err)
}
// Check expiration.
rp, _ := data.RetentionPolicy("db0", "rp0")
groups := rp.ExpiredShardGroups(time.Date(2001, time.January, 1, 0, 0, 0, 0, time.UTC))
if len(groups) != 1 {
t.Fatalf("wrong number of expired shard groups returned, got %d, exp 1", len(groups))
}
if groups[0].StartTime != time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC) {
t.Fatal("wrong shard group marked as expired")
}
// Check deletion.
if err := data.DeleteShardGroup("db0", "rp0", groups[0].ID); err != nil {
t.Fatal(err)
}
groups = rp.DeletedShardGroups()
if len(groups) != 1 {
t.Fatalf("wrong number of deleted shard groups returned, got %d, exp 1", len(groups))
}
if groups[0].StartTime != time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC) {
t.Fatal("wrong shard group marked as expired")
}
}
示例3: 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)
}
}
示例4: 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)
}
}