forked from yahoo/maha
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instantiating flat buffer schema factory using optional configs
- Loading branch information
1 parent
5d58484
commit 4944fd5
Showing
15 changed files
with
122 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...id_lookups/server/lookup/namespace/schema/flatbuffer/FlatBufferSchemaFactoryProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.yahoo.maha.maha_druid_lookups.server.lookup.namespace.schema.flatbuffer; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import com.google.inject.Inject; | ||
import com.google.inject.Provider; | ||
import com.yahoo.maha.maha_druid_lookups.server.lookup.namespace.MahaNamespaceExtractionConfig; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.apache.druid.java.util.common.logger.Logger; | ||
|
||
public class FlatBufferSchemaFactoryProvider implements Provider<FlatBufferSchemaFactory> { | ||
|
||
private static final Logger LOG = new Logger(FlatBufferSchemaFactoryProvider.class); | ||
|
||
private FlatBufferSchemaFactory flatBufferSchemaFactory = new DefaultFlatBufferSchemaFactory(ImmutableMap.<String, FlatBufferWrapper>builder().build()); | ||
|
||
@Inject | ||
public FlatBufferSchemaFactoryProvider(MahaNamespaceExtractionConfig config) { | ||
String schemaFactoryClass = config.getFlatBufferSchemaFactory(); | ||
if (StringUtils.isNotBlank(schemaFactoryClass)) { | ||
Class clazz; | ||
try { | ||
clazz = Class.forName(schemaFactoryClass); | ||
if (FlatBufferSchemaFactory.class.isAssignableFrom(clazz)) { | ||
flatBufferSchemaFactory = (FlatBufferSchemaFactory) clazz.newInstance(); | ||
} | ||
} catch (Exception e) { | ||
LOG.error(e, "Failed to instantiate FlatBufferSchemaFactory from className {}", schemaFactoryClass); | ||
throw new IllegalArgumentException(e); | ||
} | ||
} else { | ||
LOG.warn("Implementation of FlatBufferSchemaFactory class name is black in the MahaNamespaceExtractionConfig, considering default implementation"); | ||
} | ||
} | ||
|
||
@Override | ||
public FlatBufferSchemaFactory get() { | ||
return flatBufferSchemaFactory; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters