mirror of https://github.com/apache/lucene.git
SOLR-1076 -- JdbcDataSource should resolve variables in all its configuration parameters
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@756340 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
09100e8c0c
commit
b53c3495e4
|
@ -106,6 +106,9 @@ New Features
|
|||
further transformers. New methods are introduced in Context for deleting by id and query.
|
||||
(Noble Paul, Fergus McMenemie, shalin)
|
||||
|
||||
25.SOLR-1076: JdbcDataSource should resolve variables in all its configuration parameters.
|
||||
(shalin)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
1. SOLR-846: Reduce memory consumption during delta import by removing keys when used
|
||||
|
|
|
@ -61,6 +61,7 @@ public class JdbcDataSource extends
|
|||
|
||||
String bsz = initProps.getProperty("batchSize");
|
||||
if (bsz != null) {
|
||||
bsz = (String) context.getVariableResolver().resolve(bsz);
|
||||
try {
|
||||
batchSize = Integer.parseInt(bsz);
|
||||
if (batchSize == -1)
|
||||
|
@ -93,6 +94,9 @@ public class JdbcDataSource extends
|
|||
private void createConnectionFactory(final Context context,
|
||||
final Properties initProps) {
|
||||
|
||||
final VariableResolver resolver = context.getVariableResolver();
|
||||
resolveVariables(resolver, initProps);
|
||||
|
||||
final String url = initProps.getProperty(URL);
|
||||
final String driver = initProps.getProperty(DRIVER);
|
||||
|
||||
|
@ -117,11 +121,13 @@ public class JdbcDataSource extends
|
|||
|
||||
factory = new Callable<Connection>() {
|
||||
public Connection call() throws Exception {
|
||||
// Resolve variables again because the variables may have changed
|
||||
resolveVariables(resolver, initProps);
|
||||
LOG.info("Creating a connection for entity "
|
||||
+ context.getEntityAttribute(DataImporter.NAME) + " with URL: "
|
||||
+ url);
|
||||
long start = System.currentTimeMillis();
|
||||
Connection c = null;
|
||||
Connection c;
|
||||
try {
|
||||
c = DriverManager.getConnection(url, initProps);
|
||||
if (Boolean.parseBoolean(initProps.getProperty("readOnly"))) {
|
||||
|
@ -167,6 +173,14 @@ public class JdbcDataSource extends
|
|||
};
|
||||
}
|
||||
|
||||
private void resolveVariables(VariableResolver resolver, Properties initProps) {
|
||||
for (Map.Entry<Object, Object> entry : initProps.entrySet()) {
|
||||
if (entry.getValue() != null) {
|
||||
entry.setValue(resolver.replaceTokens((String) entry.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator<Map<String, Object>> getData(String query) {
|
||||
ResultSetIterator r = new ResultSetIterator(query);
|
||||
return r.getIterator();
|
||||
|
|
Loading…
Reference in New Issue