in XmlProfileParser/XmlProfileParser.cpp [754:1103]
HRESULT XmlProfileParser::_ParseTarget(IXMLDOMNode *pXmlNode, Target *pTarget)
{
// For enforcement of sequential/random conflicts.
// This is simplified for the XML since we control parse order.
bool fSequential = false;
string sPath;
HRESULT hr = _GetString(pXmlNode, "Path", &sPath);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetPath(sPath);
}
if (SUCCEEDED(hr))
{
DWORD dwBlockSize;
hr = _GetDWORD(pXmlNode, "BlockSize", &dwBlockSize);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetBlockSizeInBytes(dwBlockSize);
}
}
if (SUCCEEDED(hr))
{
bool fInterlockedSequential;
hr = _GetBool(pXmlNode, "InterlockedSequential", &fInterlockedSequential);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetUseInterlockedSequential(fInterlockedSequential);
}
}
if (SUCCEEDED(hr))
{
UINT64 ullBaseFileOffset;
hr = _GetUINT64(pXmlNode, "BaseFileOffset", &ullBaseFileOffset);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetBaseFileOffsetInBytes(ullBaseFileOffset);
}
}
if (SUCCEEDED(hr))
{
bool fBool;
hr = _GetBool(pXmlNode, "SequentialScan", &fBool);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetSequentialScanHint(fBool);
}
}
if (SUCCEEDED(hr))
{
bool fBool;
hr = _GetBool(pXmlNode, "RandomAccess", &fBool);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetRandomAccessHint(fBool);
}
}
if (SUCCEEDED(hr))
{
bool fBool;
hr = _GetBool(pXmlNode, "TemporaryFile", &fBool);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetTemporaryFileHint(fBool);
}
}
if (SUCCEEDED(hr))
{
bool fUseLargePages;
hr = _GetBool(pXmlNode, "UseLargePages", &fUseLargePages);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetUseLargePages(fUseLargePages);
}
}
if (SUCCEEDED(hr))
{
DWORD dwRequestCount;
hr = _GetDWORD(pXmlNode, "RequestCount", &dwRequestCount);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetRequestCount(dwRequestCount);
}
}
if (SUCCEEDED(hr))
{
UINT64 ullStrideSize;
hr = _GetUINT64(pXmlNode, "StrideSize", &ullStrideSize);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetBlockAlignmentInBytes(ullStrideSize);
fSequential = true;
}
}
if (SUCCEEDED(hr))
{
UINT64 ullRandom;
hr = _GetUINT64(pXmlNode, "Random", &ullRandom);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
// conflict with sequential
if (fSequential)
{
fprintf(stderr, "sequential <StrideSize> conflicts with <Random>\n");
hr = HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER);
}
else
{
pTarget->SetRandomRatio(100);
pTarget->SetBlockAlignmentInBytes(ullRandom);
}
}
}
// now override default of 100% random?
if (SUCCEEDED(hr))
{
UINT32 ulRandomRatio;
hr = _GetUINT32(pXmlNode, "RandomRatio", &ulRandomRatio);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
// conflict with sequential
if (fSequential)
{
fprintf(stderr, "sequential <StrideSize> conflicts with <RandomRatio>\n");
hr = HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER);
}
else
{
pTarget->SetRandomRatio(ulRandomRatio);
}
}
}
if (SUCCEEDED(hr))
{
bool fBool;
hr = _GetBool(pXmlNode, "DisableOSCache", &fBool);
if (SUCCEEDED(hr) && (hr != S_FALSE) && fBool)
{
pTarget->SetCacheMode(TargetCacheMode::DisableOSCache);
}
}
if (SUCCEEDED(hr))
{
bool fBool;
hr = _GetBool(pXmlNode, "MemoryMappedIo", &fBool);
if (SUCCEEDED(hr) && (hr != S_FALSE) && fBool)
{
pTarget->SetMemoryMappedIoMode(MemoryMappedIoMode::On);
}
}
if (SUCCEEDED(hr))
{
bool fBool;
hr = _GetBool(pXmlNode, "DisableAllCache", &fBool);
if (SUCCEEDED(hr) && (hr != S_FALSE) && fBool)
{
pTarget->SetCacheMode(TargetCacheMode::DisableOSCache);
pTarget->SetWriteThroughMode(WriteThroughMode::On);
}
}
if (SUCCEEDED(hr))
{
bool fBool;
hr = _GetBool(pXmlNode, "DisableLocalCache", &fBool);
if (SUCCEEDED(hr) && (hr != S_FALSE) && fBool)
{
pTarget->SetCacheMode(TargetCacheMode::DisableLocalCache);
}
}
if (SUCCEEDED(hr))
{
bool fBool;
hr = _GetBool(pXmlNode, "WriteThrough", &fBool);
if (SUCCEEDED(hr) && (hr != S_FALSE) && fBool)
{
pTarget->SetWriteThroughMode(WriteThroughMode::On);
}
}
if (SUCCEEDED(hr))
{
string sFlushType;
hr = _GetString(pXmlNode, "FlushType", &sFlushType);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
if (sFlushType == "ViewOfFile")
{
pTarget->SetMemoryMappedIoFlushMode(MemoryMappedIoFlushMode::ViewOfFile);
}
else if (sFlushType == "NonVolatileMemory")
{
pTarget->SetMemoryMappedIoFlushMode(MemoryMappedIoFlushMode::NonVolatileMemory);
}
else if (sFlushType == "NonVolatileMemoryNoDrain")
{
pTarget->SetMemoryMappedIoFlushMode(MemoryMappedIoFlushMode::NonVolatileMemoryNoDrain);
}
else
{
hr = E_INVALIDARG;
}
}
}
if (SUCCEEDED(hr))
{
hr = _ParseWriteBufferContent(pXmlNode, pTarget);
}
if (SUCCEEDED(hr))
{
DWORD dwBurstSize;
hr = _GetDWORD(pXmlNode, "BurstSize", &dwBurstSize);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetBurstSize(dwBurstSize);
pTarget->SetUseBurstSize(true);
}
}
if (SUCCEEDED(hr))
{
DWORD dwThinkTime;
hr = _GetDWORD(pXmlNode, "ThinkTime", &dwThinkTime);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetThinkTime(dwThinkTime);
pTarget->SetEnableThinkTime(true);
}
}
if (SUCCEEDED(hr))
{
hr = _ParseThroughput(pXmlNode, pTarget);
}
if (SUCCEEDED(hr))
{
DWORD dwThreadsPerFile;
hr = _GetDWORD(pXmlNode, "ThreadsPerFile", &dwThreadsPerFile);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetThreadsPerFile(dwThreadsPerFile);
}
}
if (SUCCEEDED(hr))
{
UINT64 ullFileSize;
hr = _GetUINT64(pXmlNode, "FileSize", &ullFileSize);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetFileSize(ullFileSize);
pTarget->SetCreateFile(true);
}
}
if (SUCCEEDED(hr))
{
UINT64 ullMaxFileSize;
hr = _GetUINT64(pXmlNode, "MaxFileSize", &ullMaxFileSize);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetMaxFileSize(ullMaxFileSize);
}
}
if (SUCCEEDED(hr))
{
UINT32 ulWriteRatio;
hr = _GetUINT32(pXmlNode, "WriteRatio", &ulWriteRatio);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetWriteRatio(ulWriteRatio);
}
}
if (SUCCEEDED(hr))
{
bool fParallelAsyncIO;
hr = _GetBool(pXmlNode, "ParallelAsyncIO", &fParallelAsyncIO);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetUseParallelAsyncIO(fParallelAsyncIO);
}
}
if (SUCCEEDED(hr))
{
UINT64 ullThreadStride;
hr = _GetUINT64(pXmlNode, "ThreadStride", &ullThreadStride);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetThreadStrideInBytes(ullThreadStride);
}
}
if (SUCCEEDED(hr))
{
UINT32 ulIOPriority;
hr = _GetUINT32(pXmlNode, "IOPriority", &ulIOPriority);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
PRIORITY_HINT hint[] = { IoPriorityHintVeryLow, IoPriorityHintLow, IoPriorityHintNormal };
pTarget->SetIOPriorityHint(hint[ulIOPriority - 1]);
}
}
if (SUCCEEDED(hr))
{
UINT32 ulWeight;
hr = _GetUINT32(pXmlNode, "Weight", &ulWeight);
if (SUCCEEDED(hr) && (hr != S_FALSE))
{
pTarget->SetWeight(ulWeight);
}
}
//
// Note: XSD validation ensures only one type of distribution is specified, but it as simple
// here to probe for each.
//
if (SUCCEEDED(hr))
{
hr = _ParseDistribution(pXmlNode, pTarget);
}
if (SUCCEEDED(hr))
{
hr = _ParseThreadTargets(pXmlNode, pTarget);
}
return hr;
}