Skip to content

Commit 8eb8d73

Browse files
INGEST-1513: Handle sticky session expiration - improvement/bugfix
1 parent bd937ab commit 8eb8d73

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

src/main/java/com/splunk/hecclient/Indexer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ private String readAndCloseResponse(CloseableHttpResponse resp) {
169169
if((resp.getHeaders("Set-Cookie") != null) && (resp.getHeaders("Set-Cookie").length > 0)) {
170170
log.info("Sticky session expiry detected, will cleanup old channel and its associated batches");
171171
poller.setStickySessionToTrue();
172-
// poller.stickySessionHandler(channel);
173172
}
174173

175174
int status = resp.getStatusLine().getStatusCode();

src/test/java/com/splunk/hecclient/HecAckPollerTest.java

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -326,33 +326,34 @@ public void getMinLoadChannel() {
326326

327327
@Test
328328
public void stickySessionHandler() {
329-
// PollerCallbackMock cb = new PollerCallbackMock();
330-
// HecAckPoller poller = new HecAckPoller(cb);
331-
// poller.setAckPollThreads(1);
332-
// poller.setAckPollInterval(2);
333-
// poller.start();
334-
//
335-
// IndexerMock indexer = new IndexerMock();
336-
// String ackResponse = "{\"acks\":{\"1\":true}}";
337-
// indexer.setResponse(ackResponse);
338-
//
339-
// HecChannel ch = new HecChannel(indexer);
340-
// EventBatch batch = UnitUtil.createBatch();
341-
//
342-
// String response = "{\"text\":\"Success\",\"code\":0,\"ackId\":1}";
343-
// poller.add(ch, batch, response);
344-
//
345-
// long outstanding = poller.getTotalOutstandingEventBatches();
346-
// Assert.assertEquals(1, outstanding);
347-
// UnitUtil.milliSleep(3000);
348-
//
349-
// String oldId = ch.getId();
350-
// poller.stickySessionHandler(ch);
351-
// Assert.assertNotEquals(oldId, ch.getId());
352-
//
353-
// outstanding = poller.getTotalOutstandingEventBatches();
354-
// Assert.assertEquals(0, outstanding);
355-
//
356-
// poller.stop();
329+
PollerCallbackMock cb = new PollerCallbackMock();
330+
HecAckPoller poller = new HecAckPoller(cb);
331+
poller.setAckPollThreads(1);
332+
poller.setAckPollInterval(2);
333+
poller.start();
334+
335+
IndexerMock indexer = new IndexerMock();
336+
String ackResponse = "{\"acks\":{\"1\":true}}";
337+
indexer.setResponse(ackResponse);
338+
339+
HecChannel ch = new HecChannel(indexer);
340+
EventBatch batch = UnitUtil.createBatch();
341+
342+
String response = "{\"text\":\"Success\",\"code\":0,\"ackId\":1}";
343+
poller.add(ch, batch, response);
344+
345+
long outstanding = poller.getTotalOutstandingEventBatches();
346+
Assert.assertEquals(1, outstanding);
347+
UnitUtil.milliSleep(3000);
348+
349+
String oldId = ch.getId();
350+
poller.setStickySessionToTrue();
351+
poller.stickySessionHandler(ch);
352+
Assert.assertNotEquals(oldId, ch.getId());
353+
354+
outstanding = poller.getTotalOutstandingEventBatches();
355+
Assert.assertEquals(0, outstanding);
356+
357+
poller.stop();
357358
}
358359
}

0 commit comments

Comments
 (0)