mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
merge of nb5-preview onto main, main is now the feed for nb5-preview work
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package io.nosqlbench.docsys;
|
||||
|
||||
import io.nosqlbench.docsys.api.Docs;
|
||||
import io.nosqlbench.docsys.api.DocsBinder;
|
||||
import io.nosqlbench.docapi.Docs;
|
||||
import io.nosqlbench.docapi.DocsBinder;
|
||||
import io.nosqlbench.docsys.api.DocsysStaticManifest;
|
||||
|
||||
//@Service(DocsysStaticManifest.class)
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
package io.nosqlbench.docsys.api;
|
||||
|
||||
import io.nosqlbench.nb.api.content.NBIO;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The Docs class is a utility class that makes it easy to enumerate docs for a component.
|
||||
* The primary info type which is used by the doc system is the DocsBinder.
|
||||
* A DocsBinder contains zero or more {@link DocsNameSpace}. A DocsNameSpace has a name,
|
||||
* a set of paths, and a flag that sets it enabled or disabled by default.
|
||||
*/
|
||||
public class Docs implements DocsBinder {
|
||||
|
||||
private LinkedList<DocsNameSpaceImpl> namespaces = new LinkedList<>();
|
||||
|
||||
public Docs() {
|
||||
}
|
||||
|
||||
public Docs namespace(String namespace) {
|
||||
return addNamespace(namespace);
|
||||
}
|
||||
|
||||
public Docs addFirstFoundPath(String... potentials) {
|
||||
Path pathIn = NBIO.getFirstLocalPath(potentials);
|
||||
|
||||
if (pathIn == null || !Files.exists(pathIn)) {
|
||||
throw new RuntimeException("Unable to find a path in one of " + Arrays.stream(potentials).collect(Collectors.joining(",")));
|
||||
}
|
||||
return this.addPath(pathIn);
|
||||
}
|
||||
|
||||
public Docs addPath(Path path) {
|
||||
if (namespaces.peekLast() == null) {
|
||||
throw new RuntimeException("You must add a namespace first.");
|
||||
}
|
||||
namespaces.peekLast().addPath(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Docs setEnabledByDefault(boolean enabledByDefault) {
|
||||
if (namespaces.peekLast() == null) {
|
||||
throw new RuntimeException("You must add a namespace first.");
|
||||
}
|
||||
namespaces.peekLast().setEnabledByDefault(enabledByDefault);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Docs addNamespace(String name) {
|
||||
namespaces.add(new DocsNameSpaceImpl(name));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocsBinder merge(DocsBinder other) {
|
||||
for (DocsNameSpace namespace : other.getNamespaces()) {
|
||||
this.namespace(namespace.getName());
|
||||
setEnabledByDefault(namespace.isEnabledByDefault());
|
||||
for (Path path : namespace.getPaths()) {
|
||||
addPath(path);
|
||||
}
|
||||
}
|
||||
return this.asDocsBinder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocsBinder merge(DocsNameSpace namespace) {
|
||||
this.namespace(namespace.getName());
|
||||
setEnabledByDefault(namespace.isEnabledByDefault());
|
||||
for (Path path : namespace) {
|
||||
this.addPath(path);
|
||||
}
|
||||
return this.asDocsBinder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Path> getPaths() {
|
||||
List<Path> paths = new ArrayList<>();
|
||||
for (DocsNameSpaceImpl ns : this.namespaces) {
|
||||
paths.addAll(ns.getPaths());
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Set<Path>> getPathMap() {
|
||||
Map<String, Set<Path>> pm = new HashMap();
|
||||
for (DocsNameSpaceImpl ns : this.namespaces) {
|
||||
pm.put(ns.getName(), new HashSet<>(ns.getPaths()));
|
||||
}
|
||||
return pm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DocsNameSpace> getNamespaces() {
|
||||
return new LinkedList<>(this.namespaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<DocsNameSpace> iterator() {
|
||||
List<DocsNameSpace> pathinfos = new ArrayList<>(this.namespaces);
|
||||
return pathinfos.iterator();
|
||||
}
|
||||
|
||||
public Map<String, Set<Path>> getPathMaps() {
|
||||
Map<String, Set<Path>> maps = new HashMap<>();
|
||||
for (DocsNameSpaceImpl namespace : namespaces) {
|
||||
Set<Path> paths = new HashSet<>();
|
||||
namespace.forEach(paths::add);
|
||||
maps.put(namespace.getName(), paths);
|
||||
}
|
||||
|
||||
return maps;
|
||||
}
|
||||
|
||||
public DocsBinder asDocsBinder() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocsBinder remove(Set<String> namespaces) {
|
||||
Docs removed = new Docs();
|
||||
ListIterator<DocsNameSpaceImpl> iter = this.namespaces.listIterator();
|
||||
while (iter.hasNext()) {
|
||||
DocsNameSpaceImpl next = iter.next();
|
||||
if (namespaces.contains(next.getName())) {
|
||||
iter.previous();
|
||||
iter.remove();
|
||||
removed.merge(next);
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package io.nosqlbench.docsys.api;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* DocsInfo is a manifest view of a set of namespaces and included
|
||||
* paths. The namespaces act as content slots to allow content to be
|
||||
* managed by different layers of artifacts. For example, a downstream
|
||||
* artifact can replace a context by replacing the same-named namespace.
|
||||
*
|
||||
* <pre>{@code
|
||||
* docsinfo = {
|
||||
* 'namespaces': [
|
||||
* {
|
||||
* 'namespace': 'example-namespace-1',
|
||||
* 'paths': ['path1','path2']
|
||||
* },
|
||||
* {
|
||||
* 'namespace': 'example-namespace-2',
|
||||
* 'paths': ['path-foo','other-path']
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* Internally, The namespace entries are represented by {@link DocsNameSpace} types.
|
||||
*/
|
||||
public interface DocsBinder extends Iterable<DocsNameSpace> {
|
||||
|
||||
/**
|
||||
* The result of merging two DocsInfo elements together
|
||||
* is a combined DocsInfo element with all unique namespaces
|
||||
* occurring exactly once, and with the other namespace overwriting
|
||||
* same-named namespaces in the original element.
|
||||
*
|
||||
* @param other The DocsInfo containing namespaces to overlay into this DocsInfo
|
||||
* @return
|
||||
*/
|
||||
DocsBinder merge(DocsBinder other);
|
||||
|
||||
/**
|
||||
* The result of merging a DocPathInfo entry into a DocsInfo element
|
||||
* is the combined DocsInfo element with the added entry overwriting
|
||||
* any namespace of the same name.
|
||||
*
|
||||
* @param other The namespace entry to overlay into this DocsInfo
|
||||
* @return
|
||||
*/
|
||||
DocsBinder merge(DocsNameSpace other);
|
||||
|
||||
/**
|
||||
* The result of removing a set of namespaces from a DocsInfo element
|
||||
* is a new DocsInfo element containing only the namespaces which were
|
||||
* removed. The original DocsInfo element is modified statefully in this
|
||||
* case. It is not an error to remove namespaces which are not present
|
||||
* in the original DocsInfo. If this condition is important, check for it
|
||||
* manually.
|
||||
*
|
||||
* @param namespaces The names of the namespaces to remove, should they
|
||||
* be present.
|
||||
* @return A new DocsInfo object representing what was actually removed.
|
||||
*/
|
||||
DocsBinder remove(Set<String> namespaces);
|
||||
|
||||
/**
|
||||
* @return All paths in all namespaces are returned, in no guaranteed order.
|
||||
*/
|
||||
List<Path> getPaths();
|
||||
|
||||
/**
|
||||
* @return A map of all namespaces to each set of provided paths is returned.
|
||||
*/
|
||||
Map<String, Set<Path>> getPathMap();
|
||||
|
||||
List<DocsNameSpace> getNamespaces();
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package io.nosqlbench.docsys.api;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Doc Path Info represents a readable Path which is part of a well-known
|
||||
* namespace.
|
||||
*
|
||||
* <pre>{@code
|
||||
* docpathinfo = {
|
||||
* 'namespace': 'example-namespace',
|
||||
* 'paths': ['path1', 'path2']
|
||||
* }
|
||||
*
|
||||
* }</pre>
|
||||
*
|
||||
* When callers are using doc paths from this interface, it is an error for
|
||||
* there to be multiple instance of a doc path of the same name in the same
|
||||
* namespace. As long as the root path of a doc tree is unique within the
|
||||
* given namespaces, they may be merged. This is to allow multiple contributors
|
||||
* of detailed docs to a single known namespace.
|
||||
*
|
||||
*/
|
||||
public interface DocsNameSpace extends Iterable<Path> {
|
||||
|
||||
/**
|
||||
* A simple name which can be used to nest the enclosed path within a larger
|
||||
* namespace. Users of this interface should never host content from the path
|
||||
* at a root level separate from the namespace.
|
||||
*
|
||||
* @return A canonical namespace identifier
|
||||
*/
|
||||
String getName();
|
||||
|
||||
List<Path> getPaths();
|
||||
|
||||
boolean isEnabledByDefault();
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package io.nosqlbench.docsys.api;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
public class DocsNameSpaceImpl implements DocsNameSpace {
|
||||
|
||||
private final Set<Path> paths = new HashSet<>();
|
||||
private String namespace;
|
||||
private boolean enabledByDefault = false;
|
||||
|
||||
public DocsNameSpaceImpl() {}
|
||||
|
||||
public static DocsNameSpaceImpl of(String descriptiveName, Path path) {
|
||||
return new DocsNameSpaceImpl().setNameSpace(descriptiveName).addPath(path);
|
||||
}
|
||||
|
||||
private DocsNameSpaceImpl setNameSpace(String namespace) {
|
||||
this.namespace = namespace;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DocsNameSpaceImpl(String name) {
|
||||
this.namespace = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Path> getPaths() {
|
||||
return new ArrayList<>(this.paths);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return enabledByDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DocPath{" +
|
||||
"namespace='" + namespace + '\'' +
|
||||
",paths=" + paths.toString() +
|
||||
'}';
|
||||
}
|
||||
|
||||
public DocsNameSpaceImpl addPath(Path path) {
|
||||
this.paths.add(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DocsNameSpaceImpl enabledByDefault() {
|
||||
this.enabledByDefault=true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Path> iterator() {
|
||||
return this.paths.iterator();
|
||||
}
|
||||
|
||||
public DocsNameSpaceImpl setEnabledByDefault(boolean enabledByDefault) {
|
||||
this.enabledByDefault=enabledByDefault;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.nosqlbench.docsys.api;
|
||||
|
||||
import io.nosqlbench.docapi.DocsBinder;
|
||||
import io.nosqlbench.docsys.endpoints.DocsysMarkdownEndpoint;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.docsys.api;
|
||||
|
||||
import io.nosqlbench.docapi.DocsBinder;
|
||||
|
||||
/**
|
||||
* At runtime, any instances of this service will be used to find
|
||||
* paths to be hosted as static content.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package io.nosqlbench.docsys.core;
|
||||
|
||||
import io.nosqlbench.docsys.api.*;
|
||||
import io.nosqlbench.docapi.*;
|
||||
import io.nosqlbench.docsys.api.DocsysDynamicManifest;
|
||||
import io.nosqlbench.docsys.api.DocsysStaticManifest;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
@@ -29,4 +31,6 @@ public class DocsysPathLoader {
|
||||
}
|
||||
return docs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package io.nosqlbench.docsys.core;
|
||||
|
||||
import io.nosqlbench.docsys.DocsysDefaultAppPath;
|
||||
import io.nosqlbench.docsys.api.Docs;
|
||||
import io.nosqlbench.docapi.Docs;
|
||||
import io.nosqlbench.docsys.api.WebServiceObject;
|
||||
import io.nosqlbench.docsys.handlers.FavIconHandler;
|
||||
import io.nosqlbench.nb.annotations.Maturity;
|
||||
import io.nosqlbench.nb.api.spi.SimpleServiceLoader;
|
||||
import jakarta.servlet.DispatcherType;
|
||||
import jakarta.servlet.ServletRegistration;
|
||||
@@ -123,8 +124,8 @@ public class NBWebServer implements Runnable {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
SimpleServiceLoader<WebServiceObject> svcLoader = new SimpleServiceLoader<>(WebServiceObject.class);
|
||||
svcLoader.getNamedProviders().values()
|
||||
SimpleServiceLoader<WebServiceObject> svcLoader = new SimpleServiceLoader<>(WebServiceObject.class, Maturity.Any);
|
||||
svcLoader.getNamedProviders().stream().map(p -> p.provider)
|
||||
.forEach(p -> {
|
||||
Class<? extends WebServiceObject> c = p.type();
|
||||
logger.info("Adding web service object: " + c.getSimpleName());
|
||||
@@ -294,7 +295,7 @@ public class NBWebServer implements Runnable {
|
||||
server.setHandler(handlers);
|
||||
for (Connector connector : server.getConnectors()) {
|
||||
if (connector instanceof AbstractConnector) {
|
||||
logger.debug("Setting idle timeout for " + connector.toString() + " to 300,000ms");
|
||||
logger.debug("Setting idle timeout for " + connector + " to 300,000ms");
|
||||
((AbstractConnector) connector).setIdleTimeout(300000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.nosqlbench.docsys.endpoints;
|
||||
import io.nosqlbench.docsys.api.WebServiceObject;
|
||||
import io.nosqlbench.docsys.core.NBWebServer;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
import io.nosqlbench.nb.annotations.Maturity;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
@@ -13,7 +14,7 @@ import jakarta.ws.rs.core.MediaType;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@Service(value = WebServiceObject.class, selector = "docserver-status")
|
||||
@Service(value = WebServiceObject.class, selector = "docserver-status", maturity = Maturity.Deprecated)
|
||||
@Singleton
|
||||
@Path("_")
|
||||
public class DocServerStatusEndpoint implements WebServiceObject {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package io.nosqlbench.docsys.endpoints;
|
||||
|
||||
import io.nosqlbench.docsys.api.Docs;
|
||||
import io.nosqlbench.docsys.api.DocsBinder;
|
||||
import io.nosqlbench.docsys.api.DocsNameSpace;
|
||||
import io.nosqlbench.docapi.Docs;
|
||||
import io.nosqlbench.docapi.DocsBinder;
|
||||
import io.nosqlbench.docapi.DocsNameSpace;
|
||||
import io.nosqlbench.docsys.api.WebServiceObject;
|
||||
import io.nosqlbench.docsys.core.DocsysPathLoader;
|
||||
import io.nosqlbench.docsys.core.PathWalker;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
import io.nosqlbench.nb.annotations.Maturity;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
@@ -20,7 +21,7 @@ import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
@Service(value = WebServiceObject.class, selector = "docsys-markdown")
|
||||
@Service(value = WebServiceObject.class, selector = "docsys-markdown",maturity = Maturity.Deprecated)
|
||||
@Singleton
|
||||
@Path("/services/docs/")
|
||||
public class DocsysMarkdownEndpoint implements WebServiceObject {
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
//@Service(value=WebServiceObject.class,selector="test")
|
||||
//@Service(value=WebServiceObject.class, selector="test", maturity=Stability.Stable)
|
||||
@Singleton
|
||||
@Path("test1")
|
||||
public class TestServlet1 implements WebServiceObject {
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
## Basic Markdown File
|
||||
|
||||
- item 1.
|
||||
- item 2.
|
||||
|
||||
1. numbered item 1
|
||||
2. numbered item 2
|
||||
|
||||
## a list of files:
|
||||
|
||||
{{files}}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
---
|
||||
title: topic1
|
||||
---
|
||||
|
||||
## Topic1 Heading1
|
||||
|
||||
This is a topic at `basics/section1/topic1`
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
title: Section 2 Topic 1
|
||||
---
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,8 +0,0 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>A title</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
Some content in the body.
|
||||
</BODY>
|
||||
</HTML>
|
||||
Reference in New Issue
Block a user