Skip to content

Commit

Permalink
Merge branch 'master' into grpcio-0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
overvenus committed Jan 10, 2019
2 parents f081543 + fa231fa commit 31a2da0
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 38 deletions.
6 changes: 6 additions & 0 deletions components/test_util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,10 @@ pub fn setup_for_ci() {
// but also stops tests immediately.
tikv::util::set_panic_hook(true, "./");
}

// HACK! Always use epollex in tests.
// See more: https://github.com/grpc/grpc/blob/v1.17.2/src/core/lib/iomgr/ev_posix.cc#L124
env::set_var("GRPC_POLL_STRATEGY", "epollex");

tikv::util::check_environment_variables();
}
1 change: 0 additions & 1 deletion src/bin/tikv-ctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ extern crate signal;
#[macro_use(
slog_kv,
slog_error,
slog_warn,
slog_info,
slog_log,
slog_record,
Expand Down
3 changes: 1 addition & 2 deletions src/bin/tikv-importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ extern crate signal;
#[macro_use(
slog_kv,
slog_error,
slog_warn,
slog_info,
slog_log,
slog_record,
Expand Down Expand Up @@ -58,7 +57,7 @@ use clap::{App, Arg, ArgMatches};

use tikv::config::TiKvConfig;
use tikv::import::ImportKVServer;
use tikv::util as tikv_util;
use tikv::util::{self as tikv_util, check_environment_variables};

fn main() {
let matches = App::new("TiKV Importer")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/tikv-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ use tikv::util::security::SecurityManager;
use tikv::util::time::Monitor;
use tikv::util::transport::SendCh;
use tikv::util::worker::{Builder, FutureWorker};
use tikv::util::{self as tikv_util, rocksdb as rocksdb_util};
use tikv::util::{self as tikv_util, check_environment_variables, rocksdb as rocksdb_util};

const RESERVED_OPEN_FDS: u64 = 1000;

Expand Down
28 changes: 0 additions & 28 deletions src/bin/util/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::env;
use std::process;
use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT};

Expand Down Expand Up @@ -142,30 +141,3 @@ pub fn overwrite_config_with_cmd_args(config: &mut TiKvConfig, matches: &ArgMatc
config.import.import_dir = import_dir.to_owned();
}
}

/// Check environment variables that affect TiKV.
#[allow(dead_code)]
pub fn check_environment_variables() {
if cfg!(unix) && env::var("TZ").is_err() {
env::set_var("TZ", ":/etc/localtime");
warn!("environment variable `TZ` is missing, using `/etc/localtime`");
}

if let Ok(var) = env::var("GRPC_POLL_STRATEGY") {
info!(
"environment variable `GRPC_POLL_STRATEGY` is present, {}",
var
);
} else if cfg!(target_os = "linux") {
// Set gRPC event engine to epollsig if it is missing.
// See more: https://github.com/grpc/grpc/blob/486761d04e03a9183d8013eddd86c3134d52d459\
// /src/core/lib/iomgr/ev_posix.cc#L149
env::set_var("GRPC_POLL_STRATEGY", "epollsig");
}

for proxy in &["http_proxy", "https_proxy"] {
if let Ok(var) = env::var(proxy) {
info!("environment variable `{}` is present, `{}`", proxy, var);
}
}
}
3 changes: 1 addition & 2 deletions src/util/logger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ where
D: Drain + Send + 'static,
<D as Drain>::Err: ::std::fmt::Debug,
{
grpc::redirect_log();

let logger = if use_async {
let drain = Async::new(drain.fuse())
.chan_size(SLOG_CHANNEL_SIZE)
Expand All @@ -66,6 +64,7 @@ where
::slog_global::set_global(logger);
if init_stdlog {
::slog_global::redirect_std_log(Some(level))?;
grpc::redirect_log();
}

Ok(())
Expand Down
27 changes: 23 additions & 4 deletions src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ use std::collections::hash_map::Entry;
use std::collections::vec_deque::{Iter, VecDeque};
use std::fs::File;
use std::net::{SocketAddr, ToSocketAddrs};
use std::ops::Deref;
use std::ops::DerefMut;
use std::ops::{Deref, DerefMut};
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};
use std::{io, u64};
use std::{slice, thread};
use std::{env, io, slice, thread, u64};

use protobuf::Message;
use rand::{self, ThreadRng};
Expand Down Expand Up @@ -523,6 +521,27 @@ pub fn set_panic_hook(panic_abort: bool, data_dir: &str) {
})
}

/// Checks environment variables that affect TiKV.
pub fn check_environment_variables() {
if cfg!(unix) && env::var("TZ").is_err() {
env::set_var("TZ", ":/etc/localtime");
warn!("environment variable `TZ` is missing, using `/etc/localtime`");
}

if let Ok(var) = env::var("GRPC_POLL_STRATEGY") {
info!(
"environment variable `GRPC_POLL_STRATEGY` is present, {}",
var
);
}

for proxy in &["http_proxy", "https_proxy"] {
if let Ok(var) = env::var(proxy) {
info!("environment variable `{}` is present, `{}`", proxy, var);
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 31a2da0

Please sign in to comment.