func (etr *ElasticsearchTaskRunner) FillContext(context *framework.Variables, application *framework.Application, task marathon.Task) error {
	context.SetStackVariable(fmt.Sprintf("%s.host", application.ID), task.Host)
	for idx, port := range task.Ports {
		context.SetStackVariable(fmt.Sprintf("%s.port%d", application.ID, idx), fmt.Sprint(port))
	}
	api := fmt.Sprintf("http://%s:%d", task.Host, task.Ports[0])
	context.SetStackVariable(fmt.Sprintf("%s.api", application.ID), api)

	client := NewElasticsearchClient(api)
	err := client.AwaitRunning(etr.awaitTimeout, etr.backoffTimeout)
	if err != nil {
		return err
	}

	tasks, err := client.GetTasks()
	if err != nil {
		return err
	}

	for idx, task := range tasks {
		context.SetStackVariable(fmt.Sprintf("%s.%d.httpAddress", application.ID, idx), task.HttpAddress)
		context.SetStackVariable(fmt.Sprintf("%s.%d.transportAddress", application.ID, idx), task.TransportAddress)
	}

	return nil
}
func (dtr *DSE02xTaskRunner) fillTaskContext(context *framework.Variables, application *framework.Application, response []byte) error {
	startResponse := new(DSEMesos02xStartResponse)
	err := json.Unmarshal(response, &startResponse)
	if err != nil {
		return err
	}

	if startResponse.Status == "timeout" {
		return errors.New("Timed out")
	}

	servers := make([]string, 0)
	for _, node := range startResponse.Nodes {
		nodeEndpoint := fmt.Sprintf("%s:%d", node.Runtime.Address, node.Runtime.Reservation.Ports["cql"])

		context.SetStackVariable(fmt.Sprintf("%s.cassandra-%s", application.ID, fmt.Sprint(node.ID)), nodeEndpoint)
		context.SetStackVariable(fmt.Sprintf("%s.cassandra-%s.host", application.ID, fmt.Sprint(node.ID)), node.Runtime.Address)
		for name, port := range node.Runtime.Reservation.Ports {
			context.SetStackVariable(fmt.Sprintf("%s.cassandra-%s.%sPort", application.ID, fmt.Sprint(node.ID), name), fmt.Sprint(port))
		}

		servers = append(servers, nodeEndpoint)
	}

	context.SetStackVariable(fmt.Sprintf("%s.cassandraConnect", application.ID), strings.Join(servers, ","))
	return nil
}
Example #3
0
func (dtr *DSETaskRunner) fillTaskContext(context *framework.Variables, application *framework.Application, response map[string]interface{}) error {
	servers := make([]string, 0)
	serversMap := make(map[string]string)

	value, ok := response["value"].(map[string]interface{})
	if !ok {
		return errors.New("Wrong value field")
	}

	clusterArr, ok := value["cluster"].([]interface{})
	if !ok {
		return errors.New("Wrong cluster field")
	}

	for _, clusterIface := range clusterArr {
		cluster, ok := clusterIface.(map[string]interface{})
		if !ok {
			return errors.New("Wrong cluster field")
		}

		id, ok := cluster["id"].(string)
		if !ok {
			return errors.New("Wrong id field")
		}

		runtime, ok := cluster["runtime"].(map[string]interface{})
		if !ok {
			return errors.New("Wrong runtime field")
		}

		hostname, ok := runtime["hostname"].(string)
		if !ok {
			return errors.New("Wrong hostname field")
		}

		serversMap[id] = hostname
		servers = append(servers, hostname)
	}

	for id, host := range servers {
		context.SetStackVariable(fmt.Sprintf("%s.cassandra-node-%s", application.ID, fmt.Sprint(id)), host)
	}

	context.SetStackVariable(fmt.Sprintf("%s.cassandraConnect", application.ID), strings.Join(servers, ","))
	return nil
}
func (etr *ExhibitorTaskRunner) fillTaskContext(context *framework.Variables, application *framework.Application, response *exhibitorCluster) error {
	servers := make([]string, 0)
	serversMap := make(map[string]string)

	for _, server := range response.Cluster {
		hostname := fmt.Sprintf("%s:%s", server.Config.Hostname, etr.getClientPort(server))

		serversMap[server.Id] = hostname
		servers = append(servers, hostname)
	}

	for id, host := range servers {
		context.SetStackVariable(fmt.Sprintf("%s.exhibitor-%s", application.ID, fmt.Sprint(id)), host)
	}

	context.SetStackVariable(fmt.Sprintf("%s.zkConnect", application.ID), strings.Join(servers, ","))
	return nil
}
func (ztr *ZipkinTaskRunner) fillTaskContext(context *framework.Variables, application *framework.Application, response map[string]interface{}) error {
	valueArr, ok := response["value"].([]interface{})
	if !ok {
		return errors.New("Wrong value field")
	}

	for _, valueIface := range valueArr {
		value, ok := valueIface.(map[string]interface{})
		if !ok {
			return errors.New("Wrong value interface field")
		}

		id, ok := value["id"].(string)
		if !ok {
			return errors.New("Wrong id field")
		}

		config, ok := value["config"].(map[string]interface{})
		if !ok {
			return errors.New("Wrong config field")
		}

		hostname, ok := config["hostname"].(string)
		if !ok {
			return errors.New("Wrong hostname field")
		}

		env, ok := config["env"].(map[string]interface{})
		if !ok {
			return errors.New("Wrong env field")
		}

		queryPort, ok := env["QUERY_PORT"].(string)
		if !ok {
			return errors.New("Wrong QUERY_PORT env")
		}

		context.SetStackVariable(fmt.Sprintf("%s.query-%s.endpoint", application.ID, id), fmt.Sprintf("%s:%s", hostname, queryPort))
	}

	return nil
}
Example #6
0
func (dtr *DSETaskRunner) FillContext(context *framework.Variables, application *framework.Application, task marathon.Task) error {
	context.SetStackVariable(fmt.Sprintf("%s.host", application.ID), task.Host)
	for idx, port := range task.Ports {
		context.SetStackVariable(fmt.Sprintf("%s.port%d", application.ID, idx), fmt.Sprint(port))
	}
	context.SetStackVariable(fmt.Sprintf("%s.api", application.ID), fmt.Sprintf("http://%s:%d", task.Host, task.Ports[0]))

	return nil
}