Skip to content

Commit

Permalink
GH-2902: FusekiServerCtl - Code for server on-disk state
Browse files Browse the repository at this point in the history
  • Loading branch information
afs committed Dec 20, 2024
1 parent 67bc182 commit 099d64c
Show file tree
Hide file tree
Showing 25 changed files with 307 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.jena.fuseki.main.cmds;

import org.apache.jena.fuseki.run.FusekiModServer;
import org.apache.jena.fuseki.mod.FusekiModServer;
import org.apache.jena.fuseki.system.FusekiLogging;

/** Fuseki command that runs a Fuseki server with the admin UI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,6 @@ private void setDiscovery() {
* This step does not create the module objects.
*/
private ServiceLoader<FusekiAutoModule> discover() {
// Look for the 4.8.0 name (FusekiModule) which (4.9.0) is split into
// FusekiModule (interface) and FusekiAutoModule (this is loaded by ServiceLoader)
// Remove sometime!
discoveryWarnLegacy();

Class<FusekiAutoModule> moduleClass = FusekiAutoModule.class;
ServiceLoader<FusekiAutoModule> newServiceLoader = null;
synchronized (this) {
Expand All @@ -168,18 +163,6 @@ private ServiceLoader<FusekiAutoModule> discover() {
return newServiceLoader;
}

private void discoveryWarnLegacy() {
Class<FusekiModule> moduleClass = FusekiModule.class;
try {
ServiceLoader<FusekiModule> newServiceLoader = ServiceLoader.load(moduleClass, this.getClass().getClassLoader());
newServiceLoader.stream().forEach(provider->{
FmtLog.warn(FusekiAutoModules.class, "Ignored: \"%s\" : legacy use of interface FusekiModule which has changed to FusekiAutoModule", provider.type().getSimpleName());
});
} catch (ServiceConfigurationError ex) {
// Ignore - we were only checking.
}
}

/**
* Instantiate modules found using the ServiceLoader.
* Each call to {@code load()} creates a new object for the FusekiModule.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public void execute(HttpAction action) {
};

private JsonValue description(HttpAction action) {
if ( ! Files.isDirectory(FusekiApp.dirBackups) )
ServletOps.errorOccurred(format("[%d] Backup area '%s' is not a directory", action.id, FusekiApp.dirBackups));
if ( ! Files.isDirectory(FusekiServerCtl.dirBackups) )
ServletOps.errorOccurred(format("[%d] Backup area '%s' is not a directory", action.id, FusekiServerCtl.dirBackups));

List<Path> paths = new ArrayList<>();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(FusekiApp.dirBackups, filterVisibleFiles)) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(FusekiServerCtl.dirBackups, filterVisibleFiles)) {
stream.forEach(paths::add);
} catch (IOException ex) {
action.log.error(format("[%d] Backup file list :: IOException :: %s", action.id, ex.getMessage()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ else if ( WebContent.isMultiPartForm(ct) )
// ----
// Keep a persistent copy immediately. This is not used for
// anything other than being "for the record".
systemFileCopy = FusekiApp.dirSystemFileArea.resolve(uuid.toString()).toString();
systemFileCopy = FusekiServerCtl.dirSystemFileArea.resolve(uuid.toString()).toString();
try ( OutputStream outCopy = IO.openOutputFile(systemFileCopy) ) {
RDFDataMgr.write(outCopy, descriptionModel, Lang.TURTLE);
}
Expand Down Expand Up @@ -186,8 +186,8 @@ else if ( WebContent.isMultiPartForm(ct) )

action.log.info(format("[%d] Create database : name = %s", action.id, datasetPath));

configFile = FusekiApp.generateConfigurationFilename(datasetPath);
List<String> existing = FusekiApp.existingConfigurationFile(datasetPath);
configFile = FusekiServerCtl.generateConfigurationFilename(datasetPath);
List<String> existing = FusekiServerCtl.existingConfigurationFile(datasetPath);
if ( ! existing.isEmpty() )
ServletOps.error(HttpSC.CONFLICT_409, "Configuration file for '"+datasetPath+"' already exists");

Expand Down Expand Up @@ -318,7 +318,7 @@ protected void execDeleteItem(HttpAction action) {

// Find the configuration.
String filename = name.startsWith("/") ? name.substring(1) : name;
List<String> configurationFiles = FusekiApp.existingConfigurationFile(filename);
List<String> configurationFiles = FusekiServerCtl.existingConfigurationFile(filename);

if ( configurationFiles.isEmpty() ) {
// ---- Unmanaged
Expand Down Expand Up @@ -363,7 +363,7 @@ protected void execDeleteItem(HttpAction action) {
// Delete databases created by the UI, or the admin operation, which are
// in predictable, unshared location on disk.
// There may not be any database files, the in-memory case.
Path pDatabase = FusekiApp.dirDatabases.resolve(filename);
Path pDatabase = FusekiServerCtl.dirDatabases.resolve(filename);
if ( Files.exists(pDatabase)) {
try {
if ( Files.isSymbolicLink(pDatabase)) {
Expand Down Expand Up @@ -411,7 +411,7 @@ private static void assemblerFromForm(HttpAction action, StreamRDF dest) {
params.put(Template.NAME, dbName.substring(1));
else
params.put(Template.NAME, dbName);
FusekiApp.addGlobals(params);
FusekiServerCtl.addGlobals(params);

//action.log.info(format("[%d] Create database : name = %s, type = %s", action.id, dbName, dbType ));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static String chooseFileName(String dsName) {

String timestamp = DateTimeUtils.nowAsString("yyyy-MM-dd_HH-mm-ss");
String filename = ds + "_" + timestamp;
filename = FusekiApp.dirBackups.resolve(filename).toString();
filename = FusekiServerCtl.dirBackups.resolve(filename).toString();
return filename;
}

Expand Down
Loading

0 comments on commit 099d64c

Please sign in to comment.