diff --git a/conf/sqoop-site-template.xml b/conf/sqoop-site-template.xml
index c9e2b00f..f84dcb22 100644
--- a/conf/sqoop-site-template.xml
+++ b/conf/sqoop-site-template.xml
@@ -54,7 +54,7 @@
sqoop.metastore.client.enable.autoconnectfalseIf true, Sqoop will connect to a local metastore
- for session management when no other metastore arguments are
+ for job management when no other metastore arguments are
provided.
@@ -70,7 +70,7 @@
sqoop.metastore.client.autoconnect.urljdbc:hsqldb:file:/tmp/sqoop-meta/meta.db;shutdown=trueThe connect string to use when connecting to a
- session-management metastore. If unspecified, uses ~/.sqoop/.
+ job-management metastore. If unspecified, uses ~/.sqoop/.
You can specify a different path here.
@@ -90,7 +90,7 @@
diff --git a/src/java/com/cloudera/sqoop/ConnFactory.java b/src/java/com/cloudera/sqoop/ConnFactory.java
index 04aa7ba7..b0aacfdb 100644
--- a/src/java/com/cloudera/sqoop/ConnFactory.java
+++ b/src/java/com/cloudera/sqoop/ConnFactory.java
@@ -38,7 +38,7 @@
import com.cloudera.sqoop.manager.ConnManager;
import com.cloudera.sqoop.manager.DefaultManagerFactory;
import com.cloudera.sqoop.manager.ManagerFactory;
-import com.cloudera.sqoop.metastore.SessionData;
+import com.cloudera.sqoop.metastore.JobData;
import com.cloudera.sqoop.util.ClassLoaderStack;
@@ -105,7 +105,7 @@ private void instantiateFactories(Configuration conf) {
* @return a ConnManager instance for the appropriate database.
* @throws IOException if it cannot find a ConnManager for this schema.
*/
- public ConnManager getManager(SessionData data) throws IOException {
+ public ConnManager getManager(JobData data) throws IOException {
// Try all the available manager factories.
for (ManagerFactory factory : factories) {
LOG.debug("Trying ManagerFactory: " + factory.getClass().getName());
diff --git a/src/java/com/cloudera/sqoop/SqoopOptions.java b/src/java/com/cloudera/sqoop/SqoopOptions.java
index 0515e005..c7eb1625 100644
--- a/src/java/com/cloudera/sqoop/SqoopOptions.java
+++ b/src/java/com/cloudera/sqoop/SqoopOptions.java
@@ -196,13 +196,13 @@ public enum IncrementalMode {
private String incrementalLastValue;
// These next two fields are not serialized to the metastore.
- // If this SqoopOptions is created by reading a saved session, these will
- // be populated by the SessionStorage to facilitate updating the same
- // session.
- private String sessionName;
- private Map sessionStorageDescriptor;
+ // If this SqoopOptions is created by reading a saved job, these will
+ // be populated by the JobStorage to facilitate updating the same
+ // job.
+ private String jobName;
+ private Map jobStorageDescriptor;
- // If we restore a session and then allow the user to apply arguments on
+ // If we restore a job and then allow the user to apply arguments on
// top, we retain the version without the arguments in a reference to the
// 'parent' SqoopOptions instance, here.
private SqoopOptions parent;
@@ -449,7 +449,7 @@ public void loadProperties(Properties props) {
/**
* Return a Properties instance that encapsulates all the "sticky"
* state of this SqoopOptions that should be written to a metastore
- * to restore the session later.
+ * to restore the job later.
*/
public Properties writeProperties() {
Properties props = new Properties();
@@ -1468,33 +1468,33 @@ public String getIncrementalLastValue() {
}
/**
- * Set the name of the saved session this SqoopOptions belongs to.
+ * Set the name of the saved job this SqoopOptions belongs to.
*/
- public void setSessionName(String session) {
- this.sessionName = session;
+ public void setJobName(String job) {
+ this.jobName = job;
}
/**
- * Get the name of the saved session this SqoopOptions belongs to.
+ * Get the name of the saved job this SqoopOptions belongs to.
*/
- public String getSessionName() {
- return this.sessionName;
+ public String getJobName() {
+ return this.jobName;
}
/**
- * Set the SessionStorage descriptor used to open the saved session
+ * Set the JobStorage descriptor used to open the saved job
* this SqoopOptions belongs to.
*/
public void setStorageDescriptor(Map descriptor) {
- this.sessionStorageDescriptor = descriptor;
+ this.jobStorageDescriptor = descriptor;
}
/**
- * Get the SessionStorage descriptor used to open the saved session
+ * Get the JobStorage descriptor used to open the saved job
* this SqoopOptions belongs to.
*/
public Map getStorageDescriptor() {
- return this.sessionStorageDescriptor;
+ return this.jobStorageDescriptor;
}
/**
diff --git a/src/java/com/cloudera/sqoop/manager/DefaultManagerFactory.java b/src/java/com/cloudera/sqoop/manager/DefaultManagerFactory.java
index d0b0447a..84a9d5a3 100644
--- a/src/java/com/cloudera/sqoop/manager/DefaultManagerFactory.java
+++ b/src/java/com/cloudera/sqoop/manager/DefaultManagerFactory.java
@@ -22,7 +22,7 @@
import org.apache.commons.logging.LogFactory;
import com.cloudera.sqoop.SqoopOptions;
-import com.cloudera.sqoop.metastore.SessionData;
+import com.cloudera.sqoop.metastore.JobData;
/**
* Contains instantiation code for all ConnManager implementations
@@ -33,7 +33,7 @@ public final class DefaultManagerFactory extends ManagerFactory {
public static final Log LOG = LogFactory.getLog(
DefaultManagerFactory.class.getName());
- public ConnManager accept(SessionData data) {
+ public ConnManager accept(JobData data) {
SqoopOptions options = data.getSqoopOptions();
String manualDriver = options.getDriverClassName();
if (manualDriver != null) {
diff --git a/src/java/com/cloudera/sqoop/manager/ManagerFactory.java b/src/java/com/cloudera/sqoop/manager/ManagerFactory.java
index 1d26286f..379e73df 100644
--- a/src/java/com/cloudera/sqoop/manager/ManagerFactory.java
+++ b/src/java/com/cloudera/sqoop/manager/ManagerFactory.java
@@ -19,7 +19,7 @@
package com.cloudera.sqoop.manager;
import com.cloudera.sqoop.SqoopOptions;
-import com.cloudera.sqoop.metastore.SessionData;
+import com.cloudera.sqoop.metastore.JobData;
/**
* Interface for factory classes for ConnManager implementations.
@@ -30,23 +30,23 @@
*/
public abstract class ManagerFactory {
@Deprecated
- /** Do not use accept(SqoopOptions). Use accept(SessionData) instead. */
+ /** Do not use accept(SqoopOptions). Use accept(JobData) instead. */
public ConnManager accept(SqoopOptions options) {
throw new RuntimeException(
- "Deprecated method; override ManagerFactory.accept(SessionData)");
+ "Deprecated method; override ManagerFactory.accept(JobData)");
}
/**
* Instantiate a ConnManager that can fulfill the database connection
- * requirements of the task specified in the SessionData.
- * @param sessionData the user-provided arguments that configure this
+ * requirements of the task specified in the JobData.
+ * @param jobData the user-provided arguments that configure this
* Sqoop job.
* @return a ConnManager that can connect to the specified database
* and perform the operations required, or null if this factory cannot
* find a suitable ConnManager implementation.
*/
- public ConnManager accept(SessionData sessionData) {
- return accept(sessionData.getSqoopOptions());
+ public ConnManager accept(JobData jobData) {
+ return accept(jobData.getSqoopOptions());
}
}
diff --git a/src/java/com/cloudera/sqoop/metastore/SessionData.java b/src/java/com/cloudera/sqoop/metastore/JobData.java
similarity index 89%
rename from src/java/com/cloudera/sqoop/metastore/SessionData.java
rename to src/java/com/cloudera/sqoop/metastore/JobData.java
index 52b4ce7f..c8105013 100644
--- a/src/java/com/cloudera/sqoop/metastore/SessionData.java
+++ b/src/java/com/cloudera/sqoop/metastore/JobData.java
@@ -22,17 +22,17 @@
import com.cloudera.sqoop.tool.SqoopTool;
/**
- * Container for all session data that should be stored to a
+ * Container for all job data that should be stored to a
* permanent resource.
*/
-public class SessionData {
+public class JobData {
private SqoopOptions opts;
private SqoopTool tool;
- public SessionData() {
+ public JobData() {
}
- public SessionData(SqoopOptions options, SqoopTool sqoopTool) {
+ public JobData(SqoopOptions options, SqoopTool sqoopTool) {
this.opts = options;
this.tool = sqoopTool;
}
diff --git a/src/java/com/cloudera/sqoop/metastore/SessionStorage.java b/src/java/com/cloudera/sqoop/metastore/JobStorage.java
similarity index 54%
rename from src/java/com/cloudera/sqoop/metastore/SessionStorage.java
rename to src/java/com/cloudera/sqoop/metastore/JobStorage.java
index 3291acda..74760b24 100644
--- a/src/java/com/cloudera/sqoop/metastore/SessionStorage.java
+++ b/src/java/com/cloudera/sqoop/metastore/JobStorage.java
@@ -26,21 +26,21 @@
import org.apache.hadoop.conf.Configured;
/**
- * API that defines how sessions are saved, restored, and manipulated.
+ * API that defines how jobs are saved, restored, and manipulated.
*
*
- * SessionStorage instances may be created and then not used; the
- * SessionStorage factory may create additional SessionStorage instances
+ * JobStorage instances may be created and then not used; the
+ * JobStorage factory may create additional JobStorage instances
* that return false from accept() and then discard them. The close()
- * method will only be triggered for a SessionStorage if the connect()
+ * method will only be triggered for a JobStorage if the connect()
* method is called. Connection should not be triggered by a call to
* accept().
*/
-public abstract class SessionStorage extends Configured implements Closeable {
+public abstract class JobStorage extends Configured implements Closeable {
/**
- * Returns true if the SessionStorage system can use the metadata in
- * the descriptor to connect to an underlying session resource.
+ * Returns true if the JobStorage system can use the metadata in
+ * the descriptor to connect to an underlying storage resource.
*/
public abstract boolean canAccept(Map descriptor);
@@ -53,41 +53,40 @@ public abstract void open(Map descriptor)
throws IOException;
/**
- * Given a session name, reconstitute a SessionData that contains all
- * configuration information required for the session. Returns null if the
- * session name does not match an available session.
+ * Given a job name, reconstitute a JobData that contains all
+ * configuration information required for the job. Returns null if the
+ * job name does not match an available job.
*/
- public abstract SessionData read(String sessionName)
+ public abstract JobData read(String jobName)
throws IOException;
/**
- * Forget about a saved session.
+ * Forget about a saved job.
*/
- public abstract void delete(String sessionName) throws IOException;
+ public abstract void delete(String jobName) throws IOException;
/**
- * Given a session name and the data describing a configured
- * session, record the session information to the storage medium.
+ * Given a job name and the data describing a configured job, record the job
+ * information to the storage medium.
*/
- public abstract void create(String sessionName, SessionData data)
+ public abstract void create(String jobName, JobData data)
throws IOException;
/**
- * Given a session descriptor and a configured session
- * update the underlying resource to match the current session
- * configuration.
+ * Given a job name and configured job data, update the underlying resource
+ * to match the current job configuration.
*/
- public abstract void update(String sessionName, SessionData data)
+ public abstract void update(String jobName, JobData data)
throws IOException;
/**
- * Close any resources opened by the SessionStorage system.
+ * Close any resources opened by the JobStorage system.
*/
public void close() throws IOException {
}
/**
- * Enumerate all sessions held in the connected resource.
+ * Enumerate all jobs held in the connected resource.
*/
public abstract List list() throws IOException;
}
diff --git a/src/java/com/cloudera/sqoop/metastore/SessionStorageFactory.java b/src/java/com/cloudera/sqoop/metastore/JobStorageFactory.java
similarity index 61%
rename from src/java/com/cloudera/sqoop/metastore/SessionStorageFactory.java
rename to src/java/com/cloudera/sqoop/metastore/JobStorageFactory.java
index 3ae75bb8..4ed46df2 100644
--- a/src/java/com/cloudera/sqoop/metastore/SessionStorageFactory.java
+++ b/src/java/com/cloudera/sqoop/metastore/JobStorageFactory.java
@@ -24,26 +24,26 @@
import org.apache.hadoop.conf.Configuration;
/**
- * Factory that produces the correct SessionStorage system to work with
- * a particular session descriptor.
+ * Factory that produces the correct JobStorage system to work with
+ * a particular job descriptor.
*/
-public class SessionStorageFactory {
+public class JobStorageFactory {
private Configuration conf;
/**
- * Configuration key describing the list of SessionStorage implementations
- * to use to handle sessions.
+ * Configuration key describing the list of JobStorage implementations
+ * to use to handle jobs.
*/
public static final String AVAILABLE_STORAGES_KEY =
- "sqoop.session.storage.implementations";
+ "sqoop.job.storage.implementations";
- /** The default list of available SessionStorage implementations. */
+ /** The default list of available JobStorage implementations. */
private static final String DEFAULT_AVAILABLE_STORAGES =
- "com.cloudera.sqoop.metastore.hsqldb.HsqldbSessionStorage,"
+ "com.cloudera.sqoop.metastore.hsqldb.HsqldbJobStorage,"
+ "com.cloudera.sqoop.metastore.hsqldb.AutoHsqldbStorage";
- public SessionStorageFactory(Configuration config) {
+ public JobStorageFactory(Configuration config) {
this.conf = config;
// Ensure that we always have an available storages list.
@@ -53,14 +53,14 @@ public SessionStorageFactory(Configuration config) {
}
/**
- * Given a session descriptor, determine the correct SessionStorage
- * implementation to use to handle the session and return an instance
- * of it -- or null if no SessionStorage instance is appropriate.
+ * Given a storage descriptor, determine the correct JobStorage
+ * implementation to use to connect to the storage resource and return an
+ * instance of it -- or null if no JobStorage instance is appropriate.
*/
- public SessionStorage getSessionStorage(Map descriptor) {
- List storages = this.conf.getInstances(
- AVAILABLE_STORAGES_KEY, SessionStorage.class);
- for (SessionStorage stor : storages) {
+ public JobStorage getJobStorage(Map descriptor) {
+ List storages = this.conf.getInstances(
+ AVAILABLE_STORAGES_KEY, JobStorage.class);
+ for (JobStorage stor : storages) {
if (stor.canAccept(descriptor)) {
return stor;
}
diff --git a/src/java/com/cloudera/sqoop/metastore/hsqldb/AutoHsqldbStorage.java b/src/java/com/cloudera/sqoop/metastore/hsqldb/AutoHsqldbStorage.java
index e51190fd..fded5558 100644
--- a/src/java/com/cloudera/sqoop/metastore/hsqldb/AutoHsqldbStorage.java
+++ b/src/java/com/cloudera/sqoop/metastore/hsqldb/AutoHsqldbStorage.java
@@ -29,10 +29,10 @@
import org.apache.hadoop.conf.Configuration;
/**
- * SessionStorage implementation that auto-configures an HSQLDB
- * local-file-based instance to hold sessions.
+ * JobStorage implementation that auto-configures an HSQLDB
+ * local-file-based instance to hold jobs.
*/
-public class AutoHsqldbStorage extends HsqldbSessionStorage {
+public class AutoHsqldbStorage extends HsqldbJobStorage {
public static final Log LOG = LogFactory.getLog(
AutoHsqldbStorage.class.getName());
diff --git a/src/java/com/cloudera/sqoop/metastore/hsqldb/HsqldbSessionStorage.java b/src/java/com/cloudera/sqoop/metastore/hsqldb/HsqldbJobStorage.java
similarity index 79%
rename from src/java/com/cloudera/sqoop/metastore/hsqldb/HsqldbSessionStorage.java
rename to src/java/com/cloudera/sqoop/metastore/hsqldb/HsqldbJobStorage.java
index 5009dc3a..181a4995 100644
--- a/src/java/com/cloudera/sqoop/metastore/hsqldb/HsqldbSessionStorage.java
+++ b/src/java/com/cloudera/sqoop/metastore/hsqldb/HsqldbJobStorage.java
@@ -39,20 +39,18 @@
import org.apache.hadoop.conf.Configuration;
import com.cloudera.sqoop.SqoopOptions;
-
-import com.cloudera.sqoop.metastore.SessionData;
-import com.cloudera.sqoop.metastore.SessionStorage;
-
+import com.cloudera.sqoop.metastore.JobData;
+import com.cloudera.sqoop.metastore.JobStorage;
import com.cloudera.sqoop.tool.SqoopTool;
/**
- * SessionStorage implementation that uses an HSQLDB-backed database to
- * hold session information.
+ * JobStorage implementation that uses an HSQLDB-backed database to
+ * hold job information.
*/
-public class HsqldbSessionStorage extends SessionStorage {
+public class HsqldbJobStorage extends JobStorage {
public static final Log LOG = LogFactory.getLog(
- HsqldbSessionStorage.class.getName());
+ HsqldbJobStorage.class.getName());
/** descriptor key identifying the connect string for the metastore. */
public static final String META_CONNECT_KEY = "metastore.connect.string";
@@ -77,20 +75,20 @@ public class HsqldbSessionStorage extends SessionStorage {
/** root metadata table key used to define the current schema version. */
private static final String STORAGE_VERSION_KEY =
- "sqoop.hsqldb.session.storage.version";
+ "sqoop.hsqldb.job.storage.version";
/** The current version number for the schema edition. */
private static final int CUR_STORAGE_VERSION = 0;
- /** root metadata table key used to define the session table name. */
+ /** root metadata table key used to define the job table name. */
private static final String SESSION_TABLE_KEY =
- "sqoop.hsqldb.session.info.table";
+ "sqoop.hsqldb.job.info.table";
/** Default value for SESSION_TABLE_KEY. */
private static final String DEFAULT_SESSION_TABLE_NAME =
"SQOOP_SESSIONS";
- /** Per-session key with propClass 'schema' that defines the set of
+ /** Per-job key with propClass 'schema' that defines the set of
* properties valid to be defined for propClass 'SqoopOptions'. */
private static final String PROPERTY_SET_KEY =
"sqoop.property.set.id";
@@ -111,7 +109,7 @@ public class HsqldbSessionStorage extends SessionStorage {
private static final String PROPERTY_CLASS_CONFIG = "config";
/**
- * Per-session key with propClass 'schema' that specifies the SqoopTool
+ * Per-job key with propClass 'schema' that specifies the SqoopTool
* to load.
*/
private static final String SQOOP_TOOL_KEY = "sqoop.tool";
@@ -128,8 +126,8 @@ protected Connection getConnection() {
}
// After connection to the database and initialization of the
- // schema, this holds the name of the session table.
- private String sessionTableName;
+ // schema, this holds the name of the job table.
+ private String jobTableName;
protected void setMetastoreConnectStr(String connectStr) {
this.metastoreConnectStr = connectStr;
@@ -252,23 +250,23 @@ public boolean canAccept(Map descriptor) {
@Override
/** {@inheritDoc} */
- public SessionData read(String sessionName) throws IOException {
+ public JobData read(String jobName) throws IOException {
try {
- if (!sessionExists(sessionName)) {
- LOG.error("Cannot restore session: " + sessionName);
- LOG.error("(No such session)");
- throw new IOException("Cannot restore missing session " + sessionName);
+ if (!jobExists(jobName)) {
+ LOG.error("Cannot restore job: " + jobName);
+ LOG.error("(No such job)");
+ throw new IOException("Cannot restore missing job " + jobName);
}
- LOG.debug("Restoring session: " + sessionName);
- Properties schemaProps = getV0Properties(sessionName,
+ LOG.debug("Restoring job: " + jobName);
+ Properties schemaProps = getV0Properties(jobName,
PROPERTY_CLASS_SCHEMA);
- Properties sqoopOptProps = getV0Properties(sessionName,
+ Properties sqoopOptProps = getV0Properties(jobName,
PROPERTY_CLASS_SQOOP_OPTIONS);
- Properties configProps = getV0Properties(sessionName,
+ Properties configProps = getV0Properties(jobName,
PROPERTY_CLASS_CONFIG);
- // Check that we're not using a saved session from a previous
+ // Check that we're not using a saved job from a previous
// version whose functionality has been deprecated.
String thisPropSetId = schemaProps.getProperty(PROPERTY_SET_KEY);
LOG.debug("System property set: " + CUR_PROPERTY_SET_ID);
@@ -289,7 +287,7 @@ public SessionData read(String sessionName) throws IOException {
SqoopTool tool = SqoopTool.getTool(toolName);
if (null == tool) {
- throw new IOException("Error in session metadata: invalid tool "
+ throw new IOException("Error in job metadata: invalid tool "
+ toolName);
}
@@ -302,26 +300,26 @@ public SessionData read(String sessionName) throws IOException {
opts.setConf(conf);
opts.loadProperties(sqoopOptProps);
- // Set the session connection information for this session.
- opts.setSessionName(sessionName);
+ // Set the job connection information for this job.
+ opts.setJobName(jobName);
opts.setStorageDescriptor(connectedDescriptor);
- return new SessionData(opts, tool);
+ return new JobData(opts, tool);
} catch (SQLException sqlE) {
throw new IOException("Error communicating with database", sqlE);
}
}
- private boolean sessionExists(String sessionName) throws SQLException {
+ private boolean jobExists(String jobName) throws SQLException {
PreparedStatement s = connection.prepareStatement(
- "SELECT COUNT(session_name) FROM " + this.sessionTableName
- + " WHERE session_name = ? GROUP BY session_name");
+ "SELECT COUNT(job_name) FROM " + this.jobTableName
+ + " WHERE job_name = ? GROUP BY job_name");
ResultSet rs = null;
try {
- s.setString(1, sessionName);
+ s.setString(1, jobName);
rs = s.executeQuery();
if (rs.next()) {
- return true; // We got a result, meaning the session exists.
+ return true; // We got a result, meaning the job exists.
}
} finally {
if (null != rs) {
@@ -340,16 +338,16 @@ private boolean sessionExists(String sessionName) throws SQLException {
@Override
/** {@inheritDoc} */
- public void delete(String sessionName) throws IOException {
+ public void delete(String jobName) throws IOException {
try {
- if (!sessionExists(sessionName)) {
- LOG.error("No such session: " + sessionName);
+ if (!jobExists(jobName)) {
+ LOG.error("No such job: " + jobName);
} else {
- LOG.debug("Deleting session: " + sessionName);
+ LOG.debug("Deleting job: " + jobName);
PreparedStatement s = connection.prepareStatement("DELETE FROM "
- + this.sessionTableName + " WHERE session_name = ?");
+ + this.jobTableName + " WHERE job_name = ?");
try {
- s.setString(1, sessionName);
+ s.setString(1, jobName);
s.executeUpdate();
} finally {
s.close();
@@ -368,40 +366,40 @@ public void delete(String sessionName) throws IOException {
@Override
/** {@inheritDoc} */
- public void create(String sessionName, SessionData data)
+ public void create(String jobName, JobData data)
throws IOException {
try {
- if (sessionExists(sessionName)) {
- LOG.error("Cannot create session " + sessionName
+ if (jobExists(jobName)) {
+ LOG.error("Cannot create job " + jobName
+ ": it already exists");
- throw new IOException("Session " + sessionName + " already exists");
+ throw new IOException("Job " + jobName + " already exists");
}
} catch (SQLException sqlE) {
throw new IOException("Error communicating with database", sqlE);
}
- createInternal(sessionName, data);
+ createInternal(jobName, data);
}
/**
- * Actually insert/update the resources for this session.
+ * Actually insert/update the resources for this job.
*/
- private void createInternal(String sessionName, SessionData data)
+ private void createInternal(String jobName, JobData data)
throws IOException {
try {
- LOG.debug("Creating session: " + sessionName);
+ LOG.debug("Creating job: " + jobName);
// Save the name of the Sqoop tool.
- setV0Property(sessionName, PROPERTY_CLASS_SCHEMA, SQOOP_TOOL_KEY,
+ setV0Property(jobName, PROPERTY_CLASS_SCHEMA, SQOOP_TOOL_KEY,
data.getSqoopTool().getToolName());
// Save the property set id.
- setV0Property(sessionName, PROPERTY_CLASS_SCHEMA, PROPERTY_SET_KEY,
+ setV0Property(jobName, PROPERTY_CLASS_SCHEMA, PROPERTY_SET_KEY,
CUR_PROPERTY_SET_ID);
// Save all properties of the SqoopOptions.
Properties props = data.getSqoopOptions().writeProperties();
- setV0Properties(sessionName, PROPERTY_CLASS_SQOOP_OPTIONS, props);
+ setV0Properties(jobName, PROPERTY_CLASS_SQOOP_OPTIONS, props);
// And save all unique properties of the configuration.
Configuration saveConf = data.getSqoopOptions().getConf();
@@ -416,7 +414,7 @@ private void createInternal(String sessionName, SessionData data)
}
LOG.debug("Saving " + key + " => " + rawVal + " / " + baseVal);
- setV0Property(sessionName, PROPERTY_CLASS_CONFIG, key, rawVal);
+ setV0Property(jobName, PROPERTY_CLASS_CONFIG, key, rawVal);
}
connection.commit();
@@ -433,12 +431,12 @@ private void createInternal(String sessionName, SessionData data)
@Override
/** {@inheritDoc} */
- public void update(String sessionName, SessionData data)
+ public void update(String jobName, JobData data)
throws IOException {
try {
- if (!sessionExists(sessionName)) {
- LOG.error("Cannot update session " + sessionName + ": not found");
- throw new IOException("Session " + sessionName + " does not exist");
+ if (!jobExists(jobName)) {
+ LOG.error("Cannot update job " + jobName + ": not found");
+ throw new IOException("Job " + jobName + " does not exist");
}
} catch (SQLException sqlE) {
throw new IOException("Error communicating with database", sqlE);
@@ -446,7 +444,7 @@ public void update(String sessionName, SessionData data)
// Since we set properties with update-or-insert, this is the same
// as create on this system.
- createInternal(sessionName, data);
+ createInternal(jobName, data);
}
@Override
@@ -455,15 +453,15 @@ public List list() throws IOException {
ResultSet rs = null;
try {
PreparedStatement s = connection.prepareStatement(
- "SELECT DISTINCT session_name FROM " + this.sessionTableName);
+ "SELECT DISTINCT job_name FROM " + this.jobTableName);
try {
rs = s.executeQuery();
- ArrayList sessions = new ArrayList();
+ ArrayList jobs = new ArrayList();
while (rs.next()) {
- sessions.add(rs.getString(1));
+ jobs.add(rs.getString(1));
}
- return sessions;
+ return jobs;
} finally {
if (null != rs) {
try {
@@ -626,9 +624,9 @@ private void setRootProperty(String propertyName, Integer version,
}
/**
- * Create the sessions table in the V0 schema.
+ * Create the jobs table in the V0 schema.
*/
- private void createSessionTable() throws SQLException {
+ private void createJobTable() throws SQLException {
String curTableName = DEFAULT_SESSION_TABLE_NAME;
int tableNum = -1;
while (true) {
@@ -642,16 +640,16 @@ private void createSessionTable() throws SQLException {
// curTableName contains a table name that does not exist.
// Create this table.
- LOG.debug("Creating session storage table: " + curTableName);
+ LOG.debug("Creating job storage table: " + curTableName);
Statement s = connection.createStatement();
try {
s.executeUpdate("CREATE TABLE " + curTableName + " ("
- + "session_name VARCHAR(64) NOT NULL, "
+ + "job_name VARCHAR(64) NOT NULL, "
+ "propname VARCHAR(128) NOT NULL, "
+ "propval VARCHAR(1024), "
+ "propclass VARCHAR(32) NOT NULL, "
+ "CONSTRAINT " + curTableName + "_unq UNIQUE "
- + "(session_name, propname, propclass))");
+ + "(job_name, propname, propclass))");
// Then set a property in the root table pointing to it.
setRootProperty(SESSION_TABLE_KEY, 0, curTableName);
@@ -660,7 +658,7 @@ private void createSessionTable() throws SQLException {
s.close();
}
- this.sessionTableName = curTableName;
+ this.jobTableName = curTableName;
}
/**
@@ -669,42 +667,42 @@ private void createSessionTable() throws SQLException {
* if it does not already exist.
*/
private void initV0Schema() throws SQLException {
- this.sessionTableName = getRootProperty(SESSION_TABLE_KEY, 0);
- if (null == this.sessionTableName) {
- createSessionTable();
+ this.jobTableName = getRootProperty(SESSION_TABLE_KEY, 0);
+ if (null == this.jobTableName) {
+ createJobTable();
}
- if (!tableExists(this.sessionTableName)) {
- LOG.debug("Could not find session table: " + sessionTableName);
- createSessionTable();
+ if (!tableExists(this.jobTableName)) {
+ LOG.debug("Could not find job table: " + jobTableName);
+ createJobTable();
}
}
/**
- * INSERT or UPDATE a single (session, propname, class) to point
+ * INSERT or UPDATE a single (job, propname, class) to point
* to the specified property value.
*/
- private void setV0Property(String sessionName, String propClass,
+ private void setV0Property(String jobName, String propClass,
String propName, String propVal) throws SQLException {
- LOG.debug("Session: " + sessionName + "; Setting property "
+ LOG.debug("Job: " + jobName + "; Setting property "
+ propName + " with class " + propClass + " => " + propVal);
PreparedStatement s = null;
try {
- String curValue = getV0Property(sessionName, propClass, propName);
+ String curValue = getV0Property(jobName, propClass, propName);
if (null == curValue) {
// Property is not yet set.
- s = connection.prepareStatement("INSERT INTO " + this.sessionTableName
- + " (propval, session_name, propclass, propname) "
+ s = connection.prepareStatement("INSERT INTO " + this.jobTableName
+ + " (propval, job_name, propclass, propname) "
+ "VALUES (?, ?, ?, ?)");
} else {
// Overwrite existing property.
- s = connection.prepareStatement("UPDATE " + this.sessionTableName
- + " SET propval = ? WHERE session_name = ? AND propclass = ? "
+ s = connection.prepareStatement("UPDATE " + this.jobTableName
+ + " SET propval = ? WHERE job_name = ? AND propclass = ? "
+ "AND propname = ?");
}
s.setString(1, propVal);
- s.setString(2, sessionName);
+ s.setString(2, jobName);
s.setString(3, propClass);
s.setString(4, propName);
@@ -720,18 +718,18 @@ private void setV0Property(String sessionName, String propClass,
* Return a string containing the value of a specified property,
* or null if it is not set.
*/
- private String getV0Property(String sessionName, String propClass,
+ private String getV0Property(String jobName, String propClass,
String propertyName) throws SQLException {
- LOG.debug("Session: " + sessionName + "; Getting property "
+ LOG.debug("Job: " + jobName + "; Getting property "
+ propertyName + " with class " + propClass);
ResultSet rs = null;
PreparedStatement s = connection.prepareStatement(
- "SELECT propval FROM " + this.sessionTableName
- + " WHERE session_name = ? AND propclass = ? AND propname = ?");
+ "SELECT propval FROM " + this.jobTableName
+ + " WHERE job_name = ? AND propclass = ? AND propname = ?");
try {
- s.setString(1, sessionName);
+ s.setString(1, jobName);
s.setString(2, propClass);
s.setString(3, propertyName);
rs = s.executeQuery();
@@ -759,19 +757,19 @@ private String getV0Property(String sessionName, String propClass,
/**
* Get a java.util.Properties containing all propName -> propVal
- * bindings for a given (sessionName, propClass).
+ * bindings for a given (jobName, propClass).
*/
- private Properties getV0Properties(String sessionName, String propClass)
+ private Properties getV0Properties(String jobName, String propClass)
throws SQLException {
- LOG.debug("Session: " + sessionName
+ LOG.debug("Job: " + jobName
+ "; Getting properties with class " + propClass);
ResultSet rs = null;
PreparedStatement s = connection.prepareStatement(
- "SELECT propname, propval FROM " + this.sessionTableName
- + " WHERE session_name = ? AND propclass = ?");
+ "SELECT propname, propval FROM " + this.jobTableName
+ + " WHERE job_name = ? AND propclass = ?");
try {
- s.setString(1, sessionName);
+ s.setString(1, jobName);
s.setString(2, propClass);
rs = s.executeQuery();
@@ -794,15 +792,15 @@ private Properties getV0Properties(String sessionName, String propClass)
}
}
- private void setV0Properties(String sessionName, String propClass,
+ private void setV0Properties(String jobName, String propClass,
Properties properties) throws SQLException {
- LOG.debug("Session: " + sessionName
+ LOG.debug("Job: " + jobName
+ "; Setting bulk properties for class " + propClass);
for (Map.Entry