Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend: Add an option to set SRR path mappings #7621

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class SrrResource {
private HttpServletRequest request;

private Map<String, List<String>> pgroup2vo = new HashMap<>();
private Map<String, List<String>> pgroup2path = new HashMap<>();
// info provider properties
private String name;
private String id;
Expand Down Expand Up @@ -119,6 +120,28 @@ public void setGroupMapping(String mapping) {

}

public void setPathMapping(String mapping) {

// paths=cms:/pnfs/cms,atlas:/pnfs/atlas,longvo.fqdn.name:/pnfs/longvo

Splitter.on(',')
.trimResults()
.omitEmptyStrings()
.splitToList(mapping)
.forEach(
s -> {
String[] pathMap = s.split(":");
if (pathMap.length != 2) {
throw new IllegalArgumentException(
"Invalid format of poolgroup -> path mapping");
}
pgroup2path.computeIfAbsent(pathMap[0], k -> new ArrayList<>()).add(pathMap[1]);
}

);

}

@Produces(MediaType.APPLICATION_JSON)
@GET
public Response getSrr() throws InterruptedException, CacheException, NoRouteToCellException {
Expand All @@ -141,6 +164,7 @@ public Response getSrr() throws InterruptedException, CacheException, NoRouteToC
.withQuality(quality)
.withArchitecture(architecture)
.withGroupVoMapping(pgroup2vo)
.withGroupPathMapping(pgroup2path)
.withDoorTag(doorTag)
.generate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class SrrBuilder {
private final static Logger LOGGER = LoggerFactory.getLogger(SrrBuilder.class);

private Map<String, List<String>> pgroup2vo;
private Map<String, List<String>> pgroup2path;
// info provider properties
private String name;
private String id;
Expand Down Expand Up @@ -109,6 +110,11 @@ public SrrBuilder withGroupVoMapping(Map<String, List<String>> pgroup2vo) {
return this;
}

public SrrBuilder withGroupPathMapping(Map<String, List<String>> pgroup2path) {
this.pgroup2path = pgroup2path;
return this;
}

public SrrBuilder withDoorTag(String doorTag) {
this.doorTag = doorTag;
return this;
Expand Down Expand Up @@ -176,6 +182,7 @@ private List<Storageshare> collectSpaceTokens()
.withUsedsize(space.getUsedSizeInBytes())
.withTimestamp(now)
.withVos(Collections.singletonList(space.getVoGroup()))
.withPath(pgroup2path.get(space.getDescription()))
.withAssignedendpoints(Collections.singletonList("all"))
.withAccesslatency(
Storageshare.Accesslatency.fromValue(space.getAccessLatency()))
Expand Down Expand Up @@ -232,6 +239,7 @@ private List<Storageshare> collectShares()
.withUsedsize(usedSpace)
.withTimestamp(now)
.withVos(pgroup.getValue())
.withPath(pgroup2path.get(shareName))
.withAssignedendpoints(Collections.singletonList("all"));
storageshares.put(shareName, share);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@
<bean class="org.dcache.restful.resources.srr.SrrResource" scope="request">
<property name="spaceReservationEnabled" value="${frontend.enable.space-reservation}"/>
<property name="groupMapping" value="${frontend.srr.shares}" />
<property name="pathMapping" value="${frontend.srr.paths}" />
<property name="id" value="${info-provider.se-unique-id}" />
<property name="name" value="${info-provider.se-name}" />
<property name="architecture" value="${info-provider.dcache-architecture}" />
Expand Down
14 changes: 14 additions & 0 deletions skel/share/defaults/frontend.properties
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,20 @@ frontend.version.swagger-ui = @version.swagger-ui@
# cms-user:/cms,default:/cms,default:/atlas
frontend.srr.shares =

#
# SRR path mappings
# This setting allows the optional path field to be set in the SRR
# storageshares entries (for either poolgroups or space reservations).
# The same key may be specified repeatedly to add multiple paths.
#
# Format:
# poolgroup1:/path1,poolgroup2:/path2,spaceres1:/path/other,...
#
# Example:
# cms-user:/cms/store/user,default:/cms,default:/atlas
#
frontend.srr.paths =

#
# Should SRR information be restricted to localhost only
#
Expand Down