本文整理汇总了C++中ErrorCode类的典型用法代码示例。如果您正苦于以下问题:C++ ErrorCode类的具体用法?C++ ErrorCode怎么用?C++ ErrorCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ErrorCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RegisterServiceLocation
ErrorCode FileStoreServiceReplica::RegisterServiceLocation(int64 const sequenceNumber)
{
ErrorCode error;
ManualResetEvent operationDone;
// make a copy of the serialized data
vector<BYTE> serializedData = serializedInfo_;
NamingUri serviceName(this->serviceName_);
NamePropertyOperationBatch propertyOperationBatch(serviceName);
if(sequenceNumber > 0)
{
propertyOperationBatch.AddCheckSequenceOperation(this->PartitionId.ToString(), sequenceNumber);
}
else
{
propertyOperationBatch.AddCheckExistenceOperation(this->PartitionId.ToString(), false);
}
propertyOperationBatch.AddPutPropertyOperation(this->PartitionId.ToString(), move(serializedData), FABRIC_PROPERTY_TYPE_BINARY);
propertyManagmentClient_->BeginSubmitPropertyBatch(
move(propertyOperationBatch),
FileStoreServiceConfig::GetConfig().NamingOperationTimeout,
[this, &error, &operationDone] (AsyncOperationSPtr const & operation)
{
IPropertyBatchResultPtr result;
error = propertyManagmentClient_->EndSubmitPropertyBatch(operation, result);
if(error.IsSuccess())
{
error = result->GetError();
}
WriteInfo(
TraceComponent,
this->TraceId,
"RegisterServiceLocation: Error:{0}",
error);
operationDone.Set();
},
this->CreateAsyncOperationRoot());
operationDone.WaitOne();
return error;
}
示例2: AsyncWaitHandleSetBeforeWait
template <bool ManualReset> void AsyncWaitHandleSetBeforeWait()
{
AsyncWaitHandle<ManualReset> asyncWaitHandle(true);
AutoResetEvent resultEvent(false);
asyncWaitHandle.BeginWaitOne(
TimeSpan::MaxValue,
[&asyncWaitHandle, &resultEvent] (AsyncOperationSPtr const & op)
{
ErrorCode result = asyncWaitHandle.EndWaitOne(op);
VERIFY_IS_TRUE(result.IsSuccess());
resultEvent.Set();
},
AsyncOperationSPtr());
BOOST_REQUIRE(resultEvent.WaitOne(TimeSpan::FromSeconds(60)));
}
示例3: hostDisconnectedCallback
/**
* The a particular socket's connection failed
* This function will call all substreams disconnected methods
*/
template <class ErrorCode> void hostDisconnectedCallback(const ASIOSocketWrapper* whichSocket, const ErrorCode &error) {
unsigned int which=0;
for (std::vector<ASIOSocketWrapper>::iterator i=mSockets.begin(),ie=mSockets.end(); i!=ie; ++i,++which) {
if (&*i==whichSocket)
break;
}
hostDisconnectedCallback(which==mSockets.size()?0:which,error.message());
}
示例4: EndAcceptRequest
ErrorCode ReportUpgradeHealthAsyncOperation::EndAcceptRequest(AsyncOperationSPtr const & operation)
{
ErrorCode error = this->Replica.EndAcceptReportUpgradeHealth(operation);
// Upgrade context may be enqueued
if (error.IsError(ErrorCodeValue::CMRequestAlreadyProcessing))
{
error = ErrorCodeValue::Success;
}
if (error.IsSuccess())
{
this->TryComplete(operation->Parent, error);
}
return error;
}
示例5: Call
ByteArray ConnectorMySQL::Call(const ByteArray &command, ErrorCode &error_code)
{
if (IsConnected())
{
mysql_real_query(&mysql_, command.data(), command.size());
int error = mysql_errno(&mysql_);
if (error != 0)
{
error_code.SetError(error, mysql_error(&mysql_));
return ByteArray();
}
ByteArray bytes;
MYSQL_RES *sql_result = mysql_store_result(&mysql_);
if (sql_result != nullptr)
{
mysql_stuff::Serialize(sql_result, &bytes);
mysql_free_result(sql_result);
}
else
{
ProcedureMySQL procedure(command);
if (procedure.HasVariable())
{
ByteArray query_variable = procedure.QueryVariableValue();
mysql_real_query(&mysql_, query_variable.data(), query_variable.size());
int error = mysql_errno(&mysql_);
if (error != 0)
{
error_code.SetError(error, mysql_error(&mysql_));
return ByteArray();
}
MYSQL_RES *sql_result = mysql_store_result(&mysql_);
mysql_stuff::Serialize(sql_result, &bytes);
mysql_free_result(sql_result);
}
}
return bytes;
}
else
{
throw NotConnected();
}
}
示例6: if
void RequestReceiverContext::Reject(ErrorCode const & error, ActivityId const & activityId)
{
ErrorCode rejectError;
if (error.IsError(ErrorCodeValue::RoutingNodeDoesNotMatchFault))
{
rejectError = ErrorCodeValue::RoutingError;
}
else if (error.IsError(ErrorCodeValue::P2PNodeDoesNotMatchFault))
{
rejectError = ErrorCodeValue::P2PError;
}
else
{
rejectError = error;
}
InternalReject(rejectError, activityId);
}
示例7: ReplaceErrorIf
ErrorCode HostingQueryManager::ReplaceErrorIf(ErrorCode actualError, ErrorCodeValue::Enum compareWithError, ErrorCodeValue::Enum changeToError)
{
if (actualError.IsError(compareWithError))
{
return changeToError;
}
return actualError;
}
示例8: EndArbitrate
ErrorCode SharableProxy::EndArbitrate(
AsyncOperationSPtr const & operation,
SiteNode & /*siteNode*/,
__out ArbitrationReplyBody & result)
{
SharableProxy::AribtrateAsyncOperation *op = AsyncOperation::Get<SharableProxy::AribtrateAsyncOperation>(operation);
ErrorCode error = op->End(operation);
if (error.IsSuccess())
{
result = op->Result;
}
else
{
result = ArbitrationReplyBody(TimeSpan::MaxValue, false);
}
return error;
}
示例9: GenerateNodeId
Common::ErrorCode DeployedApplicationEntityHealthInformation::GenerateNodeId()
{
Federation::NodeId nodeId;
ErrorCode error = Federation::NodeIdGenerator::GenerateFromString(nodeName_, nodeId);
if (!error.IsSuccess())
{
Trace.WriteInfo(TraceSource, "Error generating NodeId from NodeName {0}: {1}", nodeName_, error);
return error;
}
if (nodeId != nodeId_)
{
Trace.WriteInfo(TraceSource, "Generate NodeId from NodeName {0}: {1} (previous {2})", nodeName_, nodeId, nodeId_);
nodeId_ = nodeId.IdValue;
entityId_.clear();
}
return ErrorCode::Success();
}
示例10: GetTransportBehaviors
ErrorCode UnreliableTransportHelper::GetTransportBehaviors(
QueryArgumentMap const &,
ActivityId const &,
__out QueryResult & queryResult)
{
vector <pair<wstring, wstring>> parameters;
ErrorCode errorCode = GetTransportBehaviors(parameters);
if (errorCode.IsSuccess())
{
vector<wstring> tranportBehaviors;
tranportBehaviors.reserve(parameters.size());
for (auto& behavior : parameters)
{
tranportBehaviors.emplace_back(behavior.first + L"=" + behavior.second);
}
queryResult = QueryResult(move(tranportBehaviors));
}
return errorCode;
}
示例11: PreventDeadlock
ErrorCode SharableProxy::AribtrateAsyncOperation::ProcessRequest(Store::ILocalStore::TransactionSPtr const & trans)
{
ErrorCode error = PreventDeadlock(trans);
if (!error.IsSuccess())
{
WriteWarning(TraceFailure, "{0} failed to get lock for {1}: {2}",
voteId_, *this, error);
return error;
}
DateTime now;
error = GetProxyTime(now);
if (!error.IsSuccess())
{
WriteWarning(TraceFailure, "{0} failed to get time for {1}: {2}",
voteId_, *this, error);
return error;
}
DateTime expireTime = now + ttl_;
RecordVector monitorRecords(monitor_.InstanceId);
error = GetRecords(trans, monitor_, monitorRecords);
if (!error.IsSuccess())
{
WriteWarning(TraceFailure, "{0} failed to get monitor record for {1}: {2}",
voteId_, *this, error);
return error;
}
RecordVector subjectRecords(subject_.InstanceId);
error = GetRecords(trans, subject_, subjectRecords);
if (!error.IsSuccess())
{
WriteWarning(TraceFailure, "{0} failed to get subject record for {1}: {2}",
voteId_, *this, error);
return error;
}
result_ = ProcessRequest(monitorRecords, subjectRecords, expireTime);
error = StoreRecords(trans, monitor_, monitorRecords);
if (!error.IsSuccess())
{
WriteWarning(TraceFailure, "{0} failed to save monitor record for {1}: {2}",
voteId_, *this, error);
return error;
}
error = StoreRecords(trans, subject_, subjectRecords);
if (!error.IsSuccess())
{
WriteWarning(TraceFailure, "{0} failed to save subject record for {1}: {2}",
voteId_, *this, error);
}
return error;
}
示例12: WriteInfo
ErrorCode HostingQueryManager::GetServicePackages(
Application2SPtr const & applicationEntry,
wstring const & filterServiceManifestName,
ActivityId const & activityId,
__out vector<ServicePackage2SPtr> & servicePackages)
{
VersionedApplicationSPtr versionApplication = applicationEntry->GetVersionedApplication();
if (!versionApplication)
{
WriteInfo(
TraceType,
Root.TraceId,
"{0}: GetVersionedApplication for ApplicationName {1} failed",
activityId,
applicationEntry->AppName);
return ErrorCodeValue::ApplicationNotFound;
}
ErrorCode error;
if (filterServiceManifestName.empty())
{
error = versionApplication->GetAllServicePackageInstances(servicePackages);
}
else
{
error = versionApplication->GetInstancesOfServicePackage(filterServiceManifestName, servicePackages);
}
if (!error.IsSuccess())
{
WriteInfo(
TraceType,
Root.TraceId,
"{0}: GetServicePackages for ApplicationName {1} failed with error {2}",
activityId,
applicationEntry->AppName,
error);
return ReplaceErrorIf(error, ErrorCodeValue::ObjectClosed, ErrorCodeValue::ApplicationNotFound);
}
return ErrorCode::Success();
}
示例13: NamingUri
ErrorCode FileStoreServiceReplica::GetServiceLocationSequenceNumber(__out int64 & sequenceNumber)
{
ErrorCode error;
ManualResetEvent operationDone;
propertyManagmentClient_->BeginGetPropertyMetadata(
NamingUri(serviceName_),
this->PartitionId.ToString(),
FileStoreServiceConfig::GetConfig().NamingOperationTimeout,
[this, &error, &operationDone, &sequenceNumber] (AsyncOperationSPtr const & operation)
{
NamePropertyMetadataResult metadataResult;
error = propertyManagmentClient_->EndGetPropertyMetadata(operation, metadataResult);
WriteInfo(
TraceComponent,
this->TraceId,
"GetServiceLocationSequenceNumber: SequenceNumber:{0}, Error:{1}",
metadataResult.SequenceNumber,
error);
if(error.IsSuccess())
{
sequenceNumber = metadataResult.SequenceNumber;
}
else
{
// If the property is not found, then complete with success
if(error.IsError(ErrorCodeValue::PropertyNotFound))
{
// -1 indicates that sequence check should not be done
sequenceNumber = -1;
error = ErrorCodeValue::Success;
}
}
operationDone.Set();
},
this->CreateAsyncOperationRoot());
operationDone.WaitOne();
return error;
}
示例14: Prepare
ErrorCode LTSendBuffer::Prepare()
{
sendingLength_ = 0;
preparedBuffers_.resize(0);
#ifdef PLATFORM_UNIX
firstBufferToSend_ = 0;
#endif
StopwatchTime now = Stopwatch::Now();
ErrorCode error;
for (auto cur = messageQueue_.begin(); cur != messageQueue_.end(); ++cur)
{
// cap large sends
if ((sendingLength_ >= sendBatchLimitInBytes_) || (preparedBuffers_.size() >= SendBatchBufferCountLimit))
{
break;
}
if (!cur->Message())
{
continue; // message had been dropped due to expiration
}
if (cur->HasExpired(now))
{
DropExpiredMessage(*cur);
continue;
}
error = cur->PrepareForSending(*this);
if (!error.IsSuccess())
{
//TcpConnection Send Method Acuires lock before calling Prepare on SendBuffer.
connection_->Close_CallerHoldingLock(true,error);
return error;
}
}
perfCounters_->AverageTcpSendSizeBase.Increment();
perfCounters_->AverageTcpSendSize.IncrementBy(sendingLength_);
return error;
}
示例15: CompleteOrRetry
void EntreeService::ResolvePartitionAsyncOperation::OnFMResolved(
AsyncOperationSPtr const & asyncOperation,
bool expectedCompletedSynchronously)
{
if (asyncOperation->CompletedSynchronously != expectedCompletedSynchronously)
{
return;
}
Reliability::ServiceTableEntry serviceTableEntry;
GenerationNumber unused;
ErrorCode error = Properties.Resolver.EndResolveFMService(asyncOperation, /*out*/serviceTableEntry, /*out*/unused);
if (error.IsSuccess())
{
Reply = NamingMessage::GetResolvePartitionReply(serviceTableEntry);
}
CompleteOrRetry(asyncOperation->Parent, error);
}