Commit b747dda2 authored by Steven Murray's avatar Steven Murray
Browse files

Removed more CASTOR directories that are not related to tapeserverd

parent 9f994126
......@@ -37,5 +37,6 @@ add_subdirectory(objectstore)
add_subdirectory(nameserver)
add_subdirectory(remotens)
add_subdirectory(scheduler)
add_subdirectory(tapeserver)
add_subdirectory(tests)
add_subdirectory(xroot_plugins)
# 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
#
################################################################################
# Project definition section - In source build forbidding
################################################################################
cmake_minimum_required (VERSION 2.6)
project(castor)
# Explicitly setting the C and C++ compiler flags for the RelWithDebInfo build
# in order to prevent the -O2 flag from being used.
#
# The CASTOR executables are not running short of CPU cycles. The extra
# effort required to debug released binaries compiled with the -O2 option is
# therefore not justified.
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g")
IF(NOT CMAKE_BUILD_TYPE STREQUAL "")
# If the user specifies -DCMAKE_BUILD_TYPE on the command line, take their definition and dump it in the cache
message(STATUS "Setting build type to ${CMAKE_BUILD_TYPE} as requested.")
SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build.")
ELSE()
# log choosen default (RelWithDebInfo) and set it
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
message (STATUS "Override with -DCMAKE_BUILD_TYPE:STRING=Debug")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
# this command is not yet available in SLC6's cmake 2.6
# set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "")
if ("${CMAKE_SOURCE_DIR}" MATCHES "${CMAKE_BINARY_DIR}")
message (SEND_ERROR "In source building not supported. Please run something like: \"mkdir ../build; ( src=`pwd`; cd ../build; cmake $src ); make -C ../build\"")
message (SEND_ERROR "Now that you reached that point you will unfortnately have to cleanup your source directory: \"rm -rf CMakeFiles/ CMakeCache.txt\". Sorry!")
return()
endif ("${CMAKE_SOURCE_DIR}" MATCHES "${CMAKE_BINARY_DIR}")
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(cmake/CASTORVersion.cmake)
# Generate the compilation variables, if needed
if (NOT DEFINED COMPILE_SERVER)
message (STATUS "Setting COMPILE_SERVER to the value of 1")
message (STATUS "Override with -DCOMPILE_SERVER:STRING=0")
set(COMPILE_SERVER 1)
else (NOT DEFINED COMPILE_SERVER)
message (STATUS "Already set: COMPILE_SERVER=${COMPILE_SERVER}")
endif (NOT DEFINED COMPILE_SERVER)
# Generate the compilation variables, if needed
if (NOT DEFINED SKIP_UNIT_TESTS)
message (STATUS "Setting SKIP_UNIT_TESTS to the value of 1")
message (STATUS "Override with -DSKIP_UNIT_TESTS:STRING=0")
set(SKIP_UNIT_TESTS 1)
else (NOT DEFINED SKIP_UNIT_TESTS)
message (STATUS "Already set: SKIP_UNIT_TESTS=${SKIP_UNIT_TESTS}")
endif (NOT DEFINED SKIP_UNIT_TESTS)
IF(DEFINED PackageOnly)
message (STATUS "Running CMake in package-only mode")
set(COMPILE_PACKAGING "1")
ELSE(DEFINED PackageOnly)
message (STATUS "Running in full configuration mode.")
message (STATUS "Override with -DPackageOnly:Bool=true")
# Generate the compilation variables, if needed
if (NOT DEFINED COMPILE_PACKAGING)
message (STATUS "Setting COMPILE_PACKAGING to the value of 1")
message (STATUS "Override with -DCOMPILE_PACKAGING:STRING=0")
set(COMPILE_PACKAGING 1)
else (NOT DEFINED COMPILE_PACKAGING)
message (STATUS "Already set: COMPILE_PACKAGING=${COMPILE_PACKAGING}")
endif (NOT DEFINED COMPILE_PACKAGING)
################################################################################
# Configure header file
################################################################################
configure_file(${CMAKE_SOURCE_DIR}/h/patchlevel.h.in
${CMAKE_BINARY_DIR}/h/patchlevel.h)
include(cmake/CASTORInstallationFunctions.cmake)
find_package (uuid REQUIRED)
find_package (python REQUIRED)
include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_BINARY_DIR}/h)
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/h)
if (${COMPILE_SERVER} STREQUAL "1")
find_package (oracle REQUIRED)
function (CastorAddProC _name)
add_custom_command (
OUTPUT ${_name}.c DEPENDS ${_name}.pc
COMMAND
ORACLE_HOME=${ORACLE_HOME}
LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${ORACLE_LIBDIR}
${ORACLE_BIN}/proc
iname=${CMAKE_CURRENT_SOURCE_DIR}/${_name}.pc
oname=${CMAKE_CURRENT_BINARY_DIR}/${_name}.c
${ORACLE_PROCINC}
include=${CMAKE_SOURCE_DIR}
include=${CMAKE_SOURCE_DIR}/h
threads=yes
char_map=string
parse=full
prefetch=1000)
# Append the oracle specific compilation flags and also use -Wno-error to
# override the default -Werror compilation rule in the case of source files
# produced by the Pro*C precompiler. Such files contain generated code that
# generates warnings.
set_property (SOURCE ${_name}.c
PROPERTY COMPILE_FLAGS "${ORACLE_CPPFLAGS} -Wno-error")
endfunction ()
endif (${COMPILE_SERVER} STREQUAL "1")
set (CMAKE_C_FLAGS "-fPIC -Wall -Wextra -Werror -Wno-unused-parameter")
if (APPLE)
set (CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup")
else (APPLE)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -Wl,--defsym,CastorVersion_v${CASTOR_VERSION}.${CASTOR_RELEASE}=0")
endif (APPLE)
#set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wnon-virtual-dtor")
set_property (DIRECTORY PROPERTY COMPILE_DEFINITIONS _LARGEFILE64_SOURCE)
##############################################################################
# Rules to install the shared log and spool directories
##############################################################################
CastorInstallDir (/var/log/castor)
CastorInstallDir (/var/log/spool/castor)
##############################################################################
# Include the subdirectories of the project
##############################################################################
# Some directories have client components, and get included unconditionnaly
# inside them, we can filter further down what we need or not.
# The ones with only server components can already be filtered out for the
# clients builds here.
add_subdirectory (castor)
add_subdirectory (client/src/stager)
add_subdirectory (common)
add_subdirectory (dlf)
if (${COMPILE_SERVER} STREQUAL "1")
add_subdirectory (gridftp2)
add_subdirectory (ceph)
add_subdirectory (movers)
endif (${COMPILE_SERVER} STREQUAL "1")
add_subdirectory (h)
if (${COMPILE_SERVER} STREQUAL "1")
add_subdirectory (hsmtools)
add_subdirectory (monitoring)
endif (${COMPILE_SERVER} STREQUAL "1")
add_subdirectory (ns)
add_subdirectory (rfio)
add_subdirectory (rmc)
add_subdirectory (security)
add_subdirectory (shlib)
if (${COMPILE_SERVER} STREQUAL "1")
add_subdirectory (traffic-shaping)
endif (${COMPILE_SERVER} STREQUAL "1")
add_subdirectory (upv)
add_subdirectory (vdqm)
add_subdirectory (vmgr)
if (${COMPILE_SERVER} STREQUAL "1")
add_subdirectory (xrootd)
add_subdirectory (tape)
add_subdirectory (test)
endif (${COMPILE_SERVER} STREQUAL "1")
ENDIF(DEFINED PackageOnly)
################################################################################
# Packaging step (replacing the maketar)
# See http://www.vtk.org/Wiki/CMakeUserUseRPMTools
################################################################################
if (${COMPILE_PACKAGING} STREQUAL "1")
include(cmake/UseRPMToolsEnvironment.cmake)
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${CASTOR_VERSION}-${CASTOR_RELEASE}")
message (STATUS
"Setting package file name to: ${CPACK_SOURCE_PACKAGE_FILE_NAME}")
set(CPACK_SOURCE_IGNORE_FILES "/.git/")
include(CPack)
include(cmake/UseRPMTools.cmake)
if (RPMTools_FOUND)
message (STATUS "Generating spec file from debian package structure...")
execute_process (
COMMAND ./makespec.py
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_FILE ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.spec.in
OUTPUT_VARIABLE result)
if (NOT ${result} STREQUAL "")
string (REGEX REPLACE "\n$" "" result ${result})
message (STATUS "${result}")
endif (NOT ${result} STREQUAL "")
RPMTools_ADD_RPM_TARGETS(
${PROJECT_NAME} ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.spec.in)
endif (RPMTools_FOUND)
endif (${COMPILE_PACKAGING} STREQUAL "1")
#add_custom_target(test test/castorUnitTests
# COMMENT "Not running the unit tests" VERBATIM)
configure_file(test/castorThreadedUnitTests.supp test/castorThreadedUnitTests.supp COPYONLY)
add_custom_target(test test/castorUnitTests
#
COMMAND valgrind --track-fds=yes --leak-check=full --demangle=no --gen-suppressions=all --show-reachable=yes --error-exitcode=1 test/castorUnitTests
COMMAND test/castorThreadedUnitTests
COMMAND valgrind --track-fds=yes --leak-check=full --show-reachable=yes --error-exitcode=1 test/castorThreadedUnitTests
COMMAND valgrind --tool=helgrind -v --demangle=no --conflict-cache-size=30000000 --error-exitcode=1 test/castorThreadedUnitTests
COMMAND test/castorMultiprocessUnitTests
COMMAND valgrind --tool=helgrind --error-exitcode=1 test/castorMultiprocessUnitTests
DEPENDS test/castorUnitTests test/castorThreadedUnitTests test/castorMultiprocessUnitTests test/castorThreadedUnitTests.supp
COMMENT "Running unit tests" VERBATIM)
add_subdirectory (castor)
add_subdirectory (common)
add_subdirectory (dlf)
add_subdirectory (rfio)
add_subdirectory (tape)
add_subdirectory (test)
/******************************************************************************
*
* 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/acs/Acs.hpp"
#include "castor/utils/utils.hpp"
#include <iomanip>
#include <sstream>
#include <stdint.h>
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
castor::acs::Acs::~Acs() throw() {
}
//------------------------------------------------------------------------------
// str2DriveId
//------------------------------------------------------------------------------
DRIVEID castor::acs::Acs::str2DriveId(const std::string &str) {
std::vector<std::string> components;
castor::utils::splitString(str, ':', components);
// The drive ID should consist of 4 components: ACS, LSM, Panel and Transport
if(4 != components.size()) {
castor::exception::InvalidArgument ex;
ex.getMessage() << "Invalid number of components in drive ID"
": expected=4, actual=" << components.size();
throw ex;
}
const std::string &acsStr = components[0];
const std::string &lsmStr = components[1];
const std::string &panStr = components[2];
const std::string &drvStr = components[3];
// Each of the 4 components must be between 1 and than 3 characters long
if(1 > acsStr.length() || 3 < acsStr.length()) {
castor::exception::InvalidArgument ex;
ex.getMessage() << "Invalid ACS string length"
": expected=1..3, actual=" << acsStr.length();
throw ex;
}
if(1 > lsmStr.length() || 3 < lsmStr.length()) {
castor::exception::InvalidArgument ex;
ex.getMessage() << "Invalid LSM string length"
": expected=1..3, actual=" << lsmStr.length();
throw ex;
}
if(1 > panStr.length() || 3 < panStr.length()) {
castor::exception::InvalidArgument ex;
ex.getMessage() << "Invalid panel string length"
": expected=1..3, actual=" << panStr.length();
throw ex;
}
if(1 > drvStr.length() || 3 < drvStr.length()) {
castor::exception::InvalidArgument ex;
ex.getMessage() << "Invalid drive string length"
": expected=1..3, actual=" << drvStr.length();
throw ex;
}
// Each of the 4 components must only contain numerals
if(!onlyContainsNumerals(acsStr)) {
castor::exception::InvalidArgument ex;
ex.getMessage() << "ACS must only contain numerals: value=" << acsStr;
throw ex;
}
if(!onlyContainsNumerals(lsmStr)) {
castor::exception::InvalidArgument ex;
ex.getMessage() << "LSM must only contain numerals: value=" << acsStr;
throw ex;
}
if(!onlyContainsNumerals(panStr)) {
castor::exception::InvalidArgument ex;
ex.getMessage() << "Panel must only contain numerals: value=" << acsStr;
throw ex;
}
if(!onlyContainsNumerals(drvStr)) {
castor::exception::InvalidArgument ex;
ex.getMessage() << "Drive/Transport must only contain numerals: value=" <<
acsStr;
throw ex;
}
DRIVEID driveId;
driveId.panel_id.lsm_id.acs = (ACS)atoi(acsStr.c_str());
driveId.panel_id.lsm_id.lsm = (LSM)atoi(lsmStr.c_str());
driveId.panel_id.panel = (PANEL)atoi(panStr.c_str());
driveId.drive = (DRIVE)atoi(drvStr.c_str());
return driveId;
}
//------------------------------------------------------------------------------
// onlyContainsNumerals
//------------------------------------------------------------------------------
bool castor::acs::Acs::onlyContainsNumerals(const std::string &str) throw() {
for(std::string::const_iterator itor = str.begin(); itor != str.end();
itor++) {
if(*itor < '0' || *itor > '9') {
return false;
}
}
return true;
}
//------------------------------------------------------------------------------
// alpd2DriveId
//------------------------------------------------------------------------------
DRIVEID castor::acs::Acs::alpd2DriveId(const uint32_t acs,
const uint32_t lsm, const uint32_t panel, const uint32_t drive) throw () {
DRIVEID driveId;
driveId.panel_id.lsm_id.acs = (ACS)acs;
driveId.panel_id.lsm_id.lsm = (LSM)lsm;
driveId.panel_id.panel = (PANEL)panel;
driveId.drive = (DRIVE)drive;
return driveId;
}
//------------------------------------------------------------------------------
// str2Volid
//------------------------------------------------------------------------------
VOLID castor::acs::Acs::str2Volid(const std::string &str) {
if(EXTERNAL_LABEL_SIZE < str.length()) {
castor::exception::InvalidArgument ex;
ex.getMessage() << "Failed to convert string to volume identifier"
": String is longer than the " << EXTERNAL_LABEL_SIZE <<
" character maximum";
throw ex;
}
VOLID v;
strncpy(v.external_label, str.c_str(), sizeof(v.external_label));
v.external_label[sizeof(v.external_label) - 1] = '\0';
return v;
}
//------------------------------------------------------------------------------
// driveId2Str
//------------------------------------------------------------------------------
std::string castor::acs::Acs::driveId2Str(const DRIVEID &driveId) throw() {
std::ostringstream oss;
oss << std::setfill('0') <<
std::setw(3) << (int32_t)driveId.panel_id.lsm_id.acs << ":" <<
std::setw(3) << (int32_t)driveId.panel_id.lsm_id.lsm << ":" <<
std::setw(3) << (int32_t)driveId.panel_id.panel << ":" <<
std::setw(3) << (int32_t)driveId.drive;
return oss.str();
}
/******************************************************************************
*
* 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/exception/InvalidArgument.hpp"
extern "C" {
#include "acssys.h"
#include "acsapi.h"
}
#include <string>
#include <stdint.h>
namespace castor {
namespace acs {
/**
* Abstract class that defines the interface to an object that wraps the ACLS
* C-API.
*/
class Acs {
public:
/**
* Pure-virtual destructor to ensure this class is abstract.
*/
virtual ~Acs() throw() = 0;
/**
* Parses the specified string and returns the corresponding drive ID object.
*
* This method throws a castor::exception::InvalidArgument if the syntax of
* the string is invalid.
*
* @param str The string to be parsed.
* @return The drive ID object.
*/
static DRIVEID str2DriveId(const std::string &str);
/**
* Converts acs, lsm, panel, drive numbers to the corresponding
* drive ID object.
*
* @param acs The integer for acs.
* @param lsm The integer for lsm.
* @param panel The integer for panel.
* @param drive The integer for drive.
* @return The drive ID object.
*/
static DRIVEID alpd2DriveId(const uint32_t acs, const uint32_t lsm,
const uint32_t panel, const uint32_t drive) throw();
/**
* Returns the VOLID equibvalent of the specified string.
*
* This method throws a castor::exception::InvalidArgument if the string is
* longer than EXTERNAL_LABEL_SIZE.
*
* @param str The string representation of the volume identifier.
* @return The VOLID representation of the volume identifier.
*/
static VOLID str2Volid(const std::string &str);
/**
* Returns the string reprsentation of the specified drive identifier.
*
* The string format is ACS:LSM:panel:drive
*
* @param driveId The drive identifier.
* @return The string representation.
*/
static std::string driveId2Str(const DRIVEID &driveId) throw();
/**
* C++ wrapper around the acs_mount() function of the ACSLS C-API.
*
* @param seqNumber Client supplied sequence number.
* @param lockId Lock identifier or 0 meaning no lock.
* @param volId The indentifier of volume to be mounted.
* @param driveId The ID of the drive into which the volume is to be mounted.
* @param readOnly Set to true to request the volume be mounted for read-only
* access.
* @param bypass Set to true to override the ACSLS verification of
* compatibility between the drive and the media type of the volume.
* @return status value returned by acs_mount().
*/
virtual STATUS mount(
const SEQ_NO seqNumber,
const LOCKID lockId,
const VOLID &volId,
const DRIVEID &driveId,
const BOOLEAN readOnly,
const BOOLEAN bypass)
throw() = 0;
/**
* C++ wrapper around the acs_dismount() function of the ACSLS C-API.
*
* @param seqNumber Client supplied sequence number.
* @param lockId Lock identifier or 0 meaning no lock.
* @param volId The identifier of the volume to be mounted.
* @param driveId The ID of the drive into which the volume is to be mounted.
* @param force Set to true if the dismount should be forced. Forcing a
* dismount means dismounting the volume from the specified drive without
* checking the identifier of the volume.
* @return status value returned by acs_dismount().
*/
virtual STATUS dismount(
const SEQ_NO seqNumber,
const LOCKID lockId,
const VOLID &volId,
const DRIVEID &driveId,
const BOOLEAN force)
throw() = 0;
/**
* C++ wrapper around the acs_response() function of the ACSLS C-API.
*
* @param timeout Time in seconds to wait for a response. A value of -1
* means block indefinitely and an a value of 0 means poll for the existence
* of a response.
* @param seqNumber Output parameter. If a response exists then seqNumber
* is set.
* @param reqId Output parameter. For an acknowledge response reqId is set
* to the request identifier of the original request. For an intermediate or
* final response reqId will be set to 0.
* @param rType Output parameter. Set to the type of the response.
* @param rBuf Output parameter. Set to the response information.
* @return status value returned by acs_response().
*/
virtual STATUS response(
const int timeout,
SEQ_NO &seqNumber,
REQ_ID &reqId,
ACS_RESPONSE_TYPE &rType,
ALIGNED_BYTES rBuf) throw() = 0;
/**
* C++ wrapper around the acs_query_volume() function of the ACSLS C-API.
*
* @param seqNumber Client supplied sequence number.
* @param volIds Array of the volume identifiers to be queried.
* @param count The number of volume identifiers contained iwthin the volId
* parameter.
* @return status value returned by acs_response().
*/
virtual STATUS queryVolume(
const SEQ_NO seqNumber,
VOLID (&volIds)[MAX_ID],
const unsigned short count) throw() = 0;
protected:
/**
* Returns true if the specified string only contains numerals else false.
*
* @return True if the specified string only contains numerals else false.
*/
static bool onlyContainsNumerals(const std::string &str) throw();
}; // class Acs
} // namespace acs