Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5d41b29
Changes for lookup synchronization
Sep 6, 2017
8f2a360
Refactor of Lookup classes
Sep 6, 2017
317e4e3
Minor refactors and doc update
Sep 7, 2017
6eaffd4
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Sep 12, 2017
a3bfc31
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Sep 13, 2017
6731438
Change coordinator instance to be retrieved by DruidLeaderClient
Sep 13, 2017
4a11a49
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Sep 13, 2017
f3ad262
Wait before thread shutdown
Sep 13, 2017
e9b3ddc
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Sep 15, 2017
756098b
Make disablelookups flag true by default
Sep 15, 2017
1db8914
Update docs
Sep 15, 2017
727a706
Rename flag
Sep 15, 2017
263dfdc
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Sep 21, 2017
6d9278f
Move executorservice shutdown to finally block
Sep 21, 2017
e5fe3c2
Update LookupConfig
Sep 21, 2017
361d255
Doc changes
Sep 28, 2017
ce32e04
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Sep 28, 2017
99c6f60
Refactoring and doc changes
Sep 28, 2017
9876ae0
Remove lookup config constructor
Sep 28, 2017
c7ecfdc
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Sep 28, 2017
2ea72af
Revert Lookupconfig constructor changes
Oct 2, 2017
1cb6627
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Oct 3, 2017
bff5b09
Add tests to LookupConfig
Oct 3, 2017
fc9d53e
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Oct 3, 2017
37ae0c9
Make executorservice local
Oct 3, 2017
eae35a5
Update LRM
Oct 4, 2017
24eb9fb
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Oct 4, 2017
f80fbd9
Move ListeningScheduledExecutorService to ExecutorCompletionService
Oct 4, 2017
7e788fa
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Oct 4, 2017
8aa5d4f
Move exception to outer block
Oct 4, 2017
840c644
Remove check to see future is done
Oct 4, 2017
f9465d1
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Oct 7, 2017
ef3ead5
Remove unnecessary assignment
Oct 7, 2017
2bf45e1
Merge branch 'master' of https://github.com/druid-io/druid into syncl…
Oct 12, 2017
2529959
Add logging
Oct 12, 2017
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
2 changes: 2 additions & 0 deletions docs/content/querying/lookups.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ It is possible to save the configuration across restarts such that a node will n
|Property|Description|Default|
|--------|-----------|-------|
|`druid.lookup.snapshotWorkingDir`| Working path used to store snapshot of current lookup configuration, leaving this property null will disable snapshot/bootstrap utility|null|
|`druid.lookup.numLookupLoadingThreads`| Number of threads for loading the lookups in parallel on startup. This thread pool is destroyed once startup is done. It is not kept during the lifetime of the JVM|Available Processors / 2|
|`druid.lookup.enableLookupSyncOnStartup`|Enable the lookup synchronization process with coordinator on startup. The queryable nodes will fetch and load the lookups from the coordinator instead of waiting for the coordinator to load the lookups for them. Users may opt to disable this option if there are no lookups configured in the cluster.|true|

## Introspect a Lookup

Expand Down
7 changes: 7 additions & 0 deletions extensions-core/histogram/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.druid</groupId>
<artifactId>druid-server</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import io.druid.java.util.common.ISE;
import io.druid.java.util.common.logger.Logger;
import io.druid.math.expr.ExprMacroTable;
import io.druid.query.expression.TestExprMacroTable;
import io.druid.query.expression.TestExpressionMacroTable;
import io.druid.segment.IndexIO;
import io.druid.segment.IndexMergerV9;
import io.druid.segment.column.ColumnConfig;
Expand Down Expand Up @@ -74,7 +74,7 @@ public int columnCacheSizeBytes()

