Package org.apache.sqoop.common

Examples of org.apache.sqoop.common.SqoopException


    // reconfigure jdbc handler
    String newJdbcHandlerClassName = repoContext.getHandlerClassName();
    if (newJdbcHandlerClassName == null
        || newJdbcHandlerClassName.trim().length() == 0) {
      throw new SqoopException(RepositoryError.JDBCREPO_0001,
          newJdbcHandlerClassName);
    }

    String oldJdbcHandlerClassName = oldRepoContext.getHandlerClassName();
    if (!newJdbcHandlerClassName.equals(oldJdbcHandlerClassName)) {
      LOG.warn("Repository JDBC handler cannot be replaced at the runtime. " +
               "You might need to restart the server.");
    }

    // reconfigure jdbc driver
    String newJdbcDriverClassName = repoContext.getDriverClass();
    if (newJdbcDriverClassName == null
        || newJdbcDriverClassName.trim().length() == 0) {
      throw new SqoopException(RepositoryError.JDBCREPO_0003,
              newJdbcDriverClassName);
    }

    String oldJdbcDriverClassName = oldRepoContext.getDriverClass();
    if (!newJdbcDriverClassName.equals(oldJdbcDriverClassName)) {
View Full Code Here


    handlerClassName = context.getString(
        RepoConfigurationConstants.SYSCFG_REPO_JDBC_HANDLER);

    if (handlerClassName == null || handlerClassName.trim().length() == 0) {
      throw new SqoopException(RepositoryError.JDBCREPO_0001,
          RepoConfigurationConstants.SYSCFG_REPO_JDBC_HANDLER);
    }

    connectionUrl = context.getString(
        RepoConfigurationConstants.SYSCFG_REPO_JDBC_URL);

    driverClassName = context.getString(
        RepoConfigurationConstants.SYSCFG_REPO_JDBC_DRIVER);

    String jdbcUserName = context.getString(
        RepoConfigurationConstants.SYSCFG_REPO_JDBC_USER);

    String jdbcPassword = context.getString(
        RepoConfigurationConstants.SYSCFG_REPO_JDBC_PASSWORD);

    connectionProperties = new Properties();

    Map<String, String> params = context.getNestedProperties(
        RepoConfigurationConstants.PREFIX_SYSCFG_REPO_JDBC_PROPERTIES);
    for (Map.Entry<String, String> entry : params.entrySet()) {
      connectionProperties.setProperty(entry.getKey(), entry.getValue());
    }

    if (jdbcUserName != null) {
      Object oldUser = connectionProperties.put("user", jdbcUserName);
      if (oldUser != null) {
        LOG.warn("Overriding user (" + oldUser
            + ") with explicitly specified user (" + jdbcUserName + ")");
      }
    }

    if (jdbcPassword != null) {
      Object oldPassword = connectionProperties.put("password", jdbcPassword);
      if (oldPassword != null) {
        LOG.warn("Overriding password from jdbc connection properties with "
            + "explicitly specified password.");
      }
    }

    String txIsolation = context.getString(
        RepoConfigurationConstants.SYSCFG_REPO_JDBC_TX_ISOLATION);

    if (txIsolation == null || txIsolation.trim().length() == 0) {
      throw new SqoopException(RepositoryError.JDBCREPO_0004);
    }

    try {
      transactionIsolation = JdbcTransactionIsolation.getByName(txIsolation);
    } catch (IllegalArgumentException ex) {
      throw new SqoopException(RepositoryError.JDBCREPO_0004,
          txIsolation, ex);
    }

    String maxConnStr = context.getString(
        RepoConfigurationConstants.SYSCFG_REPO_JDBC_MAX_CONN);

    if (maxConnStr == null || maxConnStr.trim().length() == 0) {
      throw new SqoopException(RepositoryError.JDBCREPO_0005,
          RepoConfigurationConstants.SYSCFG_REPO_JDBC_MAX_CONN);
    }

    int maxConnInt = 0;
    try {
      maxConnInt = Integer.parseInt(maxConnStr);
    } catch (NumberFormatException ex) {
      throw new SqoopException(RepositoryError.JDBCREPO_0005, maxConnStr, ex);
    }

    if (maxConnInt <= 0) {
      throw new SqoopException(RepositoryError.JDBCREPO_0005, maxConnStr);
    }

    maxConnections = maxConnInt;

    if (LOG.isInfoEnabled()) {
View Full Code Here

    }
  }

  void initialize(DataSource source, JdbcRepositoryTransactionFactory factory) {
    if (dataSource != null || txFactory != null) {
      throw new SqoopException(RepositoryError.JDBCREPO_0011);
    }

    dataSource = source;
    txFactory = factory;
  }
View Full Code Here

      split.setPartition(partition);
      splits.add(split);
    }

    if(splits.size() > maxPartitions) {
      throw new SqoopException(MapreduceExecutionError.MAPRED_EXEC_0025,
        String.format("Got %d, max was %d", splits.size(), maxPartitions));
    }

    return splits;
  }
View Full Code Here

        throw (SqoopException) t;
      }
      //In the rare case, it was not a SqoopException
      Throwables.propagate(t);
    } catch (Exception ex) {
      throw new SqoopException(MapreduceExecutionError.MAPRED_EXEC_0019, ex);
    }
  }
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public void registerConnector(MConnector mc, Connection conn) {
    if (mc.hasPersistenceId()) {
      throw new SqoopException(DerbyRepoError.DERBYREPO_0011,
        mc.getUniqueName());
    }
    mc.setPersistenceId(getConnectorId(mc, conn));
    insertFormsForConnector(mc, conn);
  }
View Full Code Here

        registerForms(null, jobForms.getType(), jobForms.getForms(),
          MFormType.JOB.name(), baseFormStmt, baseInputStmt);
      }

    } catch (SQLException ex) {
      throw new SqoopException(DerbyRepoError.DERBYREPO_0014, mf.toString(), ex);
    } finally {
      closeStatements(baseFormStmt, baseInputStmt);
    }
  }
View Full Code Here

        registerForms(connectorId, jobForms.getType(), jobForms.getForms(),
          MFormType.JOB.name(), baseFormStmt, baseInputStmt);
      }

    } catch (SQLException ex) {
      throw new SqoopException(DerbyRepoError.DERBYREPO_0014,
        mc.toString(), ex);
    } finally {
      closeStatements(baseFormStmt, baseInputStmt);
    }
View Full Code Here

        Object content = data.getContent(type);
        return content;
      } catch (Throwable t) {
        readerFinished = true;
        LOG.error("Caught exception e while getting content ", t);
        throw new SqoopException(MapreduceExecutionError.MAPRED_EXEC_0018, t);
      } finally {
        free.release();
      }
    }
View Full Code Here

      baseConnectorStmt.setString(2, mc.getClassName());
      baseConnectorStmt.setString(3, mc.getVersion());

      int baseConnectorCount = baseConnectorStmt.executeUpdate();
      if (baseConnectorCount != 1) {
        throw new SqoopException(DerbyRepoError.DERBYREPO_0012,
          Integer.toString(baseConnectorCount));
      }

      ResultSet rsetConnectorId = baseConnectorStmt.getGeneratedKeys();

      if (!rsetConnectorId.next()) {
        throw new SqoopException(DerbyRepoError.DERBYREPO_0013);
      }
      return rsetConnectorId.getLong(1);
    } catch (SQLException ex) {
      throw new SqoopException(DerbyRepoError.DERBYREPO_0014,
        mc.toString(), ex);
    } finally {
      closeStatements(baseConnectorStmt);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.sqoop.common.SqoopException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.