Exemplo n.º 1
0
// WriteAddrs writes a ZknsAddres record to a path in Zookeeper.
func WriteAddrs(zconn zk.Conn, zkPath string, addrs *ZknsAddrs) error {
	if !(addrs.IsValidA() || addrs.IsValidCNAME() || addrs.IsValidSRV()) {
		return fmt.Errorf("invalid addrs: %v", zkPath)
	}
	data := toJson(addrs)
	_, err := zk.CreateOrUpdate(zconn, zkPath, data, 0, zookeeper.WorldACL(zk.PERM_FILE), true)
	return err
}
Exemplo n.º 2
0
func writeAddrs(zconn zk.Conn, zkPath string, addrs *LegacyZknsAddrs) error {
	data, err := json.MarshalIndent(addrs, "", "  ")
	if err != nil {
		return err
	}
	_, err = zk.CreateOrUpdate(zconn, zkPath, string(data), 0, zookeeper.WorldACL(zookeeper.PERM_ALL), true)
	return err
}
Exemplo n.º 3
0
// SaveVSchema saves the JSON vschema into the topo.
func (zkts *Server) SaveVSchema(ctx context.Context, vschema string) error {
	_, err := planbuilder.NewSchema([]byte(vschema))
	if err != nil {
		return err
	}
	_, err = zk.CreateOrUpdate(zkts.zconn, globalVSchemaPath, vschema, 0, zookeeper.WorldACL(zookeeper.PERM_ALL), true)
	return err
}
Exemplo n.º 4
0
// SaveVSchema saves the vschema into the topo.
func (zkts *Server) SaveVSchema(ctx context.Context, keyspace string, vschema *vschemapb.Keyspace) error {
	data, err := json.MarshalIndent(vschema, "", "  ")
	if err != nil {
		return err
	}
	vschemaPath := path.Join(GlobalKeyspacesPath, keyspace, vschemaPath)
	_, err = zk.CreateOrUpdate(zkts.zconn, vschemaPath, string(data), 0, zookeeper.WorldACL(zookeeper.PermAll), true)
	return convertError(err)
}
Exemplo n.º 5
0
// SaveVSchema saves the JSON vschema into the topo.
func (zkts *Server) SaveVSchema(ctx context.Context, keyspace, vschema string) error {
	err := vindexes.ValidateVSchema([]byte(vschema))
	if err != nil {
		return err
	}
	vschemaPath := path.Join(GlobalKeyspacesPath, keyspace, vschemaPath)
	_, err = zk.CreateOrUpdate(zkts.zconn, vschemaPath, vschema, 0, zookeeper.WorldACL(zookeeper.PERM_ALL), true)
	return err
}
Exemplo n.º 6
0
func writeAddrs(zconn zk.Conn, zkPath string, addrs *LegacyZknsAddrs) error {
	data := jscfg.ToJSON(addrs)
	_, err := zk.CreateOrUpdate(zconn, zkPath, data, 0, zookeeper.WorldACL(zookeeper.PERM_ALL), true)
	return err
}
Exemplo n.º 7
0
func WriteAddr(zconn zk.Conn, zkPath string, addr *zkns.ZknsAddr) error {
	data := jscfg.ToJson(addr)
	_, err := zk.CreateOrUpdate(zconn, zkPath, data, 0, zookeeper.WorldACL(zookeeper.PERM_ALL), true)
	return err
}