int getOperationFromRecord ( Record record , int defaultOpCode , UnsupportedOperationAction unsupportedAction , List < OnRecordErrorException > errorRecords ) { String op = record . getHeader ( ) . getAttribute ( OperationType . SDC_OPERATION_TYPE ) ; int opCode = - 1 ; // unsupported if ( Strings . isNullOrEmpty ( op ) ) { return defaultOpCode ; } // Check if the operation code from header attribute is valid try { opCode = JDBCOperationType . convertToIntCode ( op ) ; } catch ( NumberFormatException | UnsupportedOperationException ex ) { LOG . debug ( "Operation obtained from record is not supported. Handle by UnsupportedOperationAction {}. {}" , unsupportedAction . getLabel ( ) , ex ) ; switch ( unsupportedAction ) { case SEND_TO_ERROR : LOG . debug ( "Sending record to error due to unsupported operation {}" , op ) ; errorRecords . add ( new OnRecordErrorException ( record , JdbcErrors . JDBC_70 , op ) ) ; break ; case USE_DEFAULT : opCode = defaultOpCode ; break ; case DISCARD : default : // unknown action LOG . debug ( "Discarding record with unsupported operation {}" , op ) ; } } return opCode ; }
Get the numeric operation code from record header . The default code is used if the operation code is not found in the header . This can be overwritten in inherited classes .