コード例 #1
0
ファイル: agent_server_cmd.go プロジェクト: gao8954/glow
func (as *AgentServer) handleCommandConnection(conn net.Conn,
	command *cmd.ControlMessage) *cmd.ControlMessage {
	reply := &cmd.ControlMessage{}
	switch command.GetType() {
	case cmd.ControlMessage_StartRequest:
		reply.Type = cmd.ControlMessage_StartResponse.Enum()
		remoteAddress := conn.RemoteAddr().String()
		// println("remote address is", remoteAddress)
		host := remoteAddress[:strings.LastIndex(remoteAddress, ":")]
		command.StartRequest.Host = &host
		reply.StartResponse = as.handleStart(conn, command.StartRequest)
		// return nil to avoid writing the response to the connection.
		// Currently the connection is used for reading outputs
		return nil
	case cmd.ControlMessage_DeleteDatasetShardRequest:
		reply.Type = cmd.ControlMessage_DeleteDatasetShardResponse.Enum()
		reply.DeleteDatasetShardResponse = as.handleDeleteDatasetShard(conn, command.DeleteDatasetShardRequest)
	case cmd.ControlMessage_GetStatusRequest:
		reply.Type = cmd.ControlMessage_GetStatusResponse.Enum()
		reply.GetStatusResponse = as.handleGetStatusRequest(command.GetStatusRequest)
	case cmd.ControlMessage_StopRequest:
		reply.Type = cmd.ControlMessage_StopResponse.Enum()
		reply.StopResponse = as.handleStopRequest(command.StopRequest)
	case cmd.ControlMessage_LocalStatusReportRequest:
		reply.Type = cmd.ControlMessage_LocalStatusReportResponse.Enum()
		reply.LocalStatusReportResponse = as.handleLocalStatusReportRequest(command.LocalStatusReportRequest)
	}
	return reply
}
コード例 #2
0
ファイル: agent_server_cmd.go プロジェクト: llitfkitfk/glow
func (as *AgentServer) handleCommandConnection(conn net.Conn,
	command *cmd.ControlMessage) *cmd.ControlMessage {
	reply := &cmd.ControlMessage{}
	if command.GetType() == cmd.ControlMessage_StartRequest {
		reply.Type = cmd.ControlMessage_StartResponse.Enum()
		remoteAddress := conn.RemoteAddr().String()
		// println("remote address is", remoteAddress)
		host := remoteAddress[:strings.LastIndex(remoteAddress, ":")]
		command.StartRequest.Host = &host
		reply.StartResponse = as.handleStart(conn, command.StartRequest)
	}
	if command.GetType() == cmd.ControlMessage_DeleteDatasetShardRequest {
		reply.Type = cmd.ControlMessage_DeleteDatasetShardResponse.Enum()
		reply.DeleteDatasetShardResponse = as.handleDeleteDatasetShard(conn, command.DeleteDatasetShardRequest)
	}
	// TODO: skip return reply for now
	return nil
}
コード例 #3
0
ファイル: agent_server_cmd.go プロジェクト: nonempty/glow
func (as *AgentServer) handleCommandConnection(conn net.Conn,
	command *cmd.ControlMessage) *cmd.ControlMessage {
	reply := &cmd.ControlMessage{}
	switch command.GetType() {
	case cmd.ControlMessage_StartRequest:
		reply.Type = cmd.ControlMessage_StartResponse.Enum()
		remoteAddress := conn.RemoteAddr().String()
		// println("remote address is", remoteAddress)
		host := remoteAddress[:strings.LastIndex(remoteAddress, ":")]
		command.StartRequest.Host = &host
		reply.StartResponse = as.handleStart(conn, command.StartRequest)
		return nil
	case cmd.ControlMessage_DeleteDatasetShardRequest:
		reply.Type = cmd.ControlMessage_DeleteDatasetShardResponse.Enum()
		reply.DeleteDatasetShardResponse = as.handleDeleteDatasetShard(conn, command.DeleteDatasetShardRequest)
	case cmd.ControlMessage_GetStatusRequest:
		reply.Type = cmd.ControlMessage_GetStatusResponse.Enum()
		reply.GetStatusResponse = as.handleStatus(command.GetStatusRequest)
	case cmd.ControlMessage_StopRequest:
		reply.Type = cmd.ControlMessage_StopResponse.Enum()
		reply.StopResponse = as.handleStopRequest(command.StopRequest)
	}
	return reply
}