Ejemplo n.º 1
0
void get_workers() {
    zoo_awget_children(zh,
                       "/workers",
                       workers_watcher,
                       NULL,
                       workers_completion,
                       NULL);
}
Ejemplo n.º 2
0
/**
 *
 * Get the list of tasks.
 *
 */
void get_tasks () {
  LOG_DEBUG(("Getting tasks"));
    zoo_awget_children(zh,
                       "/tasks",
                       tasks_watcher,
                       NULL,
                       tasks_completion,
                       NULL);
}
Ejemplo n.º 3
0
static void zookeeper_get_node_completion(int rc, const char *value,
                                          int value_len,
                                          const struct Stat *stat,
                                          const void *arg) {
  int status;
  char *address = NULL;
  zookeeper_resolver *r = (zookeeper_resolver *)arg;
  r->resolved_addrs = NULL;
  r->resolved_total = 0;
  r->resolved_num = 0;

  if (rc != 0) {
    gpr_log(GPR_ERROR, "Error in getting zookeeper node %s", r->name);
    return;
  }

  /** If zookeeper node of path r->name does not have address
      (i.e. service node), get its children */
  address = zookeeper_parse_address(value, (size_t)value_len);
  if (address != NULL) {
    r->resolved_addrs = gpr_malloc(sizeof(grpc_resolved_addresses));
    r->resolved_addrs->addrs = NULL;
    r->resolved_addrs->naddrs = 0;
    r->resolved_total = 1;
    /** Further resolves address by DNS */
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resolve_address(&exec_ctx, address, NULL, zookeeper_dns_resolved, r);
    gpr_free(address);
    grpc_exec_ctx_finish(&exec_ctx);
    return;
  }

  status = zoo_awget_children(r->zookeeper_handle, r->name, zookeeper_watcher,
                              r, zookeeper_get_children_completion, r);
  if (status != 0) {
    gpr_log(GPR_ERROR, "Error in getting zookeeper children of %s", r->name);
  }
}