SDS API 개발 서비스를 Spring(Java) 으로 구현할 때의 계층 구조다. Controller → Service → Repository 로 내려가고, Repository 가 Trino JDBC 드라이버로 Trino 클러스터에 쿼리를 보낸다.
+-------------------+
| Client (FE) |
+-------------------+
|
v
+-------------------+ +-------------------+
| Controller Layer | <----> | Exception Handler |
| (RestController) | | (ControllerAdvice)|
+-------------------+ +-------------------+
|
v
+-------------------+
| Service Layer |
| (Service) |
+-------------------+
|
v
+-------------------+
| Repository Layer |
| (Repository) |
+-------------------+
|
v
+-------------------+
| TRINO JDBC |
| (Trino Driver) |
+-------------------+
|
v
+-------------------+
| Trino Cluster |
| (Coordinator & |
| Worker Nodes) |
+-------------------+
| 계층 | 주요 클래스/인터페이스 | 상속/구현 관계 | 역할 및 라이브러리 |
|---|---|---|---|
| Controller | @RestController |
Spring 의 RestController | HTTP 요청/응답, JSON 변환 — spring-boot-starter-web, jackson-databind |
| Service | @Service |
일반 Java 클래스 | 비즈니스 로직 처리 |
| Repository | @Repository, JpaRepository 또는 TrinoRepository(custom) |
JpaRepository 상속 또는 직접 구현 | DB/Trino 와의 데이터 연동 |
| Trino JDBC | TrinoDriver, Connection, Statement, ResultSet |
JDBC 인터페이스 구현 | Trino 연결 및 쿼리 실행 — trino-jdbc |
| Exception | @ControllerAdvice, @ExceptionHandler |
Spring 제공 어노테이션 | 글로벌 예외 처리 |
Trino 쪽 구성 요소는 다음과 같다.[1]
| 구성 요소 | 역할 |
|---|---|
| Coordinator | 클라이언트 요청(REST API, JDBC 등) 수신 → 쿼리 파싱 · 분석 · 계획 · 스케줄링 → Worker 에 작업 분배, REST API 제공 |
| Worker | 쿼리 실행, 데이터 처리, 데이터 소스와 직접 통신 |
| SPI | 다양한 데이터 소스 연결을 위한 인터페이스 (Metadata, Data Statistics, Data Location, Data Stream) |
| REST API | 클라이언트(JDBC, HTTP)와 Coordinator/Worker 간 통신 |
| JDBC Driver | Java 에서 Trino 에 SQL 을 보내고 결과를 받는다 |
import java.sql.*;
public class TrinoJDBCExample {
static final String JDBC_DRIVER = "io.trino.jdbc.TrinoDriver";
static final String DB_URL = "jdbc:trino://localhost:8080/catalog/schema";
public static void main(String[] args) {
try (Connection conn = DriverManager.getConnection(DB_URL, "user", null);
Statement stmt = conn.createStatement()) {
ResultSet rs = stmt.executeQuery("SELECT * FROM table");
while (rs.next()) {
// 데이터 처리
}
} catch (SQLException e) {
// 예외 처리
}
}
}
trino-jdbcTrinoDriver(JDBC 드라이버), Connection, Statement, ResultSetJdbcTemplate 또는 직접 JDBC 사용| 요청 | 용도 |
|---|---|
POST /v1/statement |
쿼리 실행 요청 (SQL) |
GET nextUri |
쿼리 결과 페이지네이션 |
DELETE nextUri |
실행 중 쿼리 취소 |
주요 응답 객체는 io.trino.client.QueryResults(trino-client 모듈)다.
+------------------------+
| ProductController | <<@RestController>>
+------------------------+
| - productService |
+------------------------+
| + getAllProducts() |
| + getProductById(id) |
| + createProduct(prod) |
+------------------------+
|
v
+------------------------+
| ProductService | <<@Service>>
+------------------------+
| - productRepository |
+------------------------+
| + getAllProducts() |
| + getProductById(id) |
| + createProduct(prod) |
+------------------------+
|
v
+------------------------+
| ProductRepository | <<@Repository>>
+------------------------+
| extends JpaRepository |
+------------------------+
// Trino 연동 Repository 예시
+------------------------+
| TrinoRepository | <<@Repository>>
+------------------------+
| - trinoDataSource |
+------------------------+
| + executeQuery(sql) |
+------------------------+
// JDBC 연동 클래스
+------------------------+
| TrinoJDBCExample |
+------------------------+
| main() |
+------------------------+
JpaRepository 상속, Trino 사용 시 직접 JDBC 구현.TrinoDriver 는 java.sql.Driver 를 구현한다.@ControllerAdvice 로 글로벌 예외 처리.@Valid, @NotBlank 등)Trino JDBC driver. 2026-09-20 확인. https://trino.io/docs/current/client/jdbc.html ↩︎