ErrorCode FileStoreServiceReplica::CreateName() { ManualResetEvent operationDone; ErrorCode error; propertyManagmentClient_->BeginCreateName( NamingUri(serviceName_), FileStoreServiceConfig::GetConfig().NamingOperationTimeout, [this, &error, &operationDone] (AsyncOperationSPtr const & operation) { error = propertyManagmentClient_->EndCreateName(operation); WriteInfo( TraceComponent, this->TraceId, "CreateName: Error:{0}", error); operationDone.Set(); }, this->CreateAsyncOperationRoot()); operationDone.WaitOne(); if(!error.IsSuccess() && !error.IsError(ErrorCodeValue::NameAlreadyExists)) { return error; } return ErrorCodeValue::Success; }
ErrorCode ReplicatedStore::TransactionBase::Commit(__out ::FABRIC_SEQUENCE_NUMBER & sequenceNumber, TimeSpan const timeout) { ManualResetEvent waiter; auto operation = BeginCommit( timeout, [&](AsyncOperationSPtr const &) { waiter.Set(); }, this->ReplicatedStore.Root.CreateAsyncOperationRoot()); waiter.WaitOne(); return EndCommit(operation, sequenceNumber); }
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; }
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; }