// Create a query node configuration func NewQueryNode(query_addr string, stndln *clustering.StdStandalone, opts *clustering.ClOptions) (clustering.QueryNode, errors.Error) { ip_addr, err := util.ExternalIP() if err != nil { ip_addr = "127.0.0.1" } // Construct query node name from ip addr and http_addr. Assumption that this will be unique queryName := ip_addr + query_addr queryEndpoint := "http://" + queryName + "/query" // TODO : protocol specification: how do we know it will be http? adminEndpoint := "http://" + queryName + "/admin" return makeZkQueryNodeConfig("", queryName, queryEndpoint, adminEndpoint, stndln, opts), nil }
func doConfig(endpoint *HttpEndpoint, w http.ResponseWriter, req *http.Request) (interface{}, errors.Error) { if localConfig.myConfig != nil { return localConfig.myConfig, nil } cfgStore := endpoint.server.ConfigurationStore() var self clustering.QueryNode ip, err := util.ExternalIP() if err != nil { return nil, err } name, er := os.Hostname() if er != nil { return nil, err } cm := cfgStore.ConfigurationManager() clusters, err := cm.GetClusters() if err != nil { return nil, err } for _, c := range clusters { clm := c.ClusterManager() queryNodes, err := clm.GetQueryNodes() if err != nil { return nil, err } for _, qryNode := range queryNodes { if qryNode.Name() == ip || qryNode.Name() == name { self = qryNode break } } } localConfig.Lock() defer localConfig.Unlock() localConfig.myConfig = self return localConfig.myConfig, nil }