Hector(API)
Hector (API)원저작자 | 런타보리 |
---|---|
최종 릴리즈 | 2.0 / 2014년 7월 [1] , 전( |
저장소 | github |
기입처 | 자바 |
유형 | 컬럼 지향 DBMS |
면허증. | MIT 라이선스 |
웹 사이트 | prettyprint![]() |
Hector는 Apache Cassandra용 고급 클라이언트 API입니다.그리스 신화에 나오는 트로이의 전사 헥터의 이름을 딴 이것은 [3]헥터가 캡슐화한 카산드라 자바 클라이언트, 즉 트리프트의 [2]대체물이다.또한 Maven 저장소 [4]액세스도 있습니다.
역사
Cassandra는 로우 레벨의 Thrift(프로토콜)와 함께 출하되기 때문에 애플리케이션 개발자를 위한 더 나은 프로토콜을 개발할 가능성이 있었습니다.Hector는 Ran Tavory에 의해 Thrift의 단점을 중첩하는 고급 인터페이스로 개발되었습니다.설계 [dubious ]사용, 변경, 분할 및 변경이 가능한 MIT 라이선스로 라이선스가 부여되어 있습니다.
특징들
헥터의[2] 개략적인 특징은
- Cassandra에 대한 높은 수준의 객체 지향 인터페이스:그것은 주로 카산드라-자바-클라이언트에서 영감을 얻었다.API는 Keyspace 인터페이스에서 정의됩니다.
- 접속 풀링대규모 애플리케이션과 마찬가지로 DAO의 일반적인 패턴은 대량의 읽기/쓰기입니다.클라이언트가 각 요구에 대해 새로운 접속을 오픈하는 것은 비용이 너무 많이 듭니다.따라서 클라이언트의 동작 속도가 빠르면 사용 가능한 소켓이 쉽게 고갈될 수 있습니다.Hector는 연결 풀링과 세부사항을 관리하는 훌륭한 프레임워크를 제공합니다.
- 페일오버 지원: Cassandra는 호스트(노드)가 다운될 수 있는 분산형 데이터스토어입니다.Hector에는 독자적인 페일오버정책이 있습니다.
유형 | 댓글 |
---|---|
FAIL_FAST | 오류가 발생하면 실패합니다. |
ON_FAIL_TRY_ONE_NEXT_AVAILABLE | 포기하기 전에 호스트를 하나 더 시도합니다. |
ON_FAIL_TRY_ALL_AVAILABLE | 포기하기 전에 사용 가능한 모든 호스트를 시도합니다. |
- JMX 지원:Hector는 사용 가능한 연결 수, 유휴 연결, 오류 통계 등 많은 중요한 런타임 메트릭에 대해 JMX를 제공합니다.
- 로드 밸런싱:새로운 [5]버전에는 단순한 로드밸런싱이 있습니다
- 명령어 설계 패턴을 지원하여 고객이 비즈니스 논리에 집중하고 필요한 배관을 Hector가 처리할 수 있도록 합니다.
가용성 지표
Hector는 JMX를 [6]통해 가용성 카운터 및 통계 정보를 제공합니다.
로드 밸런싱
Hector는 2가지 로드밸런싱 정책을 따릅니다.LoadBalancingPolicy
인터페이스입니다.기본값은 입니다.RoundRobinBalancingPolicy
단순한 라운드 파티클 분산 알고리즘입니다.그LeastActiveBalancingPolicy
는 액티브 접속 수가 가장 적은 풀에 요구를 라우팅하여 클러스터 전체에서 사용률을 적절히 분산시킵니다.
풀링
그ExhaustedPolicy
는 기본 클라이언트 연결 풀을 제어하는 방법을 결정합니다.현재 다음 세 가지 옵션을 사용할 [8]수 있습니다.
유형 | 댓글 |
---|---|
WHEN_EXHAUSTED_FAIL | 더 이상 클라이언트를 사용할 수 없을 때 취득에 실패함 |
WHEN_EXHAUSTED_GROW | 부하 증가에 대응하기 위해 풀이 자동으로 증가합니다. |
WHEN_EXHAUSTED_BLOCK | 클라이언트를 사용할 수 있게 될 때까지 취득을 차단합니다(기본값). |
코드 예시
예를 들어 Cassandra 위의 단순한 분산 해시 테이블의 구현이 나열되어 있습니다.
/** * 키로 키 입력된 새 값 삽입 * @param 키 값 * @param value 삽입할 문자열 값 */ 일반의 무효 삽입하다(최종 스트링 열쇠, 최종 스트링 가치) 던지다 예외. { 실행하다(신규 명령어(){ 일반의 무효 실행하다(최종 키 스페이스 ks) 던지다 예외. { ks.삽입하다(열쇠, create Column Path(열_이름), 바이트 수(가치)); 돌아가다 무효; } }); } /** * 문자열 값을 가져옵니다. * @return 문자열 값. 지정된 키에 대한 값이 없는 경우 null입니다. */ 일반의 스트링 얻다(최종 스트링 열쇠) 던지다 예외. { 돌아가다 실행하다(신규 명령어(){ 일반의 스트링 실행하다(최종 키 스페이스 ks) 던지다 예외. { 해라 { 돌아가다 스트링(ks.get Column(컬럼)(열쇠, create Column Path(열_이름)).가치의 취득()); } 또 만나 (Not Found Exception(예외 없음) e) { 돌아가다 무효; } } }); } /** * 카산드라에서 키 삭제 */ 일반의 무효 삭제하다(최종 스트링 열쇠) 던지다 예외. { 실행하다(신규 명령어(){ 일반의 무효 실행하다(최종 키 스페이스 ks) 던지다 예외. { ks.제거한다.(열쇠, create Column Path(열_이름)); 돌아가다 무효; } }); }
레퍼런스
- ^ "Releases · hector-client/Hector". GitHub.
- ^ a b Ran Tavory. "Hector – a Java Cassandra client". PrettyPrint.me. Retrieved 2011-03-23.
Out of the box Cassanra provides a raw thrift client, which is OK, but lacks many features essential to real world clients. I’ve built Hector to fill this gap.
Here are the high level features of Hector, currently hosted at github.- A high-level object oriented interface to cassandra.
- Failover support.
- Connection pooling.
- JMX support.
- Support for the Command design pattern to allow clients to concentrate on their business logic and let hector take care of the required plumbing.
- ^ "Hector Client for Apache Cassandra: Encapsulation of Thrift API" (PDF). DataStax. Retrieved 2011-04-12.
Hector now completely encapsulates the Thrift API so developers have to deal only with the Hector client using familiar design patterns. The original API is still available for existing users to transition their current projects as well as for those who are comfortable working with Thrift.
- ^ "Hector Client for Apache Cassandra: Fully Mavenized" (PDF). DataStax. Retrieved 2011-04-12.
Since the beta release of Cassandra 0.7.0, Riptano has been offering maven repository access for dependencies required for Cassandra usage via Hector.
- ^ Ran Tavory. "Load balancing and improved failover in Hector". PrettyPrint.me. Retrieved 2011-03-23.
ve added a very simple load balancing feature, as well as improved failover behavior to Hector. Hector is a Java Cassandra client, to read more about it please see my previous post Hector – a Java Cassandra client. In version 0.5.0-6 I added poor-man’s load balancing as well as improved failover behavior.
- ^ "Hector Client for Apache Cassandra: Availability of Metrics" (PDF). DataStax. Retrieved 2011-04-12.
To facilitate smoother operations and better awareness of performance characteristics, Hector exposes both availability counters and, optionally, performance statistics through JMX.
- ^ "Hector Client for Apache Cassandra: Basic Load Balancing" (PDF). DataStax. Retrieved 2011-04-12.
Hector provides for plugable load balancing through the
LoadBalancingPolicy
interface. Out of the box, two basic implementations are provided:LeastActiveBalancingPolicy
(the default) andRoundRobinBalancingPolicy
.LeastActiveBalancingPolicy
routes requests to the pools with the lowest number of active connections. This ensures a good spread of utilization across the cluster by sending requests to the machine that has the fewest connections.RoundRobinBalancingPolicy
implements a simple round-robin distribution algorithm. - ^ "Hector Client for Apache Cassandra: Configuration of Pooling" (PDF). DataStax. Retrieved 2011-04-12.
The behavior of the underlying pools of client connections can be controlled by the ExhaustedPolicy. […]