Skip to content

Commit

Permalink
Merge pull request #15 from jhiemstrawisc/rpm-dev
Browse files Browse the repository at this point in the history
Add RPM spec file
  • Loading branch information
jhiemstrawisc authored Sep 18, 2024
2 parents 3fd4e7c + cdce3f7 commit 0878e82
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 6 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@ target_link_libraries(XrdPurgeLotMan

set_target_properties(XrdPurgeLotMan PROPERTIES VERSION ${PROJECT_VERSION})

set(LIB_SUFFIX "" CACHE STRING "Library installation directory suffix")
set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Library installation directory")
set(INCLUDE_INSTALL_DIR "include" CACHE PATH "Include installation directory")

install(TARGETS XrdPurgeLotMan
LIBRARY DESTINATION lib
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
)

install(DIRECTORY src/
DESTINATION ${INCLUDE_INSTALL_DIR}
FILES_MATCHING PATTERN "*.hh"
)

if( XROOTD_PLUGINS_BUILD_UNITTESTS )
Expand Down
38 changes: 38 additions & 0 deletions rpm/xrootd-lotman.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Name: xrootd-lotman
Version: 0.0.1
Release: 1%{?dist}
Summary: A purge plugin for XRootD that uses Lotman's tracking for informed cache disk management

License: Apache-2.0
URL: https://github.com/PelicanPlatform/xrootd-lotman
Source0: https://github.com/PelicanPlatform/xrootd-lotman/archive/v0.0.1.tar.gz

BuildRequires: cmake
BuildRequires: g++
BuildRequires: make
BuildRequires: lotman
BuildRequires: alja-xrootd

%description
This package provides a purge plugin for XRootD that uses Lotman's tracking for informed purges.

%prep
%setup -q -n xrootd-lotman-%version

%build

%cmake
%cmake_build

%install
%cmake_install

%files
%license LICENSE
%doc README.md
%{_libdir}/libXrdPurgeLotMan.so*
%{_includedir}/XrdPurgeLotMan.hh

%changelog
* Tue Aug 27 2024 Justin Hiemstra <[email protected]> - 0.0.1-1
- Initial package
18 changes: 14 additions & 4 deletions src/XrdPurgeLotMan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ PurgePolicy getPolicyFromConfigName(const std::string &policy) {
}

XrdPurgeLotMan::XrdPurgeLotMan()
: m_purge_dirs{}, log(XrdPfc::Cache::GetInstance().GetLog()) {}
: log(XrdPfc::Cache::GetInstance().GetLog()), m_purge_dirs{} {}

XrdPurgeLotMan::~XrdPurgeLotMan() {}

Expand Down Expand Up @@ -190,7 +190,7 @@ void XrdPurgeLotMan::completePurgePolicyBase(const DataFsPurgeshot &purgeShot,
XrdPfc::PurgePolicy policy) {
char **lots;
char *err;
int rv;
int rv{-1};

switch (policy) {
case XrdPfc::PurgePolicy::PastDel:
Expand All @@ -199,6 +199,11 @@ void XrdPurgeLotMan::completePurgePolicyBase(const DataFsPurgeshot &purgeShot,
case XrdPfc::PurgePolicy::PastExp:
rv = lotman_get_lots_past_exp(true, &lots, &err);
break;
default:
log->Emsg(
"XrdPurgeLotMan", "completePurgePolicyBase",
("Unexpected purge policy: " + getPolicyName(policy)).c_str());
return;
}
std::unique_ptr<char *[], LotDeleter> lots_total_purge(lots, LotDeleter());
if (rv != 0) {
Expand Down Expand Up @@ -269,14 +274,19 @@ void XrdPurgeLotMan::partialPurgePolicyBase(const DataFsPurgeshot &purgeShot,
// TODO: Come back and think about whether we want recursive children here
// For now, I'm saying _yes_ because if a child takes up lots of space
// but isn't past its own quota, we still want the option to clear it.
int rv;
int rv{-1};
switch (policy) {
case XrdPfc::PurgePolicy::PastOpp:
rv = lotman_get_lots_past_opp(true, true, &lots, &err);
break;
case XrdPfc::PurgePolicy::PastDed:
rv = lotman_get_lots_past_ded(true, true, &lots, &err);
break;
default:
log->Emsg(
"XrdPurgeLotMan", "completePurgePolicyBase",
("Unexpected purge policy: " + getPolicyName(policy)).c_str());
return;
}
std::unique_ptr<char *[], LotDeleter> lots_partial_purge(lots,
LotDeleter());
Expand Down Expand Up @@ -485,7 +495,7 @@ bool XrdPurgeLotMan::validateConfiguration(const char *params) {

std::vector<PurgePolicy> policies;
std::set<PurgePolicy> encountered;
for (int i = 1; i < paramVec.size(); ++i) {
for (size_t i = 1; i < paramVec.size(); ++i) {
PurgePolicy policy = getPolicyFromConfigName(paramVec[i]);
if (policy == PurgePolicy::UnknownPolicy) {
log->Emsg("XrdPurgeLotMan", "validateConfiguration",
Expand Down
2 changes: 1 addition & 1 deletion src/XrdPurgeLotMan.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ json reconstructPathsAndBuildJson(const XrdPfc::DataFsPurgeshot &purge_shot) {
std::unordered_map<int, DirNode> indexToDirNode;
std::vector<DirNode *> rootDirs;

for (int i = 0; i < purge_shot.m_dir_vec.size(); ++i) {
for (size_t i = 0; i < purge_shot.m_dir_vec.size(); ++i) {
const auto &dir_entry = purge_shot.m_dir_vec[i];
DirNode &dirNode = indexToDirNode[i];
dirNode.path = dir_entry.m_dir_name;
Expand Down

0 comments on commit 0878e82

Please sign in to comment.