Skip to content

Commit

Permalink
pool: add variable to control duration of initial sticky bit upon res…
Browse files Browse the repository at this point in the history
…tore.

Motivation:
dCache sets initial sticky bit with hardcoded duration of 5 minutes upon
cached file arrival into pool repository. Sometimes it is required to have this
duration configurable (e.g. to use migration to copy/move file replica upon
arrival into a stage pool pool).

Modification:
Modified NearlineStorageHandler to use Repository.setSticky call to set
sticky bit expiration to a desired value. Default remains 5 minutes.
Pool properties file received two new variables:

    pool.sticky-on-stage-duration = 5
    (one-of?MILLISECONDS|SECONDS|MINUTES|HOURS|DAYS)pool.sticky-on-stage-duration.unit = MINUTES

Result:
Ability to control initial sticky bit duration on restores.

RELEASE_NOTES:

Add an option to set duration of initial sticky bit on file restore
from HSM. Default is 5 minutes. These variables control
the duration:

pool.sticky-on-stage-duration = 5
(one-of?MILLISECONDS|SECONDS|MINUTES|HOURS|DAYS)pool.sticky-on-stage-duration.unit = MINUTES

Require-notes: yes
Patch: https://rb.dcache.org/r/13920/
Acked-by: Albert Rossi
Target: trunk
  • Loading branch information
DmitryLitvintsev committed Mar 10, 2023
1 parent 7f16ca2 commit 5cb806a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Expand Up @@ -188,6 +188,8 @@ public int canceled() {
private OptionalLong removeTimeout = OptionalLong.empty();
private ScheduledFuture<?> timeoutFuture;
private boolean _addFromNearlineStorage;
private TimeUnit stickyOnStageDurationUnit;
private long stickyOnStageDuration;

/**
* Allocator used to use when space allocation is required.
Expand Down Expand Up @@ -258,6 +260,18 @@ public void setFileStore(FileStore fileStore) {
this.fileStore = fileStore;
}

@Required
public void setStickyOnStageDuration(long stickyOnStageDuration) {
checkArgument(stickyOnStageDuration >= -1,
"Sticky on stage duration must be >= -1");
this.stickyOnStageDuration = stickyOnStageDuration;
}

@Required
public void setStickyOnStageDurationUnit(TimeUnit stickyOnStageDurationUnit) {
this.stickyOnStageDurationUnit = stickyOnStageDurationUnit;
}

@PostConstruct
public void init() {
timeoutFuture = scheduledExecutor.scheduleWithFixedDelay(new TimeoutTask(), 30, 30,
Expand Down Expand Up @@ -1387,6 +1401,22 @@ private void done(@Nullable Throwable cause) {
}
try {
descriptor.close();
if (cause == null) {
/**
* A sticky bit with hardcoded 5 minute lifetime is added
* when a cached file is written to the pool.
* Below we add ability to override the hardcoded default which
* is useful for some workflows (e.g. when using permanent migration).
*/
long expiration = stickyOnStageDuration == -1 ? -1
: System.currentTimeMillis() +
stickyOnStageDurationUnit.toMillis(stickyOnStageDuration);

repository.setSticky(pnfsId,
"self",
expiration,
true);
}
} catch (Exception e) {
if (cause == null) {
cause = e;
Expand Down
Expand Up @@ -194,6 +194,8 @@
<property name="hsmSet" ref="hsmset"/>
<property name="allocator" ref="allocator" />
<property name="fileStore" ref="file-store" />
<property name="stickyOnStageDuration" value="${pool.sticky-on-stage-duration}" />
<property name="stickyOnStageDurationUnit" value="${pool.sticky-on-stage-duration.unit}" />
</bean>

<bean id="hsmset" class="org.dcache.pool.nearline.HsmSet">
Expand Down
8 changes: 8 additions & 0 deletions skel/share/defaults/pool.properties
Expand Up @@ -721,6 +721,14 @@ pool.destination.heartbeat = ${dcache.topic.pool-heartbeat}
# notification.
pool.destination.replicate =

# By default dCache will set a sticky bit on cached replicas that just
# have been staged. The duration of this sticky bit is 5 minutes. There
# are situations where this needs adjustment.

pool.sticky-on-stage-duration = 5
(one-of?MILLISECONDS|SECONDS|MINUTES|HOURS|DAYS)pool.sticky-on-stage-duration.unit = MINUTES


# IP address to include in replication requests
#
# This will typically be an IP address of a worker node or some other client machine.
Expand Down

0 comments on commit 5cb806a

Please sign in to comment.