github.com/pingcap/tiup@v1.15.1/components/playground/instance/tiflash_pre7_config.go (about)

     1  // Copyright 2020 PingCAP, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package instance
    15  
    16  import (
    17  	"fmt"
    18  	"io"
    19  	"strings"
    20  
    21  	"github.com/pingcap/tiup/pkg/tidbver"
    22  	"github.com/pingcap/tiup/pkg/utils"
    23  )
    24  
    25  const tiflashDaemonConfigOld = `
    26  
    27  [application]
    28  runAsDaemon = true
    29  
    30  `
    31  
    32  const tiflashMarkCacheSizeOld = `mark_cache_size = 5368709120`
    33  
    34  const tiflashConfigOld = `
    35  default_profile = "default"
    36  display_name = "TiFlash"
    37  http_port = %[2]d
    38  listen_host = "0.0.0.0"
    39  tcp_port = %[3]d
    40  path = "%[5]s"
    41  tmp_path = "%[6]s"
    42  %[14]s
    43  %[13]s
    44  [flash]
    45  service_addr = "%[10]s:%[8]d"
    46  tidb_status_addr = "%[11]s"
    47  [flash.flash_cluster]
    48  cluster_manager_path = "%[12]s"
    49  log = "%[7]s/tiflash_cluster_manager.log"
    50  master_ttl = 60
    51  refresh_interval = 20
    52  update_rule_interval = 5
    53  [flash.proxy]
    54  config = "%[4]s/tiflash-learner.toml"
    55  
    56  [logger]
    57  count = 20
    58  errorlog = "%[7]s/tiflash_error.log"
    59  level = "debug"
    60  log = "%[7]s/tiflash.log"
    61  size = "1000M"
    62  
    63  [profiles]
    64  [profiles.default]
    65  load_balancing = "random"
    66  max_memory_usage = 0
    67  use_uncompressed_cache = 0
    68  [profiles.readonly]
    69  readonly = 1
    70  
    71  [quotas]
    72  [quotas.default]
    73  [quotas.default.interval]
    74  duration = 3600
    75  errors = 0
    76  execution_time = 0
    77  queries = 0
    78  read_rows = 0
    79  result_rows = 0
    80  
    81  [raft]
    82  pd_addr = "%[1]s"
    83  
    84  [status]
    85  metrics_port = %[9]d
    86  
    87  [users]
    88  [users.default]
    89  password = ""
    90  profile = "default"
    91  quota = "default"
    92  [users.default.networks]
    93  ip = "::/0"
    94  [users.readonly]
    95  password = ""
    96  profile = "readonly"
    97  quota = "default"
    98  [users.readonly.networks]
    99  ip = "::/0"
   100  `
   101  
   102  // writeTiFlashConfigOld is for < 7.1.0. Not maintained any more. Do not introduce new features.
   103  func writeTiFlashConfigOld(w io.Writer, version utils.Version, tcpPort, httpPort, servicePort, metricsPort int, host, deployDir, clusterManagerPath string, tidbStatusAddrs, endpoints []string) error {
   104  	pdAddrs := strings.Join(endpoints, ",")
   105  	dataDir := fmt.Sprintf("%s/data", deployDir)
   106  	tmpDir := fmt.Sprintf("%s/tmp", deployDir)
   107  	logDir := fmt.Sprintf("%s/log", deployDir)
   108  	ip := AdvertiseHost(host)
   109  	var conf string
   110  
   111  	if tidbver.TiFlashNotNeedSomeConfig(version.String()) {
   112  		conf = fmt.Sprintf(tiflashConfigOld, pdAddrs, httpPort, tcpPort,
   113  			deployDir, dataDir, tmpDir, logDir, servicePort, metricsPort,
   114  			ip, strings.Join(tidbStatusAddrs, ","), clusterManagerPath, "", "")
   115  	} else {
   116  		conf = fmt.Sprintf(tiflashConfigOld, pdAddrs, httpPort, tcpPort,
   117  			deployDir, dataDir, tmpDir, logDir, servicePort, metricsPort,
   118  			ip, strings.Join(tidbStatusAddrs, ","), clusterManagerPath, tiflashDaemonConfigOld, tiflashMarkCacheSizeOld)
   119  	}
   120  	_, err := w.Write([]byte(conf))
   121  	return err
   122  }
   123  
   124  func getTiFlashProxyConfigPathOld(cfg map[string]any) string {
   125  	defer func() {
   126  		if r := recover(); r != nil {
   127  			return
   128  		}
   129  	}()
   130  	return cfg["flash"].(map[string]any)["proxy"].(map[string]any)["config"].(string)
   131  }
   132  
   133  func setTiFlashProxyConfigPathOld(cfg map[string]any, path string) {
   134  	cfg["flash"].(map[string]any)["proxy"].(map[string]any)["config"] = path
   135  }