本文整理汇总了C++中Transport::readString方法的典型用法代码示例。如果您正苦于以下问题:C++ Transport::readString方法的具体用法?C++ Transport::readString怎么用?C++ Transport::readString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transport
的用法示例。
在下文中一共展示了Transport::readString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例3: RemoteNodeSuspectException
void Codec20::checkForErrorsInResponseStatus(Transport& transport, HeaderParams& params, uint8_t status) const {
try {
switch (status) {
case HotRodConstants::INVALID_MAGIC_OR_MESSAGE_ID_STATUS:
case HotRodConstants::REQUEST_PARSING_ERROR_STATUS:
case HotRodConstants::UNKNOWN_COMMAND_STATUS:
case HotRodConstants::SERVER_ERROR_STATUS:
case HotRodConstants::COMMAND_TIMEOUT_STATUS:
case HotRodConstants::UNKNOWN_VERSION_STATUS: {
// If error, the body of the message just contains a message
std::string msgFromServer = transport.readString();
if (msgFromServer.find("SuspectException") != std::string::npos || msgFromServer.find("SuspectedException") != std::string::npos) {
// Handle both Infinispan's and JGroups' suspicions
// TODO: This will be better handled with its own status id in version 2 of protocol
throw RemoteNodeSuspectException(msgFromServer, params.messageId, status);
} else {
throw HotRodClientException(msgFromServer); //, params.messageId, status);
}
}
default: {
throw InternalException("Unknown status: " + status);
}
}
} catch (const Exception &) {
// Some operations require invalidating the transport
switch (status) {
case HotRodConstants::INVALID_MAGIC_OR_MESSAGE_ID_STATUS:
case HotRodConstants::REQUEST_PARSING_ERROR_STATUS:
case HotRodConstants::UNKNOWN_COMMAND_STATUS:
case HotRodConstants::UNKNOWN_VERSION_STATUS: {
transport.invalidate();
}
}
throw;
}
}