本文整理汇总了C++中Transport::readVInt方法的典型用法代码示例。如果您正苦于以下问题:C++ Transport::readVInt方法的具体用法?C++ Transport::readVInt怎么用?C++ Transport::readVInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transport
的用法示例。
在下文中一共展示了Transport::readVInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: host
void Codec20::readNewTopologyAndHash(Transport& transport, HeaderParams& params) const{
// Just consume the header's byte
// Do not evaluate new topology right now
int newTopologyId = transport.readVInt();
params.topologyId.setId(newTopologyId); //update topologyId reference
uint32_t clusterSize = transport.readVInt();
TRACE("Coded20::readNewToplogyAndhash(): clusterSize=%d",clusterSize);
std::vector<InetSocketAddress> addresses(clusterSize);
for (uint32_t i = 0; i < clusterSize; i++) {
std::string host(transport.readString());
int16_t port = transport.readUnsignedShort();
addresses[i] = InetSocketAddress(host, port);
}
uint8_t hashFunctionVersion = transport.readByte();
uint32_t numSegments = transport.readVInt();
std::vector<std::vector<InetSocketAddress>> segmentOwners(numSegments);
if (hashFunctionVersion > 0) {
TRACE("Codec20::readNewTopologyAndHash: numSegments=%d", numSegments);
for (uint32_t i = 0; i < numSegments; i++) {
uint8_t numOwners = transport.readByte();
segmentOwners[i]=std::vector<InetSocketAddress>(numOwners);
for (uint8_t j = 0; j < numOwners; j++) {
uint32_t memberIndex = transport.readVInt();
segmentOwners[i][j] = addresses[memberIndex];
}
}
}
TransportFactory &tf = transport.getTransportFactory();
bool noTopologyInfo=false;
int currentTopology = 0;
try
{
currentTopology = tf.getTopologyId(params.cacheName);
}
catch (std::exception &e)
{
noTopologyInfo=true;
}
int topologyAge = tf.getTopologyAge();
if (noTopologyInfo || (params.topologyAge == topologyAge && currentTopology != newTopologyId)) {
params.topologyId = newTopologyId;
tf.updateServers(addresses);
if (hashFunctionVersion == 0) {
TRACE("Not using a consistent hash function (hash function version == 0).");
} else {
TRACE("Updating client hash function with %u number of segments", numSegments);
}
tf.updateHashFunction(segmentOwners,
numSegments, hashFunctionVersion, params.cacheName, params.topologyId.getId());
} else {
TRACE("Outdated topology received (topology id = %d, topology age = %d), so ignoring it: s",
newTopologyId, topologyAge/*, Arrays.toString(addresses)*/);
}
}
示例2: TRACE
std::map<std::string, std::string> StatsOperation::executeOperation(Transport& transport)
{
TRACE("Executing Stats");
hr_scoped_ptr<HeaderParams> params(&(RetryOnFailureOperation<std::map<std::string, std::string> >::writeHeader(transport, STATS_REQUEST)));
transport.flush();
RetryOnFailureOperation<std::map<std::string, std::string> >::readHeaderAndValidate(transport, *params);
int nrOfStats = transport.readVInt();
TRACE("Stats returning map of %d entries:", nrOfStats);
std::map<std::string, std::string> result;
for (int i = 0; i < nrOfStats; i++) {
std::string statName = transport.readString();
std::string statValue = transport.readString();
result[statName] = statValue;
TRACE("%s -> %s", statName.c_str(), statValue.c_str());
}
return result;
}