예제 #1
0
int64_t Storage::vector_put_string(const std::string& table,
            const std::string& cf,
            const int64_t shard_id,
            const std::vector<std::string>& row_key,
            const std::vector<std::string>& column_key,
            const std::vector<std::string>& value) {

    int64_t node_id = StorageInfo::singleton().
            _table_info[table].
            _table_property.
            shard_location[shard_id];

    if(CPUNetworks::singleton()._cpu_networks.find(std::this_thread::get_id())
            != CPUNetworks::singleton()._cpu_networks.end()) {
        auto i = CPUNetworks::singleton()._cpu_networks[std::this_thread::get_id()][node_id];
        i->open_transport();
        i->method()->vector_put_string(table,shard_id, cf, row_key, column_key, value);
        i->close_transport();
    } else {
        auto i =  NodeInfo::singleton()._client_task_tracker[node_id];
        i->open_transport();
        i->method()->vector_put_string(table,shard_id, cf, row_key, column_key, value);
        i->close_transport();
    }
    return 1;
}
예제 #2
0
void Storage::timed_scan_string(const std::string& table,
        const std::string& cf,
        const int64_t shard_id,
        const int64_t time_stamp,
        std::map<std::string, std::map<std::string, std::string>>& value) {

    value.clear();
    int64_t node_id = StorageInfo::singleton().
        _table_info[table].
        _table_property.
        shard_location[shard_id];

    if(CPUNetworks::singleton()._cpu_networks.find(std::this_thread::get_id())
            != CPUNetworks::singleton()._cpu_networks.end()) {
        auto i = CPUNetworks::singleton()._cpu_networks[std::this_thread::get_id()][node_id];
        i->open_transport();
        i->method()->timed_scan_string(value, table, shard_id, cf, time_stamp);
        i->close_transport();
    } else {
        auto i =  NodeInfo::singleton()._client_task_tracker[node_id];
        i->open_transport();
        i->method()->timed_scan_string(value, table, shard_id, cf, time_stamp);
        i->close_transport();
    }
}
예제 #3
0
zmq::pgm_socket_t::pgm_socket_t (bool receiver_, const char *interface_, 
      size_t readbuf_size_) : 
    g_transport (NULL), 
    receiver (receiver_),
    port_number (0),
    udp_encapsulation (false),
    readbuf_size (readbuf_size_),
    pgm_msgv (NULL),
    nbytes_rec (0),
    nbytes_processed (0),
    pgm_msgv_processed (0),
    pgm_msgv_len (0)
{
    
    //  Check if we are encapsulating into UDP, interface string has to 
    //  start with udp:.

    const char *interface_ptr = interface_;

    if (strlen (interface_) >= 4 && interface_ [0] == 'u' && 
          interface_ [1] == 'd' && interface_ [2] == 'p' && 
          interface_ [3] == ':') {
    
        //  Shift interface_ptr after ':'.
        interface_ptr += 4;

        udp_encapsulation = true;
    }
 
    //  Parse port number.
    const char *port_delim = strchr (interface_ptr, ':');
    assert (port_delim);

    port_number = atoi (port_delim + 1);
  
    //  Store interface string.
    assert (port_delim > interface_ptr);
    assert (port_delim - interface_ptr < (int) sizeof (network) - 1);

    memset (network, '\0', sizeof (network));
    memcpy (network, interface_ptr, port_delim - interface_ptr);

    zmq_log (1, "parsed: network  %s, port %i, udp encaps. %s, %s(%i)\n", 
        network, port_number, udp_encapsulation ? "yes" : "no",
        __FILE__, __LINE__);

    //  Open PGM transport.
    open_transport ();

    //  For receiver transport preallocate pgm_msgv array.
    if (receiver_) {
        pgm_msgv_len = get_max_apdu_at_once (readbuf_size_);
        pgm_msgv = new pgm_msgv_t [pgm_msgv_len];
    }

}
예제 #4
0
zmq::pgm_socket_t::pgm_socket_t (bool receiver_, const char *interface_,
      size_t readbuf_size_) :
    receiver (receiver_),
    port_number (0),
    readbuf_size (readbuf_size_),
    nbytes_rec (0),
    nbytes_processed (0),
    pgm_msgv_processed (0),
    created_receiver_socket (false)
{
    zmq_log (1, "interface_  %s, %s(%i)\n", interface_, __FILE__, __LINE__);

    //  Check if we are encapsulating into UDP.
    const char* iface = interface_;
    if (strlen (iface) >= 4 && iface [0] == 'u' &&
        iface [1] == 'd' && iface [2] == 'p' &&
        iface [3] == ':') {

        //  Ms-pgm does not support udp encapsulation.
        assert (false);
    }

    //  Parse port number.
    char *port_delim = strchr ((char *)iface, ':');
    assert (port_delim);
    port_number = atoi (port_delim + 1);
	

    //  Store interface string.
    assert (port_delim > iface);
    assert (port_delim - iface < (int) sizeof (network) - 1);
    memset (network, '\0', sizeof (network));
    memset (multicast, '\0', sizeof (multicast));

    char *network_delim = strchr ((char *)iface, ';');
    assert (network_delim);
    memcpy (network, iface, strlen (iface) - strlen (network_delim));

    memcpy (multicast, network_delim + 1, 
        strlen (iface) - strlen(network) - strlen (port_delim) - 1);

    zmq_log (1, "parsed: network  %s, port %i, %s(%i)\n",
        network, port_number, __FILE__, __LINE__);

    //  Open PGM transport.
    open_transport ();
}
예제 #5
0
int zmq::pgm_socket_t::init (bool udp_encapsulation_, const char *network_)
{
    udp_encapsulation = udp_encapsulation_;
 
    //  Parse port number.
    const char *port_delim = strchr (network_, ':');
    if (!port_delim) {
        errno = EINVAL;
        return -1;
    }

    port_number = atoi (port_delim + 1);
  
    if (port_delim - network_ >= (int) sizeof (network) - 1) {
        errno = EINVAL;
        return -1;
    }

    memset (network, '\0', sizeof (network));
    memcpy (network, network_, port_delim - network_);

    //  Open PGM transport.
    int rc = open_transport ();
    if (rc != 0)
        return -1;

    //  For receiver transport preallocate pgm_msgv array.
    //  in_batch_size configured in confing.hpp
    if (receiver) {
        pgm_msgv_len = get_max_apdu_at_once (in_batch_size);
        //  TODO: use malloc instead of new
        pgm_msgv = new pgm_msgv_t [pgm_msgv_len];
    }

    return 0;
}