You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2018/08/07 12:02:16 UTC
[04/16] jena git commit: JENA-1585: Fuseki core reorg
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/Backup.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/Backup.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/Backup.java
new file mode 100644
index 0000000..4bf9496
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/Backup.java
@@ -0,0 +1,131 @@
+/**
+ * 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.fuseki.ctl;
+
+import java.io.* ;
+import java.util.Collections;
+import java.util.Set ;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.zip.GZIPOutputStream ;
+
+import org.apache.jena.atlas.io.IO ;
+import org.apache.jena.atlas.lib.DateTimeUtils ;
+import org.apache.jena.atlas.logging.Log ;
+import org.apache.jena.fuseki.Fuseki ;
+import org.apache.jena.fuseki.FusekiException ;
+import org.apache.jena.fuseki.webapp.FusekiSystem;
+import org.apache.jena.query.ReadWrite ;
+import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RDFDataMgr ;
+import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.core.Transactional ;
+import org.apache.jena.sparql.core.TransactionalNull ;
+
+/** Perform a backup */
+public class Backup
+{
+ public static String chooseFileName(String dsName) {
+ // Without the "/" - ie. a relative name.
+ String ds = dsName ;
+ if ( ds.startsWith("/") )
+ ds = ds.substring(1) ;
+ if ( ds.contains("/") ) {
+ Fuseki.adminLog.warn("Dataset name: weird format: "+dsName) ;
+ // Some kind of fixup
+ ds = ds.replace("/", "_") ;
+ }
+
+ String timestamp = DateTimeUtils.nowAsString("yyyy-MM-dd_HH-mm-ss") ;
+ String filename = ds + "_" + timestamp ;
+ filename = FusekiSystem.dirBackups.resolve(filename).toString() ;
+ return filename ;
+ }
+
+ // Record of all backups so we don't attempt to backup the
+ // same dataset multiple times at the same time.
+ private static Set<DatasetGraph> activeBackups = Collections.newSetFromMap(new ConcurrentHashMap<>());
+
+ /** Perform a backup.
+ * A backup is a dump of the dataset in compressed N-Quads, done inside a transaction.
+ */
+ public static void backup(Transactional transactional, DatasetGraph dsg, String backupfile) {
+ if ( transactional == null )
+ transactional = new TransactionalNull() ;
+ transactional.begin(ReadWrite.READ);
+ try {
+ Backup.backup(dsg, backupfile) ;
+ } catch (Exception ex) {
+ Log.warn(Fuseki.serverLog, "Exception in backup", ex);
+ }
+ finally {
+ transactional.end() ;
+ }
+ }
+
+ /** Perform a backup.
+ *
+ * @see #backup(Transactional, DatasetGraph, String)
+ */
+ private static void backup(DatasetGraph dsg, String backupfile) {
+ if ( !backupfile.endsWith(".nq") )
+ backupfile = backupfile + ".nq" ;
+
+ // Per backup source lock.
+ synchronized(activeBackups) {
+ // Atomically check-and-set
+ if ( activeBackups.contains(dsg) )
+ Log.warn(Fuseki.serverLog, "Backup already in progress") ;
+ activeBackups.add(dsg) ;
+ }
+
+ OutputStream out = null ;
+ try {
+
+ if ( true ) {
+ // This seems to achive about the same as "gzip -6"
+ // It's not too expensive in elapsed time but it's not
+ // zero cost. GZip, large buffer.
+ out = new FileOutputStream(backupfile + ".gz") ;
+ out = new GZIPOutputStream(out, 8 * 1024) ;
+ out = new BufferedOutputStream(out) ;
+ } else {
+ out = new FileOutputStream(backupfile) ;
+ out = new BufferedOutputStream(out) ;
+ }
+ RDFDataMgr.write(out, dsg, Lang.NQUADS) ;
+ out.close() ;
+ out = null ;
+ } catch (FileNotFoundException e) {
+ Log.warn(Fuseki.serverLog, "File not found: " + backupfile) ;
+ throw new FusekiException("File not found: " + backupfile) ;
+ } catch (IOException e) {
+ IO.exception(e) ;
+ } finally {
+ try {
+ if ( out != null )
+ out.close() ;
+ } catch (IOException e) { /* ignore */}
+ // Remove lock.
+ synchronized(activeBackups) {
+ activeBackups.remove(dsg) ;
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/JsonConstCtl.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/JsonConstCtl.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/JsonConstCtl.java
new file mode 100644
index 0000000..7007098
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/JsonConstCtl.java
@@ -0,0 +1,29 @@
+/*
+ * 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.fuseki.ctl;
+
+public class JsonConstCtl {
+
+ public static final String taskId = "taskId" ;
+ public static final String taskRequestId = "requestId" ;
+ public static final String task = "task" ;
+ public static final String finished = "finished" ;
+ public static final String started = "started" ;
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/TaskBase.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/TaskBase.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/TaskBase.java
new file mode 100644
index 0000000..f885839
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/TaskBase.java
@@ -0,0 +1,43 @@
+/**
+ * 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.fuseki.ctl;
+
+import org.apache.jena.fuseki.servlets.HttpAction ;
+import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.core.Transactional ;
+
+/** Base of async tasks - this caries some useful information around, leaving the
+ * implementation of Callable.run() to the specific task.
+ */
+abstract class TaskBase implements Runnable {
+ public final long actionId ;
+ public final DatasetGraph dataset ;
+ public final String datasetName ;
+ public final Transactional transactional ;
+
+ protected TaskBase(HttpAction action) {
+ // The action is closed as part of action processing so is not
+ // available in the async task. Anything from it that is needed,
+ // taken out here.
+ this.actionId = action.id ;
+ this.dataset = action.getDataset() ;
+ this.transactional = action.getTransactional() ;
+ this.datasetName = action.getDatasetName() ;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
index 483fb65..aa1340b 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
@@ -31,7 +31,7 @@ import org.apache.jena.fuseki.Fuseki ;
import org.apache.jena.fuseki.FusekiException ;
import org.apache.jena.fuseki.mgt.MgtJMX ;
import org.apache.jena.fuseki.server.DataAccessPointRegistry ;
-import org.apache.jena.fuseki.server.FusekiEnv ;
+import org.apache.jena.fuseki.webapp.FusekiEnv;
import org.eclipse.jetty.security.* ;
import org.eclipse.jetty.security.authentication.BasicAuthenticator ;
import org.eclipse.jetty.server.HttpConnectionFactory ;
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionAsyncTask.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionAsyncTask.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionAsyncTask.java
deleted file mode 100644
index 69206e0..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionAsyncTask.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * 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.fuseki.mgt;
-
-import org.apache.jena.atlas.json.JsonValue ;
-import org.apache.jena.atlas.lib.InternalErrorException ;
-import org.apache.jena.fuseki.async.AsyncPool ;
-import org.apache.jena.fuseki.async.AsyncTask ;
-import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.fuseki.servlets.ServletOps ;
-
-/** Base helper class for creating async tasks on "items", based on POST */
-public abstract class ActionAsyncTask extends ActionItem
-{
- public ActionAsyncTask() { super() ; }
-
- @Override
- final
- protected void execGet(HttpAction action) {
- ServletOps.errorMethodNotAllowed(METHOD_GET);
- }
-
- @Override
- final
- protected JsonValue execGetItem(HttpAction action) {
- throw new InternalErrorException("GET for AsyncTask -- Should not be here!") ;
- }
-
- @Override
- final
- protected JsonValue execPostItem(HttpAction action) {
- Runnable task = createRunnable(action) ;
- AsyncTask aTask = Async.execASyncTask(action, AsyncPool.get(), "backup", task) ;
- Async.setLocationHeader(action, aTask);
- return Async.asJson(aTask) ;
- }
-
- protected abstract Runnable createRunnable(HttpAction action) ;
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java
deleted file mode 100644
index a08b15a..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * 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.fuseki.mgt;
-
-import static java.lang.String.format ;
-import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.fuseki.servlets.ServletOps ;
-import org.slf4j.Logger ;
-import org.slf4j.LoggerFactory ;
-
-public class ActionBackup extends ActionAsyncTask
-{
- public ActionBackup() { super() ; }
-
- @Override
- protected Runnable createRunnable(HttpAction action) {
- String name = action.getDatasetName() ;
- if ( name == null ) {
- action.log.error("Null for dataset name in item request") ;
- ServletOps.errorOccurred("Null for dataset name in item request");
- return null ;
- }
-
- action.log.info(format("[%d] Backup dataset %s", action.id, name)) ;
- return new BackupTask(action) ;
- }
-
- static class BackupTask extends TaskBase {
- static private Logger log = LoggerFactory.getLogger("Backup") ;
-
- public BackupTask(HttpAction action) {
- super(action) ;
- }
-
- @Override
- public void run() {
- try {
- String backupFilename = Backup.chooseFileName(datasetName) ;
- log.info(format("[%d] >>>> Start backup %s -> %s", actionId, datasetName, backupFilename)) ;
- Backup.backup(transactional, dataset, backupFilename) ;
- log.info(format("[%d] <<<< Finish backup %s -> %s", actionId, datasetName, backupFilename)) ;
- } catch (Exception ex) {
- log.info(format("[%d] **** Exception in backup", actionId), ex) ;
- }
- }
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java
deleted file mode 100644
index cf9c3cd..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * 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.fuseki.mgt;
-
-import static java.lang.String.format ;
-
-import java.io.File ;
-import java.io.IOException ;
-import java.nio.file.DirectoryStream ;
-import java.nio.file.Files ;
-import java.nio.file.Path ;
-import java.util.ArrayList ;
-import java.util.List ;
-import java.util.stream.Collectors ;
-
-import javax.servlet.http.HttpServletRequest ;
-import javax.servlet.http.HttpServletResponse ;
-
-import org.apache.jena.atlas.json.JsonBuilder ;
-import org.apache.jena.atlas.json.JsonValue ;
-import org.apache.jena.fuseki.server.FusekiSystem ;
-import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.fuseki.servlets.ServletOps ;
-
-/**
- * A JSON API to list all the backups in the backup directory
- */
-public class ActionBackupList extends ActionCtl {
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
- doCommon(req, resp);
- }
-
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
- doCommon(req, resp);
- }
-
- @Override
- protected void perform(HttpAction action) {
- JsonValue result = description(action) ;
- ServletOps.setNoCache(action.response) ;
- ServletOps.sendJsonReponse(action, result);
- }
-
- private static DirectoryStream.Filter<Path> filterVisibleFiles = (entry) -> {
- File f = entry.toFile() ;
- return f.isFile() && !f.isHidden() ;
- } ;
-
- private JsonValue description(HttpAction action) {
- if ( ! Files.isDirectory(FusekiSystem.dirBackups) )
- ServletOps.errorOccurred(format("[%d] Backup area '%s' is not a directory", action.id, FusekiSystem.dirBackups)) ;
-
- List<Path> paths = new ArrayList<>() ;
- try (DirectoryStream<Path> stream = Files.newDirectoryStream(FusekiSystem.dirBackups, filterVisibleFiles)) {
- stream.forEach(paths::add) ;
- } catch (IOException ex) {
- action.log.error(format("[%d] Backup file list :: IOException :: %s", action.id, ex.getMessage())) ;
- ServletOps.errorOccurred(ex);
- }
-
- List<String> fileNames = paths.stream().map((p)->p.getFileName().toString()).sorted().collect(Collectors.toList()) ;
-
- JsonBuilder builder = new JsonBuilder() ;
- builder.startObject("top") ;
- builder.key("backups") ;
-
- builder.startArray() ;
- fileNames.forEach(builder::value) ;
- builder.finishArray() ;
-
- builder.finishObject("top") ;
- return builder.build() ;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionContainerItem.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionContainerItem.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionContainerItem.java
deleted file mode 100644
index 803e249..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionContainerItem.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * 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.fuseki.mgt;
-
-import javax.servlet.http.HttpServletRequest ;
-import javax.servlet.http.HttpServletResponse ;
-
-import org.apache.jena.atlas.json.JsonValue ;
-import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.fuseki.servlets.ServletOps ;
-import org.apache.jena.web.HttpSC ;
-
-/** Base for actions that are container and also have action on items */
-public abstract class ActionContainerItem extends ActionCtl {
-
- public ActionContainerItem() { super() ; }
-
- // Redirect operations so they dispatch to perform(HttpAction)
- @Override
- final protected void doGet(HttpServletRequest request, HttpServletResponse response) {
- doCommon(request, response);
- }
-
- @Override
- final protected void doPost(HttpServletRequest request, HttpServletResponse response) {
- doCommon(request, response);
- }
-
- @Override
- final protected void doHead(HttpServletRequest request, HttpServletResponse response) {
- doCommon(request, response);
- }
-
- @Override
- final protected void doDelete(HttpServletRequest request, HttpServletResponse response) {
- doCommon(request, response);
- }
-
- @Override
- final
- protected void perform(HttpAction action) {
- String method = action.request.getMethod() ;
- if ( method.equals(METHOD_GET) )
- execGet(action) ;
- else if ( method.equals(METHOD_POST) )
- execPost(action) ;
- else if ( method.equals(METHOD_DELETE) )
- execDelete(action) ;
- else
- ServletOps.error(HttpSC.METHOD_NOT_ALLOWED_405) ;
- }
-
- protected void execGet(HttpAction action) {
- JsonValue v ;
- if ( isContainerAction(action) )
- v = execGetContainer(action) ;
- else
- v = execGetItem(action) ;
-
- ServletOps.sendJsonReponse(action, v);
- }
-
- /** GET request on the container - respond with JSON, or null for plain 200 */
- protected abstract JsonValue execGetContainer(HttpAction action) ;
- /** GET request on an item in the container - respond with JSON, or null for plain 200 */
- protected abstract JsonValue execGetItem(HttpAction action) ;
-
- protected void execPost(HttpAction action) {
- JsonValue v ;
- if ( isContainerAction(action) )
- v = execPostContainer(action) ;
- else
- v = execPostItem(action) ;
-
- ServletOps.sendJsonReponse(action, v);
- }
-
- /** POST request on the container - respond with JSON, or null for plain 200 */
- protected abstract JsonValue execPostContainer(HttpAction action) ;
- /** POST request on an item in the container - respond with JSON, or null for plain 200 */
- protected abstract JsonValue execPostItem(HttpAction action) ;
-
-
- /** DELETE request */
- protected void execDelete(HttpAction action) {
- if ( isContainerAction(action) )
- execDeleteContainer(action) ;
- else
- execDeleteItem(action) ;
- ServletOps.success(action) ;
- }
-
- /** DELETE request on an item in the container */
- protected void execDeleteContainer(HttpAction action) {
- ServletOps.errorMethodNotAllowed(METHOD_DELETE, "DELETE applied to a container") ;
- }
-
- /** DELETE request on an item in the container */
- protected void execDeleteItem(HttpAction action) {
- ServletOps.errorMethodNotAllowed(METHOD_DELETE) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionCtl.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionCtl.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionCtl.java
deleted file mode 100644
index 24d55dd..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionCtl.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.fuseki.mgt;
-
-import org.apache.jena.fuseki.Fuseki ;
-import org.apache.jena.fuseki.server.DataAccessPoint ;
-import org.apache.jena.fuseki.servlets.ActionBase ;
-import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.fuseki.servlets.ServletOps ;
-
-/** Control/admin request lifecycle */
-public abstract class ActionCtl extends ActionBase {
-
- protected ActionCtl() { super(Fuseki.adminLog) ; }
-
- @Override
- final
- protected void execCommonWorker(HttpAction action) {
- DataAccessPoint dataAccessPoint ;
-
- String datasetUri = mapRequestToDatasetName(action) ;
- if ( datasetUri != null ) {
- dataAccessPoint = action.getDataAccessPointRegistry().get(datasetUri) ;
- if ( dataAccessPoint == null ) {
- ServletOps.errorNotFound("Not found: "+datasetUri) ;
- return ;
- }
- }
- else {
- // This is a placeholder when creating new DatasetRefs
- // and also if addressing a container, not a dataset
- dataAccessPoint = null ;
- }
-
- action.setControlRequest(dataAccessPoint, datasetUri) ;
- action.setEndpoint(null, null) ; // No operation or service name.
- executeAction(action) ;
- }
-
- protected String mapRequestToDatasetName(HttpAction action) {
- return extractItemName(action) ;
- }
-
- // Possible intercept point
- protected void executeAction(HttpAction action) {
- executeLifecycle(action) ;
- }
-
- // This is the service request lifecycle.
- final
- protected void executeLifecycle(HttpAction action) {
- perform(action) ;
- }
-
- final
- protected boolean isContainerAction(HttpAction action) {
- return (action.getDataAccessPoint() == null ) ;
- }
-
- protected abstract void perform(HttpAction action) ;
-
-// /** Map request to uri in the registry.
-// * null means no mapping done (passthrough).
-// */
-// protected String mapRequestToDataset(HttpAction action)
-// {
-// return ActionLib.mapRequestToDataset(action.request.getRequestURI()) ;
-// }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
index e34bf25..8ee6ff5 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
@@ -42,11 +42,14 @@ import org.apache.jena.fuseki.build.DatasetDescriptionRegistry ;
import org.apache.jena.fuseki.build.FusekiBuilder ;
import org.apache.jena.fuseki.build.Template ;
import org.apache.jena.fuseki.build.TemplateFunctions ;
+import org.apache.jena.fuseki.ctl.ActionContainerItem;
import org.apache.jena.fuseki.server.* ;
import org.apache.jena.fuseki.servlets.ActionLib;
import org.apache.jena.fuseki.servlets.HttpAction;
import org.apache.jena.fuseki.servlets.ServletOps;
-import org.apache.jena.fuseki.servlets.Upload;
+import org.apache.jena.fuseki.system.Upload;
+import org.apache.jena.fuseki.webapp.FusekiSystem;
+import org.apache.jena.fuseki.webapp.SystemState;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.NodeFactory ;
import org.apache.jena.query.Dataset ;
@@ -87,7 +90,7 @@ public class ActionDatasets extends ActionContainerItem {
action.log.info(format("[%d] GET datasets", action.id)) ;
JsonBuilder builder = new JsonBuilder() ;
builder.startObject("D") ;
- builder.key(JsonConst.datasets) ;
+ builder.key(MgtConst.datasets) ;
JsonDescription.arrayDatasets(builder, action.getDataAccessPointRegistry());
builder.finishObject("D") ;
return builder.build() ;
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionItem.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionItem.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionItem.java
index 72d3c65..3308880 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionItem.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionItem.java
@@ -19,6 +19,7 @@
package org.apache.jena.fuseki.mgt;
import org.apache.jena.atlas.json.JsonValue ;
+import org.apache.jena.fuseki.ctl.ActionContainerItem;
import org.apache.jena.fuseki.servlets.HttpAction ;
import org.apache.jena.fuseki.servlets.ServletOps ;
import org.apache.jena.web.HttpSC ;
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionLogs.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionLogs.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionLogs.java
index c4d6579..aeb83f4 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionLogs.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionLogs.java
@@ -27,6 +27,7 @@ import javax.servlet.ServletOutputStream ;
import javax.servlet.http.HttpServletRequest ;
import javax.servlet.http.HttpServletResponse ;
+import org.apache.jena.fuseki.ctl.ActionCtl;
import org.apache.jena.fuseki.servlets.HttpAction ;
import org.apache.jena.fuseki.servlets.ServletOps ;
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionPing.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionPing.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionPing.java
deleted file mode 100644
index 35e6136..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionPing.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * 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.fuseki.mgt;
-
-import static org.apache.jena.riot.WebContent.charsetUTF8 ;
-import static org.apache.jena.riot.WebContent.contentTypeTextPlain ;
-
-import java.io.IOException ;
-
-import javax.servlet.ServletOutputStream ;
-import javax.servlet.http.HttpServlet ;
-import javax.servlet.http.HttpServletRequest ;
-import javax.servlet.http.HttpServletResponse ;
-
-import org.apache.jena.atlas.lib.DateTimeUtils ;
-import org.apache.jena.fuseki.Fuseki ;
-import org.apache.jena.fuseki.servlets.ServletOps ;
-import org.apache.jena.web.HttpSC ;
-
-/** The ping servlet provides a low cost, uncached endpoint that can be used
- * to determine if this component is running and responding. For example,
- * a nagios check should use this endpoint.
- */
-public class ActionPing extends HttpServlet
-{
- // Ping is special.
- // To avoid excessive logging and id allocation for a "noise" operation,
- // this is a raw servlet.
- public ActionPing() { super() ; }
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
- doCommon(req, resp);
- }
-
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
- doCommon(req, resp);
- }
-
-
- @Override
- protected void doHead(HttpServletRequest req, HttpServletResponse resp) {
- doCommon(req, resp);
- }
-
- protected void doCommon(HttpServletRequest request, HttpServletResponse response) {
- try {
- ServletOps.setNoCache(response) ;
- response.setContentType(contentTypeTextPlain);
- response.setCharacterEncoding(charsetUTF8) ;
- response.setStatus(HttpSC.OK_200);
- ServletOutputStream out = response.getOutputStream() ;
- out.println(DateTimeUtils.nowAsXSDDateTimeString());
- } catch (IOException ex) {
- Fuseki.serverLog.warn("ping :: IOException :: "+ex.getMessage());
- }
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionServerStatus.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionServerStatus.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionServerStatus.java
index bb75347..3e060cd 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionServerStatus.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionServerStatus.java
@@ -31,6 +31,7 @@ import org.apache.jena.atlas.json.JSON ;
import org.apache.jena.atlas.json.JsonBuilder ;
import org.apache.jena.atlas.json.JsonValue ;
import org.apache.jena.fuseki.Fuseki ;
+import org.apache.jena.fuseki.ctl.ActionCtl;
import org.apache.jena.fuseki.server.DataAccessPointRegistry ;
import org.apache.jena.fuseki.servlets.HttpAction ;
import org.apache.jena.fuseki.servlets.ServletOps ;
@@ -97,16 +98,16 @@ public class ActionServerStatus extends ActionCtl
// .finishObject() ;
builder
- .key(JsonConst.version).value(versionStr)
- .key(JsonConst.built).value(builtDateStr)
- .key(JsonConst.startDT).value(Fuseki.serverStartedAt())
- .key(JsonConst.uptime).value(Fuseki.serverUptimeSeconds())
+ .key(MgtConst.version).value(versionStr)
+ .key(MgtConst.built).value(builtDateStr)
+ .key(MgtConst.startDT).value(Fuseki.serverStartedAt())
+ .key(MgtConst.uptime).value(Fuseki.serverUptimeSeconds())
;
}
private void describeDatasets(JsonBuilder builder, DataAccessPointRegistry registry) {
- builder.key(JsonConst.datasets) ;
+ builder.key(MgtConst.datasets) ;
JsonDescription.arrayDatasets(builder, registry);
}
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionSleep.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionSleep.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionSleep.java
deleted file mode 100644
index 9dd939d..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionSleep.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * 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.fuseki.mgt;
-
-import static java.lang.String.format ;
-
-import javax.servlet.http.HttpServletRequest ;
-import javax.servlet.http.HttpServletResponse ;
-
-import org.apache.jena.atlas.json.JsonValue ;
-import org.apache.jena.atlas.lib.Lib ;
-import org.apache.jena.fuseki.async.AsyncPool ;
-import org.apache.jena.fuseki.async.AsyncTask ;
-import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.fuseki.servlets.ServletOps ;
-import org.slf4j.Logger ;
-
-/** A task that kicks off a asynchronous operation that simply waits and exits. For testing. */
-public class ActionSleep extends ActionCtl /* Not ActionAsyncTask - that is a container-item based.c */
-{
- public ActionSleep() { super() ; }
-
- // And only POST
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response) {
- doCommon(request, response);
- }
-
- @Override
- protected void perform(HttpAction action) {
- Runnable task = createRunnable(action) ;
- AsyncTask aTask = Async.execASyncTask(action, AsyncPool.get(), "sleep", task) ;
- JsonValue v = Async.asJson(aTask) ;
- Async.setLocationHeader(action, aTask);
- ServletOps.sendJsonReponse(action, v);
- }
-
- protected Runnable createRunnable(HttpAction action) {
- String name = action.getDatasetName() ;
- if ( name == null )
- name = "''" ;
-
- String interval = action.request.getParameter("interval") ;
- int sleepMilli = 5000 ;
- if ( interval != null )
- try {
- sleepMilli = Integer.parseInt(interval) ;
- } catch (NumberFormatException ex) {
- action.log.error(format("[%d] NumberFormatException: %s", action.id, interval)) ;
- }
- action.log.info(format("[%d] Sleep %s %d ms", action.id, name, sleepMilli)) ;
- return new SleepTask(action, sleepMilli) ;
- }
-
- static class SleepTask implements Runnable {
- private final Logger log ;
- private final long actionId ;
- private final int sleepMilli ;
-
- public SleepTask(HttpAction action, int sleepMilli ) {
- this.log = action.log ;
- this.actionId = action.id ;
- this.sleepMilli = sleepMilli ;
- }
-
- @Override
- public void run() {
- try {
- log.info(format("[%d] >> Sleep start", actionId)) ;
- Lib.sleep(sleepMilli) ;
- log.info(format("[%d] << Sleep finish", actionId)) ;
- } catch (Exception ex) {
- log.info(format("[%d] **** Exception", actionId), ex) ;
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java
deleted file mode 100644
index 54ee095..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/**
- * 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.fuseki.mgt;
-
-import static java.lang.String.format ;
-import static org.apache.jena.riot.WebContent.charsetUTF8 ;
-import static org.apache.jena.riot.WebContent.contentTypeTextPlain ;
-
-import java.io.IOException ;
-import java.util.Iterator ;
-import java.util.List ;
-
-import javax.servlet.ServletOutputStream ;
-import javax.servlet.http.HttpServletResponse ;
-
-import org.apache.jena.atlas.json.JsonBuilder ;
-import org.apache.jena.atlas.json.JsonObject ;
-import org.apache.jena.atlas.json.JsonValue ;
-import org.apache.jena.fuseki.server.* ;
-import org.apache.jena.fuseki.servlets.HttpAction ;
-
-public class ActionStats extends ActionContainerItem
-{
- public ActionStats() { super() ; }
-
- // This does not consult the system database for dormant etc.
- @Override
- protected JsonValue execGetContainer(HttpAction action) {
- action.log.info(format("[%d] GET stats all", action.id)) ;
- return generateStats(action.getDataAccessPointRegistry()) ;
- }
-
- public static JsonObject generateStats(DataAccessPointRegistry registry) {
- JsonBuilder builder = new JsonBuilder() ;
- builder.startObject("top") ;
- builder.key(JsonConst.datasets) ;
- builder.startObject("datasets") ;
- registry.forEach((name, access)->statsDataset(builder, access));
- builder.finishObject("datasets") ;
- builder.finishObject("top") ;
- return builder.build().getAsObject() ;
- }
-
- @Override
- protected JsonValue execGetItem(HttpAction action) {
- action.log.info(format("[%d] GET stats dataset %s", action.id, action.getDatasetName())) ;
-
- JsonBuilder builder = new JsonBuilder() ;
- String datasetPath = DataAccessPoint.canonical(action.getDatasetName()) ;
- builder.startObject("TOP") ;
-
- builder.key(JsonConst.datasets) ;
- builder.startObject("datasets") ;
- statsDataset(builder, datasetPath, action.getDataAccessPointRegistry()) ;
- builder.finishObject("datasets") ;
-
- builder.finishObject("TOP") ;
- return builder.build() ;
- }
-
- public static JsonObject generateStats(DataAccessPoint access) {
- JsonBuilder builder = new JsonBuilder() ;
- statsDataset(builder, access) ;
- return builder.build().getAsObject() ;
- }
-
- private void statsDataset(JsonBuilder builder, String name, DataAccessPointRegistry registry) {
- DataAccessPoint access = registry.get(name) ;
- statsDataset(builder, access);
- }
-
- private static void statsDataset(JsonBuilder builder, DataAccessPoint access) {
- // Object started
- builder.key(access.getName()) ;
- DataService dSrv = access.getDataService() ;
- builder.startObject("counters") ;
-
- builder.key(CounterName.Requests.getName()).value(dSrv.getCounters().value(CounterName.Requests)) ;
- builder.key(CounterName.RequestsGood.getName()).value(dSrv.getCounters().value(CounterName.RequestsGood)) ;
- builder.key(CounterName.RequestsBad.getName()).value(dSrv.getCounters().value(CounterName.RequestsBad)) ;
-
- builder.key(JsonConst.endpoints).startObject("endpoints") ;
-
- for ( Operation operName : dSrv.getOperations() ) {
- List<Endpoint> endpoints = access.getDataService().getEndpoints(operName) ;
-
- for ( Endpoint endpoint : endpoints ) {
- // Endpoint names are unique for a given service.
- builder.key(endpoint.getEndpoint()) ;
- builder.startObject() ;
-
- operationCounters(builder, endpoint);
- builder.key(JsonConst.operation).value(operName.getName()) ;
- builder.key(JsonConst.description).value(operName.getDescription());
-
- builder.finishObject() ;
- }
- }
- builder.finishObject("endpoints") ;
- builder.finishObject("counters") ;
- }
-
- private static void operationCounters(JsonBuilder builder, Endpoint operation) {
- for (CounterName cn : operation.getCounters().counters()) {
- Counter c = operation.getCounters().get(cn) ;
- builder.key(cn.getName()).value(c.value()) ;
- }
- }
-
- private void statsTxt(HttpServletResponse resp, DataAccessPointRegistry registry) throws IOException
- {
- ServletOutputStream out = resp.getOutputStream() ;
- resp.setContentType(contentTypeTextPlain);
- resp.setCharacterEncoding(charsetUTF8) ;
-
- Iterator<String> iter = registry.keys().iterator() ;
- while(iter.hasNext())
- {
- String ds = iter.next() ;
- DataAccessPoint desc = registry.get(ds) ;
- statsTxt(out, desc) ;
- if ( iter.hasNext() )
- out.println() ;
- }
- out.flush() ;
- }
-
- private void statsTxt(ServletOutputStream out, DataAccessPoint desc) throws IOException
- {
- DataService dSrv = desc.getDataService() ;
- out.println("Dataset: "+desc.getName()) ;
- out.println(" Requests = "+dSrv.getCounters().value(CounterName.Requests)) ;
- out.println(" Good = "+dSrv.getCounters().value(CounterName.RequestsGood)) ;
- out.println(" Bad = "+dSrv.getCounters().value(CounterName.RequestsBad)) ;
-
- out.println(" SPARQL Query:") ;
- out.println(" Request = "+counter(dSrv, Operation.Query, CounterName.Requests)) ;
- out.println(" Good = "+counter(dSrv, Operation.Query, CounterName.RequestsGood)) ;
- out.println(" Bad requests = "+counter(dSrv, Operation.Query, CounterName.RequestsBad)) ;
- out.println(" Timeouts = "+counter(dSrv, Operation.Query, CounterName.QueryTimeouts)) ;
- out.println(" Bad exec = "+counter(dSrv, Operation.Query, CounterName.QueryExecErrors)) ;
- out.println(" IO Errors = "+counter(dSrv, Operation.Query, CounterName.QueryIOErrors)) ;
-
- out.println(" SPARQL Update:") ;
- out.println(" Request = "+counter(dSrv, Operation.Update, CounterName.Requests)) ;
- out.println(" Good = "+counter(dSrv, Operation.Update, CounterName.RequestsGood)) ;
- out.println(" Bad requests = "+counter(dSrv, Operation.Update, CounterName.RequestsBad)) ;
- out.println(" Bad exec = "+counter(dSrv, Operation.Update, CounterName.UpdateExecErrors)) ;
-
- out.println(" Upload:") ;
- out.println(" Requests = "+counter(dSrv, Operation.Upload, CounterName.Requests)) ;
- out.println(" Good = "+counter(dSrv, Operation.Upload, CounterName.RequestsGood)) ;
- out.println(" Bad = "+counter(dSrv, Operation.Upload, CounterName.RequestsBad)) ;
-
- out.println(" SPARQL Graph Store Protocol:") ;
- out.println(" GETs = "+gspValue(dSrv, CounterName.HTTPget) + " (good="+gspValue(dSrv, CounterName.HTTPgetGood)+"/bad="+gspValue(dSrv, CounterName.HTTPgetBad)+")") ;
- out.println(" PUTs = "+gspValue(dSrv, CounterName.HTTPput) + " (good="+gspValue(dSrv, CounterName.HTTPputGood)+"/bad="+gspValue(dSrv, CounterName.HTTPputBad)+")") ;
- out.println(" POSTs = "+gspValue(dSrv, CounterName.HTTPpost) + " (good="+gspValue(dSrv, CounterName.HTTPpostGood)+"/bad="+gspValue(dSrv, CounterName.HTTPpostBad)+")") ;
- out.println(" PATCHs = "+gspValue(dSrv, CounterName.HTTPpatch) + " (good="+gspValue(dSrv, CounterName.HTTPpatchGood)+"/bad="+gspValue(dSrv, CounterName.HTTPpatchBad)+")") ;
- out.println(" DELETEs = "+gspValue(dSrv, CounterName.HTTPdelete) + " (good="+gspValue(dSrv, CounterName.HTTPdeleteGood)+"/bad="+gspValue(dSrv, CounterName.HTTPdeleteBad)+")") ;
- out.println(" HEADs = "+gspValue(dSrv, CounterName.HTTPhead) + " (good="+gspValue(dSrv, CounterName.HTTPheadGood)+"/bad="+gspValue(dSrv, CounterName.HTTPheadBad)+")") ;
- }
-
- private long counter(DataService dSrv, Operation operation, CounterName cName) {
- return 0 ;
- }
-
- private long gspValue(DataService dSrv, CounterName cn) {
- return counter(dSrv, Operation.GSP_RW, cn) +
- counter(dSrv, Operation.GSP_R, cn) ;
- }
-
- // We shouldn't get here - no doPost above.
-
- @Override
- protected JsonValue execPostContainer(HttpAction action) {
- throw new InternalError(METHOD_POST+" container") ;
- }
-
- @Override
- protected JsonValue execPostItem(HttpAction action) {
- throw new InternalError(METHOD_POST+" item") ;
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionTasks.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionTasks.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionTasks.java
deleted file mode 100644
index 97f8027..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionTasks.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * 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.fuseki.mgt;
-import static java.lang.String.format ;
-
-import javax.servlet.http.HttpServletRequest ;
-import javax.servlet.http.HttpServletResponse ;
-
-import org.apache.jena.atlas.json.JsonBuilder ;
-import org.apache.jena.atlas.json.JsonValue ;
-import org.apache.jena.fuseki.Fuseki ;
-import org.apache.jena.fuseki.async.AsyncPool ;
-import org.apache.jena.fuseki.async.AsyncTask ;
-import org.apache.jena.fuseki.servlets.ActionBase ;
-import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.fuseki.servlets.ServletOps ;
-import org.apache.jena.web.HttpSC ;
-
-public class ActionTasks extends ActionBase //ActionContainerItem
-{
- private static AsyncPool[] pools = { AsyncPool.get() } ;
-
- public ActionTasks() { super(Fuseki.serverLog) ; }
-
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response) {
- doCommon(request, response);
- }
-
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response) {
- doCommon(request, response);
- }
-
- private static String prefix = "/" ;
-
- @Override
- protected void execCommonWorker(HttpAction action) {
- String name = extractItemName(action) ;
- if ( name != null ) {
- if ( name.startsWith(prefix))
- name = name.substring(prefix.length()) ;
- else
- log.warn("Unexpected task name : "+name) ;
- }
-
- String method = action.request.getMethod() ;
- if ( method.equals(METHOD_GET) )
- execGet(action, name) ;
- else if ( method.equals(METHOD_POST) )
- execPost(action, name) ;
- else
- ServletOps.error(HttpSC.METHOD_NOT_ALLOWED_405) ;
- }
-
- private void execGet(HttpAction action, String name) {
- if ( name == null )
- log.info(format("[%d] Tasks", action.id));
- else
- log.info(format("[%d] Task %s", action.id, name));
-
- JsonValue responseBody = null ;
-
- if ( name == null ) {
- JsonBuilder builder = new JsonBuilder() ;
- builder.startArray() ;
-
- for ( AsyncPool pool : pools ) {
- for ( AsyncTask aTask : pool.tasks() ) {
- //builder.value(aTask.getTaskId()) ;
- descOneTask(builder, aTask) ;
- }
- }
- builder.finishArray() ;
- responseBody = builder.build();
- } else {
- for ( AsyncPool pool : pools ) {
- // Assumes first is only.
- AsyncTask aTask = pool.getTask(name) ;
- if ( aTask != null ) {
- JsonBuilder builder = new JsonBuilder() ;
- descOneTask(builder, aTask);
- responseBody = builder.build() ;
- }
- }
- }
-
- if ( responseBody == null )
- ServletOps.errorNotFound("Task '"+name+"' not found") ;
- ServletOps.setNoCache(action) ;
- ServletOps.sendJsonReponse(action, responseBody);
- }
-
- private void execPost(HttpAction action, String name) {
-
- }
-
- private static void descOneTask(JsonBuilder builder, AsyncTask aTask) {
- builder.startObject("SingleTask") ;
- builder.key(JsonConst.task).value(aTask.displayName()) ;
- builder.key(JsonConst.taskId).value(aTask.getTaskId()) ;
- if ( aTask.getStartPoint() != null )
- builder.key(JsonConst.started).value(aTask.getStartPoint()) ;
- if ( aTask.getFinishPoint() != null )
- builder.key(JsonConst.finished).value(aTask.getFinishPoint()) ;
- builder.finishObject("SingleTask") ;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Async.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Async.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Async.java
deleted file mode 100644
index 260fcb1..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Async.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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.fuseki.mgt;
-
-import org.apache.http.HttpHeaders ;
-import org.apache.jena.atlas.json.JsonBuilder ;
-import org.apache.jena.atlas.json.JsonValue ;
-import org.apache.jena.fuseki.async.AsyncPool ;
-import org.apache.jena.fuseki.async.AsyncTask ;
-import org.apache.jena.fuseki.server.DataService ;
-import org.apache.jena.fuseki.servlets.HttpAction ;
-
-public class Async
-{
- public static AsyncTask asyncTask(AsyncPool asyncPool, String displayName, DataService dataService, Runnable task, long requestId) {
- AsyncTask asyncTask = asyncPool.submit(task, displayName, dataService, requestId) ;
- return asyncTask ;
- }
-
- public static JsonValue asJson(AsyncTask asyncTask) {
- JsonBuilder builder = new JsonBuilder() ;
- builder.startObject("outer") ;
- builder.key(JsonConst.taskId).value(asyncTask.getTaskId()) ;
- if ( asyncTask.getOriginatingRequestId() > 0 )
- builder.key(JsonConst.taskRequestId).value(asyncTask.getOriginatingRequestId()) ;
- builder.finishObject("outer") ;
- return builder.build() ;
- }
-
- public static void setLocationHeader(HttpAction action, AsyncTask asyncTask) {
- String x = action.getRequest().getRequestURI() ;
- if ( ! x.endsWith("/") )
- x += "/" ;
- x += asyncTask.getTaskId() ;
- //String x = "/$/tasks/"+asyncTask.getTaskId() ;
- action.getResponse().setHeader(HttpHeaders.LOCATION, x) ;
- }
-
- public static AsyncTask execASyncTask(HttpAction action, AsyncPool asyncPool, String displayName, Runnable runnable) {
- AsyncTask atask = Async.asyncTask(asyncPool, displayName, action.getDataService(), runnable, action.id) ;
- Async.setLocationHeader(action, atask);
- return atask ;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Backup.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Backup.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Backup.java
deleted file mode 100644
index 840b85b..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Backup.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * 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.fuseki.mgt;
-
-import java.io.* ;
-import java.util.Collections;
-import java.util.Set ;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.zip.GZIPOutputStream ;
-
-import org.apache.jena.atlas.io.IO ;
-import org.apache.jena.atlas.lib.DateTimeUtils ;
-import org.apache.jena.atlas.logging.Log ;
-import org.apache.jena.fuseki.Fuseki ;
-import org.apache.jena.fuseki.FusekiException ;
-import org.apache.jena.fuseki.server.FusekiSystem ;
-import org.apache.jena.query.ReadWrite ;
-import org.apache.jena.riot.Lang ;
-import org.apache.jena.riot.RDFDataMgr ;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.sparql.core.Transactional ;
-import org.apache.jena.sparql.core.TransactionalNull ;
-
-/** Perform a backup */
-public class Backup
-{
- public static String chooseFileName(String dsName) {
- // Without the "/" - ie. a relative name.
- String ds = dsName ;
- if ( ds.startsWith("/") )
- ds = ds.substring(1) ;
- if ( ds.contains("/") ) {
- Fuseki.adminLog.warn("Dataset name: weird format: "+dsName) ;
- // Some kind of fixup
- ds = ds.replace("/", "_") ;
- }
-
- String timestamp = DateTimeUtils.nowAsString("yyyy-MM-dd_HH-mm-ss") ;
- String filename = ds + "_" + timestamp ;
- filename = FusekiSystem.dirBackups.resolve(filename).toString() ;
- return filename ;
- }
-
- // Record of all backups so we don't attempt to backup the
- // same dataset multiple times at the same time.
- private static Set<DatasetGraph> activeBackups = Collections.newSetFromMap(new ConcurrentHashMap<>());
-
- /** Perform a backup.
- * A backup is a dump of the dataset in compressed N-Quads, done inside a transaction.
- */
- public static void backup(Transactional transactional, DatasetGraph dsg, String backupfile) {
- if ( transactional == null )
- transactional = new TransactionalNull() ;
- transactional.begin(ReadWrite.READ);
- try {
- Backup.backup(dsg, backupfile) ;
- } catch (Exception ex) {
- Log.warn(Fuseki.serverLog, "Exception in backup", ex);
- }
- finally {
- transactional.end() ;
- }
- }
-
- /** Perform a backup.
- *
- * @see #backup(Transactional, DatasetGraph, String)
- */
- private static void backup(DatasetGraph dsg, String backupfile) {
- if ( !backupfile.endsWith(".nq") )
- backupfile = backupfile + ".nq" ;
-
- // Per backup source lock.
- synchronized(activeBackups) {
- // Atomically check-and-set
- if ( activeBackups.contains(dsg) )
- Log.warn(Fuseki.serverLog, "Backup already in progress") ;
- activeBackups.add(dsg) ;
- }
-
- OutputStream out = null ;
- try {
-
- if ( true ) {
- // This seems to achive about the same as "gzip -6"
- // It's not too expensive in elapsed time but it's not
- // zero cost. GZip, large buffer.
- out = new FileOutputStream(backupfile + ".gz") ;
- out = new GZIPOutputStream(out, 8 * 1024) ;
- out = new BufferedOutputStream(out) ;
- } else {
- out = new FileOutputStream(backupfile) ;
- out = new BufferedOutputStream(out) ;
- }
- RDFDataMgr.write(out, dsg, Lang.NQUADS) ;
- out.close() ;
- out = null ;
- } catch (FileNotFoundException e) {
- Log.warn(Fuseki.serverLog, "File not found: " + backupfile) ;
- throw new FusekiException("File not found: " + backupfile) ;
- } catch (IOException e) {
- IO.exception(e) ;
- } finally {
- try {
- if ( out != null )
- out.close() ;
- } catch (IOException e) { /* ignore */}
- // Remove lock.
- synchronized(activeBackups) {
- activeBackups.remove(dsg) ;
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/DumpServlet.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/DumpServlet.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/DumpServlet.java
index 0b2a070..da66a3c 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/DumpServlet.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/DumpServlet.java
@@ -41,19 +41,7 @@ import org.apache.jena.atlas.io.IO ;
public class DumpServlet extends HttpServlet
{
- private static final long serialVersionUID = 99L; // Serilizable.
-
-
- public DumpServlet()
- {
-
- }
-
- @Override
- public void init()
- {
- return ;
- }
+ public DumpServlet() { }
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonConst.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonConst.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonConst.java
deleted file mode 100644
index baaef7a..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonConst.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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.fuseki.mgt ;
-
-public class JsonConst
-{
- public static final String taskId = "taskId" ;
- public static final String taskRequestId = "requestId" ;
- public static final String task = "task" ;
- public static final String datasets = "datasets" ;
-
- public static final String finished = "finished" ;
- public static final String started = "started" ;
-
- public static final String uptime = "uptime" ;
- public static final String startDT = "startDateTime" ;
- public static final String server = "server" ;
- public static final String port = "port" ;
- public static final String hostname = "hostname" ;
- public static final String admin = "admin" ;
- public static final String version = "version" ;
- public static final String built = "built" ;
-
- public static final String services = "services" ;
- public static final String operation = "operation" ;
- public static final String description = "description" ;
- public static final String endpoints = "endpoints" ;
-
- public static final String dsName = "ds.name" ;
- public static final String dsState = "ds.state" ;
- public static final String dsService = "ds.services" ;
-
- public static final String srvType = "srv.type" ;
- public static final String srvDescription = "srv.description" ;
- public static final String srvEndpoints = "srv.endpoints" ;
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java
index c4158d7..749aa3e 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java
@@ -40,11 +40,11 @@ public class JsonDescription {
public static void describe(JsonBuilder builder, DataAccessPoint access) {
builder.startObject() ;
- builder.key(JsonConst.dsName).value(access.getName()) ;
+ builder.key(MgtConst.dsName).value(access.getName()) ;
- builder.key(JsonConst.dsState).value(access.getDataService().isAcceptingRequests()) ;
+ builder.key(MgtConst.dsState).value(access.getDataService().isAcceptingRequests()) ;
- builder.key(JsonConst.dsService) ;
+ builder.key(MgtConst.dsService) ;
builder.startArray() ;
for ( Operation operation : access.getDataService().getOperations() ) {
@@ -58,9 +58,9 @@ public class JsonDescription {
private static void describe(JsonBuilder builder, Operation operation, List<Endpoint> endpoints) {
builder.startObject() ;
- builder.key(JsonConst.srvType).value(operation.getName()) ;
- builder.key(JsonConst.srvDescription).value(operation.getDescription()) ;
- builder.key(JsonConst.srvEndpoints) ;
+ builder.key(MgtConst.srvType).value(operation.getName()) ;
+ builder.key(MgtConst.srvDescription).value(operation.getDescription()) ;
+ builder.key(MgtConst.srvEndpoints) ;
builder.startArray() ;
for ( Endpoint endpoint : endpoints )
builder.value(endpoint.getEndpoint()) ;
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/MgtConst.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/MgtConst.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/MgtConst.java
index 85cfd26..2659313 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/MgtConst.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/MgtConst.java
@@ -27,5 +27,26 @@ public class MgtConst {
public static final String opDatasets = "datasets" ;
public static final String opListBackups = "backups-list" ;
public static final String opServer = "server" ;
+
+ // JSON constants
+ public static final String datasets = "datasets" ;
+ public static final String uptime = "uptime" ;
+ public static final String startDT = "startDateTime" ;
+ public static final String server = "server" ;
+ public static final String port = "port" ;
+ public static final String hostname = "hostname" ;
+ public static final String admin = "admin" ;
+ public static final String version = "version" ;
+ public static final String built = "built" ;
+ public static final String services = "services" ;
+ public static final String operation = "operation" ;
+ public static final String description = "description" ;
+ public static final String endpoints = "endpoints" ;
+ public static final String dsName = "ds.name" ;
+ public static final String dsState = "ds.state" ;
+ public static final String dsService = "ds.services" ;
+ public static final String srvType = "srv.type" ;
+ public static final String srvDescription = "srv.description" ;
+ public static final String srvEndpoints = "srv.endpoints" ;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ServiceMXBean.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ServiceMXBean.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ServiceMXBean.java
new file mode 100644
index 0000000..72ce3a3
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ServiceMXBean.java
@@ -0,0 +1,32 @@
+/**
+ * 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.fuseki.mgt;
+
+public interface ServiceMXBean
+{
+ String getName() ;
+
+ long getRequests() ;
+ long getRequestsGood() ;
+ long getRequestsBad() ;
+
+// void enable() ;
+// void disable() ;
+}
+
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/TaskBase.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/TaskBase.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/TaskBase.java
deleted file mode 100644
index 52282e2..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/TaskBase.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.fuseki.mgt;
-
-import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.sparql.core.Transactional ;
-
-/** Base of async tasks - this caries some useful information around, leaving the
- * implementation of Callable.run() to the specific task.
- */
-abstract class TaskBase implements Runnable {
- public final long actionId ;
- public final DatasetGraph dataset ;
- public final String datasetName ;
- public final Transactional transactional ;
-
- protected TaskBase(HttpAction action) {
- // The action is closed as part of action processing so is not
- // available in the async task. Anything from it that is needed,
- // taken out here.
- this.actionId = action.id ;
- this.dataset = action.getDataset() ;
- this.transactional = action.getTransactional() ;
- this.datasetName = action.getDatasetName() ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/migrate/GraphLoadUtils.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/migrate/GraphLoadUtils.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/migrate/GraphLoadUtils.java
deleted file mode 100644
index 4e4c837..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/migrate/GraphLoadUtils.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.fuseki.migrate;
-
-import org.apache.jena.fuseki.Fuseki ;
-import org.apache.jena.graph.Factory ;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
-import org.apache.jena.riot.RDFParser ;
-import org.apache.jena.riot.system.StreamRDF ;
-import org.apache.jena.riot.system.StreamRDFLib ;
-
-/** A packaging of code to do a controlled read of a graph or model */
-
-public class GraphLoadUtils
-{
- // ---- Model level
-
- public static Model readModel(String uri, int limit)
- {
- Graph g = Factory.createGraphMem() ;
- readUtil(g, uri, limit) ;
- return ModelFactory.createModelForGraph(g) ;
- }
-
- public static void loadModel(Model model, String uri, int limit)
- {
- Graph g = model.getGraph() ;
- readUtil(g, uri, limit) ;
- }
-
- // ---- Graph level
-
- public static Graph readGraph(String uri, int limit)
- {
- Graph g = Factory.createGraphMem() ;
- readUtil(g, uri, limit) ;
- return g ;
- }
-
- public static void loadGraph(Graph g, String uri, int limit)
- {
- readUtil(g, uri, limit) ;
- }
-
- // ** Worker.
- private static void readUtil(Graph graph, String uri, int limit)
- {
- StreamRDF sink = StreamRDFLib.graph(graph) ;
- sink = new StreamRDFLimited(sink, limit) ;
- RDFParser.source(uri).streamManager(Fuseki.webStreamManager).parse(sink);
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/1d41d2ce/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/migrate/StreamRDFLimited.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/migrate/StreamRDFLimited.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/migrate/StreamRDFLimited.java
deleted file mode 100644
index 947fffa..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/migrate/StreamRDFLimited.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.fuseki.migrate ;
-
-import org.apache.jena.graph.Triple ;
-import org.apache.jena.riot.RiotException ;
-import org.apache.jena.riot.system.StreamRDF ;
-import org.apache.jena.riot.system.StreamRDFWrapper ;
-import org.apache.jena.sparql.core.Quad ;
-
-/**
- * Limit triples/quads and stop passing through after a limit is reached.
- */
-public class StreamRDFLimited extends StreamRDFWrapper {
- private long count = 0 ;
- private final long limit ;
-
- public StreamRDFLimited(StreamRDF output, long limit) {
- super(output) ;
- this.limit = limit ;
- }
-
- @Override
- public void triple(Triple triple) {
- count++ ;
- if ( count > limit )
- throw new RiotException("Limit ("+limit+") reached") ;
- super.triple(triple) ;
- }
-
- @Override
- public void quad(Quad quad) {
- count++ ;
- if ( count > limit )
- throw new RiotException("Limit ("+limit+") reached") ;
- super.quad(quad) ;
- }
-
- public long getCount() {
- return count ;
- }
-
- public long getLimit() {
- return limit ;
- }
-}