Skip to content

Commit

Permalink
boot: Don't fail on missing layout file
Browse files Browse the repository at this point in the history
Currently, when installing the dCache package and then immediately removing it
again, the uninstall fails beause 'dcache stop' cannot complete when the layout
file is missing.

Also, on a node that doesn't need to run any dCache services, doing a setup
without a layout file is currently not possible. This could for instance be a
node that needs to run the info provider and nothing else.

This patch solves this by not making the boot loader fall over when the layout
file is missing. Instead it adds the failure as a warning to the problem
consumer. The check-config command will output a nice warning. To supress the
warning, one can set dcache.layout.uri to the empty string.

Target: trunk
Request: 2.13
Request: 2.12
Request: 2.11
Request: 2.10
Require-notes: yes
Require-book: no
Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Acked-by: Paul Millar <paul.millar@desy.de>
Patch: https://rb.dcache.org/r/7431/
  • Loading branch information
gbehrmann committed Jun 22, 2015
1 parent 5279408 commit 7b3fbd5
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions modules/dcache/src/main/java/org/dcache/boot/LayoutBuilder.java
Expand Up @@ -5,16 +5,20 @@
import com.google.common.collect.Sets;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.LineNumberReader;
import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.nio.file.NoSuchFileException;
import java.util.Arrays;
import java.util.Objects;
import java.util.Set;

import diskCacheV111.util.FileNotFoundCacheException;

import org.dcache.util.ConfigurationProperties;
import org.dcache.util.Version;

Expand Down Expand Up @@ -152,12 +156,18 @@ private Layout loadLayout(ConfigurationProperties config)
}
URI uri = new URI(path);
Layout layout = new Layout(config);
layout.load(uri);
if (!path.isEmpty()) {
try {
layout.load(uri);
} catch (FileNotFoundException e) {
config.getProblemConsumer().warning(e.getMessage());
}

if (Objects.equals(uri.getScheme(), "file")) {
_sourceFiles.add(new File(uri.getPath()));
} else {
layout.properties().setProperty(PROPERTY_DCACHE_CONFIG_CACHE, "false");
if (Objects.equals(uri.getScheme(), "file")) {
_sourceFiles.add(new File(uri.getPath()));
} else {
layout.properties().setProperty(PROPERTY_DCACHE_CONFIG_CACHE, "false");
}
}
layout.properties().setProperty(PROPERTY_DCACHE_CONFIG_FILES,
Joiner.on(" ").join(transform(_sourceFiles, file -> '"' + file.getPath() + '"')));
Expand Down

0 comments on commit 7b3fbd5

Please sign in to comment.