This commit is contained in:
Jonathan Shook 2020-05-19 17:02:14 -05:00
commit 5862b6adae
6 changed files with 105 additions and 29 deletions

View File

@ -1,23 +1,5 @@
7b61ee3a (HEAD -> master) Don't swallow exception in VirtdataComposer
2d4bf8d0 DateRangeFunc allows flexible signatures
8cad4414 improve debugger view of virtdata AST
2de8df4e incremental cql-d4 work
7fb0eb83 make cql-d4 optional via profile
be160856 organize virtdata entry points
4f2b2929 remove extraneous build file
6e74b5ab virtdata composer considers all arg type combinations
526dc5de longflow example
52501f40 (HEAD -> master) support graal-js in nashorn compat mode
9d0403a5 polyglot mode now does full type introspection
ae8506ca incremental work on cql-d4
302c3ca4 higher order functions now consider all possible matches without explicity input and output types
5f63092e misc AST cleanups
087c0b80 (origin/master, origin/HEAD) release commit
2d4bf8d0 DateRangeFunc allows flexible signatures
8cad4414 improve debugger view of virtdata AST
2de8df4e incremental cql-d4 work
7fb0eb83 make cql-d4 optional via profile
be160856 organize virtdata entry points
4f2b2929 remove extraneous build file
6e74b5ab virtdata composer considers all arg type combinations
526dc5de longflow example
de6c6b36 (origin/http-script-plugin, http-script-plugin) return types
442b5cbb fixed a docker-metrics bug that prevents grafana started by --docker-metrics on a Linux server from accessing prometheus in another docker container
3b6b88f9 overload post for null payload & no content type
39d6c50a http plugin for scripts
c99b609a (origin/refactor-sslksfactory) Refactor SSLKsFactory

View File

@ -1,8 +1,8 @@
{
"name":"prometheus",
"type":"prometheus",
"url":"http://localhost:9090",
"access":"direct",
"url":"http://prom:9090",
"access":"proxy",
"editable":true,
"basicAuth":false
}

View File

@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static io.nosqlbench.engine.docker.RestHelper.post;
@ -45,7 +46,7 @@ public class DockerHelper {
.withDockerCmdExecFactory(dockerCmdExecFactory)
.build();
}
public String startDocker(String IMG, String tag, String name, List<Integer> ports, List<String> volumeDescList, List<String> envList, List<String> cmdList, String reload) {
public String startDocker(String IMG, String tag, String name, List<Integer> ports, List<String> volumeDescList, List<String> envList, List<String> cmdList, String reload, List<String> linkNames) {
logger.debug("Starting docker with img=" + IMG + ", tag=" + tag + ", name=" + name + ", " +
"ports=" + ports + ", volumes=" + volumeDescList + ", env=" + envList + ", cmds=" + cmdList + ", reload=" + reload);
@ -108,6 +109,7 @@ public class DockerHelper {
CreateContainerResponse containerResponse;
List<Link> links = linkNames.stream().map(x->new Link(x,x)).collect(Collectors.toList());
if (envList == null) {
containerResponse = dockerClient.createContainerCmd(IMG + ":" + tag)
.withCmd(cmdList)
@ -120,6 +122,7 @@ public class DockerHelper {
)
.withName(name)
//.withVolumes(volumeList)
.withLinks(links)
.exec();
} else {
long user = new UnixSystem().getUid();
@ -133,6 +136,7 @@ public class DockerHelper {
.withBinds(volumeBindList)
)
.withName(name)
.withLinks(links)
.withUser(""+user)
//.withVolumes(volumeList)
.exec();

View File

@ -74,7 +74,9 @@ public class DockerMetricsManager {
);
String reload = null;
String containerId = dh.startDocker(GRAFANA_IMG, tag, name, port, volumeDescList, envList, null, reload);
List<String> linkNames = new ArrayList();
linkNames.add("prom");
String containerId = dh.startDocker(GRAFANA_IMG, tag, name, port, volumeDescList, envList, null, reload, linkNames);
if (containerId == null){
return;
}
@ -118,7 +120,8 @@ public class DockerMetricsManager {
);
String reload = "http://localhost:9090/-/reload";
dh.startDocker(PROMETHEUS_IMG, tag, name, port, volumeDescList, envList, cmdList, reload);
List<String> linkNames = new ArrayList();
dh.startDocker(PROMETHEUS_IMG, tag, name, port, volumeDescList, envList, cmdList, reload, linkNames);
logger.info("prometheus started and listenning");
}
@ -137,7 +140,8 @@ public class DockerMetricsManager {
List<String> envList = Arrays.asList();
String reload = null;
dh.startDocker(GRAPHITE_EXPORTER_IMG, tag, name, port, volumeDescList, envList, null, reload);
List<String> linkNames = new ArrayList();
dh.startDocker(GRAPHITE_EXPORTER_IMG, tag, name, port, volumeDescList, envList, null, reload, linkNames);
logger.info("graphite exporter container started");

View File

@ -0,0 +1,59 @@
package io.nosqlbench.engine.extensions.http;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class HttpPlugin {
private HttpClient client = HttpClient.newHttpClient();
public HttpResponse<String> get(String url) throws IOException, InterruptedException {
HttpRequest.Builder builder = HttpRequest.newBuilder();
URI uri = URI.create(url);
HttpRequest request = builder
.uri(uri)
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
return response;
}
public HttpResponse<String> post(String url) throws IOException, InterruptedException {
return post(url, null, null);
}
public HttpResponse<String> post(String url, String data, String contentType) throws IOException, InterruptedException {
HttpRequest.Builder builder = HttpRequest.newBuilder();
URI uri = URI.create(url);
HttpRequest request;
if (data == null && contentType == null || contentType == null){
request = builder
.uri(uri)
.POST(HttpRequest.BodyPublishers.noBody())
.build();
} else if (data == null) {
request = builder
.uri(uri)
.header("Content-Type", contentType)
.POST(HttpRequest.BodyPublishers.noBody())
.build();
} else {
request = builder
.uri(uri)
.header("Content-Type", contentType)
.POST(HttpRequest.BodyPublishers.ofString(data))
.build();
}
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
return response;
}
}

View File

@ -0,0 +1,27 @@
package io.nosqlbench.engine.extensions.http;
import com.codahale.metrics.MetricRegistry;
import io.nosqlbench.engine.api.extensions.ScriptingPluginInfo;
import io.nosqlbench.engine.extensions.optimizers.BobyqaOptimizerPlugin;
import io.nosqlbench.nb.annotations.Service;
import org.slf4j.Logger;
import javax.script.ScriptContext;
@Service(ScriptingPluginInfo.class)
public class HttpPluginData implements ScriptingPluginInfo<HttpPlugin> {
@Override
public String getDescription() {
return "use http get and post in scripts";
}
@Override
public HttpPlugin getExtensionObject(Logger logger, MetricRegistry metricRegistry, ScriptContext scriptContext) {
return new HttpPlugin();
}
@Override
public String getBaseVariableName() {
return "http";
}
}