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

GH-2462: Fuseki reload configuration #2464

Closed
wants to merge 7 commits into from
Closed
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 @@ -65,8 +65,8 @@ static public void init()
initialized = true ;
registerDataset(tDataset, new DatasetAssemblerGeneral());
registerDataset(tDatasetOne, new DatasetOneAssembler());
registerDataset(tDatasetZero, new DatasetNullAssembler(tDatasetZero));
registerDataset(tDatasetSink, new DatasetNullAssembler(tDatasetSink));
registerDataset(tDatasetZero, new DatasetZeroAssembler());
registerDataset(tDatasetSink, new DatasetSinkAssembler());
registerDataset(tMemoryDataset, new InMemDatasetAssembler());
registerDataset(tDatasetTxnMem, new InMemDatasetAssembler());
registerDataset(tDatasetView, new ViewDatasetAssembler());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.jena.sparql.core.assembler ;

import java.util.List ;
import java.util.Map;

import org.apache.jena.assembler.Assembler ;
import org.apache.jena.atlas.logging.Log ;
Expand All @@ -41,11 +40,6 @@ public static Resource getType() {

public DatasetAssemblerGeneral() {}

@Override
public Map<String, DatasetGraph> pool() {
return sharedDatasetPool;
}

@Override
public DatasetGraph createDataset(Assembler a, Resource root) {
// -------- Default graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.jena.sparql.core.assembler;

import java.util.List;
import java.util.Map;

import org.apache.jena.assembler.Assembler;
import org.apache.jena.assembler.exceptions.AssemblerException;
Expand Down Expand Up @@ -51,11 +50,6 @@ public static Resource getType() {

public DatasetOneAssembler() {}

@Override
public Map<String, DatasetGraph> pool() {
return sharedDatasetPool;
}

@Override
public DatasetGraph createDataset(Assembler a, Resource root) {
// Can use ja:graph or ja:defaultGraph but not both.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,29 @@

package org.apache.jena.sparql.core.assembler;

import java.util.Map;

import org.apache.jena.assembler.Assembler;
import org.apache.jena.atlas.lib.InternalErrorException;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.sparql.core.DatasetGraphSink;
import org.apache.jena.sparql.core.DatasetGraphZero;

/**
* An assembler that creates datasets that do nothing, either a sink or a always empty one.
* An assembler that creates datasets that do nothing, either a sink or an always empty one.

* @see DatasetGraphSink
* @see DatasetGraphZero
*/

public class DatasetNullAssembler extends NamedDatasetAssembler {
public class DatasetSinkAssembler extends NamedDatasetAssembler {

private final Resource tDataset;
public static Resource getType() { return DatasetAssemblerVocab.tDatasetSink; }

public DatasetNullAssembler(Resource tDataset) {
this.tDataset = tDataset;
}
public DatasetSinkAssembler() {}

@Override
public DatasetGraph createDataset(Assembler a, Resource root) {
DatasetGraph dsg;
if ( DatasetAssemblerVocab.tDatasetSink.equals(tDataset) )
dsg = DatasetGraphSink.create();
else if ( DatasetAssemblerVocab.tDatasetZero.equals(tDataset) )
dsg = DatasetGraphZero.create();
else
throw new InternalErrorException();
DatasetGraph dsg = DatasetGraphSink.create();
AssemblerUtils.mergeContext(root, dsg.getContext());
return dsg;
}

@Override
public Map<String, DatasetGraph> pool() {
return sharedDatasetPool;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.jena.sparql.core.assembler;

import org.apache.jena.assembler.Assembler;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.sparql.core.DatasetGraphZero;

/**
* An assembler that creates datasets that do nothing, either a sink or an always empty one.
*
* @see DatasetGraphZero
*/

public class DatasetZeroAssembler extends NamedDatasetAssembler {

public static Resource getType() { return DatasetAssemblerVocab.tDatasetZero; }

public DatasetZeroAssembler() {}

@Override
public DatasetGraph createDataset(Assembler a, Resource root) {
DatasetGraph dsg = DatasetGraphZero.create();
AssemblerUtils.mergeContext(root, dsg.getContext());
return dsg;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import static org.apache.jena.sparql.core.assembler.AssemblerUtils.loadData;
import static org.apache.jena.sparql.core.assembler.AssemblerUtils.mergeContext;

import java.util.Map;

import org.apache.jena.assembler.Assembler;
import org.apache.jena.query.Dataset;
import org.apache.jena.rdf.model.Resource;
Expand All @@ -39,11 +37,6 @@ public class InMemDatasetAssembler extends NamedDatasetAssembler {

public InMemDatasetAssembler() {}

@Override
public Map<String, DatasetGraph> pool() {
return sharedDatasetPool;
}

public static Resource getType() {
return DatasetAssemblerVocab.tMemoryDataset ;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public final DatasetGraph createNamedDataset(Assembler a, Resource root) {
return createDataset(a, root);
}

/** Shared {@link DatasetGraph} objects */
public abstract Map<String, DatasetGraph> pool();
/**
* Shared {@link DatasetGraph} objects.
* Subclasses may override for a different policy, or return null for "don't pool".
* Pools only affect {@link #createNamedDataset} and then only when {@code ja:name}
* ({@code DatasetAssemblerVocab.pDatasetName}) is present.
*/
public Map<String, DatasetGraph> pool() { return sharedDatasetPool; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

package org.apache.jena.sparql.core.assembler;

import java.util.Map;

import org.apache.jena.assembler.Assembler;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.sparql.core.DatasetGraph;
Expand All @@ -38,11 +36,6 @@ public class ViewDatasetAssembler extends NamedDatasetAssembler {

public ViewDatasetAssembler() {}

@Override
public Map<String, DatasetGraph> pool() {
return sharedDatasetPool;
}

@Override
public DatasetGraph createDataset(Assembler a, Resource root) {
DatasetGraph sub = createBaseDataset(root, DatasetAssemblerVocab.pDataset);
Expand Down
60 changes: 14 additions & 46 deletions jena-base/src/main/java/org/apache/jena/atlas/logging/LogCtl.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
* This needs access to log4j2 binaries including log4j-core, which is encapsulated in LogCtlLog4j2.
*/
public class LogCtl {
private static final boolean hasLog4j2 = hasClass("org.apache.logging.slf4j.Log4jLoggerFactory");
private static final boolean hasLog4j1 = hasClass("org.slf4j.impl.Log4jLoggerFactory");
private static final boolean hasJUL = hasClass("org.slf4j.impl.JDK14LoggerFactory");
private static final boolean hasLog4j2 = hasClass("org.apache.logging.slf4j.Log4jLoggerFactory");
private static final boolean hasLog4j1 = hasClass("org.slf4j.impl.Log4jLoggerFactory");
// JUL always present but needs slf4j adapter.
private static final boolean hasJUL = hasClass("org.slf4j.impl.JDK14LoggerFactory");
private static final boolean hasLogback = hasClass("ch.qos.logback.core.LogbackException");
// Put per-logging system code in separate classes to avoid needing them on the classpath.

private static boolean hasClass(String className) {
Expand Down Expand Up @@ -83,67 +84,34 @@ public static String getLevel(String logger) {
String s2 = getLevelLog4j2(logger);
if ( s2 != null )
return s2;
// Always present.
String s3 = getLevelJUL(logger);
if ( s3 != null )
return s3;
return null;
}

static private String getLevelJUL(String logger) {
java.util.logging.Level level = java.util.logging.Logger.getLogger(logger).getLevel();
if ( level == null )
static private String getLevelLog4j2(String logger) {
if ( !hasLog4j2 )
return null;
if ( level == java.util.logging.Level.SEVERE )
return "ERROR";
return level.getName();
return LogCtlLog4j2.getLoggerlevel(logger);
}

static private String getLevelLog4j2(String logger) {
if ( !hasLog4j2 )
static private String getLevelJUL(String logger) {
if ( ! hasJUL )
return null;
org.apache.logging.log4j.Level level = org.apache.logging.log4j.LogManager.getLogger(logger).getLevel();
if ( level != null )
return level.toString();
return null;
return LogCtlJUL.getLevelJUL(logger);
}

private static void setLevelJUL(String logger, String levelName) {
java.util.logging.Level level = java.util.logging.Level.ALL;
if ( levelName == null )
level = null;
else if ( levelName.equalsIgnoreCase("info") )
level = java.util.logging.Level.INFO;
else if ( levelName.equalsIgnoreCase("debug") )
level = java.util.logging.Level.FINE;
else if ( levelName.equalsIgnoreCase("warn") || levelName.equalsIgnoreCase("warning") )
level = java.util.logging.Level.WARNING;
else if ( levelName.equalsIgnoreCase("error") || levelName.equalsIgnoreCase("severe") )
level = java.util.logging.Level.SEVERE;
else if ( levelName.equalsIgnoreCase("OFF") )
level = java.util.logging.Level.OFF;
java.util.logging.Logger.getLogger(logger).setLevel(level);
if ( ! hasJUL )
return ;
LogCtlJUL.setLevelJUL(logger, levelName);
}

private static void setLevelLog4j2(String logger, String levelName) {
if ( !hasLog4j2 )
return;
org.apache.logging.log4j.Level level = org.apache.logging.log4j.Level.ALL;
if ( levelName == null )
level = null;
else if ( levelName.equalsIgnoreCase("info") )
level = org.apache.logging.log4j.Level.INFO;
else if ( levelName.equalsIgnoreCase("debug") )
level = org.apache.logging.log4j.Level.DEBUG;
else if ( levelName.equalsIgnoreCase("warn") || levelName.equalsIgnoreCase("warning") )
level = org.apache.logging.log4j.Level.WARN;
else if ( levelName.equalsIgnoreCase("error") || levelName.equalsIgnoreCase("severe") )
level = org.apache.logging.log4j.Level.ERROR;
else if ( levelName.equalsIgnoreCase("fatal") )
level = org.apache.logging.log4j.Level.FATAL;
else if ( levelName.equalsIgnoreCase("OFF") )
level = org.apache.logging.log4j.Level.OFF;
LogCtlLog4j2.setLoggerlevel(logger, level);
LogCtlLog4j2.setLoggerlevel(logger, levelName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,32 @@ public class LogCtlJUL {

private LogCtlJUL() {}

/*package*/ static String getLevelJUL(String logger) {
java.util.logging.Level level = java.util.logging.Logger.getLogger(logger).getLevel();
if ( level == null )
return null;
if ( level == java.util.logging.Level.SEVERE )
return "ERROR";
return level.getName();
}

/*package*/ static void setLevelJUL(String logger, String levelName) {
java.util.logging.Level level = java.util.logging.Level.ALL;
if ( levelName == null )
level = null;
else if ( levelName.equalsIgnoreCase("info") )
level = java.util.logging.Level.INFO;
else if ( levelName.equalsIgnoreCase("debug") )
level = java.util.logging.Level.FINE;
else if ( levelName.equalsIgnoreCase("warn") || levelName.equalsIgnoreCase("warning") )
level = java.util.logging.Level.WARNING;
else if ( levelName.equalsIgnoreCase("error") || levelName.equalsIgnoreCase("severe") )
level = java.util.logging.Level.SEVERE;
else if ( levelName.equalsIgnoreCase("OFF") )
level = java.util.logging.Level.OFF;
java.util.logging.Logger.getLogger(logger).setLevel(level);
}

/**
* Reset java.util.logging - this overrides the previous configuration, if any.
*/
Expand Down
Loading
Loading