Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Agent: make http server injection optional
Browse files Browse the repository at this point in the history
It should be OK to run the agent when http.enabled is set to false, shipping to another cluster.

Closes elastic#374
  • Loading branch information
bleskes committed Dec 20, 2014
1 parent b5cd137 commit 717db3a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public String name() {
return "es_exporter";
}

@Inject
@Inject(optional = true)
public void setHttpServer(HttpServer httpServer) {
this.httpServer = httpServer;
}
Expand Down Expand Up @@ -337,7 +337,7 @@ private HttpURLConnection openAndValidateConnection(String method, String path)
private HttpURLConnection openAndValidateConnection(String method, String path, String contentType) {
if (hosts.length == 0) {
if (httpServer == null) {
logger.debug("local http server is not yet injected. can't connect.");
logger.warn("http server is not enabled no hosts are manually configured");
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@
@ClusterScope(transportClientRatio = 0.0, scope = ElasticsearchIntegrationTest.Scope.TEST, numNodes = 0)
public class ESExporterTests extends ElasticsearchIntegrationTest {

@Test
public void testHttpServerOff() {
ImmutableSettings.Builder builder = ImmutableSettings.builder()
.put(AgentService.SETTINGS_INTERVAL, "200m")
.put("http.enabled", "false");
cluster().startNode(builder);
ESExporter esExporter = getEsExporter();
logger.info("trying exporting despite of no target");
esExporter.exportEvents(new Event[]{
new TestEvent()
});
}

@Test
public void testLargeClusterStateSerialization() throws InterruptedException {
// make sure no other exporting is done (quicker)..
Expand Down

0 comments on commit 717db3a

Please sign in to comment.