Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reclaim TiKV's component server and status server #152

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions components/proxy_server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,27 @@ pub fn ensure_no_common_unrecognized_keys(
Ok(())
}

// Not the same as TiKV
pub const TIFLASH_DEFAULT_LISTENING_ADDR: &str = "127.0.0.1:20170";
pub const TIFLASH_DEFAULT_STATUS_ADDR: &str = "127.0.0.1:20292";

pub fn make_tikv_config() -> TiKvConfig {
let mut default = TiKvConfig::default();
setup_default_tikv_config(&mut default);
default
}

pub fn setup_default_tikv_config(default: &mut TiKvConfig) {
default.server.addr = TIFLASH_DEFAULT_LISTENING_ADDR.to_string();
default.server.status_addr = TIFLASH_DEFAULT_STATUS_ADDR.to_string();
default.server.advertise_status_addr = TIFLASH_DEFAULT_STATUS_ADDR.to_string();
default.raft_store.region_worker_tick_interval = ReadableDuration::millis(500);
let stale_peer_check_tick =
(10_000 / default.raft_store.region_worker_tick_interval.as_millis()) as usize;
default.raft_store.stale_peer_check_tick = stale_peer_check_tick;
}

/// This function changes TiKV's config according to ProxyConfig.
pub fn address_proxy_config(config: &mut TiKvConfig) {
// We must add engine label to our TiFlash config
pub const DEFAULT_ENGINE_LABEL_KEY: &str = "engine";
Expand All @@ -137,6 +158,9 @@ pub fn address_proxy_config(config: &mut TiKvConfig) {
.server
.labels
.insert(DEFAULT_ENGINE_LABEL_KEY.to_owned(), engine_name);
let stale_peer_check_tick =
(10_000 / config.raft_store.region_worker_tick_interval.as_millis()) as usize;
config.raft_store.stale_peer_check_tick = stale_peer_check_tick;
}

pub fn validate_and_persist_config(config: &mut TiKvConfig, persist: bool) {
Expand Down
25 changes: 1 addition & 24 deletions components/proxy_server/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,7 @@ use clap::{App, Arg, ArgMatches};
use tikv::config::TiKvConfig;
use tikv_util::config::ReadableDuration;

use crate::{
fatal,
setup::{ensure_no_unrecognized_config, overwrite_config_with_cmd_args},
};

// Not the same as TiKV
pub const TIFLASH_DEFAULT_LISTENING_ADDR: &str = "127.0.0.1:20170";
pub const TIFLASH_DEFAULT_STATUS_ADDR: &str = "127.0.0.1:20292";

fn make_tikv_config() -> TiKvConfig {
let mut default = TiKvConfig::default();
setup_default_tikv_config(&mut default);
default
}

pub fn setup_default_tikv_config(default: &mut TiKvConfig) {
default.server.addr = TIFLASH_DEFAULT_LISTENING_ADDR.to_string();
default.server.status_addr = TIFLASH_DEFAULT_STATUS_ADDR.to_string();
default.server.advertise_status_addr = TIFLASH_DEFAULT_STATUS_ADDR.to_string();
default.raft_store.region_worker_tick_interval = ReadableDuration::millis(500);
let stale_peer_check_tick =
(10_000 / default.raft_store.region_worker_tick_interval.as_millis()) as usize;
default.raft_store.stale_peer_check_tick = stale_peer_check_tick;
}
use crate::{config::make_tikv_config, fatal, setup::overwrite_config_with_cmd_args};

/// Generate default TiKvConfig, but with some Proxy's default values.
pub fn gen_tikv_config(
Expand Down
18 changes: 17 additions & 1 deletion components/proxy_server/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,29 @@ use std::{
use chrono::Local;
use clap::ArgMatches;
use collections::HashMap;
pub use server::setup::{ensure_no_unrecognized_config, initial_logger, initial_metric};
pub use server::setup::initial_logger;
use tikv::config::{MetricConfig, TiKvConfig};
use tikv_util::{self, config, logger};

use crate::config::{validate_and_persist_config, ProxyConfig};
pub use crate::fatal;

#[allow(dead_code)]
pub fn initial_metric(cfg: &MetricConfig) {
tikv_util::metrics::monitor_process()
.unwrap_or_else(|e| fatal!("failed to start process monitor: {}", e));
tikv_util::metrics::monitor_threads("")
.unwrap_or_else(|e| fatal!("failed to start thread monitor: {}", e));
tikv_util::metrics::monitor_allocator_stats("")
.unwrap_or_else(|e| fatal!("failed to monitor allocator stats: {}", e));

if cfg.interval.as_secs() == 0 || cfg.address.is_empty() {
return;
}

warn!("metrics push is not supported any more.");
}

#[allow(dead_code)]
pub fn overwrite_config_with_cmd_args(
config: &mut TiKvConfig,
Expand Down
8 changes: 0 additions & 8 deletions components/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ portable = ["tikv/portable"]
sse = ["tikv/sse"]
mem-profiling = ["tikv/mem-profiling"]
failpoints = ["tikv/failpoints"]
bcc-iosnoop = ["tikv/bcc-iosnoop"]

cloud-aws = ["encryption_export/cloud-aws"]
cloud-gcp = ["encryption_export/cloud-gcp"]
cloud-azure = ["encryption_export/cloud-azure"]
Expand Down Expand Up @@ -57,15 +55,12 @@ futures = "0.3"
grpcio = { version = "0.10", default-features = false, features = ["openssl-vendored"] }
grpcio-health = { version = "0.10", default-features = false, features = ["protobuf-codec"] }
hex = "0.4"

itertools = "0.10"
keys = { path = "../keys", default-features = false }
kvproto = { git = "https://github.com/pingcap/kvproto.git" }
libc = "0.2"
log = { version = "0.4", features = ["max_level_trace", "release_max_level_debug"] }
log_wrappers = { path = "../log_wrappers" }
nix = "0.23"
online_config = { path = "../online_config" }
pd_client = { path = "../pd_client", default-features = false }
prometheus = { version = "0.13", features = ["nightly"] }
protobuf = { version = "2.8", features = ["bytes"] }
Expand All @@ -76,9 +71,6 @@ rand = "0.8"
resolved_ts = { path = "../../components/resolved_ts", default-features = false }
resource_metering = { path = "../resource_metering" }
security = { path = "../security", default-features = false }
serde = "1.0"
serde_derive = "1.0"
serde_ignored = "0.1"
serde_json = "1.0"
slog = { version = "2.3", features = ["max_level_trace", "release_max_level_debug"] }
slog-global = { version = "0.1", git = "https://github.com/breeswish/slog-global.git", rev = "d592f88e4dbba5eb439998463054f1a44fbf17b9" }
Expand Down
3 changes: 1 addition & 2 deletions components/server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.

extern crate slog_global;

#[macro_use]
extern crate tikv_util;

Expand All @@ -10,3 +8,4 @@ pub mod setup;
pub mod memory;
pub mod raft_engine_switch;
pub mod server;
pub mod signal_handler;
Loading