Skip to content

Commit 1bc0214

Browse files
committed
Add xjccleand with hot-reloadable cleaner.conf and systemd units.
Rename xrdclcacheclean to xjccleand, remove CacheCleaner.py, add xjc cleaner commands, and have xjcd render/install xjccleand.service alongside xjcd. Assisted-by: Cursor:Composer-2.5 CursorAI
1 parent 89adeb7 commit 1bc0214

17 files changed

Lines changed: 987 additions & 326 deletions

src/XrdApps/CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,17 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
7070
target_link_libraries(${XrdClJournalCachePlugin} PRIVATE stdc++fs)
7171
endif()
7272

73-
add_executable(xrdclcacheclean
74-
XrdClJournalCachePlugin/app/XrdClCacheCleaner.cc)
73+
add_executable(xjccleand
74+
XrdClJournalCachePlugin/app/xjccleand.cc
75+
XrdClJournalCachePlugin/file/CleanerConfig.cc)
76+
77+
target_include_directories(xjccleand
78+
PRIVATE "${CMAKE_SOURCE_DIR}/src/XrdApps/XrdClJournalCachePlugin/")
7579

7680
add_executable(xjc
7781
XrdClJournalCachePlugin/app/xjc.cc
7882
XrdClJournalCachePlugin/file/PolicyConfig.cc
83+
XrdClJournalCachePlugin/file/CleanerConfig.cc
7984
XrdClJournalCachePlugin/file/OriginAllowlist.cc
8085
XrdClJournalCachePlugin/file/ExternalRedirect.cc)
8186

@@ -95,6 +100,7 @@ add_executable(xjcd
95100
XrdClJournalCachePlugin/daemon/XjcdState.cc
96101
XrdClJournalCachePlugin/daemon/XjcdRender.cc
97102
XrdClJournalCachePlugin/file/PolicyConfig.cc
103+
XrdClJournalCachePlugin/file/CleanerConfig.cc
98104
XrdClJournalCachePlugin/file/OriginAllowlist.cc
99105
XrdClJournalCachePlugin/file/ExternalRedirect.cc)
100106

@@ -112,7 +118,7 @@ endif()
112118
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
113119
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1
114120
AND NOT APPLE)
115-
target_link_libraries(xrdclcacheclean PRIVATE stdc++fs)
121+
target_link_libraries(xjccleand PRIVATE stdc++fs)
116122
endif()
117123

