SlideShare a Scribd company logo
1 of 26
Download to read offline
Append Protocol
(고속 입력 프로토콜)
www.infiniflux.com
Table of Contents
배경 설명
CLI API
JDBC API
Multi Table Insert
1
2
3
4
배경 설명
4
배경 – 전통 프로토콜의 한계
Client
Server
Idle time
……
Client
Client
Client
Server
Server
Idle time
Idle time
• 전통적인 동기 프로토콜(Request / Reply )의 한계
• 매번 레코드 입력 시 Execute 이후 결과를 확인하는 동기적인 방식
• I/O 수행 횟수가 레코드 개수에 따라 급격하게 증가
• 한 레코드에 대한 결과를 매번 확인해야 함
• 초당 1000건 이상 입력하기 힘듦
5
배경 – 개선 프로토콜
Append Protocol 개념도
• 낙관적 비동기 프로토콜 도입 (Append Protocol)
• 입력 레코드를 연속적으로 버퍼에 쌓고, 일정 조건에 다다르면 버퍼 Flush 수행
• Append Success시 결과를 돌리지 않음.
• Append Failure 시에만 서버로부터 에러 코드, 메시지를 클라이언트로 되돌림
• 초당 수백만 건의 레코드 입력 가능
• 대부분의 입력이 성공하며, 극히 일부분 에러가 발생하므로 최적의 대안
Flush Append
Flush Append
Client
Client
Client
No Idle time
No Idle time
Server
Server
Server
6
배경 – API 구조
Title Contents
통신 채널 수립 API
• Append를 위한 채널을 Open 하도록 함
• 입력 대상 테이블을 명시
• 이 채널을 통해 데이터를 고속으로 입력
데이터 입력 API
• 주어진 테이블 스키마에 맞는 컬럼 데이터 바인딩
• 길이 및 포맷에 어긋날 경우 에러 검출
• 버퍼링을 통해 빠른 데이터 전송 성능 보장
데이터 Flush API • 입력버퍼가 모두 채워지지 않을 경우 강제로 네트워크로 전송하도록 함
에러 Callback 설정 API
• 서버로부터 도달하는 에러코드 및 메시지를 처리하는 비동기 사용자 Callback
설정 기능
• 입력과는 비동기적으로 동작
통신 채널 종료 API
• 현재 Append 중엔 프로토콜을 종료함
• 버퍼에 남아있는 레코드를 모두 네트워크로 전송
CLI API
8
CLI 설치 확인
InfiniFlux가 설치된 디렉토리의 install, include, lib 디렉토리에서 파일을 확인한다.
• Makefile
• Header file
• Library file
$IFLUX_HOME/install/iflux_env.mk
$IFLUX_HOME/include/iflux_sqlcli.h
$IFLUX_HOME/lib/libifluxcli.a
$IFLUX_HOME/lib/libifluxcli_dll.so
9
Makefile & Compile
• sample/cli 디렉토리로 이동한다.
• Makefile의 내용을 확인한다.
• Compile을 해본다.
$ cd $IFLUX_HOME/sample/cli
include $(IFLUX_HOME)/install/iflux_env.mk
INCLUDES += $(LIBDIR_OPT)/$(IFLUX_HOME)/include
all : sample4_append2
sample4_append2 : sample4_append2.o
$(LD_CC) $(LD_FLAGS) $(LD_OUT_OPT)$@ $< $(LIB_OPT)ifluxcli$(LIB_AFT) $(LIBDIR_OPT)$(IFLUX_HOME)/lib $(LD_LIBS)
sample4_append2.o : sample4_append2.c
$(COMPILE.cc) $(CC_FLAGS) $(INCLUDES) $(CC_OUT_OPT)$@ $<
clean :
rm -f *.o sample4_append2
$ make
$IFLUX_HOME/sample/cli/makefile을 확인하여 compile을 해본다.
10
Append program 구조
InfiniFlux 고유의 확장 함수
CLI 표준 연결 함수
CLI 표준 연결 해제 함수
$IFLUX_HOME/sample/cli/sample4_append1.c 에 대해서 설명한다.
SQLAllocEnv
SQLAllocConnect
SQLDriverConnect
SQLAllocStmt
SQLAppendOpen
SQLAppendDataV2
SQLAppendClose
SQLAppendSetErrorCallback
SQLFreeStmt
SQLDisconnect
SQLFreeConnect
SQLFreeEnv
11
SQLAppendOpen
• 특정 테이블에 데이터를 입력하기 위해서 채널을 오픈한다.
• 이후 이 채널을 close하지 않으면 계속 열린 상태를 유지한다.
• 하나의 연결에 최대 1024개의 Statement 설정이 가능한다.
• 각 Statement마다 SQLAppendOpen을 사용하면 된다.
SQLRETURN SQLAppendOpen( SQLHSTMT aStatementHandle,
SQLCHAR *aTableName,
SQLINTEGER aErrorCheckCount );
• aStatementHandle : append를 수행할 statement의 핸들
• aTableName : append를 수행할 대상 테이블의 이름
• aErrorCheckCount : 서버 에러를 검사하는 입력 건수. 0이면 검사하지 않음
12
SQLAppendDataV2
• 해당 채널에 대해서 데이터를 입력하는 함수이다.
• InfiniFlux v2.0 부터 지원한다.
• TEXT, BINARY 타입의 데이터 입력이 가능하다.
SQLRETURN SQLAppendDataV2( SQLHSTMT aStatementHandle,
SQL_APPEND_PARAM *aData );
• aStatementHandle : append를 수행할 statement의 핸들
• aData : SQL_APPEND_PARAM이라는 인자 배열을 가리키는 포인터
SQL_APPEND_PARAM은 iflux_sqlcli.h에 정의되어 있음
13
SQLAppendClose
• 현재 열린 채널을 닫는다.
• Append 성공, 실패한 레코드 개수를 확인할 수 있다.
SQLRETURN SQLAppendClose( SQLHSTMT aStatementHandle,
int *aSuccessCount,
int *aFailureCount );
• aStatementHandle : append를 수행한 statemen의 핸들
• aSuccessCount : append를 성공한 레코드 개수 값
• aFailureCount : append를 실패한 레코드 개수 값
14
SQLAppendSetErrorCallback
• Append 도중에 에러가 발생할 경우 호출되는 callback 함수를 설정한다.
• 만약 이 함수를 설정하지 않을 경우 서버에서 에러가 발생하더라도 클라이언트에서는 무시하게 된다.
SQLRETURN SQLAppendSetErrorCallback( SQLHSTMT aStatementHandle,
SQLAppendErrorCallback *aFunc );
• aStatementHandle : append를 수행하는 statement의 핸들
• aFunc : append 에러시 호출할 callback 함수 포인터
typedef void (*SQLAppendErrorCallback)( SQLHSTMT aStatementHandle,
SQLINTEGER aErrorCode,
SQLPOINTER aErrorMessage,
SQLLEN aErrorBufLen,
SQLPOINTER aRowBuf,
SQLLEN aRowBufLen );
• aStatementHandle : append를 수행하는 statement의 핸들.
• aErrorCode : 에러의 원인이 된 32bit 에러 코드.
• aErrorMessage : 해당 에러코드에 대한 문자열
• aErrorBufLen : aErrorMessage의 길이
• aRowBuf : 에러를 발생시킨 레코드의 내용이 담긴 문자열
• aRowBufLen : aRowBuf의 길이
15
기타 함수
• 추가적으로 몇 가지 유용한 함수를 제공한다.
• 자세한 사항은 InfiniFlux 홈페이지 매뉴얼 문서를 참조하면 된다. (http://www.infiniflux.com/document)
함수명 함수 선언 함수 설명
SQLAppendDataByTimeV2
SQLRETURN SQL_API
SQLAppendDataByTimeV2(
SQLHSTMT aStatmentHandle,
SQLBIGINT aTime,
SQL_APPEND_PARAM *aData)
SQLAppendDataV2()처럼 해당 채널에 데이터를 입력한다.
다만 숨은 칼럼인 _arrival_time 값은 현재 시간이 아닌 특정 시간의
값으로 설정할때 사용한다.
즉 로그 파일에 있는 시간을 aTime값으로 넘겨주면 된다.
SQLAppendFlush
SQLRETURN SQL_API
SQLAppendFlush(
SQLHSTMT aStatementHandle)
현재 채널 버퍼에 쌓여 있는 데이터를 InfiniFlux 서버로 즉시 전송
한다.
SQLSetConnectAppendFlush
SQLRETURN SQL_API
SQLSetConnectAppendFlush(
SQLHDBC aHdbc,
SQLINTEGER aTimeOption)
일정 주기로 InfiniFlux 서버로 전송할지 여부를 설정한다.
0 : auto flush off
1 : auto flush on
SQLSetStmtAppendInterval
SQLRETURN SQL_API
SQLSetStmtAppendInterval(
SQLHSTMT aStatementHandle,
SQLINTEGER aValue)
SQLSetConnectAppendFlush()를 이용하여 auto flush on한 경우,
flush 주기를 조정하거나 auto flush off 한다.
aValue가 0이면 flush를 하지 않는다.
기본 값은 1000이며 단위는 ms이다.
100의 배수로 설정해야 한다.
JDBC API
17
Library 설치 확인
 Java 1.6 이상 지원
InfiniFlux가 설치된 디렉토리의 lib 디렉토리에서 파일을 확인한다.
• Library file
• Log4j file
• Sample
• Makefile
$IFLUX_HOME/lib/iflux.jar
$IFLUX_HOME/lib/ifluxLog.jar
$IFLUX_HOME/lib/log4j.jar
$IFLUX_HOME/sample/jdbc
$IFLUX_HOME/sample/jdbc/Makefile
18
Append program 구조
InfiniFlux 고유의 확장 함수
표준 연결 함수
표준 연결 해제 함수
$IFLUX_HOME/sample/jdbc/sample4_append.java에 대해서 설명한다.
DriverManager.getConnection
Connection.createStatement
executeAppendOpen
executeAppendData
executeAppendClose
executeSetAppendErrorCallback
ResultSet.close
Statement.close
Connection.close
19
executeAppendOpen
• 특정 테이블에 데이터를 입력하기 위해서 채널을 오픈한다.
• 이후 이 채널을 close하지 않으면 계속 열린 상태를 유지한다.
• 하나의 연결에 최대 1024개의 Statement 설정이 가능한다.
ResultSet IfluxStatement.executeAppendOpen(
String aTableName,
int aErrorCheckCount );
• aTableName : append를 수행할 대상 테이블의 이름
• aErrorCheckCount : 서버 에러를 검사하는 입력 건수. 0이면 검사하지 않음
20
executeAppendData
• 해당 채널에 대해서 데이터를 입력하는 함수이다.
int IfluxStatement.executeAppendData( ResultSetMetaData aRsmd,
ArrayList aData );
• aRsmd : 해당 테이블의 칼럼 meta 정보
• aData : appen할 데이터의 array list
21
executeAppendClose
• 현재 열린 채널을 닫는다.
int IfluxStatement.executeAppendClose();
이 함수 실행 이후에
getAppendSuccessCount(), getAppendFailureCount()를 호출하여 성공,실패한 개수를 확인할 수 있다.
22
executeSetAppendErrorCallback
• Append 도중에 에러가 발생할 경우 호출되는 callback 함수를 설정한다.
• 만약 이 함수를 설정하지 않을 경우 서버에서 에러가 발생하더라도 클라이언트에서는 무시하게 된다.
int IfluxStatement.executeSetAppendErrorCallback( IfluxAppendCallback aCallback);
• aCallback : append 에러시 호출할 callback 함수
IfluxAppendCallback cb = new IfluxAppendCallback() {
@Override
public void onAppendError(long aErrNo, String aErrMsg, String aRowMsg) {
System.out.format("Append Error : [%05d - %s]n%sn", aErrNo, aErrMsg, aRowMsg);
}
};
stmt.executeSetAppendErrorCallback(cb);
23
기타 함수
• 추가적으로 몇 가지 유용한 함수를 제공한다.
• 자세한 사항은 InfiniFlux 홈페이지 매뉴얼 문서를 참조하면 된다. (http://www.infiniflux.com/document)
함수명 함수 선언 함수 설명
executeAppendDataByTime
int
executeAppendDataByTime(R
esultSetMetaData aRsmd,
long aTime,
ArrayList aData)
executeAppendData()처럼 해당 채널에 데이터를 입력한다.
다만 숨은 칼럼인 _arrival_time 값은 현재 시간이 아닌 특정
시간의 값으로 설정할때 사용한다.
즉 로그 파일에 있는 시간을 aTime값으로 넘겨주면 된다.
executeAppendFlush int executeAppendFlush()
현재 채널 버퍼에 쌓여 있는 데이터를 InfiniFlux 서버로
즉시 전송한다.
executeAppendSuccessCount
long
getAppendSuccessCount()
Append 성공한 레코드 개수를 리턴한다.
executeAppendFailureCount
long
executeAppendFailureCount()
Append 실패한 레코드 개수를 리턴한다.
Multi Table Insert
25
Multi Table Insert 구조
$IFLUX_HOME/sample/cli/sample8_multi_session_multi_table.c에 대해서 설명한다.
• Main함수에서 threa를 생성하고, 개별 threa에서 모든 것을 처리한다.
• 즉 SQLHENV, SQLHDBC, SQLHSTMT 에 대한 alloc과 free를 개별 thread에서 처리한다.
• 하나의 statement가 한 개의 table에 데이터를 입력하도록 한다.
• 이렇게 하는 이유는 thread간에 statement 또는 connection 정보를 공유할 경우 하나의 thread에서 에러가 발생할 경우 전체
세션을 종료할 가능성이 있기 때문이다.
• 가능하면 thread간 resource의 공유는 하지 않도록 하는 것이 안전하다.
• 데이터의 입력 주기가 불규칙하고 interval이 긴 경우가 있으면 SQLSetConnectionAppendFlush()와
SQLSetStmtAppendInterval()을 이용하여 auto timed flush를 수행하도록 한다.
The World's Fastest
Time Series DBMS
for IoT and BigData
www.infiniflux.com
info@infiniflux.com
InfiniFlux

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

InfiniFlux Append Protocol

  • 1. Append Protocol (고속 입력 프로토콜) www.infiniflux.com
  • 2. Table of Contents 배경 설명 CLI API JDBC API Multi Table Insert 1 2 3 4
  • 4. 4 배경 – 전통 프로토콜의 한계 Client Server Idle time …… Client Client Client Server Server Idle time Idle time • 전통적인 동기 프로토콜(Request / Reply )의 한계 • 매번 레코드 입력 시 Execute 이후 결과를 확인하는 동기적인 방식 • I/O 수행 횟수가 레코드 개수에 따라 급격하게 증가 • 한 레코드에 대한 결과를 매번 확인해야 함 • 초당 1000건 이상 입력하기 힘듦
  • 5. 5 배경 – 개선 프로토콜 Append Protocol 개념도 • 낙관적 비동기 프로토콜 도입 (Append Protocol) • 입력 레코드를 연속적으로 버퍼에 쌓고, 일정 조건에 다다르면 버퍼 Flush 수행 • Append Success시 결과를 돌리지 않음. • Append Failure 시에만 서버로부터 에러 코드, 메시지를 클라이언트로 되돌림 • 초당 수백만 건의 레코드 입력 가능 • 대부분의 입력이 성공하며, 극히 일부분 에러가 발생하므로 최적의 대안 Flush Append Flush Append Client Client Client No Idle time No Idle time Server Server Server
  • 6. 6 배경 – API 구조 Title Contents 통신 채널 수립 API • Append를 위한 채널을 Open 하도록 함 • 입력 대상 테이블을 명시 • 이 채널을 통해 데이터를 고속으로 입력 데이터 입력 API • 주어진 테이블 스키마에 맞는 컬럼 데이터 바인딩 • 길이 및 포맷에 어긋날 경우 에러 검출 • 버퍼링을 통해 빠른 데이터 전송 성능 보장 데이터 Flush API • 입력버퍼가 모두 채워지지 않을 경우 강제로 네트워크로 전송하도록 함 에러 Callback 설정 API • 서버로부터 도달하는 에러코드 및 메시지를 처리하는 비동기 사용자 Callback 설정 기능 • 입력과는 비동기적으로 동작 통신 채널 종료 API • 현재 Append 중엔 프로토콜을 종료함 • 버퍼에 남아있는 레코드를 모두 네트워크로 전송
  • 8. 8 CLI 설치 확인 InfiniFlux가 설치된 디렉토리의 install, include, lib 디렉토리에서 파일을 확인한다. • Makefile • Header file • Library file $IFLUX_HOME/install/iflux_env.mk $IFLUX_HOME/include/iflux_sqlcli.h $IFLUX_HOME/lib/libifluxcli.a $IFLUX_HOME/lib/libifluxcli_dll.so
  • 9. 9 Makefile & Compile • sample/cli 디렉토리로 이동한다. • Makefile의 내용을 확인한다. • Compile을 해본다. $ cd $IFLUX_HOME/sample/cli include $(IFLUX_HOME)/install/iflux_env.mk INCLUDES += $(LIBDIR_OPT)/$(IFLUX_HOME)/include all : sample4_append2 sample4_append2 : sample4_append2.o $(LD_CC) $(LD_FLAGS) $(LD_OUT_OPT)$@ $< $(LIB_OPT)ifluxcli$(LIB_AFT) $(LIBDIR_OPT)$(IFLUX_HOME)/lib $(LD_LIBS) sample4_append2.o : sample4_append2.c $(COMPILE.cc) $(CC_FLAGS) $(INCLUDES) $(CC_OUT_OPT)$@ $< clean : rm -f *.o sample4_append2 $ make $IFLUX_HOME/sample/cli/makefile을 확인하여 compile을 해본다.
  • 10. 10 Append program 구조 InfiniFlux 고유의 확장 함수 CLI 표준 연결 함수 CLI 표준 연결 해제 함수 $IFLUX_HOME/sample/cli/sample4_append1.c 에 대해서 설명한다. SQLAllocEnv SQLAllocConnect SQLDriverConnect SQLAllocStmt SQLAppendOpen SQLAppendDataV2 SQLAppendClose SQLAppendSetErrorCallback SQLFreeStmt SQLDisconnect SQLFreeConnect SQLFreeEnv
  • 11. 11 SQLAppendOpen • 특정 테이블에 데이터를 입력하기 위해서 채널을 오픈한다. • 이후 이 채널을 close하지 않으면 계속 열린 상태를 유지한다. • 하나의 연결에 최대 1024개의 Statement 설정이 가능한다. • 각 Statement마다 SQLAppendOpen을 사용하면 된다. SQLRETURN SQLAppendOpen( SQLHSTMT aStatementHandle, SQLCHAR *aTableName, SQLINTEGER aErrorCheckCount ); • aStatementHandle : append를 수행할 statement의 핸들 • aTableName : append를 수행할 대상 테이블의 이름 • aErrorCheckCount : 서버 에러를 검사하는 입력 건수. 0이면 검사하지 않음
  • 12. 12 SQLAppendDataV2 • 해당 채널에 대해서 데이터를 입력하는 함수이다. • InfiniFlux v2.0 부터 지원한다. • TEXT, BINARY 타입의 데이터 입력이 가능하다. SQLRETURN SQLAppendDataV2( SQLHSTMT aStatementHandle, SQL_APPEND_PARAM *aData ); • aStatementHandle : append를 수행할 statement의 핸들 • aData : SQL_APPEND_PARAM이라는 인자 배열을 가리키는 포인터 SQL_APPEND_PARAM은 iflux_sqlcli.h에 정의되어 있음
  • 13. 13 SQLAppendClose • 현재 열린 채널을 닫는다. • Append 성공, 실패한 레코드 개수를 확인할 수 있다. SQLRETURN SQLAppendClose( SQLHSTMT aStatementHandle, int *aSuccessCount, int *aFailureCount ); • aStatementHandle : append를 수행한 statemen의 핸들 • aSuccessCount : append를 성공한 레코드 개수 값 • aFailureCount : append를 실패한 레코드 개수 값
  • 14. 14 SQLAppendSetErrorCallback • Append 도중에 에러가 발생할 경우 호출되는 callback 함수를 설정한다. • 만약 이 함수를 설정하지 않을 경우 서버에서 에러가 발생하더라도 클라이언트에서는 무시하게 된다. SQLRETURN SQLAppendSetErrorCallback( SQLHSTMT aStatementHandle, SQLAppendErrorCallback *aFunc ); • aStatementHandle : append를 수행하는 statement의 핸들 • aFunc : append 에러시 호출할 callback 함수 포인터 typedef void (*SQLAppendErrorCallback)( SQLHSTMT aStatementHandle, SQLINTEGER aErrorCode, SQLPOINTER aErrorMessage, SQLLEN aErrorBufLen, SQLPOINTER aRowBuf, SQLLEN aRowBufLen ); • aStatementHandle : append를 수행하는 statement의 핸들. • aErrorCode : 에러의 원인이 된 32bit 에러 코드. • aErrorMessage : 해당 에러코드에 대한 문자열 • aErrorBufLen : aErrorMessage의 길이 • aRowBuf : 에러를 발생시킨 레코드의 내용이 담긴 문자열 • aRowBufLen : aRowBuf의 길이
  • 15. 15 기타 함수 • 추가적으로 몇 가지 유용한 함수를 제공한다. • 자세한 사항은 InfiniFlux 홈페이지 매뉴얼 문서를 참조하면 된다. (http://www.infiniflux.com/document) 함수명 함수 선언 함수 설명 SQLAppendDataByTimeV2 SQLRETURN SQL_API SQLAppendDataByTimeV2( SQLHSTMT aStatmentHandle, SQLBIGINT aTime, SQL_APPEND_PARAM *aData) SQLAppendDataV2()처럼 해당 채널에 데이터를 입력한다. 다만 숨은 칼럼인 _arrival_time 값은 현재 시간이 아닌 특정 시간의 값으로 설정할때 사용한다. 즉 로그 파일에 있는 시간을 aTime값으로 넘겨주면 된다. SQLAppendFlush SQLRETURN SQL_API SQLAppendFlush( SQLHSTMT aStatementHandle) 현재 채널 버퍼에 쌓여 있는 데이터를 InfiniFlux 서버로 즉시 전송 한다. SQLSetConnectAppendFlush SQLRETURN SQL_API SQLSetConnectAppendFlush( SQLHDBC aHdbc, SQLINTEGER aTimeOption) 일정 주기로 InfiniFlux 서버로 전송할지 여부를 설정한다. 0 : auto flush off 1 : auto flush on SQLSetStmtAppendInterval SQLRETURN SQL_API SQLSetStmtAppendInterval( SQLHSTMT aStatementHandle, SQLINTEGER aValue) SQLSetConnectAppendFlush()를 이용하여 auto flush on한 경우, flush 주기를 조정하거나 auto flush off 한다. aValue가 0이면 flush를 하지 않는다. 기본 값은 1000이며 단위는 ms이다. 100의 배수로 설정해야 한다.
  • 17. 17 Library 설치 확인  Java 1.6 이상 지원 InfiniFlux가 설치된 디렉토리의 lib 디렉토리에서 파일을 확인한다. • Library file • Log4j file • Sample • Makefile $IFLUX_HOME/lib/iflux.jar $IFLUX_HOME/lib/ifluxLog.jar $IFLUX_HOME/lib/log4j.jar $IFLUX_HOME/sample/jdbc $IFLUX_HOME/sample/jdbc/Makefile
  • 18. 18 Append program 구조 InfiniFlux 고유의 확장 함수 표준 연결 함수 표준 연결 해제 함수 $IFLUX_HOME/sample/jdbc/sample4_append.java에 대해서 설명한다. DriverManager.getConnection Connection.createStatement executeAppendOpen executeAppendData executeAppendClose executeSetAppendErrorCallback ResultSet.close Statement.close Connection.close
  • 19. 19 executeAppendOpen • 특정 테이블에 데이터를 입력하기 위해서 채널을 오픈한다. • 이후 이 채널을 close하지 않으면 계속 열린 상태를 유지한다. • 하나의 연결에 최대 1024개의 Statement 설정이 가능한다. ResultSet IfluxStatement.executeAppendOpen( String aTableName, int aErrorCheckCount ); • aTableName : append를 수행할 대상 테이블의 이름 • aErrorCheckCount : 서버 에러를 검사하는 입력 건수. 0이면 검사하지 않음
  • 20. 20 executeAppendData • 해당 채널에 대해서 데이터를 입력하는 함수이다. int IfluxStatement.executeAppendData( ResultSetMetaData aRsmd, ArrayList aData ); • aRsmd : 해당 테이블의 칼럼 meta 정보 • aData : appen할 데이터의 array list
  • 21. 21 executeAppendClose • 현재 열린 채널을 닫는다. int IfluxStatement.executeAppendClose(); 이 함수 실행 이후에 getAppendSuccessCount(), getAppendFailureCount()를 호출하여 성공,실패한 개수를 확인할 수 있다.
  • 22. 22 executeSetAppendErrorCallback • Append 도중에 에러가 발생할 경우 호출되는 callback 함수를 설정한다. • 만약 이 함수를 설정하지 않을 경우 서버에서 에러가 발생하더라도 클라이언트에서는 무시하게 된다. int IfluxStatement.executeSetAppendErrorCallback( IfluxAppendCallback aCallback); • aCallback : append 에러시 호출할 callback 함수 IfluxAppendCallback cb = new IfluxAppendCallback() { @Override public void onAppendError(long aErrNo, String aErrMsg, String aRowMsg) { System.out.format("Append Error : [%05d - %s]n%sn", aErrNo, aErrMsg, aRowMsg); } }; stmt.executeSetAppendErrorCallback(cb);
  • 23. 23 기타 함수 • 추가적으로 몇 가지 유용한 함수를 제공한다. • 자세한 사항은 InfiniFlux 홈페이지 매뉴얼 문서를 참조하면 된다. (http://www.infiniflux.com/document) 함수명 함수 선언 함수 설명 executeAppendDataByTime int executeAppendDataByTime(R esultSetMetaData aRsmd, long aTime, ArrayList aData) executeAppendData()처럼 해당 채널에 데이터를 입력한다. 다만 숨은 칼럼인 _arrival_time 값은 현재 시간이 아닌 특정 시간의 값으로 설정할때 사용한다. 즉 로그 파일에 있는 시간을 aTime값으로 넘겨주면 된다. executeAppendFlush int executeAppendFlush() 현재 채널 버퍼에 쌓여 있는 데이터를 InfiniFlux 서버로 즉시 전송한다. executeAppendSuccessCount long getAppendSuccessCount() Append 성공한 레코드 개수를 리턴한다. executeAppendFailureCount long executeAppendFailureCount() Append 실패한 레코드 개수를 리턴한다.
  • 25. 25 Multi Table Insert 구조 $IFLUX_HOME/sample/cli/sample8_multi_session_multi_table.c에 대해서 설명한다. • Main함수에서 threa를 생성하고, 개별 threa에서 모든 것을 처리한다. • 즉 SQLHENV, SQLHDBC, SQLHSTMT 에 대한 alloc과 free를 개별 thread에서 처리한다. • 하나의 statement가 한 개의 table에 데이터를 입력하도록 한다. • 이렇게 하는 이유는 thread간에 statement 또는 connection 정보를 공유할 경우 하나의 thread에서 에러가 발생할 경우 전체 세션을 종료할 가능성이 있기 때문이다. • 가능하면 thread간 resource의 공유는 하지 않도록 하는 것이 안전하다. • 데이터의 입력 주기가 불규칙하고 interval이 긴 경우가 있으면 SQLSetConnectionAppendFlush()와 SQLSetStmtAppendInterval()을 이용하여 auto timed flush를 수행하도록 한다.
  • 26. The World's Fastest Time Series DBMS for IoT and BigData www.infiniflux.com info@infiniflux.com InfiniFlux