DataTransferSession.hpp 6.56 KB
Newer Older
Eric Cano's avatar
Eric Cano committed
1
/******************************************************************************
2
 *                      DataTransferSession.hpp
Eric Cano's avatar
Eric Cano committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 *
 * 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

27
#include "castor/legacymsg/RtcpJobRqstMsgBody.hpp"
28
#include "castor/messages/TapeserverProxy.hpp"
29
30
#include "castor/log/Logger.hpp"
#include "castor/log/LogContext.hpp"
31
#include "castor/server/ProcessCap.hpp"
32
33
#include "castor/tape/tapeserver/system/Wrapper.hpp"
#include "castor/tape/utils/utils.hpp"
34
#include "castor/tape/tapeserver/client/ClientProxy.hpp"
35
#include "castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp"
Eric Cano's avatar
Eric Cano committed
36
37

namespace castor {
38
39
40
41
42
namespace legacymsg {
  class VdqmProxy;
  class VmgrProxy;
  class RmcProxy;
}
Eric Cano's avatar
Eric Cano committed
43
namespace tape {
44
45
namespace tapeserver {
namespace daemon {
Eric Cano's avatar
Eric Cano committed
46
47
48
49
50
  /**
   * The main class handling a tape session. This is the main container started
   * by the master process. It will drive a separate process. Only the sub
   * process interface is not included here to allow testability.
   */
51
  class DataTransferSession {
Eric Cano's avatar
Eric Cano committed
52
  public:
53
54
55
56
57
    /** Subclass holding all the contents from castor.conf file. The pre-
     * extraction of the contents by the caller instead of direct getconfent
     * calls allows unit testing */
    class CastorConf {
    public:
58
      CastorConf(): 
59
        rtcopydBufsz(0), rtcopydNbBufs(0),
60
61
62
63
        tapebridgeBulkRequestMigrationMaxBytes(0),
        tapebridgeBulkRequestMigrationMaxFiles(0),
        tapebridgeBulkRequestRecallMaxBytes(0),
        tapebridgeBulkRequestRecallMaxFiles(0),
64
65
        tapebridgeMaxBytesBeforeFlush(0),
        tapebridgeMaxFilesBeforeFlush(0),
66
67
68
69
        tapeserverdDiskThreads(0) {}
      uint32_t rtcopydBufsz;
      uint32_t rtcopydNbBufs;
      std::string tapeBadMIRHandlingRepair;
70
71
72
73
      uint64_t tapebridgeBulkRequestMigrationMaxBytes;
      uint64_t tapebridgeBulkRequestMigrationMaxFiles;
      uint64_t tapebridgeBulkRequestRecallMaxBytes;
      uint64_t tapebridgeBulkRequestRecallMaxFiles;
74
75
      uint64_t tapebridgeMaxBytesBeforeFlush;
      uint64_t tapebridgeMaxFilesBeforeFlush;
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Other values found on production tape servers
//      TAPE CRASHED_RLS_HANDLING RETRY
//      TAPE CRASHED_RLS_HANDLING_RETRIES 3
//      TAPE CRASHED_RLS_HANDLING_RETRY_DELAY 180
//      TAPE DOWN_ON_TPALERT NO
//      TAPE DOWN_ON_UNLOAD_FAILURE NO
//      TAPEBRIDGE BULKREQUESTMIGRATIONMAXBYTES 5000000000
//      TAPEBRIDGE BULKREQUESTMIGRATIONMAXFILES 500
//      TAPEBRIDGE BULKREQUESTRECALLMAXBYTES 5000000000
//      TAPEBRIDGE BULKREQUESTRECALLMAXFILES 500
//      TAPEBRIDGE MAXBYTESBEFOREFLUSH 32000000000
//      TAPEBRIDGE MAXFILESBEFOREFLUSH 500
//      TAPEBRIDGE TAPEFLUSHMODE ONE_FLUSH_PER_N_FILES
//      UPV HOST castorcupv
//      VDQM HOST castorvdqm1
//      VMGR HOST castorvmgr

      // Additions for tapeserverd
      uint32_t tapeserverdDiskThreads;
    };
Eric Cano's avatar
Eric Cano committed
96
    /** Constructor */
97
    DataTransferSession(
98
99
100
101
102
103
104
105
      int argc,
      char ** argv,
      const std::string & hostname,
      const legacymsg::RtcpJobRqstMsgBody & clientRequest, 
      castor::log::Logger & logger,
      System::virtualWrapper & sysWrapper,
      const utils::DriveConfig & driveConfig,
      castor::legacymsg::RmcProxy & rmc,
106
      castor::messages::TapeserverProxy & initialProcess,
107
      castor::server::ProcessCap &capUtils,
108
      const CastorConf & castorConf);
Eric Cano's avatar
Eric Cano committed
109
    /** The only method. It will execute (like a task, that it is) */
110
    int execute() ;
Eric Cano's avatar
Eric Cano committed
111
112
    /** Temporary method used for debugging while building the session class */
    std::string getVid() { return m_volInfo.vid; }
113
    
114
    /**
Steven Murray's avatar
Steven Murray committed
115
     * Return the global shared zmq context for the data-transfer session
116
117
118
     * THIS FUNCTION SHALL ONLY BE CALLED IN THE FORKED PROCESS
     *
     * @return The global shared zmq context for the data-transfer session.
119
     */
120
    static void *getZmqContext();
121
    
122
    ~DataTransferSession();
123

Eric Cano's avatar
Eric Cano committed
124
  private:
125
126
127
128
129
130

    /**
     * The global shared zmq context for the date-transfer session.
     */
    static void *m_zmqContext;

Eric Cano's avatar
Eric Cano committed
131
132
    legacymsg::RtcpJobRqstMsgBody m_request;
    castor::log::Logger & m_logger;
133
134
    client::ClientProxy m_clientProxy;
    client::ClientProxy::VolumeInfo m_volInfo;
135
    System::virtualWrapper & m_sysWrapper;
136
137
138
139
    /**
     * The configuration of the tape drive to be used by this session.
     */
    const utils::DriveConfig m_driveConfig;
140
    const CastorConf & m_castorConf;
141
142
143
    /** utility to find the drive on the system. This function logs 
     * all errors and hence does not throw exceptions. It returns NULL
     * in case of failure. */
144
    castor::tape::drives::DriveInterface * findDrive(
145
     const utils::DriveConfig &driveConfig,log::LogContext & lc);
146
        
147
    /** sub-part of execute for the read sessions */
148
    int executeRead(log::LogContext & lc);
149
    /** sub-part of execute for a write session */
150
    int executeWrite(log::LogContext & lc);
151
    /** sub-part of execute for a dump session */
152
    void executeDump(log::LogContext & lc);
153
154
155
156
    /** Reference to the RmcProxy, allowing the mounting of the tape by the
     * library. It will be used exclusively by the tape thread. */
    castor::legacymsg::RmcProxy & m_rmc;
    /** Reference to the tape server's parent process to report detailed status */
157
    castor::messages::TapeserverProxy & m_intialProcess;
158
    /** Object providing utilities for working UNIX capabilities. */
159
    castor::server::ProcessCap &m_capUtils;
160
161
162
163
164
165
166
167
    /** copy of the process's argc to allow "command line reporting"
     * i.e. snprintf to argv's, which will be visible in 'ps' */
    int m_argc;
    /** copy of the process's argv to allow "command line reporting"
     * i.e. snprintf to argv's, which will be visible in 'ps' */
    char ** m_argv;
    /** hostname, used to report status of the drive */
    const std::string m_hostname;
Eric Cano's avatar
Eric Cano committed
168
169
170
171
  };
}
}
}
172
}