DiskReadTask.hpp 2.61 KB
Newer Older
1
/******************************************************************************
2
 *                      DiskReadFileTask.hpp
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

David COME's avatar
David COME committed
27
#include "castor/tape/tapeserver/daemon/DiskReadTaskInterface.hpp"
28
29
#include "castor/tape/tapeserver/daemon/DataFifo.hpp"
#include "castor/tape/tapeserver/daemon/DataConsumer.hpp"
30
#include "castor/tape/tapegateway/FileToMigrateStruct.hpp"
31
#include "castor/tape/tapeserver/threading/AtomicCounter.hpp"
David COME's avatar
David COME committed
32
33
34
35
36
namespace castor {
namespace tape {
namespace tapeserver {
namespace daemon {
  
David COME's avatar
David COME committed
37
class DiskReadTask :public DiskReadTaskInterface {
38
public:
39
40
41
42
43
  /**
   * @param destination The task that will consume data block we fill up
   * @param file the file we are migrating. We acquire the ownership of the pointer
   * @param numberOfBlock number of memory block we need read the whole file
   */
44
  DiskReadTask(DataConsumer & destination, 
45
46
          tape::tapegateway::FileToMigrateStruct* file,size_t numberOfBlock,
          castor::tape::threading::AtomicFlag& errorFlag);
47
  
48
  virtual void execute(log::LogContext& lc);
49
private:
50
51
52
53
54
55
  void hasAnotherTaskTailed() const {
    //if a task has signaled an error, we stop our job
    if(m_errorFlag){
      throw  castor::tape::exceptions::ErrorFlag();
    }
  }
56
  void circulateAllBlocks(size_t fromBlockId);
57
58
59
  /**
   * The task (a TapeWriteTask) that will handle the read blocks
   */
60
  DataConsumer & m_nextTask;
61
62
63
64
  
  /**
   * All we need to know about the file we are migrating
   */
65
  std::auto_ptr<tape::tapegateway::FileToMigrateStruct> m_migratedFile;
66
67
68
69
  
  /**
   * The number of memory block we will need to read the whole file
   */
70
  size_t m_numberOfBlock;
71
72
  
  castor::tape::threading::AtomicFlag& m_errorFlag;
73
};
David COME's avatar
David COME committed
74
75

}}}}
76