Minor fix on comments

pull/2549/head
Hongwei Wang 9 years ago
parent 85ad685e57
commit c3f48c80d4
  1. 18
      src/core/client_config/resolvers/zookeeper_resolver.c
  2. 22
      test/cpp/end2end/zookeeper_test.cc

@ -157,7 +157,7 @@ static void zookeeper_global_watcher(zhandle_t *zookeeper_handle, int type,
}
/** Zookeeper watcher triggered by changes to watched nodes
Start to resolve again to get updated addresses */
Once triggered, it tries to resolve again to get updated addresses */
static void zookeeper_watcher(zhandle_t *zookeeper_handle, int type, int state,
const char *path, void *watcher_ctx) {
if (watcher_ctx != NULL) {
@ -173,7 +173,7 @@ static void zookeeper_watcher(zhandle_t *zookeeper_handle, int type, int state,
}
/** Callback function after getting all resolved addresses
Create a subchannel for each address */
Creates a subchannel for each address */
static void zookeeper_on_resolved(void *arg,
grpc_resolved_addresses *addresses) {
zookeeper_resolver *r = arg;
@ -243,7 +243,7 @@ static void zookeeper_dns_resolved(void *arg,
}
}
/** Parse JSON format address of a zookeeper node */
/** Parses JSON format address of a zookeeper node */
static char *zookeeper_parse_address(const char *value, int value_len) {
grpc_json *json;
grpc_json *cur;
@ -296,7 +296,7 @@ static void zookeeper_get_children_node_completion(int rc, const char *value,
address = zookeeper_parse_address(value, value_len);
if (address != NULL) {
/** Further resolve address by DNS */
/** Further resolves address by DNS */
grpc_resolve_address(address, NULL, zookeeper_dns_resolved, r);
gpr_free(address);
} else {
@ -333,8 +333,8 @@ static void zookeeper_get_children_completion(
r->resolved_addrs->naddrs = 0;
r->resolved_total = children->count;
/** TODO: Replace expensive heap allocation and free with stack
if we can get maximum allowed length of zookeeper path */
/** TODO: Replace expensive heap allocation with stack
if we can get maximum length of zookeeper path */
for (i = 0; i < children->count; i++) {
gpr_asprintf(&path, "%s/%s", r->name, children->data[i]);
status = zoo_awget(r->zookeeper_handle, path, zookeeper_watcher, r,
@ -370,7 +370,7 @@ static void zookeeper_get_node_completion(int rc, const char *value,
r->resolved_addrs->addrs = NULL;
r->resolved_addrs->naddrs = 0;
r->resolved_total = 1;
/** Further resolve address by DNS */
/** Further resolves address by DNS */
grpc_resolve_address(address, NULL, zookeeper_dns_resolved, r);
gpr_free(address);
return;
@ -437,7 +437,7 @@ static grpc_resolver *zookeeper_create(
return NULL;
}
/** Remove the trailing slash if exists */
/** Removes the trailing slash if exists */
length = strlen(path);
if (length > 1 && path[length - 1] == '/') {
path[length - 1] = 0;
@ -454,7 +454,7 @@ static grpc_resolver *zookeeper_create(
r->lb_policy_factory = lb_policy_factory;
grpc_subchannel_factory_ref(subchannel_factory);
/** Initialize zookeeper client */
/** Initializes zookeeper client */
zoo_set_debug_level(ZOO_LOG_LEVEL_WARN);
r->zookeeper_handle = zookeeper_init(uri->authority, zookeeper_global_watcher,
GRPC_ZOOKEEPER_SESSION_TIMEOUT, 0, 0, 0);

@ -73,30 +73,30 @@ class ZookeeperTest : public ::testing::Test {
void SetUp() GRPC_OVERRIDE {
SetUpZookeeper();
// Setup two servers
// Sets up two servers
int port1 = grpc_pick_unused_port_or_die();
server1_ = SetUpServer(port1);
int port2 = grpc_pick_unused_port_or_die();
server2_ = SetUpServer(port2);
// Register service /test in zookeeper
// Registers service /test in zookeeper
RegisterService("/test", "test");
// Register service instance /test/1 in zookeeper
// Registers service instance /test/1 in zookeeper
string value =
"{\"host\":\"localhost\",\"port\":\"" + to_string(port1) + "\"}";
RegisterService("/test/1", value);
// Register service instance /test/2 in zookeeper
// Registers service instance /test/2 in zookeeper
value =
"{\"host\":\"localhost\",\"port\":\"" + to_string(port2) + "\"}";
RegisterService("/test/2", value);
}
// Require zookeeper server running
// Requires zookeeper server running
void SetUpZookeeper() {
// Find zookeeper server address in environment
// Finds zookeeper server address in environment
// Default is localhost:2181
zookeeper_address_ = "localhost:2181";
char* addr = gpr_getenv("GRPC_ZOOKEEPER_SERVER_TEST");
@ -107,13 +107,13 @@ class ZookeeperTest : public ::testing::Test {
}
gpr_log(GPR_DEBUG, zookeeper_address_.c_str());
// Connect to zookeeper server
// Connects to zookeeper server
zoo_set_debug_level(ZOO_LOG_LEVEL_WARN);
zookeeper_handle_ =
zookeeper_init(zookeeper_address_.c_str(), NULL, 15000, 0, 0, 0);
GPR_ASSERT(zookeeper_handle_ != NULL);
// Register zookeeper name resolver in grpc
// Registers zookeeper name resolver in grpc
grpc_zookeeper_register();
}
@ -180,7 +180,7 @@ class ZookeeperTest : public ::testing::Test {
string zookeeper_address_;
};
// Test zookeeper state change between two RPCs
// Tests zookeeper state change between two RPCs
// TODO(ctiller): leaked objects in this test
TEST_F(ZookeeperTest, ZookeeperStateChangeTwoRpc) {
ResetStub();
@ -195,10 +195,10 @@ TEST_F(ZookeeperTest, ZookeeperStateChangeTwoRpc) {
EXPECT_EQ(response1.message(), request1.message());
EXPECT_TRUE(s1.ok());
// Zookeeper state change
// Zookeeper state changes
gpr_log(GPR_DEBUG, "Zookeeper state change");
ChangeZookeeperState();
// Wait for re-resolving addresses
// Waits for re-resolving addresses
// TODO(ctiller): RPC will probably fail if not waiting
sleep(1);

Loading…
Cancel
Save