@Override public String getPhysicalTableName(Map<String, Object> hints, String logicalTableName) { TopicPartitionAware tpAware = (TopicPartitionAware) hints.get(QueryEngine.HINT_DATA_OBJECT); String fmt = null; String db = toDbName(tpAware.getTopic(), tpAware.getPartition()); switch (logicalTableName) { case MESSAGE_TABLE: fmt = "%s_message_%s"; TopicPartitionPriorityAware tppAware = (TopicPartitionPriorityAware) tpAware; return String.format(fmt, db, tppAware.getPriority()); case RESEND_MESSAGE_TABLE: fmt = "%s_resend_%s"; TopicPartitionPriorityGroupAware tpgAware = (TopicPartitionPriorityGroupAware) tpAware; return String.format(fmt, db, tpgAware.getGroupId()); case MESSAGE_OFFSET_TABLE: fmt = "%s_offset_message"; return String.format(fmt, db); case RESEND_OFFSET_TABLE: fmt = "%s_offset_resend"; return String.format(fmt, db); case DEAD_LETTER_TABLE: fmt = "%s_dead_letter"; return String.format(fmt, db); default: throw new IllegalArgumentException( String.format("Unknown physical table for %s %s", hints, logicalTableName)); } }
private String findDataSourceName( QueryDef def, TopicPartitionAware tpAware, String logicalTableName) { QueryType queryType = def.getType(); Partition p = findPartition(tpAware.getTopic(), tpAware.getPartition()); switch (queryType) { case INSERT: return MESSAGE_TABLE.equals(logicalTableName) ? p.getWriteDatasource() : p.getReadDatasource(); case SELECT: case UPDATE: case DELETE: return p.getReadDatasource(); default: throw new IllegalArgumentException(String.format("Unknown query type '%s'", queryType)); } }