jsonMapper.setInjectableValues(
new InjectableValues.Std()
.addValue(ExprMacroTable.class.getName(), TestExprMacroTable.INSTANCE)
.addValue(ExprMacroTable.class.getName(), TestExpressionMacroTable.INSTANCE)
.addValue(IndexIO.class, indexIO)
.addValue(ObjectMapper.class, jsonMapper)
.addValue(ChatHandlerProvider.class, new NoopChatHandlerProvider())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
@JsonSubTypes.Type(name = "default", value = DefaultDimensionSpec.class),
@JsonSubTypes.Type(name = "extraction", value = ExtractionDimensionSpec.class),
@JsonSubTypes.Type(name = "regexFiltered", value = RegexFilteredDimensionSpec.class),
@JsonSubTypes.Type(name = "listFiltered", value = ListFilteredDimensionSpec.class),
@JsonSubTypes.Type(name = "lookup", value = LookupDimensionSpec.class)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JsonSubTypes.Type(name = "listFiltered", value = ListFilteredDimensionSpec.class)
})
public interface DimensionSpec extends Cacheable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.druid.guice.annotations.ExtensionPoint;
import io.druid.java.util.common.Cacheable;
import io.druid.query.lookup.LookupExtractionFn;
import io.druid.query.lookup.RegisteredLookupExtractionFn;

import javax.annotation.Nullable;

Expand All @@ -41,7 +40,6 @@
@JsonSubTypes.Type(name = "timeFormat", value = TimeFormatExtractionFn.class),
@JsonSubTypes.Type(name = "identity", value = IdentityExtractionFn.class),
@JsonSubTypes.Type(name = "lookup", value = LookupExtractionFn.class),
@JsonSubTypes.Type(name = "registeredLookup", value = RegisteredLookupExtractionFn.class),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JsonSubTypes.Type(name = "substring", value = SubstringDimExtractionFn.class),
@JsonSubTypes.Type(name = "cascade", value = CascadeExtractionFn.class),
@JsonSubTypes.Type(name = "stringFormat", value = StringFormatExtractionFn.class),
Expand Down
29 changes: 25 additions & 4 deletions processing/src/main/java/io/druid/query/lookup/LookupConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@
public class LookupConfig
{

@JsonProperty
private final String snapshotWorkingDir;
@JsonProperty("snapshotWorkingDir")
private String snapshotWorkingDir;

@JsonProperty("enableLookupSyncOnStartup")
private boolean enableLookupSyncOnStartup = true;

@JsonProperty("numLookupLoadingThreads")
private int numLookupLoadingThreads = Runtime.getRuntime().availableProcessors() / 2;

/**
* @param snapshotWorkingDir working directory to store lookups snapshot file, passing null or empty string will disable the snapshot utility
* @param snapshotWorkingDir working directory to store lookups snapshot file, passing null or empty string will disable the snapshot utility
* @param numLookupLoadingThreads number of threads for loading the lookups as part of the synchronization process
* @param enableLookupSyncOnStartup decides whether the lookup synchronization process should be enabled at startup
*/
@JsonCreator
public LookupConfig(
Expand All @@ -45,6 +53,15 @@ public String getSnapshotWorkingDir()
return snapshotWorkingDir;
}

public int getNumLookupLoadingThreads()
{
return numLookupLoadingThreads;
}

public boolean getEnableLookupSyncOnStartup()
{
return enableLookupSyncOnStartup;
}

@Override
public boolean equals(Object o)
Expand All @@ -58,7 +75,9 @@ public boolean equals(Object o)

LookupConfig that = (LookupConfig) o;

return getSnapshotWorkingDir().equals(that.getSnapshotWorkingDir());
return snapshotWorkingDir.equals(that.snapshotWorkingDir) &&
enableLookupSyncOnStartup == that.enableLookupSyncOnStartup &&
numLookupLoadingThreads == that.numLookupLoadingThreads;

}

