Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0003830: Tibero bulk loader using tbLoader
- Loading branch information
elong
committed
Dec 14, 2018
1 parent
09f40f7
commit 475beae
Showing
6 changed files
with
205 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
symmetric-client/src/main/java/org/jumpmind/symmetric/ext/TiberoBulkDataLoaderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* Licensed to JumpMind Inc under one or more contributor | ||
* license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding | ||
* copyright ownership. JumpMind Inc licenses this file | ||
* to you under the GNU General Public License, version 3.0 (GPLv3) | ||
* (the "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* You should have received a copy of the GNU General Public License, | ||
* version 3.0 (GPLv3) along with this library; if not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
* 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.jumpmind.symmetric.ext; | ||
|
||
import java.util.List; | ||
|
||
import org.jumpmind.db.platform.DatabaseNamesConstants; | ||
import org.jumpmind.db.platform.IDatabasePlatform; | ||
import org.jumpmind.db.util.BasicDataSourcePropertyConstants; | ||
import org.jumpmind.security.SecurityConstants; | ||
import org.jumpmind.symmetric.ISymmetricEngine; | ||
import org.jumpmind.symmetric.common.ParameterConstants; | ||
import org.jumpmind.symmetric.db.ISymmetricDialect; | ||
import org.jumpmind.symmetric.io.OracleBulkDatabaseWriter; | ||
import org.jumpmind.symmetric.io.data.IDataWriter; | ||
import org.jumpmind.symmetric.io.data.writer.Conflict; | ||
import org.jumpmind.symmetric.io.data.writer.IDatabaseWriterErrorHandler; | ||
import org.jumpmind.symmetric.io.data.writer.IDatabaseWriterFilter; | ||
import org.jumpmind.symmetric.io.data.writer.ResolvedData; | ||
import org.jumpmind.symmetric.io.data.writer.TransformWriter; | ||
import org.jumpmind.symmetric.load.DefaultDataLoaderFactory; | ||
import org.jumpmind.symmetric.service.IParameterService; | ||
|
||
public class TiberoBulkDataLoaderFactory extends DefaultDataLoaderFactory { | ||
|
||
private ISymmetricEngine engine; | ||
|
||
public TiberoBulkDataLoaderFactory(ISymmetricEngine engine) { | ||
this.engine = engine; | ||
this.parameterService = engine.getParameterService(); | ||
} | ||
|
||
public String getTypeName() { | ||
return "tibero_bulk"; | ||
} | ||
|
||
public IDataWriter getDataWriter(String sourceNodeId, ISymmetricDialect symmetricDialect, | ||
TransformWriter transformWriter, List<IDatabaseWriterFilter> filters, | ||
List<IDatabaseWriterErrorHandler> errorHandlers, | ||
List<? extends Conflict> conflictSettings, List<ResolvedData> resolvedData) { | ||
|
||
IParameterService parmService = engine.getParameterService(); | ||
String dbUrl = parmService.getString(BasicDataSourcePropertyConstants.DB_POOL_URL); | ||
String dbUser = parmService.getString(BasicDataSourcePropertyConstants.DB_POOL_USER); | ||
if (dbUser != null && dbUser.startsWith(SecurityConstants.PREFIX_ENC)) { | ||
dbUser = engine.getSecurityService().decrypt(dbUser.substring(SecurityConstants.PREFIX_ENC.length())); | ||
} | ||
|
||
String dbPassword = parmService.getString(BasicDataSourcePropertyConstants.DB_POOL_PASSWORD); | ||
if (dbPassword != null && dbPassword.startsWith(SecurityConstants.PREFIX_ENC)) { | ||
dbPassword = engine.getSecurityService().decrypt(dbPassword.substring(SecurityConstants.PREFIX_ENC.length())); | ||
} | ||
|
||
String tbLoaderCommand = parmService.getString(ParameterConstants.DBDIALECT_TIBERO_BULK_LOAD_TBLOADER_CMD); | ||
String tbLoaderOptions = parmService.getString(ParameterConstants.DBDIALECT_TIBERO_BULK_LOAD_TBLOADER_OPTIONS); | ||
String ezConnectString = parmService.getString(ParameterConstants.DBDIALECT_TIBERO_BULK_LOAD_EZCONNECT); | ||
|
||
return new OracleBulkDatabaseWriter(symmetricDialect.getPlatform(), symmetricDialect.getTargetPlatform(), | ||
engine.getStagingManager(), engine.getTablePrefix(), tbLoaderCommand, tbLoaderOptions, | ||
dbUser, dbPassword, dbUrl, ezConnectString, | ||
buildDatabaseWriterSettings(filters, errorHandlers, conflictSettings, resolvedData)); | ||
} | ||
|
||
public boolean isPlatformSupported(IDatabasePlatform platform) { | ||
return DatabaseNamesConstants.TIBERO.equals(platform.getName()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
symmetric-client/src/main/java/org/jumpmind/symmetric/io/TiberoBulkDatabaseWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Licensed to JumpMind Inc under one or more contributor | ||
* license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding | ||
* copyright ownership. JumpMind Inc licenses this file | ||
* to you under the GNU General Public License, version 3.0 (GPLv3) | ||
* (the "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* You should have received a copy of the GNU General Public License, | ||
* version 3.0 (GPLv3) along with this library; if not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
* 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.jumpmind.symmetric.io; | ||
|
||
import java.io.File; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.jumpmind.db.platform.IDatabasePlatform; | ||
import org.jumpmind.symmetric.io.data.writer.DatabaseWriterSettings; | ||
import org.jumpmind.symmetric.io.stage.IStagingManager; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class TiberoBulkDatabaseWriter extends OracleBulkDatabaseWriter { | ||
|
||
protected final Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
public TiberoBulkDatabaseWriter(IDatabasePlatform symmetricPlatform, IDatabasePlatform targetPlatform, | ||
IStagingManager stagingManager, String tablePrefix, String tbLoaderCommand, String tbLoaderOptions, | ||
String dbUser, String dbPassword, String dbUrl, String ezConnectString, DatabaseWriterSettings settings) { | ||
super(symmetricPlatform, targetPlatform, stagingManager, tablePrefix, tbLoaderCommand, tbLoaderOptions, | ||
dbUser, dbPassword, dbUrl, ezConnectString, settings); | ||
} | ||
|
||
@Override | ||
protected void init() { | ||
if (StringUtils.isBlank(this.sqlLoaderCommand)) { | ||
String oracleHome = System.getenv("TB_HOME"); | ||
if (StringUtils.isNotBlank(oracleHome)) { | ||
this.sqlLoaderCommand = oracleHome + File.separator + "bin" + File.separator + "tbldr"; | ||
} else { | ||
this.sqlLoaderCommand = "tbldr"; | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected String getInfileControl() { | ||
return "INFILE '" + dataResource.getFile().getName() + "'\n"; | ||
} | ||
|
||
@Override | ||
protected String getLineTerminatedByControl() { | ||
return "LINES TERMINATED BY '" + LINE_TERMINATOR + "'"; | ||
} | ||
|
||
protected String getLoaderName() { | ||
return "TBLoader"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters