Commit ad43133c authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Removed tpcp

parent 314de5c2
/******************************************************************************
*
* 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 <stdint.h>
#include <stdlib.h>
namespace castor {
namespace tape {
namespace tpcp {
/**
* The number of seconds to stay blocked while waiting for a callback
* connection from the tape-server daemon.
*/
const int WAITCALLBACKTIMEOUT = 60;
/**
* The time format specified using the recognized formatting characters of
* 'std::strftime'.
*/
const char *const TIMEFORMAT = "%b %d %H:%M:%S";
/**
* The default blocksize in bytes to be used when dumping a tape.
*/
const int32_t DEFAULTDUMPBLOCKSIZE = 262144;
/**
* The default file destination to be used when recalling with -n/--nodata
* option.
*/
const char *const NODATAFILENAME = "localhost:/dev/null";
} // namespace tpcp
} // namespace tape
} // namespace castor
/******************************************************************************
*
* 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 <list>
#include <ostream>
#include <string>
namespace castor {
namespace tape {
namespace tpcp {
/**
* A list of filenames. This class effectively tags a list of strings for the
* specific use of representing an list of filenames. This "tag" allows the
* creation of an ostream << operator.
*/
class FilenameList : public std::list<std::string> {
};
} // namespace tpcp
} // namespace tape
} // namespace castor
/******************************************************************************
*
* 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/Constants.hpp"
#include "castor/tape/tpcp/Helper.hpp"
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
castor::tape::tpcp::Helper::~Helper() {
// Do nothing
}
//------------------------------------------------------------------------------
// objectTypeToString
//------------------------------------------------------------------------------
const char *castor::tape::tpcp::Helper::objectTypeToString(
const unsigned int type) throw() {
if(type >= castor::ObjectsIdsNb) {
return "UNKNOWN";
}
return castor::ObjectsIdStrings[type];
}
/******************************************************************************
*
* 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 <iostream>
#include <sstream>
namespace castor {
namespace tape {
namespace tpcp {
/**
* Collection of static helper functions.
*/
class Helper {
public:
/**
* Convenience method that displays the specified received message if debug
* is on.
*
* @param msg The message to be displayed.
* @param debug To be set to true if debug is on, else false.
*/
template<class T> static void displayRcvdMsgIfDebug(T &msg, const bool debug)
throw() {
if(debug) {
std::ostream &os = std::cout;
os <<
"Received " << objectTypeToString(msg.type()) <<
" from tape server" << std::endl <<
msg << std::endl;
}
}
/**
* Convenience method that displays the specified sent message if debug is on.
*
* @param msg The message to be displayed.
* @param debug To be set to true if debug is on, else false.
*/
template<class T> static void displaySentMsgIfDebug(T &msg, const bool debug)
throw() {
if(debug) {
std::ostream &os = std::cout;
os <<
"Sent " << objectTypeToString(msg.type()) <<
" to tape server" << std::endl <<
msg << std::endl;
}
}
/**
* Returns the string representation of the specified CASTOR object type.
* In the case of the type being unknown, the returned string is "UNKNOWN".
*
* @param type The type of the CASTOR object.
*/
static const char *objectTypeToString(const unsigned int type) throw();
private:
/**
* Private destructor to prevent instances of this class from being
* instantiated.
*/
~Helper();
}; // class Helper
} // namespace tpcp
} // namespace tape
} // namespace castor
/******************************************************************************
*
* 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/tpcp/Constants.hpp"
#include "castor/tape/tpcp/FilenameList.hpp"
#include "castor/tape/tpcp/TapeFseqRangeList.hpp"
#include "castor/utils/utils.hpp"
#include "Castor_limits.h"
#include <list>
#include <ostream>
#include <string>
namespace castor {
namespace tape {
namespace tpcp {
/**
* Data type used to store the results of parsing the command-line.
*/
struct ParsedCommandLine {
/**
* True if the debug option has been set.
*/
bool debugSet;
/**
* The filename of the "file list" file.
*/
std::string fileListFilename;
/**
* True if the "file list" filename option has been set.
*/
bool fileListSet;
/**
* The list filenames given on the command-line.
*/
FilenameList filenames;
/**
* True if the help option has been set.
*/
bool helpSet;
/**
* True if the tape server option has been set.
*/
bool serverSet;
/**
* True if the nodata option has been set.
*/
bool nodataSet;
/**
* The tape server to be used therefore overriding the drive scheduling of
* the VDQM.
*/
char server[CA_MAXHOSTNAMELEN+1];
/**
* The tape file sequence number ranges.
*/
TapeFseqRangeList tapeFseqRanges;
/**
* The VID of the tape to be mounted.
*/
char vid[CA_MAXVIDLEN+1];
/**
* Corresponds to the similarly named field of the RTCP_DUMPTAPE_REQ message.
*/
int32_t dumpTapeMaxBytes;
/**
* Corresponds to the similarly named field of the RTCP_DUMPTAPE_REQ message.
*/
int32_t dumpTapeBlockSize;
/**
* Corresponds to the similarly named field of the RTCP_DUMPTAPE_REQ message.
*/
int32_t dumpTapeErrAction;
/**
* Corresponds to the similarly named field of the RTCP_DUMPTAPE_REQ message.
*/
int32_t dumpTapeFromFile;
/**
* Corresponds to the similarly named field of the RTCP_DUMPTAPE_REQ message.
*/
int32_t dumpTapeMaxFiles;
/**
* Corresponds to the similarly named field of the RTCP_DUMPTAPE_REQ message.
*/
int32_t dumpTapeFromBlock;
/**
* Corresponds to the similarly named field of the RTCP_DUMPTAPE_REQ message.
*/
int32_t dumpTapeToBlock;
/**
* Constructor.
*/
ParsedCommandLine() :
debugSet(false),
fileListSet(false),
helpSet(false),
serverSet(false),
nodataSet(false),
dumpTapeMaxBytes(320),
dumpTapeBlockSize(DEFAULTDUMPBLOCKSIZE),
dumpTapeErrAction(-1),
dumpTapeFromFile(1),
dumpTapeMaxFiles(1),
dumpTapeFromBlock(1),
dumpTapeToBlock(1)
{
castor::utils::setBytes(server, '\0');
castor::utils::setBytes(vid , '\0');
}
}; // struct ParsedCommandLine
} // namespace tpcp
} // namespace tape
} // namespace castor
/******************************************************************************
*
* 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/tpcp/StreamOperators.hpp"
#include "castor/utils/utils.hpp"
/**
* Local help function that returns the string representation of the specified
* boolean value.
*
* @param value The boolean value.
* @return The string representation of the boolean value.
*/
static const char *boolToString(const bool value) {
return value ? "TRUE" : "FALSE";
}
//------------------------------------------------------------------------------
// ostream << operator for castor::tape::tpcp::FilenameList
//------------------------------------------------------------------------------
std::ostream &operator<<(std::ostream &os,
const castor::tape::tpcp::FilenameList &value) {
os << '{';
for(castor::tape::tpcp::FilenameList::const_iterator itor =
value.begin(); itor != value.end(); itor++) {
// Write a separating comma if not the first item in the list
if(itor!=value.begin()) {
os << ",";
}
os << "\"" << *itor << "\"";
}
os << '}';
return os;
}
//------------------------------------------------------------------------------
// ostream << operator for castor::tape::tpcp::ParsedCommandLine
//------------------------------------------------------------------------------
std::ostream &operator<<(std::ostream &os,
const castor::tape::tpcp::ParsedCommandLine &value) {
os <<
"{"
"debugSet=" << boolToString(value.debugSet) << ","
"helpSet=" << boolToString(value.helpSet) << ","
"vid=\"" << value.vid << "\","
"tapeFseqRanges=" << value.tapeFseqRanges <<","
"fileListSet=" << boolToString(value.fileListSet) <<","
"fileListFilename=\"" << value.fileListFilename << "\","
"filenames=" << value.filenames <<
"}";
return os;
}
//------------------------------------------------------------------------------
// ostream << operator for castor::tape::tpcp::TapeFseqRange
//------------------------------------------------------------------------------
std::ostream &operator<<(std::ostream &os,
const castor::tape::tpcp::TapeFseqRange &value) {
if(value.isEmpty()) {
os << "EMPTY";
} else {
uint32_t lower = 0;
uint32_t upper = 0;
try {
lower = value.lower();
upper = value.upper();
os << lower << "-";
// An upper value of 0 means END of tape
if(upper !=0) {
os << upper;
} else {
os << "END";
}
} catch(castor::exception::NoValue &ex) {
os << "ERROR";
}
}
return os;
}
//------------------------------------------------------------------------------
// ostream << operator for castor::tape::tpcp::TapeFseqRangeList
//------------------------------------------------------------------------------
std::ostream &operator<<(std::ostream &os,
const castor::tape::tpcp::TapeFseqRangeList &value) {
os << '{';
for(castor::tape::tpcp::TapeFseqRangeList::const_iterator itor =
value.begin(); itor != value.end(); itor++) {
// Write a separating comma if not the first item in the list
if(itor!=value.begin()) {
os << ",";
}
os << *itor;
}
os << '}';
return os;
}
//------------------------------------------------------------------------------
// ostream << operator for vmgr_tape_info_byte_u64
//------------------------------------------------------------------------------
std::ostream &operator<<(std::ostream &os,
const vmgr_tape_info_byte_u64 &value) {
os << "{"
"vid=\"" << value.vid << "\","
"vsn=\"" << value.vsn << "\","
"library=\"" << value.library << "\","
"density=\"" << value.density << "\","
"lbltype=\"" << value.lbltype << "\","
"model=\"" << value.model << "\","
"media_letter=\"" << value.media_letter << "\","
"manufacturer=\"" << value.manufacturer << "\","
"sn= \"" << value.sn << "\","
"nbsides=" << value.nbsides << ","
"etime=" << value.etime << ","
"rcount=" << value.rcount << ","
"wcount=" << value.wcount << ","
"rhost=\"" << value.rhost << "\","
"whost=\"" << value.whost << "\","
"rjid=" << value.rjid << ","
"wjid=" << value.wjid << ","
"rtime=" << value.rtime << ","
"wtime=" << value.wtime << ","
"side=" << value.side << ","
"poolname=\"" << value.poolname << "\","
"status=" << value.status << ","
"estimated_free_space_byte_u64="<< value.estimated_free_space_byte_u64
<< ","
"nbfiles=" << value.nbfiles
<< "}";
return os;
}
/******************************************************************************
*
* 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.
*
*