Skip to content
GitLab
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
470d232b
Commit
470d232b
authored
Jul 09, 2014
by
Daniele Kruse
Browse files
Added the DriveCatalogueCleanerSession
parent
df6132cc
Changes
5
Hide whitespace changes
Inline
Side-by-side
castor/tape/tapeserver/daemon/CMakeLists.txt
View file @
470d232b
...
...
@@ -13,6 +13,7 @@ add_library(castorTapeServerDaemon
DriveCatalogueSession.cpp
DriveCatalogueLabelSession.cpp
DriveCatalogueTransferSession.cpp
DriveCatalogueCleanerSession.cpp
../drive/Drive.cpp
TapeServerReporter.cpp
LabelCmdAcceptHandler.cpp
...
...
castor/tape/tapeserver/daemon/DriveCatalogueCleanerSession.cpp
0 → 100644
View file @
470d232b
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include
"castor/tape/tapeserver/daemon/DriveCatalogueCleanerSession.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor
::
tape
::
tapeserver
::
daemon
::
DriveCatalogueCleanerSession
::
DriveCatalogueCleanerSession
(
const
castor
::
tape
::
tapeserver
::
daemon
::
DriveCatalogueSession
::
SessionState
state
)
:
DriveCatalogueSession
(
state
)
{
}
\ No newline at end of file
castor/tape/tapeserver/daemon/DriveCatalogueCleanerSession.hpp
0 → 100644
View file @
470d232b
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#pragma once
#include
"castor/tape/tapeserver/daemon/DriveCatalogueSession.hpp"
namespace
castor
{
namespace
tape
{
namespace
tapeserver
{
namespace
daemon
{
/**
* Derived class containing info about the cleaner session attached to a drive catalogue entry
*/
class
DriveCatalogueCleanerSession
:
public
DriveCatalogueSession
{
public:
/**
* Constructor
*
* @param state The state of the drive catalogue session
*/
DriveCatalogueCleanerSession
(
const
SessionState
state
);
};
// class DriveCatalogueCleanerSession
}
// namespace daemon
}
// namespace tapeserver
}
// namespace tape
}
// namespace castor
castor/tape/tapeserver/daemon/DriveCatalogueEntry.cpp
View file @
470d232b
...
...
@@ -25,6 +25,7 @@
#include
"castor/tape/tapeserver/daemon/DriveCatalogueEntry.hpp"
#include
"castor/utils/utils.hpp"
#include
"h/Ctape_constants.h"
#include
"castor/tape/tapeserver/daemon/DriveCatalogueCleanerSession.hpp"
#include
"castor/tape/tapeserver/daemon/DriveCatalogueLabelSession.hpp"
#include
"castor/tape/tapeserver/daemon/DriveCatalogueTransferSession.hpp"
...
...
@@ -90,6 +91,7 @@ const char
case
SESSION_TYPE_NONE
:
return
"NONE"
;
case
SESSION_TYPE_DATATRANSFER
:
return
"DATATRANSFER"
;
case
SESSION_TYPE_LABEL
:
return
"LABEL"
;
case
SESSION_TYPE_CLEANER
:
return
"CLEANER"
;
default
:
return
"UNKNOWN"
;
}
}
...
...
@@ -481,6 +483,35 @@ void castor::tape::tapeserver::daemon::DriveCatalogueEntry::receivedLabelJob(
}
}
//-----------------------------------------------------------------------------
// receivedCleanerJob
//-----------------------------------------------------------------------------
void
castor
::
tape
::
tapeserver
::
daemon
::
DriveCatalogueEntry
::
receivedCleanerJob
()
{
std
::
ostringstream
task
;
task
<<
"handle cleaner job for tape drive "
<<
m_config
.
unitName
;
switch
(
m_state
)
{
case
DRIVE_STATE_INIT
:
case
DRIVE_STATE_DOWN
:
case
DRIVE_STATE_UP
:
case
DRIVE_STATE_SESSIONRUNNING
:
case
DRIVE_STATE_WAITDOWN
:
m_state
=
DRIVE_STATE_SESSIONRUNNING
;
m_sessionType
=
SESSION_TYPE_CLEANER
;
m_session
=
new
DriveCatalogueCleanerSession
(
castor
::
tape
::
tapeserver
::
daemon
::
DriveCatalogueSession
::
SESSION_STATE_WAITFORK
);
break
;
default:
{
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to "
<<
task
.
str
()
<<
": Incompatible drive state: state="
<<
drvState2Str
(
m_state
);
throw
ex
;
}
}
}
//-----------------------------------------------------------------------------
// forkedDataTransferSession
//-----------------------------------------------------------------------------
...
...
@@ -528,6 +559,29 @@ void castor::tape::tapeserver::daemon::DriveCatalogueEntry::forkedLabelSession(
}
}
//-----------------------------------------------------------------------------
// forkedCleanerSession
//-----------------------------------------------------------------------------
void
castor
::
tape
::
tapeserver
::
daemon
::
DriveCatalogueEntry
::
forkedCleanerSession
(
const
pid_t
sessionPid
)
{
std
::
ostringstream
task
;
task
<<
"handle fork of cleaner session for tape drive "
<<
m_config
.
unitName
;
switch
(
getSession
()
->
getState
())
{
case
castor
::
tape
::
tapeserver
::
daemon
::
DriveCatalogueSession
::
SESSION_STATE_WAITFORK
:
getSession
()
->
setState
(
castor
::
tape
::
tapeserver
::
daemon
::
DriveCatalogueSession
::
SESSION_STATE_RUNNING
);
getSession
()
->
setPid
(
sessionPid
);
break
;
default:
{
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to "
<<
task
.
str
()
<<
": Incompatible drive state: state="
<<
getSession
()
->
getState
();
throw
ex
;
}
}
}
//-----------------------------------------------------------------------------
// sessionSucceeded
//-----------------------------------------------------------------------------
...
...
castor/tape/tapeserver/daemon/DriveCatalogueEntry.hpp
View file @
470d232b
...
...
@@ -159,7 +159,8 @@ public:
enum
SessionType
{
SESSION_TYPE_NONE
,
SESSION_TYPE_DATATRANSFER
,
SESSION_TYPE_LABEL
};
SESSION_TYPE_LABEL
,
SESSION_TYPE_CLEANER
};
/**
* Always returns a string representation of the specified session type.
...
...
@@ -273,7 +274,8 @@ public:
void
configureDown
();
/**
* Moves the state of tape drive to DRIVE_STATE_WAITFORK.
* Moves the state of tape drive to DRIVE_STATE_SESSIONRUNNING and sets the
* current session type to SESSION_TYPE_DATATRANSFER.
*
* This method throws an exception if the current state of the tape drive is
* not DRIVE_STATE_UP.
...
...
@@ -292,7 +294,8 @@ public:
void
receivedVdqmJob
(
const
legacymsg
::
RtcpJobRqstMsgBody
&
job
);
/**
* Moves the state of the tape drive to DRIVE_STATE_WAITLABEL.
* Moves the state of tape drive to DRIVE_STATE_SESSIONRUNNING and sets the
* current session type to SESSION_TYPE_LABEL.
*
* This method throws an exception if the current state of the tape drive is
* not DRIVE_STATE_UP.
...
...
@@ -310,7 +313,7 @@ public:
* the file descriptor of the TCP/IP connection with the tape labeling
* command-line tool castor-tape-label. The caller of this method is left
* to close the connection because this gives them the opportunity to send
* an appropri
o
ate error message to the client.
* an appropriate error message to the client.
*
* @param job The label job.
* @param labelCmdConnection The file descriptor of the TCP/IP connection
...
...
@@ -318,12 +321,20 @@ public:
*/
void
receivedLabelJob
(
const
legacymsg
::
TapeLabelRqstMsgBody
&
job
,
const
int
labelCmdConnection
);
/**
* Moves the state of tape drive to DRIVE_STATE_SESSIONRUNNING and sets the
* current session type to SESSION_TYPE_CLEANER.
*
* This method will accept any drive state.
*/
void
receivedCleanerJob
();
/**
* Moves the state of the tape drive to DRIVE_STATE_RUNNING.
*
* This method throws an exception if the current state of the tape drive is
* not
DRIVE
_STATE_WAITFORK.
* This method throws an exception if the current state of the
session of the
tape drive is
* not
SESSION
_STATE_WAITFORK.
*
* @param sessionPid The process ID of the child process responsible for
* running the data-transfer session.
...
...
@@ -333,13 +344,24 @@ public:
/**
* Moves the state of the tape drive to DRIVE_STATE_RUNNING.
*
* This method throws an exception if the current state of the tape drive is
* not
DRIVE
_STATE_WAIT
LABEL
.
* This method throws an exception if the current state of the
session of the
tape drive is
* not
SESSION
_STATE_WAIT
FORK
.
*
* @param sessionPid The process ID of the child process responsible for
* running the label session.
*/
void
forkedLabelSession
(
const
pid_t
sessionPid
);
/**
* Moves the state of the session of the tape drive to SESSION_STATE_RUNNING.
*
* This method throws an exception if the current state of the session of the tape drive is
* not SESSION_STATE_WAITFORK.
*
* @param sessionPid The process ID of the child process responsible for
* running the cleaner session.
*/
void
forkedCleanerSession
(
const
pid_t
sessionPid
);
/**
* Moves the state of the tape drive to DRIVE_STATE_UP if the
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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