Skip to content

Commit 1db0c69

Browse files
authored
Merge pull request apache#471 from catpineapple/ddc-debug
Ddc debug
2 parents 440c9cf + 5a59e4c commit 1db0c69

File tree

3 files changed

+77
-31
lines changed

3 files changed

+77
-31
lines changed

Dockerfile_doris_jdk

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
FROM ubuntu:22.04
19+
20+
ARG TARGETARCH
21+
22+
23+
RUN sed -i -e 's/^APT/# APT/' -e 's/^DPkg/# DPkg/' /etc/apt/apt.conf.d/docker-clean && \
24+
apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends wget && mkdir -p /usr/lib/jvm/;
25+
26+
RUN if echo $TARGETARCH | grep 'arm64' >>/dev/null ; then \
27+
wget -c http://selectdb-doris-1308700295.cos.ap-beijing.myqcloud.com/release/jdbc_driver/bisheng-jdk-17.0.11-linux-aarch64.tar.gz -O - | tar -xz -C /usr/lib/jvm/ && mv /usr/lib/jvm/bisheng-jdk-17.0.11/ /usr/lib/jvm/jdk-17 && \
28+
wget -c http://selectdb-doris-1308700295.cos.ap-beijing.myqcloud.com/release/jdbc_driver/bisheng-jdk-8u352-linux-aarch64.tar.gz -O - | tar -xz -C /usr/lib/jvm/ && mv /usr/lib/jvm/bisheng-jdk1.8.0_352/ /usr/lib/jvm/jdk-8; \
29+
else \
30+
wget -c http://selectdb-doris-1308700295.cos.ap-beijing.myqcloud.com/release/jdbc_driver/openjdk-17.0.2_linux-x64_bin.tar.gz -O - | tar -xz -C /usr/lib/jvm/ && mv /usr/lib/jvm/jdk-17.0.2/ /usr/lib/jvm/jdk-17 && \
31+
wget -c http://selectdb-doris-1308700295.cos.ap-beijing.myqcloud.com/release/jdbc_driver/openjdk-8u352-b08-linux-x64.tar.gz -O - | tar -xz -C /usr/lib/jvm/ && mv /usr/lib/jvm/openjdk-8u352-b08-linux-x64/ /usr/lib/jvm/jdk-8; \
32+
fi;
33+
34+
WORKDIR /workspace

api/doris/v1/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424

2525
var (
2626
AnnotationDebugKey = "selectdb.com.doris/runmode"
27+
AnnotationDebugDorisKey = "apache.org.doris/runmode"
2728
AnnotationDebugValue = "debug"
28-
AnnotationDebugDorisKey = "apache.com.doris/runmode"
2929
)
3030

3131
// DorisClusterSpec defines the desired state of DorisCluster

cmd/doris-debug/main.go

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ package main
2020
import (
2121
"flag"
2222
"fmt"
23-
v1 "github.com/apache/doris-operator/api/doris/v1"
24-
"github.com/apache/doris-operator/pkg/common/utils/resource"
25-
"github.com/spf13/viper"
2623
"net/http"
2724
"os"
2825
"strconv"
26+
27+
v1 "github.com/apache/doris-operator/api/doris/v1"
28+
"github.com/apache/doris-operator/pkg/common/utils/resource"
29+
"github.com/spf13/viper"
2930
)
3031

3132
var (
@@ -40,7 +41,7 @@ func main() {
4041
return
4142
}
4243

43-
fmt.Println("start component " + componentType + "for debugging.....")
44+
fmt.Println("start component " + componentType + " for debugging.....")
4445
listenPort := readConfigListenPort()
4546
//registerMockApiHealth()
4647
if err := http.ListenAndServe(":"+listenPort, nil); err != nil {
@@ -62,7 +63,28 @@ func flagParse() {
6263
}
6364

6465
func readConfigListenPort() string {
65-
configFileName := dorisRootPath + "/" + componentType + "/conf/" + componentType + ".conf"
66+
67+
var listenPortName string
68+
var configFileName string
69+
var listenPort string
70+
71+
switch componentType {
72+
case "fe":
73+
configFileName = dorisRootPath + "/fe/conf/fe.conf"
74+
listenPortName = resource.QUERY_PORT
75+
case "be":
76+
configFileName = dorisRootPath + "/be/conf/be.conf"
77+
listenPortName = resource.HEARTBEAT_SERVICE_PORT
78+
case "ms":
79+
configFileName = dorisRootPath + "/ms/conf/doris_cloud.conf"
80+
listenPortName = resource.BRPC_LISTEN_PORT
81+
default:
82+
{
83+
fmt.Println("the componentType is not supported:" + componentType)
84+
os.Exit(1)
85+
}
86+
}
87+
6688
_, err := os.Stat(configFileName)
6789
if err != nil {
6890
fmt.Println("the config file is not exist, stat error", err.Error())
@@ -72,34 +94,15 @@ func readConfigListenPort() string {
7294
file, _ := os.Open(configFileName)
7395
viper.SetConfigType("properties")
7496
viper.ReadConfig(file)
75-
76-
var listenPort string
77-
if componentType == "fe" {
78-
configQueryPort := viper.GetString(resource.QUERY_PORT)
79-
if configQueryPort == "" {
80-
listenPort = strconv.Itoa(int(resource.GetDefaultPort(resource.QUERY_PORT)))
81-
}
82-
} else if componentType == "be" {
83-
configHeartbeatPort := viper.GetString(resource.HEARTBEAT_SERVICE_PORT)
84-
fmt.Println("component be" + configHeartbeatPort)
85-
if configHeartbeatPort == "" {
86-
listenPort = strconv.Itoa(int(resource.GetDefaultPort(resource.HEARTBEAT_SERVICE_PORT)))
87-
}
97+
listenPort = viper.GetString(listenPortName)
98+
if listenPort == "" {
99+
listenPort = strconv.Itoa(int(resource.GetDefaultPort(listenPortName)))
88100
}
89-
fmt.Println("component listen port " + listenPort)
90101

102+
fmt.Println("component listen port " + listenPort)
91103
return listenPort
92104
}
93105

94-
func registerMockApiHealth() {
95-
if componentType == "fe" {
96-
http.HandleFunc("/api/health", mockFEHealth)
97-
return
98-
}
99-
100-
http.HandleFunc("/api/health", mockBEHealth)
101-
}
102-
103106
func kickOffDebug() bool {
104107
annotationFileName := resource.POD_INFO_PATH + "/annotations"
105108
if _, err := os.Stat(annotationFileName); os.IsNotExist(err) {
@@ -123,14 +126,23 @@ func kickOffDebug() bool {
123126

124127
valueDoris := viper.GetString(v1.AnnotationDebugDorisKey)
125128

126-
if valueDoris == "\""+v1.AnnotationDebugDorisKey+"\"" {
129+
if valueDoris == "\""+v1.AnnotationDebugValue+"\"" {
127130
return true
128131
}
129132

130-
fmt.Println("the value not equal!", value, v1.AnnotationDebugValue, v1.AnnotationDebugDorisKey)
133+
fmt.Printf("No debug flag matched, flags: [%s:%s],[%s:%s] !", v1.AnnotationDebugDorisKey, valueDoris, v1.AnnotationDebugKey, value)
131134
return false
132135
}
133136

137+
func registerMockApiHealth() {
138+
if componentType == "fe" {
139+
http.HandleFunc("/api/health", mockFEHealth)
140+
return
141+
}
142+
143+
http.HandleFunc("/api/health", mockBEHealth)
144+
}
145+
134146
func mockFEHealth(w http.ResponseWriter, r *http.Request) {
135147
//{"msg":"success","code":0,"data":{"online_backend_num":3,"total_backend_num":3},"count":0}
136148
w.WriteHeader(http.StatusOK)

0 commit comments

Comments
 (0)