Beispiel #1
0
func setValueConst(
	b *couchbase.Bucket,
	maxvb int, value map[string]interface{}) ([]uint64, []uint64, uint16, uint64, uint64) {

	seqnos1, _, err := common.BucketTs(b, maxvb)
	if err != nil {
		log.Fatal(err)
	}
	// identify vbucket for `docid`
	err = b.Set(docid, 0, value)
	if err != nil {
		log.Fatal(err)
	}
	seqnos2, vbuuids2, err := common.BucketTs(b, maxvb)
	if err != nil {
		log.Fatal(err)
	}
	vbno, vbuuid, seqno := diffSeqno(seqnos1, seqnos2, vbuuids2)
	fmt.Printf(
		"Updated %v on vbucket: %v(%v) seqno: %v\n",
		docid, vbno, vbuuid, seqno)
	return seqnos2, vbuuids2, vbno, vbuuid, seqno
}
Beispiel #2
0
func bucketTs(cluster, bucketn string, numVb int) {
	b, err := common.ConnectBucket(cluster, "default" /*pooln*/, bucketn)
	if err != nil {
		log.Fatal(err)
	}
	defer b.Close()

	start := time.Now()
	for i := 0; i < options.trials; i++ {
		if _, _, err = common.BucketTs(b, numVb); err != nil {
			log.Fatal(err)
		}
	}
	durtn := time.Since(start) / time.Duration(options.trials)
	log.Printf("bucketTs: %v\n", durtn)
}
Beispiel #3
0
// BucketTs will return the current vbucket-timestamp using STATS
// command.
func (c *GsiClient) BucketTs(bucketn string) (*TsConsistency, error) {
	b, err := common.ConnectBucket(c.cluster, "default" /*pooln*/, bucketn)
	if err != nil {
		return nil, err
	}
	defer b.Close()

	if c.maxvb == -1 {
		if c.maxvb, err = common.MaxVbuckets(b); err != nil {
			return nil, err
		}
	}
	seqnos, vbuuids, err := common.BucketTs(b, c.maxvb)
	if err != nil {
		return nil, err
	}
	vbnos := make([]uint16, c.maxvb)
	for i := range vbnos {
		vbnos[i] = uint16(i)
	}
	return NewTsConsistency(vbnos, seqnos, vbuuids), nil
}