Пример #1
0
std::map<InetSocketAddress, std::set<int32_t> > Codec11::computeNewHashes(
        infinispan::hotrod::transport::Transport& transport, uint32_t /*newTopologyId*/, int16_t /*numKeyOwners*/,
        uint8_t hashFunctionVersion, uint32_t /*hashSpace*/, uint32_t clusterSize) const {

    uint32_t numVirtualNodes = transport.readVInt();
    std::map<InetSocketAddress, std::set<int32_t> > servers2Hash;

    ConsistentHash* ch;
    if (hashFunctionVersion != 0) {
        ch = transport.getTransportFactory().getConsistentHashFactory().newConsistentHash(hashFunctionVersion);
    } else {
        ch = 0;
        WARN("Could not obtain a consistent hash for version %d", hashFunctionVersion);
    }

    for (uint32_t i = 0; i < clusterSize; i++) {
        std::string host = transport.readString();
        int16_t port = transport.readUnsignedShort();
        // TODO: Performance improvement, since hash positions are fixed, we could
        //maybe only calculate for those nodes that the client is not aware of?
        int32_t baseHashCode = transport.read4ByteInt();
        int32_t normalizedHashCode = getNormalizedHash(baseHashCode, ch);

        cacheHashCode(servers2Hash, host, port, normalizedHashCode);
        if (numVirtualNodes > 1) {
            calcVirtualHashCodes(baseHashCode, numVirtualNodes, servers2Hash,
                    host, port, ch);
        }
    }

    return servers2Hash;
}
Пример #2
0
std::set<std::string> GetCounterNamesOperation::executeOperation(infinispan::hotrod::transport::Transport& transport) {
    TRACE("Executing GetCounterNamesOperation(flags=%u)", flags);
    std::unique_ptr<HeaderParams> params(
            RetryOnFailureOperation<std::set<std::string>>::writeHeader(transport, COUNTER_GET_NAMES_REQUEST));
    uint8_t status = readHeaderAndValidate(transport, *params);
    std::set<std::string> ret;
    if (!isSuccess(status)) {
        auto num = transport.readVInt();
        for (uint32_t i = 0; i < num; i++) {
            auto name = transport.readString();
            ret.insert(name);
        }
    }
    TRACE("Finished GetCounterNamesOperation");
    return ret;
}