提交 6bd57024 编写于 作者: Z zhenshan.cao 提交者: yefu.chen

Add indexbuilder address to paramstable

Signed-off-by: Nzhenshan.cao <zhenshan.cao@zilliz.com>
上级 cb3ca1ab
......@@ -21,6 +21,7 @@ type ParamTable struct {
KvRootPath string
WriteNodeSegKvSubPath string
PulsarAddress string
IndexBuilderAddress string
// nodeID
ProxyIDList []typeutil.UniqueID
......@@ -71,6 +72,7 @@ func (p *ParamTable) Init() {
p.initKvRootPath()
p.initWriteNodeSegKvSubPath()
p.initPulsarAddress()
p.initIndexBuilderAddress()
p.initProxyIDList()
p.initWriteNodeIDList()
......@@ -125,6 +127,14 @@ func (p *ParamTable) initPulsarAddress() {
p.PulsarAddress = addr
}
func (p *ParamTable) initIndexBuilderAddress() {
ret, err := p.Load("_IndexBuilderAddress")
if err != nil {
panic(err)
}
p.IndexBuilderAddress = ret
}
func (p *ParamTable) initMetaRootPath() {
rootPath, err := p.Load("etcd.rootPath")
if err != nil {
......
......@@ -31,6 +31,11 @@ func TestParamTable_KVRootPath(t *testing.T) {
assert.Equal(t, path, "by-dev/kv")
}
func TestParamTable_IndexBuilderAddress(t *testing.T) {
path := Params.IndexBuilderAddress
assert.Equal(t, path, "localhost:31000")
}
func TestParamTable_TopicNum(t *testing.T) {
num := Params.TopicNum
fmt.Println("TopicNum:", num)
......
......@@ -57,19 +57,40 @@ func (gp *BaseTable) Init() {
if err != nil {
panic(err)
}
gp.tryloadFromEnv()
}
func (gp *BaseTable) tryloadFromEnv() {
minioAddress := os.Getenv("MINIO_ADDRESS")
if minioAddress == "" {
minioAddress = "localhost:9000"
minioHost, err := gp.Load("minio.address")
if err != nil {
panic(err)
}
port, err := gp.Load("minio.port")
if err != nil {
panic(err)
}
minioAddress = minioHost + ":" + port
}
err = gp.Save("_MinioAddress", minioAddress)
err := gp.Save("_MinioAddress", minioAddress)
if err != nil {
panic(err)
}
etcdAddress := os.Getenv("ETCD_ADDRESS")
if etcdAddress == "" {
etcdAddress = "localhost:2379"
etcdHost, err := gp.Load("etcd.address")
if err != nil {
panic(err)
}
port, err := gp.Load("etcd.port")
if err != nil {
panic(err)
}
etcdAddress = etcdHost + ":" + port
}
err = gp.Save("_EtcdAddress", etcdAddress)
if err != nil {
......@@ -78,7 +99,15 @@ func (gp *BaseTable) Init() {
pulsarAddress := os.Getenv("PULSAR_ADDRESS")
if pulsarAddress == "" {
pulsarAddress = "pulsar://localhost:6650"
pulsarHost, err := gp.Load("pulsar.address")
if err != nil {
panic(err)
}
port, err := gp.Load("pulsar.port")
if err != nil {
panic(err)
}
pulsarAddress = "pulsar://" + pulsarHost + ":" + port
}
err = gp.Save("_PulsarAddress", pulsarAddress)
if err != nil {
......@@ -87,12 +116,37 @@ func (gp *BaseTable) Init() {
masterAddress := os.Getenv("MASTER_ADDRESS")
if masterAddress == "" {
masterAddress = "localhost:53100"
masterHost, err := gp.Load("master.address")
if err != nil {
panic(err)
}
port, err := gp.Load("master.port")
if err != nil {
panic(err)
}
masterAddress = masterHost + ":" + port
}
err = gp.Save("_MasterAddress", masterAddress)
if err != nil {
panic(err)
}
indexBuilderAddress := os.Getenv("INDEX_BUILDER_ADDRESS")
if indexBuilderAddress == "" {
indexBuilderHost, err := gp.Load("indexBuilder.address")
if err != nil {
panic(err)
}
port, err := gp.Load("indexBuilder.port")
if err != nil {
panic(err)
}
indexBuilderAddress = indexBuilderHost + ":" + port
}
err = gp.Save("_IndexBuilderAddress", indexBuilderAddress)
if err != nil {
panic(err)
}
}
func (gp *BaseTable) Load(key string) (string, error) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册