Author: blee
Date: Mon Aug 13 19:23:28 2012
New Revision: 1372557
URL: http://svn.apache.org/viewvc?rev=1372557&view=rev
Log:
SQOOP-568: Configuration reload period should be configurable in
PropertiesConfigurationProvider
Modified:
sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/core/ConfigurationConstants.java
sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/core/PropertiesConfigurationProvider.java
sqoop/branches/sqoop2/dist/src/main/server/conf/sqoop.properties
Modified:
sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/core/ConfigurationConstants.java
URL:
http://svn.apache.org/viewvc/sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/core/ConfigurationConstants.java?rev=1372557&r1=1372556&r2=1372557&view=diff
==============================================================================
---
sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/core/ConfigurationConstants.java
(original)
+++
sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/core/ConfigurationConstants.java
Mon Aug 13 19:23:28 2012
@@ -33,6 +33,12 @@ public final class ConfigurationConstant
+ "log4j.";
/**
+ * Prefix for PropertiesConfigurationProvider implementation
+ */
+ public static final String PREFIX_PROPERTIES_PROVIDER_CONFIG =
+ PREFIX_GLOBAL_CONFIG + "core.configuration.provider.properties.";
+
+ /**
* The system property that must be set for specifying the system
* configuration directory: <tt>sqoop.config.dir</tt>.
*/
@@ -61,6 +67,9 @@ public final class ConfigurationConstant
public static final String CONNPROP_CONNECTOR_NAME =
"org.apache.sqoop.connector.name";
+ public static final String PROPERTIES_PROVIDER_SLEEP =
+ PREFIX_PROPERTIES_PROVIDER_CONFIG + "sleep";
+
private ConfigurationConstants() {
// Disable explicit object creation
Modified:
sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/core/PropertiesConfigurationProvider.java
URL:
http://svn.apache.org/viewvc/sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/core/PropertiesConfigurationProvider.java?rev=1372557&r1=1372556&r2=1372557&view=diff
==============================================================================
---
sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/core/PropertiesConfigurationProvider.java
(original)
+++
sqoop/branches/sqoop2/core/src/main/java/org/apache/sqoop/core/PropertiesConfigurationProvider.java
Mon Aug 13 19:23:28 2012
@@ -31,6 +31,7 @@ import java.util.Properties;
import org.apache.log4j.Logger;
import org.apache.sqoop.common.SqoopException;
+import static
org.apache.sqoop.core.ConfigurationConstants.PROPERTIES_PROVIDER_SLEEP;
public class PropertiesConfigurationProvider implements ConfigurationProvider {
@@ -39,6 +40,8 @@ public class PropertiesConfigurationProv
public static final String CONFIG_FILENAME = "sqoop.properties";
+ public static final long DEFAULT_SLEEP_TIME = 60000;
+
private Map<String, String> configuration = new HashMap<String, String>();
private List<ConfigurationListener> listeners =
@@ -82,7 +85,7 @@ public class PropertiesConfigurationProv
@Override
public synchronized void initialize(
- File configDir, Properties bootstrapCongiruation) {
+ File configDir, Properties bootstrapConfiguration) {
configFile = new File(configDir, CONFIG_FILENAME);
if (!configFile.exists() || !configFile.isFile() || !configFile.canRead())
{
throw new SqoopException(CoreError.CORE_0006, configFile.getPath());
@@ -133,11 +136,14 @@ public class PropertiesConfigurationProv
private boolean shutdown;
+ private long sleepTime;
+
ConfigFilePoller(File configFile) {
this.file = configFile;
lastUpdatedAt = configFile.lastModified();
this.setName("sqoop-config-file-poller");
this.setDaemon(true);
+ loadSleepTime();
}
synchronized void setShutdown() {
@@ -148,6 +154,17 @@ public class PropertiesConfigurationProv
return shutdown;
}
+ protected synchronized void loadSleepTime() {
+ try {
+ String value = configuration.get(PROPERTIES_PROVIDER_SLEEP);
+ sleepTime = Long.valueOf(value);
+ } catch(Exception e) {
+ LOG.debug("Can't load sleeping period from configuration file,"
+ + " using default value " + DEFAULT_SLEEP_TIME, e);
+ sleepTime = DEFAULT_SLEEP_TIME;
+ }
+ }
+
@Override
public void run() {
@@ -159,13 +176,14 @@ public class PropertiesConfigurationProv
try {
lastUpdatedAt = file.lastModified();
loadConfiguration(true);
+ loadSleepTime();
} catch (Exception ex) {
LOG.error("Exception while loading configuration", ex);
}
}
try {
- Thread.sleep(30);
+ Thread.sleep(sleepTime);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
Modified: sqoop/branches/sqoop2/dist/src/main/server/conf/sqoop.properties
URL:
http://svn.apache.org/viewvc/sqoop/branches/sqoop2/dist/src/main/server/conf/sqoop.properties?rev=1372557&r1=1372556&r2=1372557&view=diff
==============================================================================
--- sqoop/branches/sqoop2/dist/src/main/server/conf/sqoop.properties (original)
+++ sqoop/branches/sqoop2/dist/src/main/server/conf/sqoop.properties Mon Aug 13
19:23:28 2012
@@ -83,3 +83,5 @@ org.apache.sqoop.repository.jdbc.passwor
# System properties for embedded Derby configuration
org.apache.sqoop.repository.sysprop.derby.stream.error.file=@LOGDIR@/derbyrepo.log
+# Sleeping period for reloading configuration file (once a minute)
+org.apache.sqoop.core.configuration.provider.properties.sleep=60000