Ejemplo n.º 1
0
func ReserveRouterPortAndUpdateTrie(internal bool, app, sha, env string) (string, bool, error) {
	helper.SetRouterRoot(internal)
	var (
		err      error
		created  = false
		port     = ""
		trieName = ""
	)
	// reserve port for app env
	if !HasRouterPortForAppEnv(internal, app, env) {
		created = true
	}
	if port, err = reserveRouterPort(internal, app, env); err != nil {
		return port, created, err
	}
	if trieName, err = UpdateAppEnvTrie(internal, app, sha, env); err != nil {
		return port, created, err
	}
	// now port is reserved and trie is created so we can actually create port for router
	portUInt, err := strconv.ParseUint(port, 10, 16)
	if err != nil {
		return port, created, err
	}
	err = routerzk.SetPort(Zk.Conn, routercfg.Port{
		Port: uint16(portUInt),
		Trie: trieName,
	})
	if err != nil {
		return port, created, err
	}
	// return true if port was created
	return port, created, err
}
Ejemplo n.º 2
0
func SetPort(port cfg.Port) error {

	if port.Port == 0 {
		return errors.New("Please specify a port")
	} else if port.Trie == "" {
		return errors.New("Please specify a trie")
	}

	return routerzk.SetPort(zkConn.Conn, port)
}
Ejemplo n.º 3
0
func (e *UpdatePortExecutor) Execute(t *Task) (err error) {
	if e.arg.Port.Trie == "" {
		return errors.New("Please specify a trie")
	}
	if e.arg.Port.Port == uint16(0) {
		return errors.New("Please specify a port")
	}
	helper.SetRouterRoot(e.arg.Port.Internal)
	return routerzk.SetPort(datamodel.Zk.Conn, e.arg.Port)
}