118124
if(BUILD_HTTP AND NOT XRDCL_ONLY)
@@ -159,7 +165,7 @@ target_link_libraries(xrdreplay
159165
install(
160166
TARGETS
161167
xrdreplay
162-
xrdclcacheclean
168+
xjccleand
163169
xjc
164170
xjcd
165171
XrdAppUtils

src/XrdApps/XrdClJournalCachePlugin/README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,26 @@ or via the environment variable XRD_JOURNALCACHE_SIZE=1000000000
276276

277277
The minimum cleaner size is 1GB, otherwise it is ignored. The cleaner thread by default runs every minutes and when the given size is exceeded (high water mark), it cleans the cache directory to 90% starting with the oldest files by access time. Setting the size to 0 disables the cleaning (default behaviour).
278278

279-
In more complex environments the cleaner can be run as a daemon using a standalone application:
279+
In more complex environments the cleaner runs as **`xjccleand`**, configured via **`$journal/.xjc/cleaner.conf`** (edit with **`xjc cleaner`**, hot-reloaded on mtime change):
280280

281+
```ini
282+
enabled = 1
283+
journal = /var/tmp/journalcache
284+
high_watermark = 10000000000
285+
low_watermark = 0
286+
interval = 60
287+
config_poll = 2
281288
```
282-
xrdclcacheclean
283-
Usage: xrdclcacheclean <directory> <highwatermark> <lowwatermark> <interval>
289+
290+
```bash
291+
xjc cleaner show
292+
xjc cleaner enable on
293+
xjc cleaner set high 10000000000
294+
xjccleand --journal /var/tmp/journalcache
284295
```
285296

297+
`xjcd init` seeds `cleaner.conf`, generates `xjccleand.service` / `xjccleand.env`, and `--install-systemd` enables both `xjcd.service` and `xjccleand.service`.
298+
286299
# 7 HTTP cache integration
287300

288301
JournalCache can behave as an HTTP-aware read cache when used behind **XrdHttp** or when applications pass cache metadata as CGI parameters on `root://` file URLs.
@@ -576,7 +589,10 @@ xjc redirect add /live/ https://stream.example.org/live/
576589
| `$journal/.xjc/etc/journalcache-http.ext.conf` | HTTP ext (forwarding mode) |
577590
| `$journal/.xjc/etc/client.plugins.d/journalcache.conf` | Client plugins for the xrootd/PSS process |
578591
| `$journal/.xjc/etc/xjcd.env` | `EnvironmentFile` snippet for systemd |
579-
| `$journal/.xjc/etc/xjcd.service` | Generated systemd unit (install into `/etc/systemd/system/`) |
592+
| `$journal/.xjc/etc/xjcd.service` | Generated systemd unit for xrootd |
593+
| `$journal/.xjc/etc/xjccleand.service` | Generated systemd unit for xjccleand |
594+
| `$journal/.xjc/etc/xjccleand.env` | EnvironmentFile for xjccleand |
595+
| `$journal/.xjc/cleaner.conf` | Cleaner daemon config — edit with **`xjc cleaner`** |
580596

581597
Initial policy is **open** (no `allow_origin` lines) until you add rules with **`xjc`**. TLS certificate and key paths are **required** at init time.
582598

@@ -587,7 +603,7 @@ xjcd init --journal /var/tmp/journalcache \
587603
--install-systemd
588604
```
589605

590-
With `--install-systemd`, init installs `$journal/.xjc/etc/xjcd.service` into `/etc/systemd/system/`, runs `systemctl daemon-reload`, and `systemctl enable --now xjcd.service` (requires root). Use `--systemd-unit NAME` for a non-default unit name when running multiple journals on one host.
606+
With `--install-systemd`, init installs `$journal/.xjc/etc/xjcd.service` and `xjccleand.service` into `/etc/systemd/system/`, runs `systemctl daemon-reload`, and `systemctl enable --now xjcd.service xjccleand.service` (requires root). Use `--systemd-unit NAME` / `--systemd-cleaner-unit NAME` for non-default unit names when running multiple journals on one host.
591607

592608
Manual install (without the flag):
593609

@@ -603,11 +619,12 @@ xjcd render --journal /var/tmp/journalcache # after editing state.conf
603619

604620
```bash
605621
sudo install -m 0644 /var/tmp/journalcache/.xjc/etc/xjcd.service /etc/systemd/system/
622+
sudo install -m 0644 /var/tmp/journalcache/.xjc/etc/xjccleand.service /etc/systemd/system/
606623
sudo systemctl daemon-reload
607-
sudo systemctl enable --now xjcd.service
624+
sudo systemctl enable --now xjcd.service xjccleand.service
608625
```
609626

610-
Re-run `xjcd render` after changing `state.conf`, then `systemctl restart xjcd.service`.
627+
Re-run `xjcd render` after changing `state.conf`, then `systemctl restart xjcd.service xjccleand.service`.
611628

612629
See **xjcd(1)** for the full command reference.
613630

@@ -670,7 +687,7 @@ env XRD_PLUGIN=/usr/lib64/libXrdClJournalCachePlugin-5.so XRD_JOURNALCACHE_CACHE
670687
## Open
671688

672689
- Add optional dynamic read-ahead with window scaling
673-
- Make `xrdclcacheclean` a daemon with systemd support
690+
- Make `xjccleand` systemd support part of xjcd bootstrap :white_check_mark:
674691
- Add automatic connection de-multiplexing if contention to storage servers is detected
675692
- ~~Add a CGI option to force cleaning of journal cache for a given file~~ :white_check_mark:
676693
- ~~Add a CGI option to bypass journal cache for a given file~~ :white_check_mark:

src/XrdApps/XrdClJournalCachePlugin/app/CacheCleaner.py

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/XrdApps/XrdClJournalCachePlugin/app/XrdClCacheCleaner.cc

Lines changed: 0 additions & 142 deletions
This file was deleted.

0 commit comments

Comments
 (0)