Expand All @@ -67,6 +86,8 @@ public String toString()
{
return "LookupConfig{" +
"snapshotWorkingDir='" + getSnapshotWorkingDir() + '\'' +
" numLookupLoadingThreads='" + getNumLookupLoadingThreads() + '\'' +
" enableLookupSyncOnStartup='" + getEnableLookupSyncOnStartup() + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,7 @@
package io.druid.query.expression;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.druid.math.expr.ExprMacroTable;
import io.druid.query.extraction.MapLookupExtractor;
import io.druid.query.lookup.LookupExtractor;
import io.druid.query.lookup.LookupExtractorFactory;
import io.druid.query.lookup.LookupExtractorFactoryContainer;
import io.druid.query.lookup.LookupIntrospectHandler;
import io.druid.query.lookup.LookupReferencesManager;
import org.easymock.EasyMock;

import javax.annotation.Nullable;

public class TestExprMacroTable extends ExprMacroTable
{
Expand All @@ -41,7 +31,6 @@ private TestExprMacroTable()
super(
ImmutableList.of(
new LikeExprMacro(),
new LookupExprMacro(createTestLookupReferencesManager(ImmutableMap.of("foo", "xfoo"))),
new RegexpExtractExprMacro(),
new TimestampCeilExprMacro(),
new TimestampExtractExprMacro(),
Expand All @@ -55,52 +44,4 @@ private TestExprMacroTable()
)
);
}

/**
* Returns a mock {@link LookupReferencesManager} that has one lookup, "lookyloo".
*/
public static LookupReferencesManager createTestLookupReferencesManager(final ImmutableMap<String, String> theLookup)
{
final LookupReferencesManager lookupReferencesManager = EasyMock.createMock(LookupReferencesManager.class);
EasyMock.expect(lookupReferencesManager.get(EasyMock.eq("lookyloo"))).andReturn(
new LookupExtractorFactoryContainer(
"v0",
new LookupExtractorFactory()
{
@Override
public boolean start()
{
throw new UnsupportedOperationException();
}

@Override
public boolean close()
{
throw new UnsupportedOperationException();
}

@Override
public boolean replaces(@Nullable final LookupExtractorFactory other)
{
throw new UnsupportedOperationException();
}

@Override
public LookupIntrospectHandler getIntrospectHandler()
{
throw new UnsupportedOperationException();
}

@Override
public LookupExtractor get()
{
return new MapLookupExtractor(theLookup, false);
}
}
)
).anyTimes();
EasyMock.expect(lookupReferencesManager.get(EasyMock.not(EasyMock.eq("lookyloo")))).andReturn(null).anyTimes();
EasyMock.replay(lookupReferencesManager);
return lookupReferencesManager;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,36 @@ public class LookupConfigTest
{

ObjectMapper mapper = TestHelper.getJsonMapper();

@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();

@Test
public void TestSerDesr() throws IOException
{
LookupConfig lookupConfig = new LookupConfig(temporaryFolder.newFile().getAbsolutePath());
Assert.assertEquals(lookupConfig, mapper.reader(LookupConfig.class).readValue(mapper.writeValueAsString(lookupConfig)));
Assert.assertEquals(
lookupConfig,
mapper.reader(LookupConfig.class).readValue(mapper.writeValueAsString(lookupConfig))
);
}

@Test
public void testSerdeWithNonDefaults() throws Exception
{
String json = "{\n"
+ " \"enableLookupSyncOnStartup\": false,\n"
+ " \"snapshotWorkingDir\": \"/tmp\",\n"
+ " \"numLookupLoadingThreads\": 4 \n"
+ "}\n";
LookupConfig config = mapper.readValue(
mapper.writeValueAsString(
mapper.readValue(json, LookupConfig.class)
),
LookupConfig.class
);

Assert.assertEquals("/tmp", config.getSnapshotWorkingDir());
Assert.assertEquals(false, config.getEnableLookupSyncOnStartup());
Assert.assertEquals(4, config.getNumLookupLoadingThreads());
}
}
8 changes: 7 additions & 1 deletion server/src/main/java/io/druid/query/lookup/LookupModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
Expand All @@ -48,6 +49,7 @@
import io.druid.guice.annotations.Smile;
import io.druid.initialization.DruidModule;
import io.druid.java.util.common.logger.Logger;
import io.druid.query.dimension.LookupDimensionSpec;
import io.druid.query.expression.LookupExprMacro;
import io.druid.server.DruidNode;
import io.druid.server.http.HostAndPortWithScheme;
Expand Down Expand Up @@ -84,7 +86,11 @@ public static String getTierListenerPath(String tier)
public List<? extends Module> getJacksonModules()
{
return ImmutableList.<Module>of(
new SimpleModule("DruidLookupModule").registerSubtypes(MapLookupExtractorFactory.class)
new SimpleModule("DruidLookupModule").registerSubtypes(MapLookupExtractorFactory.class),
new SimpleModule().registerSubtypes(
new NamedType(LookupDimensionSpec.class, "lookup"),
new NamedType(RegisteredLookupExtractionFn.class, "registeredLookup")
)
);
}

Expand Down
Loading