mirror of
https://github.com/apache/sqoop.git
synced 2025-05-09 21:01:20 +08:00
SQOOP-2398: Sqoop2: Show all job with order
(Richard via Jarek Jarcec Cecho)
This commit is contained in:
parent
aca7d75589
commit
81b42fe4c0
@ -945,7 +945,7 @@ public List<MJob> findJobs(Connection conn) {
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
stmt = conn
|
||||
.prepareStatement(crudQueries.getStmtSelectJobAll());
|
||||
.prepareStatement(crudQueries.getStmtSelectJobAllWithOrder());
|
||||
return loadJobs(stmt, conn);
|
||||
} catch (SQLException ex) {
|
||||
logException(ex);
|
||||
|
@ -441,6 +441,11 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
|
||||
+ " LEFT JOIN " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " TO_CONNECTOR"
|
||||
+ " ON " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_TO_LINK) + " = TO_CONNECTOR." + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID);
|
||||
|
||||
//DML: Select all jobs with order
|
||||
public static final String STMT_SELECT_JOB_ALL_WITH_ORDER =
|
||||
STMT_SELECT_JOB_ALL +
|
||||
" ORDER BY JOB." + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID);
|
||||
|
||||
// DML: Select one specific job
|
||||
public static final String STMT_SELECT_JOB_SINGLE_BY_ID =
|
||||
STMT_SELECT_JOB_ALL +
|
||||
@ -824,8 +829,8 @@ public String getStmtSelectJobsForLinkCheck() {
|
||||
return STMT_SELECT_JOBS_FOR_LINK_CHECK;
|
||||
}
|
||||
|
||||
public String getStmtSelectJobAll() {
|
||||
return STMT_SELECT_JOB_ALL;
|
||||
public String getStmtSelectJobAllWithOrder() {
|
||||
return STMT_SELECT_JOB_ALL_WITH_ORDER;
|
||||
}
|
||||
|
||||
public String getStmtSelectJobSingleById() {
|
||||
|
@ -0,0 +1,104 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.sqoop.integration.server;
|
||||
|
||||
import org.apache.sqoop.connector.hdfs.configuration.ToFormat;
|
||||
import org.apache.sqoop.model.MJob;
|
||||
import org.apache.sqoop.model.MLink;
|
||||
import org.apache.sqoop.test.testcases.ConnectorTestCase;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Ensure that jobs will be shown in order
|
||||
*/
|
||||
public class ShowJobInOrderTest extends ConnectorTestCase {
|
||||
|
||||
public ShowJobInOrderTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowJobInOrder() throws Exception {
|
||||
createAndLoadTableCities();
|
||||
|
||||
// RDBMS link
|
||||
MLink rdbmsLink = getClient().createLink("generic-jdbc-connector");
|
||||
fillRdbmsLinkConfig(rdbmsLink);
|
||||
saveLink(rdbmsLink);
|
||||
|
||||
// HDFS link
|
||||
MLink hdfsLink = getClient().createLink("hdfs-connector");
|
||||
fillHdfsLink(hdfsLink);
|
||||
saveLink(hdfsLink);
|
||||
|
||||
// Job creation
|
||||
MJob job = getClient().createJob(rdbmsLink.getPersistenceId(), hdfsLink.getPersistenceId());
|
||||
|
||||
// rdms "FROM" config
|
||||
fillRdbmsFromConfig(job, "id");
|
||||
|
||||
// hdfs "TO" config
|
||||
fillHdfsToConfig(job, ToFormat.TEXT_FILE);
|
||||
|
||||
saveJob(job);
|
||||
|
||||
// Job creation
|
||||
job = getClient().createJob(hdfsLink.getPersistenceId(), rdbmsLink.getPersistenceId());
|
||||
|
||||
// rdms "To" config
|
||||
fillRdbmsToConfig(job);
|
||||
|
||||
// hdfs "From" config
|
||||
fillHdfsFromConfig(job);
|
||||
|
||||
saveJob(job);
|
||||
|
||||
// Job creation
|
||||
job = getClient().createJob(rdbmsLink.getPersistenceId(), hdfsLink.getPersistenceId());
|
||||
|
||||
// rdms "FROM" config
|
||||
fillRdbmsFromConfig(job, "id");
|
||||
|
||||
// hdfs "TO" config
|
||||
fillHdfsToConfig(job, ToFormat.TEXT_FILE);
|
||||
|
||||
saveJob(job);
|
||||
|
||||
// Job creation
|
||||
job = getClient().createJob(hdfsLink.getPersistenceId(), rdbmsLink.getPersistenceId());
|
||||
|
||||
|
||||
// hdfs "From" config
|
||||
fillHdfsFromConfig(job);
|
||||
|
||||
// rdms "To" config
|
||||
fillRdbmsToConfig(job);
|
||||
|
||||
saveJob(job);
|
||||
|
||||
List<MJob> jobs = getClient().getJobs();
|
||||
|
||||
assertEquals(1, jobs.get(0).getPersistenceId());
|
||||
assertEquals(2, jobs.get(1).getPersistenceId());
|
||||
assertEquals(3, jobs.get(2).getPersistenceId());
|
||||
assertEquals(4, jobs.get(3).getPersistenceId());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user