示例#1
0
burst_serv::burst_serv(const server_argv& a,
                       const shared_ptr<common::lock_service>& zk)
    : server_base(a),
      mixer_(create_mixer(a, zk, rw_mutex(), user_data_version())),
      zk_(zk),
      watcher_binded_(false) {
}
示例#2
0
recommender_serv::recommender_serv(
    const framework::server_argv& a,
    const jubatus::util::lang::shared_ptr<lock_service>& zk)
    : server_base(a),
      mixer_(create_mixer(a, zk, rw_mutex())),
      clear_row_cnt_(),
      update_row_cnt_() {
}
示例#3
0
/*
 * Updates the model on the specified node and returns the score.
 * If the host/port of the current process is specified, update
 * is processed locally.
 * Caller is responsible for handling exceptions including RPC
 * errors.
 */
float anomaly_serv::selective_update(
    const string& host,
    int port,
    const string& id,
    const datum& d) {
  // nolock context
  if (host == argv().eth && port == argv().port) {
    jubatus::util::concurrent::scoped_wlock lk(rw_mutex());
    event_model_updated();
    return this->update(id, d);
  } else {  // needs no lock
    client::anomaly c(host, port, argv().name, argv().interconnect_timeout);
    return c.update(id, d);
  }
}
示例#4
0
void burst_serv::watcher_impl_(int type, int state, const std::string& path) {
#ifdef HAVE_ZOOKEEPER_H
  JUBATUS_ASSERT(!argv().is_standalone());

  if (type == ZOO_CHILD_EVENT) {
    jubatus::util::concurrent::scoped_wlock lk(rw_mutex());
    rehash_keywords();
  } else {
    LOG(WARNING) << "burst_serv::watcher_impl_ got unexpected event ("
                 << type << "), something wrong: " << path;
  }

  // reregister
  bind_watcher_();
#endif
}
示例#5
0
// nolock, random
id_with_score anomaly_serv::add(const datum& data) {
  check_set_config();

  uint64_t id = idgen_->generate();
  string id_str = jubatus::util::lang::lexical_cast<string>(id);

#ifdef HAVE_ZOOKEEPER_H
  if (argv().is_standalone()) {
#endif
    jubatus::util::concurrent::scoped_wlock lk(rw_mutex());
    event_model_updated();
    // TODO(unno): remove conversion code
    pair<string, float> res = anomaly_->add(id_str, data);
    return id_with_score(res.first, res.second);
#ifdef HAVE_ZOOKEEPER_H
  } else {
    return add_zk(id_str, data);
  }
#endif
}
示例#6
0
anomaly_serv::anomaly_serv(
    const server_argv& a,
    const jubatus::util::lang::shared_ptr<lock_service>& zk)
    : server_base(a),
      mixer_(create_mixer(a, zk, rw_mutex())) {
#ifdef HAVE_ZOOKEEPER_H
  if (a.is_standalone()) {
#endif
    idgen_.reset(new common::global_id_generator_standalone());
#ifdef HAVE_ZOOKEEPER_H
  } else {
    zk_ = zk;
    common::global_id_generator_zk* idgen_zk =
        new common::global_id_generator_zk();
    idgen_.reset(idgen_zk);

    string counter_path;
    common::build_actor_path(counter_path, a.type, a.name);
    idgen_zk->set_ls(zk_, counter_path);
  }
#endif
}
示例#7
0
clustering_serv::clustering_serv(
    const framework::server_argv& a,
    const shared_ptr<common::lock_service>& zk)
    : server_base(a),
      mixer_(create_mixer(a, zk, rw_mutex(), user_data_version())) {
}