Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,32 @@ public InputStream getLog(LogType logType) {
throw new IllegalArgumentException("Log file " + logFile + " does not exist.");
}

public void writeAdHocConfigFile(String fileName, String content) {
final Path target = configDir.resolve(fileName);
final Path directory = target.getParent();
if (Files.exists(directory) == false) {
try {
Files.createDirectories(directory);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
try {
Files.writeString(target, content);
} catch (IOException e) {
throw new UncheckedIOException("Could not write ad-hoc config file: " + fileName, e);
}
}

public void removeAdHocConfigFile(String fileName) {
final Path target = configDir.resolve(fileName);
try {
Files.deleteIfExists(target);
} catch (IOException e) {
throw new UncheckedIOException("Could not remove ad-hoc config file: " + fileName, e);
}
}

public LocalNodeSpec getSpec() {
return spec;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ public InputStream getNodeLog(int index, LogType logType) {
return nodes.get(index).getLog(logType);
}

@Override
public void writeAdHocConfigFile(int index, String fileName, String content) {
nodes.get(index).writeAdHocConfigFile(fileName, content);
}

@Override
public void deleteAdHocConfigFile(int index, String fileName) {
nodes.get(index).removeAdHocConfigFile(fileName);
}

@Override
public void updateStoredSecureSettings() {
execute(() -> nodes.parallelStream().forEach(Node::updateStoredSecureSettings));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ public InputStream getNodeLog(int index, LogType logType) {
return handle.getNodeLog(index, logType);
}

@Override
public void writeAdHocConfigFile(int index, String fileName, String content) {
handle.writeAdHocConfigFile(index, fileName, content);
}

@Override
public void deleteAdHocConfigFile(int index, String fileName) {
handle.deleteAdHocConfigFile(index, fileName);
}

@Override
public void updateStoredSecureSettings() {
checkHandle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ public interface LocalClusterHandle extends ClusterHandle {
*/
InputStream getNodeLog(int index, LogType logType);

/**
* Write an ad-hoc file in the config directory
*/
void writeAdHocConfigFile(int index, String fileName, String content);

/**
* Delete an ad-hoc file in the config directory
*/
void deleteAdHocConfigFile(int index, String fileName);

/**
* Writes secure settings to the relevant secure config file on each node. Use this method if you are dynamically updating secure
* settings via a {@link MutableSettingsProvider} and need the update to be written to file, without a cluster restart.
Expand Down
Loading