本文整理匯總了Java中com.goldengate.atg.datasource.adapt.Op類的典型用法代碼示例。如果您正苦於以下問題:Java Op類的具體用法?Java Op怎麽用?Java Op使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Op類屬於com.goldengate.atg.datasource.adapt包,在下文中一共展示了Op類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
@Override
public void init(DsConfiguration arg0, DsMetaData arg1) {
super.init(arg0, arg1);
// TODO: Do something with the config file
kafkaConfigFile = KAFKA_CONFIG_FILE; // set default value
MutationMapper<Op, TableMetaData> mapper = new TypedMutationMapper();// TODO:
// get
// this
// from
// a
// config
// file
handler = new KafkaAvroHandler<Op, TableMetaData, MutationMapper<Op, TableMetaData>>(
mapper, kafkaConfigFile);
super.init(arg0, arg1);
logger.info("Done Initializing Kafka Handler");
}
示例2: operationAdded
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
@Override
final public Status operationAdded(DsEvent e, DsTransaction transaction,
DsOperation operation) {
logger.info("Operation added event. Operation type = "
+ operation.getOperationType());
Status status = Status.OK;
super.operationAdded(e, transaction, operation);
if (isOperationMode()) {
final Tx tx = new Tx(transaction, getMetaData(), getConfig());
final TableMetaData tMeta = getMetaData().getTableMetaData(
operation.getTableName());
final Op op = new Op(operation, tMeta, getConfig());
status = processOp(tx, op); // process data...
// TODO: Should we flush somewhere here?
}
return status;
}
示例3: processOp
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
final protected Status processOp(Tx currentTx, Op op) {
Status status = Status.OK;
logger.debug("Process operation: table=[" + op.getTableName() + "]"
+ ", op pos=" + op.getPosition() + ", tx pos="
+ currentTx.getTranID() + ", op ts=" + op.getTimestamp());
try {
processOpImpl(currentTx, op);
handlerProperties.totalOperations++;
} catch (RuntimeException e) {
status = Status.ABEND;
logger.error(
"Failed to Process operation: table=[" + op.getTableName()
+ "]" + ", op pos=" + op.getPosition()
+ ", tx pos=" + currentTx.getTranID() + ", op ts="
+ op.getTimestamp() + " with error: ", e);
}
return status;
}
示例4: createRow
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
private Row createRow(Op op, Schema schema, boolean onlyChanged ) throws IOException{
Row row = new Row();
TableMetaData tbl_meta = op.getTableMeta();
int i = 0;
for(DsColumn column : op) {
ColumnMetaData col_meta = tbl_meta.getColumnMetaData(i);;
// TODO: DO we really need key columns here? Yes, for now!. Considering adding a key field or row (since keys can be aggregates) to Mutation
if (!onlyChanged || column.isChanged() || col_meta.isKeyCol()){
String name = col_meta.getColumnName();
if (column.getAfter() == null){
logger.warn("column {}.{} of SQL type {} in null" , tbl_meta.getTableName(), name , column, col_meta.getDataType().getJDBCType());
}else{
logger.debug("\t convertColumn {} = {} colType = {}" , name , column, col_meta.getDataType().getJDBCType());
row.addColumn(name,convertColumn(column.getAfter(),col_meta.getDataType().getJDBCType()));
}
}
i++;
}
logger.info("row: {} ", row);
return row;
}
示例5: toMutation
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
@Override
public Mutation toMutation(Op op) throws IOException {
Row row;
Table table = toTable(op.getTableMeta());
Schema schema = table.getSchema();
switch(op.getOpType()){
case DO_INSERT:
row = createRow(op, schema, false);
return new InsertMutation(table, row);
case DO_DELETE:
//row = createRow(op, schema, false);
return new DeleteMutation(table, createBeforeKeyRow(op, schema));
case DO_UPDATE:
case DO_UPDATE_FIELDCOMP:
case DO_UPDATE_AC:
row = createRow(op, schema, true);
return new UpdateMutation(table, row);
case DO_UPDATE_FIELDCOMP_PK:
row = createRow(op, schema, true);
return new PkUpdateMutation(table, createBeforeKeyRow(op, schema), row);
default:
//logger.error("The operation type " + op.getOpType() + " on operation: table=[" + op.getTableName() + "]" + ", op ts=" + op.getTimestamp() + "is not supported");
throw new IllegalArgumentException("KafkaAvroHandler::getMagicByte Unknown operation type");
}
}
示例6: encode
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
@Override
public byte[] encode(Tx tx, Op op) {
try {
ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
JsonGenerator jsonGenerator = factory.createGenerator(outBytes);
jsonGenerator.writeStartObject();
writeOperationMetaData(op, jsonGenerator);
writeColumnArray(op, jsonGenerator, op.getOpType());
writeTokenArray(op, jsonGenerator);
jsonGenerator.writeEndObject();
jsonGenerator.flush();
return outBytes.toByteArray();
} catch (IOException e) {
log.error("Error serializing operation to JSON. message: " + op.toString(), e);
throw new UnableToEncodeMessageException("Error encoding message as JSON.", e);
}
}
示例7: writeTokenArray
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
private void writeTokenArray(Op op, JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeArrayFieldStart(JsonFields.JSON_TOKENS);
Optional<TableConfiguration> configurationForTable = getConfigurationForTable(op.getTableName());
if (configurationForTable.isPresent()) {
Map<String, String> tokenMap = new HashMap<>();
for (Map.Entry<String,DsToken> entry : op.getData().getTokens().entrySet()) {
if (entry.getValue().isSet()) {
tokenMap.put(entry.getKey().toUpperCase(), entry.getValue().toString());
} else {
tokenMap.put(entry.getKey().toUpperCase(), null);
}
}
for (String tokenName : configurationForTable.get().getTokenNames()) {
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField(JsonFields.JSON_COLUMN_NAME, tokenName.toUpperCase());
writeNullableField(JsonFields.JSON_VALUE, tokenMap.get(tokenName), jsonGenerator);
jsonGenerator.writeEndObject();
}
}
jsonGenerator.writeEndArray();
}
示例8: processOperation
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
protected void processOperation(Op op, Configure configure) throws Exception {
String oracleFullTableName = op.getTableName().getFullName().toLowerCase();
TableMapping tableMapping = configure.getTableMapping(oracleFullTableName);
if(tableMapping != null){
RecordEntry record;
try {
record = RecordBuilder.instance().buildRecord(op,
getOperateType(),
tableMapping);
} catch (Exception e){
logger.error("dirty data :" + op.toString(), e);
if(configure.isDirtyDataContinue()){
BadOperateWriter.write(op,
oracleFullTableName,
tableMapping.getTopic().getTopicName(),
configure.getDirtyDataFile(),
configure.getDirtyDataFileMaxSize() * 1000000,
e.getMessage());
return;
} else{
throw e;
}
}
DataHubWriter.instance().addRecord(tableMapping.getOracleFullTableName(), record);
} else{
logger.warn("oracle table:" + oracleFullTableName + " not config");
}
}
示例9: write
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
public static void write(Op op, String oracleFullTableName, String topicName, String fileName,
int maxFileSize, String msg) {
checkFileSize(fileName, maxFileSize);
DirtyRecordInfo dirtyRecordInfo = new DirtyRecordInfo();
dirtyRecordInfo.setOracleTable(oracleFullTableName);
dirtyRecordInfo.setTopicName(topicName);
dirtyRecordInfo.setShardId(null);
dirtyRecordInfo.setErrorMessage(msg);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dirtyRecordInfo.setErrorTime(simpleDateFormat.format(new Date()));
Map<String, String> record = Maps.newHashMap();
dirtyRecordInfo.setRecord(record);
List<DsColumn> cols = op.getColumns();
for (int i = 0; i < cols.size(); i++) {
String colName = op.getTableMeta().getColumnName(i).toLowerCase();
record.put(colName, cols.get(i).getAfterValue());
}
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(fileName, true));
bw.write(JsonHelper.beanToJson(dirtyRecordInfo) + "\n");
bw.close();
} catch (IOException e) {
logger.error("logBadOperation() failed. ", e);
throw new RuntimeException("logBadOperation() failed. ", e);
}
}
示例10: createBeforeKeyRow
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
private Row createBeforeKeyRow(Op op, Schema schema) throws IOException{
Row row = new Row();
TableMetaData tbl_meta = op.getTableMeta();
int i = 0;
for(DsColumn column : op) {
ColumnMetaData col_meta = tbl_meta.getColumnMetaData(i);;
if ( col_meta.isKeyCol()){
String name = col_meta.getColumnName();
row.addColumn(name,convertColumn(column.getBefore(),col_meta.getDataType().getJDBCType()));
}
i++;
}
logger.info("row: {}", row);
return row;
}
示例11: writeOperationMetaData
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
private void writeOperationMetaData(Op op, JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeStringField(JsonFields.JSON_SCHEMA, op.getTableName().getSchemaName());
jsonGenerator.writeStringField(JsonFields.JSON_TABLE, op.getTableName().getShortName());
jsonGenerator.writeStringField(JsonFields.JSON_MODTYPE, String.valueOf(op.getOperationType().getCharID()));
jsonGenerator.writeStringField(JsonFields.JSON_TIMESTAMP, op.getTimestamp());
jsonGenerator.writeStringField(JsonFields.JSON_TIMEZONE, ENV_TIMEZONE);
writeTransactionMetadata(op, jsonGenerator);
}
示例12: writeTransactionMetadata
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
private void writeTransactionMetadata(Op op, JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeNumberField(JsonFields.JSON_FILESEQNO, op.getSeqno());
jsonGenerator.writeNumberField(JsonFields.JSON_FILERBA, op.getRba());
jsonGenerator.writeNumberField(JsonFields.JSON_TRANSIND, op.getTxState().getState());
writeNullableField(JsonFields.JSON_DBUSER, op.getEnv(GoldenGateConstants.ENV_TRANSACTION, GoldenGateConstants.ENV_USERNAME), jsonGenerator);
writeNullableField(JsonFields.JSON_GGHOST, op.getEnv(GoldenGateConstants.ENV_GGENVIRONMENT, GoldenGateConstants.ENV_HOSTNAME), jsonGenerator);
writeNullableField(JsonFields.JSON_TRANSID, op.getEnv(GoldenGateConstants.ENV_TRANSACTION, GoldenGateConstants.ENV_TRANSACTIONID), jsonGenerator);
}
示例13: writeColumnArray
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
private void writeColumnArray(Op op, JsonGenerator jsonGenerator, DsOperation.OpType operationType) throws IOException {
jsonGenerator.writeArrayFieldStart(JsonFields.JSON_COLUMNS);
for (Col column : op) {
writeColumnObject(jsonGenerator, operationType, column);
}
jsonGenerator.writeEndArray();
}
示例14: operationAdded
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
@Override
public Status operationAdded(DsEvent e, DsTransaction transaction, DsOperation operation) {
Status overallStatus = Status.OK;
super.operationAdded(e, transaction, operation);
numOps.incrementAndGet();
final Tx tx = new Tx(transaction, getMetaData(), getConfig());
final TableMetaData tMeta = getMetaData().getTableMetaData(operation.getTableName());
final Op op = new Op(operation, tMeta, getConfig());
operation.getTokens();
if (isOperationMode()) {
if (log.isDebugEnabled()) {
log.debug(" Received operation: table='"
+ op.getTableName() + "'"
+ ", pos=" + op.getPosition()
+ " (total_ops= " + tx.getTotalOps()
+ ", buffered=" + tx.getSize() + ")"
+ ", ts=" + op.getTimestamp());
}
Status operationStatus = processOperation(tx, op);
if (Status.ABEND.equals(operationStatus)) {
overallStatus = Status.ABEND;
}
}
return overallStatus;
}
示例15: transactionCommit
import com.goldengate.atg.datasource.adapt.Op; //導入依賴的package包/類
@Override
public Status transactionCommit(DsEvent e, DsTransaction transaction) {
Status overallStatus = Status.OK;
super.transactionCommit(e, transaction);
Tx tx = txFactory.createAdapterTx(transaction, getMetaData(), getConfig());
numTxs.incrementAndGet();
if (log.isDebugEnabled()) {
log.debug("transactionCommit event, tx #" + numTxs.get() + ":"
+ ", pos=" + tx.getTranID()
+ " (total_ops= " + tx.getTotalOps()
+ ", buffered=" + tx.getSize() + ")"
+ ", ts=" + tx.getTimestamp() + ")");
}
if (!isOperationMode()) {
for (Op op : tx) {
Status operationStatus = processOperation(tx, op);
if (Status.ABEND.equals(operationStatus)) {
overallStatus = Status.ABEND;
}
}
}
return overallStatus;
}