Review Board 1.7.22


SQOOP-1044 Sqoop2: Improve logging in metadata upgrade methods

Review Request #11074 - Created May 12, 2013 and submitted

Jarek Cecho
SQOOP-1044
Reviewers
Sqoop
sqoop-sqoop2
I've added extra logging so that we can find in log whether Sqoop server was or wasn't performing upgrade during start.
Both unit and integration tests seems to be passing.

Diff revision 1 (Latest)

  1. core/src/main/java/org/apache/sqoop/repository/Repository.java: Loading...
core/src/main/java/org/apache/sqoop/repository/Repository.java
Revision 3e34ccb New Change
[20] 14 lines
[+20]
15
 * See the License for the specific language governing permissions and
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
16
 * limitations under the License.
17
 */
17
 */
18
package org.apache.sqoop.repository;
18
package org.apache.sqoop.repository;
19

    
   
19

   

    
   
20
import org.apache.log4j.Logger;
20
import org.apache.sqoop.common.SqoopException;
21
import org.apache.sqoop.common.SqoopException;
21
import org.apache.sqoop.connector.ConnectorManager;
22
import org.apache.sqoop.connector.ConnectorManager;
22
import org.apache.sqoop.connector.spi.MetadataUpgrader;
23
import org.apache.sqoop.connector.spi.MetadataUpgrader;
23
import org.apache.sqoop.connector.spi.SqoopConnector;
24
import org.apache.sqoop.connector.spi.SqoopConnector;
24
import org.apache.sqoop.framework.FrameworkManager;
25
import org.apache.sqoop.framework.FrameworkManager;
[+20] [20] 22 lines
[+20]
47
 * Sqoop to store metadata, statistics and other state relevant to Sqoop
48
 * Sqoop to store metadata, statistics and other state relevant to Sqoop
48
 * Jobs in the system.
49
 * Jobs in the system.
49
 */
50
 */
50
public abstract class Repository {
51
public abstract class Repository {
51

    
   
52

   

    
   
53
  private static final Logger LOG = Logger.getLogger(Repository.class);

    
   
54

   
52
  public abstract RepositoryTransaction getTransaction();
55
  public abstract RepositoryTransaction getTransaction();
53

    
   
56

   
54
  /**
57
  /**
55
   * Registers given connector in the repository and return registered
58
   * Registers given connector in the repository and return registered
56
   * variant. This method might return an exception in case that metadata for
59
   * variant. This method might return an exception in case that metadata for
[+20] [20] 262 lines
[+20] [+] private void deleteConnectionsAndJobs(List<MConnection> connections,
319
   *
322
   *
320
   * @param oldConnector The old connector that should be upgraded.
323
   * @param oldConnector The old connector that should be upgraded.
321
   * @param newConnector New properties for the Connector that should be
324
   * @param newConnector New properties for the Connector that should be
322
   *                     upgraded.
325
   *                     upgraded.
323
   */
326
   */
324
  public final void upgradeConnector(MConnector oldConnector,
327
  public final void upgradeConnector(MConnector oldConnector, MConnector newConnector) {
325
    MConnector newConnector) {
328
    LOG.info("Upgrading metadata for connector: " + oldConnector.getUniqueName());
326
    long connectorID = oldConnector.getPersistenceId();
329
    long connectorID = oldConnector.getPersistenceId();
327
    newConnector.setPersistenceId(connectorID);
330
    newConnector.setPersistenceId(connectorID);
328
    /* Algorithms:
331
    /* Algorithms:
329
     * 1. Get an upgrader for the connector.
332
     * 1. Get an upgrader for the connector.
330
     * 2. Get all connections associated with the connector.
333
     * 2. Get all connections associated with the connector.
[+20] [20] 55 lines
[+20] public final void upgradeConnector(MConnector oldConnector, public final void upgradeConnector(MConnector oldConnector, MConnector newConnector) {
386
      throw new SqoopException(RepositoryError.JDBCREPO_0000, ex);
389
      throw new SqoopException(RepositoryError.JDBCREPO_0000, ex);
387
    } finally {
390
    } finally {
388
      if(tx != null) {
391
      if(tx != null) {
389
        tx.close();
392
        tx.close();
390
      }
393
      }

    
   
394
      LOG.info("Metadata upgrade finished for connector: " + oldConnector.getUniqueName());
391
    }
395
    }
392
  }
396
  }
393

    
   
397

   
394
  public final void upgradeFramework(MFramework framework) {
398
  public final void upgradeFramework(MFramework framework) {

    
   
399
    LOG.info("Upgrading framework metadata");
395
    RepositoryTransaction tx = null;
400
    RepositoryTransaction tx = null;
396
    try {
401
    try {
397
      MetadataUpgrader upgrader = FrameworkManager.getInstance()
402
      MetadataUpgrader upgrader = FrameworkManager.getInstance()
398
        .getMetadataUpgrader();
403
        .getMetadataUpgrader();
399
      List<MConnection> connections = findConnections();
404
      List<MConnection> connections = findConnections();
[+20] [20] 39 lines
[+20] public final void upgradeConnector(MConnector oldConnector, public final void upgradeConnector(MConnector oldConnector, MConnector newConnector) {
439
      throw new SqoopException(RepositoryError.JDBCREPO_0000, ex);
444
      throw new SqoopException(RepositoryError.JDBCREPO_0000, ex);
440
    } finally {
445
    } finally {
441
      if(tx != null) {
446
      if(tx != null) {
442
        tx.close();
447
        tx.close();
443
      }
448
      }

    
   
449
      LOG.info("Framework metadata upgrade finished");
444
    }
450
    }
445
  }
451
  }
446

    
   
452

   
447
  /**
453
  /**
448
   * Clones the forms, but does not set the actual data,
454
   * Clones the forms, but does not set the actual data,
[+20] [20] 33 lines
  1. core/src/main/java/org/apache/sqoop/repository/Repository.java: Loading...