Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
6f2f2ccc
Commit
6f2f2ccc
authored
Apr 28, 2014
by
David COME
Browse files
Added logging into RecallMemoryManager and into MigrationMemoryManager (new name of MemoryManager)
parent
028ddecd
Changes
11
Hide whitespace changes
Inline
Side-by-side
castor/tape/tapeserver/daemon/DiskWriteTaskTest.cpp
View file @
6f2f2ccc
...
...
@@ -32,7 +32,7 @@ namespace unitTests{
MockRecallReportPacker
report
(
client
,
lc
);
EXPECT_CALL
(
report
,
reportFailedJob
(
_
,
_
,
_
));
RecallMemoryManager
mm
(
10
,
100
);
RecallMemoryManager
mm
(
10
,
100
,
lc
);
castor
::
tape
::
tapegateway
::
FileToRecallStruct
file
;
file
.
setPath
(
"/dev/null"
);
...
...
castor/tape/tapeserver/daemon/DiskWriteThreadPoolTest.cpp
View file @
6f2f2ccc
...
...
@@ -38,7 +38,7 @@ namespace unitTests{
//EXPECT_CALL(tskInjectorl,requestInjection(_,_,_)).Times(2);
EXPECT_CALL
(
report
,
reportEndOfSession
()).
Times
(
1
);
RecallMemoryManager
mm
(
10
,
100
);
RecallMemoryManager
mm
(
10
,
100
,
lc
);
DiskWriteThreadPool
dwtp
(
2
,
5
,
500
,
report
,
lc
);
dwtp
.
startThreads
();
...
...
castor/tape/tapeserver/daemon/MemManager.hpp
View file @
6f2f2ccc
...
...
@@ -29,6 +29,7 @@
#include "castor/tape/tapeserver/threading/BlockingQueue.hpp"
#include "castor/tape/tapeserver/threading/Threading.hpp"
#include "castor/exception/Exception.hpp"
#include "castor/log/LogContext.hpp"
#include <iostream>
namespace
castor
{
...
...
@@ -39,7 +40,7 @@ namespace daemon {
* The memory manager is responsible for allocating memory blocks and distributing
* the free ones around to any class in need.
*/
class
MemoryManager
:
private
castor
::
tape
::
threading
::
Thread
{
class
Migration
MemoryManager
:
private
castor
::
tape
::
threading
::
Thread
{
public:
/**
...
...
@@ -47,15 +48,19 @@ public:
* @param numberOfBlocks: number of blocks to allocate
* @param blockSize: size of each block
*/
MemoryManager
(
const
size_t
numberOfBlocks
,
const
size_t
blockSize
)
Migration
MemoryManager
(
const
size_t
numberOfBlocks
,
const
size_t
blockSize
,
castor
::
log
::
LogContext
lc
)
throw
(
castor
::
exception
::
Exception
)
:
m_blockCapacity
(
blockSize
),
m_totalNumberOfBlocks
(
0
),
m_totalMemoryAllocated
(
0
),
m_blocksProvided
(
0
),
m_blocksReturned
(
0
)
{
m_totalMemoryAllocated
(
0
),
m_blocksProvided
(
0
),
m_blocksReturned
(
0
)
,
m_lc
(
lc
)
{
for
(
size_t
i
=
0
;
i
<
numberOfBlocks
;
i
++
)
{
m_freeBlocks
.
push
(
new
MemBlock
(
i
,
blockSize
));
m_totalNumberOfBlocks
++
;
m_totalMemoryAllocated
+=
blockSize
;
m_lc
.
pushOrReplace
(
log
::
Param
(
"blockId"
,
i
));
m_lc
.
log
(
LOG_INFO
,
"MigrationMemoryManager Created a block"
);
}
m_lc
.
log
(
LOG_INFO
,
"MigrationMemoryManager: all blocks have been created"
);
}
/**
...
...
@@ -79,6 +84,7 @@ public:
*/
void
startThreads
()
throw
(
castor
::
exception
::
Exception
)
{
castor
::
tape
::
threading
::
Thread
::
start
();
m_lc
.
log
(
LOG_INFO
,
"MigrationMemoryManager starting thread"
);
}
/**
...
...
@@ -120,7 +126,7 @@ public:
/**
* Destructor
*/
~
MemoryManager
()
throw
()
{
~
Migration
MemoryManager
()
throw
()
{
// Make sure the thread is finished: this should be done by the caller,
// who should have called waitThreads.
// castor::tape::threading::Thread::wait();
...
...
@@ -134,6 +140,7 @@ public:
catch
(
castor
::
tape
::
threading
::
noMore
)
{
//done
}
m_lc
.
log
(
LOG_INFO
,
"MigrationMemoryManager destruction : all memory blocks have been deleted"
);
}
private:
...
...
@@ -176,6 +183,12 @@ private:
*/
castor
::
tape
::
threading
::
BlockingQueue
<
MemoryManagerClient
*>
m_clientQueue
;
/**
* Logging purpose. Given the fact the class is threaded, the LogContext
* has to be copied.
*/
castor
::
log
::
LogContext
m_lc
;
/**
* Thread routine: pops a client and provides him blocks until he is happy!
*/
...
...
castor/tape/tapeserver/daemon/MigrationTaskInjector.cpp
View file @
6f2f2ccc
...
...
@@ -43,7 +43,7 @@ namespace tapeserver{
namespace
daemon
{
MigrationTaskInjector
::
MigrationTaskInjector
(
MemoryManager
&
mm
,
MigrationTaskInjector
::
MigrationTaskInjector
(
Migration
MemoryManager
&
mm
,
DiskThreadPoolInterface
<
DiskReadTaskInterface
>
&
diskReader
,
TapeSingleThreadInterface
<
TapeWriteTask
>
&
tapeWriter
,
client
::
ClientInterface
&
client
,
castor
::
log
::
LogContext
lc
)
:
...
...
castor/tape/tapeserver/daemon/MigrationTaskInjector.hpp
View file @
6f2f2ccc
...
...
@@ -46,7 +46,7 @@ namespace daemon {
class
MigrationTaskInjector
:
public
TaskInjector
{
public:
MigrationTaskInjector
(
MemoryManager
&
mm
,
MigrationTaskInjector
(
Migration
MemoryManager
&
mm
,
DiskThreadPoolInterface
<
DiskReadTaskInterface
>
&
diskReader
,
TapeSingleThreadInterface
<
TapeWriteTask
>
&
tapeWriter
,
client
::
ClientInterface
&
client
,
castor
::
log
::
LogContext
lc
);
...
...
@@ -107,7 +107,7 @@ private:
MigrationTaskInjector
&
m_parent
;
}
m_thread
;
MemoryManager
&
m_memManager
;
Migration
MemoryManager
&
m_memManager
;
TapeSingleThreadInterface
<
TapeWriteTask
>&
m_tapeWriter
;
...
...
castor/tape/tapeserver/daemon/MountSession.cpp
View file @
6f2f2ccc
...
...
@@ -247,7 +247,7 @@ void castor::tape::tapeserver::daemon::MountSession::executeRead(LogContext & lc
{
// Allocate all the elements of the memory management (in proper order
// to refer them to each other)
RecallMemoryManager
mm
(
m_castorConf
.
rtcopydNbBufs
,
m_castorConf
.
rtcopydBufsz
);
RecallMemoryManager
mm
(
m_castorConf
.
rtcopydNbBufs
,
m_castorConf
.
rtcopydBufsz
,
lc
);
TapeReadSingleThread
trst
(
*
drive
,
m_volInfo
.
vid
,
m_castorConf
.
tapebridgeBulkRequestRecallMaxFiles
,
lc
);
RecallReportPacker
rrp
(
m_clientProxy
,
...
...
castor/tape/tapeserver/daemon/RecallMemoryManager.hpp
View file @
6f2f2ccc
...
...
@@ -48,11 +48,16 @@ public:
* @param numberOfBlocks: number of blocks to allocate
* @param blockSize: size of each block
*/
RecallMemoryManager
(
const
size_t
numberOfBlocks
,
const
size_t
blockSize
)
:
m_totalNumberOfBlocks
(
numberOfBlocks
)
{
RecallMemoryManager
(
const
size_t
numberOfBlocks
,
const
size_t
blockSize
,
castor
::
log
::
LogContext
&
lc
)
:
m_totalNumberOfBlocks
(
numberOfBlocks
),
m_lc
(
lc
)
{
for
(
size_t
i
=
0
;
i
<
numberOfBlocks
;
i
++
)
{
m_freeBlocks
.
push
(
new
MemBlock
(
i
,
blockSize
));
m_lc
.
pushOrReplace
(
log
::
Param
(
"blockId"
,
i
));
m_lc
.
log
(
LOG_INFO
,
"RecallMemoryManager created a block"
);
}
m_lc
.
log
(
LOG_INFO
,
"RecallMemoryManager: all blocks have been created"
);
}
/**
...
...
@@ -68,6 +73,8 @@ public:
* @param mb: the pointer to the block
*/
void
releaseBlock
(
MemBlock
*
mb
)
{
m_lc
.
pushOrReplace
(
log
::
Param
(
"blockId"
,
mb
->
m_memoryBlockId
));
m_lc
.
log
(
LOG_DEBUG
,
"RecallMemoryManager A block has been released"
);
mb
->
reset
();
m_freeBlocks
.
push
(
mb
);
}
...
...
@@ -93,6 +100,7 @@ public:
catch
(
castor
::
tape
::
threading
::
noMore
)
{
//done
}
m_lc
.
log
(
LOG_INFO
,
"RecallMemoryManager destruction : all memory blocks have been deleted"
);
}
private:
...
...
@@ -107,6 +115,11 @@ private:
* Container for the free blocks
*/
castor
::
tape
::
threading
::
BlockingQueue
<
MemBlock
*>
m_freeBlocks
;
/**
* Logging. The class is not threaded, so it can be shared with its parent
*/
castor
::
log
::
LogContext
&
m_lc
;
};
}}}}
...
...
castor/tape/tapeserver/daemon/RecallTaskInjectorTest.cpp
View file @
6f2f2ccc
...
...
@@ -57,11 +57,10 @@ public:
};
TEST
(
castor_tape_tapeserver_daemon
,
RecallTaskInjectorNominal
)
{
RecallMemoryManager
mm
(
50U
,
50U
);
const
int
nbCalls
=
2
;
castor
::
log
::
StringLogger
log
(
"castor_tape_tapeserver_daemon_RecallTaskInjectorTest"
);
castor
::
log
::
LogContext
lc
(
log
);
RecallMemoryManager
mm
(
50U
,
50U
,
lc
);
castor
::
tape
::
drives
::
FakeDrive
drive
;
FakeClient
client
(
nbCalls
);
FakeDiskWriteThreadPool
diskWrite
;
...
...
@@ -102,10 +101,9 @@ TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNominal) {
}
}
TEST
(
castor_tape_tapeserver_daemon
,
RecallTaskInjectorNoFiles
)
{
RecallMemoryManager
mm
(
50U
,
50U
);
castor
::
log
::
StringLogger
log
(
"castor_tape_tapeserver_daemon_RecallTaskInjectorTest"
);
castor
::
log
::
LogContext
lc
(
log
);
RecallMemoryManager
mm
(
50U
,
50U
,
lc
);
castor
::
tape
::
drives
::
FakeDrive
drive
;
FakeClient
client
(
0
);
FakeDiskWriteThreadPool
diskWrite
;
...
...
castor/tape/tapeserver/daemon/TapeWriteTask.cpp
View file @
6f2f2ccc
...
...
@@ -44,7 +44,7 @@ namespace daemon {
TapeWriteTask
::
TapeWriteTask
(
int
blockCount
,
tapegateway
::
FileToMigrateStruct
*
file
,
MemoryManager
&
mm
,
castor
::
tape
::
threading
::
AtomicFlag
&
errorFlag
)
:
Migration
MemoryManager
&
mm
,
castor
::
tape
::
threading
::
AtomicFlag
&
errorFlag
)
:
m_fileToMigrate
(
file
),
m_memManager
(
mm
),
m_fifo
(
blockCount
),
m_blockCount
(
blockCount
),
m_errorFlag
(
errorFlag
)
{
...
...
@@ -76,7 +76,7 @@ namespace daemon {
hasAnotherTaskTailed
();
MemBlock
*
const
mb
=
m_fifo
.
popDataBlock
();
AutoReleaseBlock
<
MemoryManager
>
releaser
(
mb
,
m_memManager
);
AutoReleaseBlock
<
Migration
MemoryManager
>
releaser
(
mb
,
m_memManager
);
if
(
m_fileToMigrate
->
fileid
()
!=
static_cast
<
unsigned
int
>
(
mb
->
m_fileid
)
||
blockId
!=
mb
->
m_fileBlock
||
mb
->
m_failed
){
...
...
castor/tape/tapeserver/daemon/TapeWriteTask.hpp
View file @
6f2f2ccc
...
...
@@ -51,7 +51,7 @@ public:
* @param mm: reference to the memory manager in use
*/
TapeWriteTask
(
int
blockCount
,
tape
::
tapegateway
::
FileToMigrateStruct
*
file
,
MemoryManager
&
mm
,
castor
::
tape
::
threading
::
AtomicFlag
&
errorFlag
);
Migration
MemoryManager
&
mm
,
castor
::
tape
::
threading
::
AtomicFlag
&
errorFlag
);
/**
...
...
@@ -110,7 +110,7 @@ private:
/**
* reference to the memory manager in use
*/
MemoryManager
&
m_memManager
;
Migration
MemoryManager
&
m_memManager
;
/**
* The fifo containing the memory blocks holding data to be written to tape
...
...
castor/tape/tapeserver/daemon/tapeserver-mm.cpp
View file @
6f2f2ccc
...
...
@@ -56,10 +56,10 @@ int main(void) {
// printf("%s\n", e.what());
//}
// Allocate the memory
castor
::
tape
::
tapeserver
::
daemon
::
MemoryManager
mm
(
blocks
,
blockSize
);
/*
castor::tape::tapeserver::daemon::
Migration
MemoryManager mm(blocks, blockSize);
mm.startThreads();
castor::tape::drives::FakeDrive drive;
/*
{
MockTapeGateway tg(filesNumber, modulo);
castor::tape::tapeserver::daemon::MigrationReportPacker mrp(tg);
...
...
@@ -106,8 +106,9 @@ int main(void) {
printf("disk write threads complete\n");
rji.waitThreads();
printf("Recall job injector complete\n");
}
*/
}
mm.finish();
mm.waitThreads();
printf("memory management thread complete\n");
*/
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment