Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
f-galland committed Oct 4, 2024
1 parent acceed2 commit 80f121e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public Collection<Object> createComponents(
Supplier<RepositoriesService> repositoriesServiceSupplier
) {
this.commandIndex = new CommandIndex(client, clusterService, threadPool);
ConfigReader configReader = new ConfigReader("127.0.0.1", 8080, "", "admin", "admin");
ConfigReader configReader = new ConfigReader("127.0.0.1", 8080, "/", "admin", "admin");
//ConfigReader configReader = new ConfigReader("httpbin.org", 80, "/post", "admin", "admin");
//ConfigReader configReader = new ConfigReader();
JobScheduler jobScheduler = new JobScheduler(threadPool, configReader);
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public class AsyncRequestRepository {
public AsyncRequestRepository(ConfigReader configReader) throws Exception {
this.target = new HttpHost(configReader.getHostName(), configReader.getPort());
this.requestUri = configReader.getPath();
prepareAsyncRequest();
}

public void prepareAsyncRequest() {
logger.info("Preparing Async Request");
IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
.setSoTimeout(5, TimeUnit.SECONDS)
.build();
Expand Down Expand Up @@ -98,10 +98,11 @@ public CompletableFuture<String> performAsyncRequest() throws Exception {
CompletableFuture<String> future = new CompletableFuture<>();

this.requester.execute(
AsyncRequestBuilder.post()
AsyncRequestBuilder.get()
.setHttpHost(this.target)
.setPath(this.requestUri)
.setEntity("{\"field\":\"value\"}",ContentType.APPLICATION_JSON)
.addHeader("Content-Type", "application/json")
.setEntity("{\"field\":\"value\"}")
.build(),
new BasicResponseConsumer<>(new StringAsyncEntityConsumer()),
Timeout.ofSeconds(5),
Expand All @@ -112,7 +113,6 @@ public void completed(final Message<HttpResponse, String> message) {
final HttpResponse response = message.getHead();
final String body = message.getBody();
logger.info(requestUri + "->{}", response.getCode());
logger.info(body);
future.complete(body);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ private void start(ThreadPool threadPool) {
Thread.sleep(5000);
logger.info("Running task");
AsyncRequestRepository asyncRequestRepository = new AsyncRequestRepository(this.configReader);
asyncRequestRepository.prepareAsyncRequest();
asyncRequestRepository.performAsyncRequest()
.thenAccept(
logger::info
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
grant {
permission java.net.SocketPermission "*:8080", "connect,resolve";
permission java.net.SocketPermission "*", "connect,resolve";
};

0 comments on commit 80f121e

Please sign in to comment.