|
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
- <mapper namespace="com.imitate.common.k8s.mapper.BridgePodMapper">
- <resultMap id="BaseResultMap"
- type="com.imitate.common.k8s.pojo.BridgePod">
- <id column="id" property="id" jdbcType="BIGINT" />
- <result column="name" property="name" jdbcType="VARCHAR" />
- <result column="tpi_ID" property="tpiID" jdbcType="VARCHAR" />
- <result column="build_ID" property="buildID" jdbcType="VARCHAR" />
- <result column="uid" property="uid" jdbcType="VARCHAR" />
- <result column="k8s_create_time" property="k8sCreateTime"
- jdbcType="TIMESTAMP" />
- <result column="delete_time" property="deleteTime"
- jdbcType="TIMESTAMP" />
- <result column="sec_key" property="secKey" jdbcType="VARCHAR" />
- <result column="request_time" property="requestTime"
- jdbcType="TIMESTAMP" />
- <result column="pull" property="pull" jdbcType="DOUBLE" />
- <result column="create_pod" property="createPod"
- jdbcType="DOUBLE" />
- <result column="execute" property="execute" jdbcType="DOUBLE" />
- <result column="evaluate_all_time" property="evaluateAllTime"
- jdbcType="DOUBLE" />
- <result column="node_name" property="nodeName"
- jdbcType="VARCHAR" />
- <result column="node_ip" property="nodeIp" jdbcType="VARCHAR" />
- <result column="download_status" property="downloadStatus"
- jdbcType="CHAR" />
- <result column="create_pod_status" property="createPodStatus"
- jdbcType="CHAR" />
- <result column="compile_status" property="compileStatus"
- jdbcType="CHAR" />
- <result column="run_status" property="runStatus"
- jdbcType="CHAR" />
- <result column="status" property="status" jdbcType="CHAR" />
- <result column="image_name" property="imageName"
- jdbcType="VARCHAR" />
- <result column="image_version" property="imageVersion"
- jdbcType="VARCHAR" />
- <result column="cpu_limit" property="cpuLimit"
- jdbcType="DOUBLE" />
- <result column="memory_limit" property="memoryLimit"
- jdbcType="INTEGER" />
- <result column="cpu_request" property="cpuRequest"
- jdbcType="DOUBLE" />
- <result column="memory_request" property="memoryRequest"
- jdbcType="INTEGER" />
- </resultMap>
- <sql id="Base_Column_List">
- id, name, tpi_ID, build_ID, uid, k8s_create_time, delete_time,
- sec_key,
- request_time,
- pull, create_pod,
- execute, evaluate_all_time,
- node_name,
- node_ip, download_status, create_pod_status,
- compile_status,
- run_status, status, image_name, image_version,
- cpu_limit, memory_limit, cpu_request, memory_request
- </sql>
-
-
- <insert id="insert" useGeneratedKeys="true" keyProperty="id"
- parameterType="com.imitate.common.k8s.pojo.BridgePod">
- insert into bridge_pod (id, name, tpi_ID, build_ID, uid,
- k8s_create_time, delete_time, sec_key,
- request_time, pull, create_pod,
- execute, evaluate_all_time, node_name,
- node_ip, download_status,
- create_pod_status,
- compile_status, run_status, status,
- image_version,
- image_name,
- cpu_limit,
- memory_limit,
- cpu_request,
- memory_request
- )
- values
- (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR},
- #{tpiID,jdbcType=VARCHAR},
- #{buildID,jdbcType=VARCHAR},
- #{uid,jdbcType=VARCHAR},
- #{k8sCreateTime,jdbcType=TIMESTAMP},
- #{deleteTime,jdbcType=TIMESTAMP},
- #{secKey,jdbcType=VARCHAR},
- #{requestTime,jdbcType=TIMESTAMP},
- #{pull,jdbcType=DOUBLE},
- #{createPod,jdbcType=DOUBLE},
- #{execute,jdbcType=DOUBLE},
- #{evaluateAllTime,jdbcType=DOUBLE},
- #{nodeName,jdbcType=VARCHAR},
- #{nodeIp,jdbcType=VARCHAR},
- #{downloadStatus,jdbcType=CHAR},
- #{createPodStatus,jdbcType=CHAR},
- #{compileStatus,jdbcType=CHAR},
- #{runStatus,jdbcType=CHAR},
- #{status,jdbcType=CHAR},
- #{imageName,jdbcType=VARCHAR},
- #{imageVersion,jdbcType=VARCHAR},
- #{cpuLimit,jdbcType=DOUBLE},
- #{memoryLimit,jdbcType=INTEGER},
- #{cpuRequest,jdbcType=DOUBLE},
- #{memoryRequest,jdbcType=INTEGER}
- )
- </insert>
- <insert id="insertSelective"
- parameterType="com.imitate.common.k8s.pojo.BridgePod">
- insert into bridge_pod
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">
- id,
- </if>
- <if test="name != null">
- name,
- </if>
- <if test="tpiID != null">
- tpi_ID,
- </if>
- <if test="buildID != null">
- build_ID,
- </if>
- <if test="uid != null">
- uid,
- </if>
- <if test="k8sCreateTime != null">
- k8s_create_time,
- </if>
- <if test="deleteTime != null">
- delete_time,
- </if>
- <if test="secKey != null">
- sec_key,
- </if>
- <if test="requestTime != null">
- request_time,
- </if>
- <if test="pull != null">
- pull,
- </if>
- <if test="createPod != null">
- create_pod,
- </if>
- <if test="execute != null">
- execute,
- </if>
- <if test="evaluateAllTime != null">
- evaluate_all_time,
- </if>
- <if test="nodeName != null">
- node_name,
- </if>
- <if test="nodeIp != null">
- node_ip,
- </if>
- <if test="downloadStatus != null">
- download_status,
- </if>
- <if test="createPodStatus != null">
- create_pod_status,
- </if>
- <if test="compileStatus != null">
- compile_status,
- </if>
- <if test="runStatus != null">
- run_status,
- </if>
- <if test="status != null">
- status,
- </if>
- <if test="imageName != null">
- image_name,
- </if>
- <if test="imageVersion != null">
- image_version,
- </if>
- <if test="cpuLimit != null">
- cpu_limit,
- </if>
- <if test="memoryLimit != null">
- memory_limit,
- </if>
- <if test="cpuRequest != null">
- cpu_request,
- </if>
- <if test="memoryRequest != null">
- memory_request,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">
- #{id,jdbcType=BIGINT},
- </if>
- <if test="name != null">
- #{name,jdbcType=VARCHAR},
- </if>
- <if test="tpiID != null">
- #{tpiID,jdbcType=VARCHAR},
- </if>
- <if test="buildID != null">
- #{buildID,jdbcType=VARCHAR},
- </if>
- <if test="uid != null">
- #{uid,jdbcType=VARCHAR},
- </if>
- <if test="k8sCreateTime != null">
- #{k8sCreateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="deleteTime != null">
- #{deleteTime,jdbcType=TIMESTAMP},
- </if>
- <if test="secKey != null">
- #{secKey,jdbcType=VARCHAR},
- </if>
- <if test="requestTime != null">
- #{requestTime,jdbcType=TIMESTAMP},
- </if>
- <if test="pull != null">
- #{pull,jdbcType=DOUBLE},
- </if>
- <if test="createPod != null">
- #{createPod,jdbcType=DOUBLE},
- </if>
- <if test="execute != null">
- #{execute,jdbcType=DOUBLE},
- </if>
- <if test="evaluateAllTime != null">
- #{evaluateAllTime,jdbcType=DOUBLE},
- </if>
- <if test="nodeName != null">
- #{nodeName,jdbcType=VARCHAR},
- </if>
- <if test="nodeIp != null">
- #{nodeIp,jdbcType=VARCHAR},
- </if>
- <if test="downloadStatus != null">
- #{downloadStatus,jdbcType=CHAR},
- </if>
- <if test="createPodStatus != null">
- #{createPodStatus,jdbcType=CHAR},
- </if>
- <if test="compileStatus != null">
- #{compileStatus,jdbcType=CHAR},
- </if>
- <if test="runStatus != null">
- #{runStatus,jdbcType=CHAR},
- </if>
- <if test="status != null">
- #{status,jdbcType=CHAR},
- </if>
- <if test="imageName != null">
- #{imageName,jdbcType=VARCHAR},
- </if>
- <if test="imageVersion != null">
- #{imageVersion,jdbcType=VARCHAR},
- </if>
- <if test="cpuLimit != null">
- #{cpuLimit,jdbcType=DOUBLE},
- </if>
- <if test="memoryLimit != null">
- #{memoryLimit,jdbcType=INTEGER},
- </if>
- <if test="cpuRequest != null">
- #{cpuRequest,jdbcType=DOUBLE},
- </if>
- <if test="memoryRequest != null">
- #{memoryRequest,jdbcType=INTEGER},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective"
- parameterType="com.imitate.common.k8s.pojo.BridgePod">
- update bridge_pod
- <set>
- <if test="name != null">
- name = #{name,jdbcType=VARCHAR},
- </if>
- <if test="tpiID != null">
- tpi_ID = #{tpiID,jdbcType=VARCHAR},
- </if>
- <if test="buildID != null">
- build_ID = #{buildID,jdbcType=VARCHAR},
- </if>
- <if test="uid != null">
- uid = #{uid,jdbcType=VARCHAR},
- </if>
- <if test="k8sCreateTime != null">
- k8s_create_time = #{k8sCreateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="deleteTime != null">
- delete_time = #{deleteTime,jdbcType=TIMESTAMP},
- </if>
- <if test="secKey != null">
- sec_key = #{secKey,jdbcType=VARCHAR},
- </if>
- <if test="requestTime != null">
- request_time = #{requestTime,jdbcType=TIMESTAMP},
- </if>
- <if test="pull != null">
- pull = #{pull,jdbcType=DOUBLE},
- </if>
- <if test="createPod != null">
- create_pod = #{createPod,jdbcType=DOUBLE},
- </if>
- <if test="execute != null">
- execute = #{execute,jdbcType=DOUBLE},
- </if>
- <if test="evaluateAllTime != null">
- evaluate_all_time = #{evaluateAllTime,jdbcType=DOUBLE},
- </if>
- <if test="nodeName != null">
- node_name = #{nodeName,jdbcType=VARCHAR},
- </if>
- <if test="nodeIp != null">
- node_ip = #{nodeIp,jdbcType=VARCHAR},
- </if>
- <if test="downloadStatus != null">
- download_status = #{downloadStatus,jdbcType=CHAR},
- </if>
- <if test="createPodStatus != null">
- create_pod_status = #{createPodStatus,jdbcType=CHAR},
- </if>
- <if test="compileStatus != null">
- compile_status = #{compileStatus,jdbcType=CHAR},
- </if>
- <if test="runStatus != null">
- run_status = #{runStatus,jdbcType=CHAR},
- </if>
- <if test="status != null">
- status = #{status,jdbcType=CHAR},
- </if>
- <if test="imageName != null">
- image_name = #{imageName,jdbcType=VARCHAR},
- </if>
- <if test="imageVersion != null">
- image_version = #{imageVersion,jdbcType=VARCHAR},
- </if>
- <if test="cpuLimit != null">
- cpu_limit = #{cpuLimit,jdbcType=DOUBLE},
- </if>
- <if test="memoryLimit != null">
- memory_limit = #{memoryLimit,jdbcType=INTEGER},
- </if>
- <if test="cpuRequest != null">
- cpu_request = #{cpuRequest,jdbcType=DOUBLE},
- </if>
- <if test="memoryRequest != null">
- memory_request = #{memoryRequest,jdbcType=INTEGER},
- </if>
- </set>
- where id = #{id,jdbcType=BIGINT}
- </update>
- <update id="updateByPrimaryKey"
- parameterType="com.imitate.common.k8s.pojo.BridgePod">
- update bridge_pod
- set name = #{name,jdbcType=VARCHAR},
- tpi_ID = #{tpiID,jdbcType=VARCHAR},
- build_ID = #{buildID,jdbcType=VARCHAR},
- uid = #{uid,jdbcType=VARCHAR},
- k8s_create_time =
- #{k8sCreateTime,jdbcType=TIMESTAMP},
- delete_time =
- #{deleteTime,jdbcType=TIMESTAMP},
- sec_key = #{secKey,jdbcType=VARCHAR},
- request_time = #{requestTime,jdbcType=TIMESTAMP},
- pull =
- #{pull,jdbcType=DOUBLE},
- create_pod = #{createPod,jdbcType=DOUBLE},
- execute = #{execute,jdbcType=DOUBLE},
- evaluate_all_time =
- #{evaluateAllTime,jdbcType=DOUBLE},
- node_name =
- #{nodeName,jdbcType=VARCHAR},
- node_ip = #{nodeIp,jdbcType=VARCHAR},
- download_status = #{downloadStatus,jdbcType=CHAR},
- create_pod_status =
- #{createPodStatus,jdbcType=CHAR},
- compile_status =
- #{compileStatus,jdbcType=CHAR},
- run_status =
- #{runStatus,jdbcType=CHAR},
- status = #{status,jdbcType=CHAR},
- image_name =
- #{imageName,jdbcType=VARCHAR},
- image_version =
- #{imageVersion,jdbcType=VARCHAR},
- cpu_limit =
- #{cpuLimit,jdbcType=DOUBLE},
- memory_limit =
- #{memoryLimit,jdbcType=INTEGER},
- cpu_request =
- #{cpuRequest,jdbcType=DOUBLE},
- memory_request =
- #{memoryRequest,jdbcType=INTEGER}
- where id =
- #{id,jdbcType=BIGINT}
- </update>
-
- <select id="selectBridgePod" resultMap="BaseResultMap"
- parameterType="com.imitate.common.k8s.bean.PodQueryParam">
- select
- <include refid="Base_Column_List" />
- from bridge_pod
- where 1 = 1
- <if test="id != null">
- and id = #{id,jdbcType=BIGINT}
- </if>
- <if test="name != null">
- and name like "%"#{name,jdbcType=VARCHAR}"%"
- </if>
- <if test="tpiID != null">
- and tpi_ID = #{tpiID,jdbcType=VARCHAR}
- </if>
- <if test="buildID != null">
- and build_ID = #{buildID,jdbcType=VARCHAR}
- </if>
- <if test="uid != null">
- and uid = #{uid,jdbcType=VARCHAR}
- </if>
- <if test="secKey != null">
- and sec_key = #{secKey,jdbcType=VARCHAR}
- </if>
- <if test="requestTime != null">
- and request_time = #{requestTime,jdbcType=TIMESTAMP}
- </if>
- <if test="minRequestTime != null">
- and request_time >= #{minRequestTime,jdbcType=TIMESTAMP}
- </if>
- <if test="maxRequestTime != null">
- and request_time < #{maxRequestTime,jdbcType=TIMESTAMP}
- </if>
- <if test="nodeName != null">
- and node_name = #{nodeName,jdbcType=VARCHAR}
- </if>
- <if test="nodeIp != null">
- and node_ip = #{nodeIp,jdbcType=VARCHAR}
- </if>
- <if test="downloadStatus != null">
- and download_status = #{downloadStatus,jdbcType=CHAR}
- </if>
- <if test="createPodStatus != null">
- and create_pod_status = #{createPodStatus,jdbcType=CHAR}
- </if>
- <if test="compileStatus != null">
- and compile_status = #{compileStatus,jdbcType=CHAR}
- </if>
- <if test="runStatus != null">
- and run_status = #{runStatus,jdbcType=CHAR}
- </if>
- <if test="status != null">
- and status = #{status,jdbcType=CHAR}
- </if>
-
- <if test="imageName != null">
- and image_name = #{imageName,jdbcType=VARCHAR}
- </if>
- <if test="imageVersion != null">
- and image_version = #{imageVersion,jdbcType=VARCHAR}
- </if>
- <if test="cpuLimit != null">
- and cpu_limit = #{cpuLimit,jdbcType=DOUBLE}
- </if>
-
- <if test="memoryLimit != null">
- and memory_limit = #{memoryLimit,jdbcType=INTEGER}
- </if>
-
- <if test="cpuRequest != null">
- and cpu_request = #{cpuRequest,jdbcType=DOUBLE}
- </if>
-
- <if test="memoryRequest != null">
- and memory_request = #{memoryRequest,jdbcType=INTEGER}
- </if>
- <choose>
- <when test="sortField != null || sortDirection != null">
- order by ${sortField} ${sortDirection}
- </when>
- <when test="sortField != null">
- order by ${sortField} desc
- </when>
- <otherwise>
- order by id desc
- </otherwise>
- </choose>
- </select>
- <update id="updateUpdateDeleteTime"
- parameterType="com.imitate.common.k8s.pojo.BridgePod">
- update bridge_pod
- set delete_time = #{deleteTime,jdbcType=TIMESTAMP}
- where name = #{name,jdbcType=VARCHAR} and delete_time is null
- <if test="requestTime != null">
- and request_time >= #{requestTime,jdbcType=TIMESTAMP}
- </if>
- </update>
-
- <delete id="deleteByRequestTime"
- parameterType="java.time.LocalDateTime">
- delete from
- bridge_pod
- where request_time < #{requestTime,jdbcType=TIMESTAMP}
- </delete>
-
- <select id="countEvaDayStat" resultMap="com.imitate.common.k8s.mapper.EvaDayStatMapper.BaseResultMap"
- parameterType="java.lang.Integer">
- SELECT stat_date,eva_total,pull_slow,pull_fail,create_pod_slow,create_pod_fail,
- exec_fail,others_fail,
- CONVERT((exec_fail+others_fail)/eva_total, DECIMAL(10,6)) AS eva_fail_ratio,
- eva_timeout,
- CONVERT(eva_timeout/eva_total, DECIMAL(10,6)) AS eva_timeout_ratio FROM (
- select DATE_FORMAT(request_time,'%Y%m%d') AS stat_date,
- COUNT(*) AS eva_total,
- SUM(IF(pull > 5, 1, 0)) AS pull_slow,
- SUM(IF(download_status=0,1,0)) AS pull_fail,
- SUM(IF(create_pod > 5, 1, 0)) AS create_pod_slow,
- SUM(IF(create_pod_status=0,1,0)) AS create_pod_fail,
- SUM(IF(run_status=1,1,0)) AS exec_fail,
- SUM(IF(run_status=2,1,0)) AS eva_timeout,
- SUM(IF(run_status=3,1,0)) AS others_fail
- FROM bridge_pod WHERE DATE_FORMAT(request_time,'%Y%m%d') = #{requestTime,jdbcType=INTEGER} AND run_status IS NOT null) as temp;
- </select>
-
- <select id="selectNodeEvaErrorInfos" resultType="com.imitate.common.k8s.bean.NodeEvaErrorInfo"
- parameterType="java.time.LocalDateTime">
- select node_name AS nodeName,
- SUM(IF(download_status = 0, 1, 0)) AS downloadErrorNum,
- SUM(IF(create_pod_status = 0, 1, 0)) AS createPodErrorNum,
- SUM(IF(run_status = 1, 1, 0)) AS runErrorNum,
- COUNT(id) AS evaCount
- from bridge_pod
- where request_time > #{requestTime,jdbcType=TIMESTAMP}
- and node_name is not null
- group by node_name
- </select>
- </mapper>
|