Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,28 @@ public interface LookupExtractorFactory extends Supplier<LookupExtractor>

/**
* <p>
* This method will be called to stop the LookupExtractor upon deletion.
* This method will be called to stop the LookupExtractor upon Druid process stop. This would be used, for
* example, to stop any thread pools it might have.
* Calling this method multiple times should always return true if successfully closed.
* </p>
* @return Returns false if not successfully closed the {@link LookupExtractor} otherwise returns true
*/
boolean close();

/**
* <p>
* This method will be called to drop the LookupExtractor upon explicit user request to coordinator to drop
* this lookup. In this method user can do additional cleanup (e.g. deleting disk persisted cache) not done simply
* when Druid process was being stopped to be restarted.
* Calling this method multiple times should always return true if successfully destroyed.
* </p>
* @return Returns false if not successfully destroyed the {@link LookupExtractor} otherwise returns true
*/
default boolean destroy()
{
return close();
}

/**
* This method is deprecated and is not removed only to allow 0.10.0 to 0.10.1 transition. It is not used
* on a cluster that is running 0.10.1. It will be removed in a later release.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,8 @@ public void handle(Map<String, LookupExtractorFactoryContainer> lookupMap) throw
LOG.debug("Loaded lookup [%s] with spec [%s].", lookupName, lookupExtractorFactoryContainer);

if (old != null) {
if (!old.getLookupExtractorFactory().close()) {
throw new ISE("close method returned false for lookup [%s]:[%s]", lookupName, old);
if (!old.getLookupExtractorFactory().destroy()) {
throw new ISE("destroy method returned false for lookup [%s]:[%s]", lookupName, old);
}
}
}
Expand Down Expand Up @@ -659,9 +659,9 @@ public void handle(Map<String, LookupExtractorFactoryContainer> lookupMap)
if (lookupExtractorFactoryContainer != null) {
LOG.debug("Removed lookup [%s] with spec [%s].", lookupName, lookupExtractorFactoryContainer);

if (!lookupExtractorFactoryContainer.getLookupExtractorFactory().close()) {
if (!lookupExtractorFactoryContainer.getLookupExtractorFactory().destroy()) {
throw new ISE(
"close method returned false for lookup [%s]:[%s]",
"destroy method returned false for lookup [%s]:[%s]",
lookupName,
lookupExtractorFactoryContainer
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void testAddGetRemove() throws Exception
{
LookupExtractorFactory lookupExtractorFactory = EasyMock.createMock(LookupExtractorFactory.class);
EasyMock.expect(lookupExtractorFactory.start()).andReturn(true).once();
EasyMock.expect(lookupExtractorFactory.close()).andReturn(true).once();
EasyMock.expect(lookupExtractorFactory.destroy()).andReturn(true).once();
EasyMock.replay(lookupExtractorFactory);

Map<String, Object> lookupMap = new HashMap<>();
Expand Down Expand Up @@ -221,15 +221,15 @@ public void testCloseIsCalledAfterStopping() throws Exception
}

@Test
public void testCloseIsCalledAfterRemove() throws Exception
public void testDestroyIsCalledAfterRemove() throws Exception
{
LookupExtractorFactory lookupExtractorFactory = EasyMock.createStrictMock(LookupExtractorFactory.class);
EasyMock.expect(lookupExtractorFactory.start()).andReturn(true).once();
EasyMock.expect(lookupExtractorFactory.close()).andReturn(true).once();
EasyMock.expect(lookupExtractorFactory.destroy()).andReturn(true).once();
EasyMock.replay(lookupExtractorFactory);

Map<String, Object> lookupMap = new HashMap<>();
lookupMap.put("testMockForCloseIsCalledAfterRemove", container);
lookupMap.put("testMockForDestroyIsCalledAfterRemove", container);
String strResult = mapper.writeValueAsString(lookupMap);
Request request = new Request(HttpMethod.GET, new URL("http://localhost:1234/xx"));
expect(config.getLookupTier()).andReturn(LOOKUP_TIER);
Expand Down Expand Up @@ -280,7 +280,7 @@ public void testUpdateWithHigherVersion() throws Exception
{
LookupExtractorFactory lookupExtractorFactory1 = EasyMock.createNiceMock(LookupExtractorFactory.class);
EasyMock.expect(lookupExtractorFactory1.start()).andReturn(true).once();
EasyMock.expect(lookupExtractorFactory1.close()).andReturn(true).once();
EasyMock.expect(lookupExtractorFactory1.destroy()).andReturn(true).once();

LookupExtractorFactory lookupExtractorFactory2 = EasyMock.createNiceMock(LookupExtractorFactory.class);
EasyMock.expect(lookupExtractorFactory2.start()).andReturn(true).once();
Expand Down Expand Up @@ -461,7 +461,7 @@ public void testRealModeWithMainThread() throws Exception

LookupExtractorFactory lookupExtractorFactory = EasyMock.createMock(LookupExtractorFactory.class);
EasyMock.expect(lookupExtractorFactory.start()).andReturn(true).once();
EasyMock.expect(lookupExtractorFactory.close()).andReturn(true).once();
EasyMock.expect(lookupExtractorFactory.destroy()).andReturn(true).once();
EasyMock.replay(lookupExtractorFactory);
Assert.assertNull(lookupReferencesManager.get("test"));

Expand Down