3. Google Data Store GoogleApp Engine이 사용하는 분산 데이터베이스 시스템 Google File System을 기반 PetaByte 급 구조화된 데이터 저장 가능 구조화된 데이터를 위한 분산 저장 시스템 범용성, 확장성, 고성능, 고가용성을 위해 개발됨 Non-Relational Database Key-Value Store JDO/JPA & Native API 지원 단위 테스트를 위한 Local 버전 App Application Django WAS Python JAVA BigTable(분산스토리지) GFS(Google File System) 리눅스OS 서버 (최소 100만대)
4. Bigtable의 주요 특징 Big HASHMAP NoSQL, Key/Value Store No schema Entity Group 기반 Write 비용 : Expensive Read 비용: Cheap
5. Google Data Store의데이터 모델 Google Data Store의 특징 Distributed Persistent Multidimensional Sorted 디자인 핵심 키워드 Fault-tolerant Persistent Scalable Self-managing 동적인 서버 확장 및 조정 MAP
6. Google Datastore의 장점 Excellent read performance. Excellent query performance. Transparent redundant storage and load balancing. Flexible data structure. Query indexes.
7. Datastore의 제약사항 Write가 느림 검색 가능한 Text 사이즈: 500 자 Entity 최대 사이즈: 1Mb 최대 Batch (save/delete) : 500 Entity SQL을 사용할 수 없음 데이터베이스의 제약조건을 적용할 수 없음 Aggregation 함수를 지원하지 않음 (count, avg) 쿼리가 최대 조회 레코드: 1000 쿼리에서 Equal 연산 이외의 조건은 1개만 추가 가능 트랜잭션의 단위는 Entity Group에 한정 됨
14. Datastore Interface (Native vs Standard) Low Level API & ORM Standard (JDO & JPA) Low Level API& ORM Standard의 기능적인 차이점은 없음 Schemaless의 특정을 고려할 때 Native API가 더 적합 ORM Standard는 Google App Engine에 애플리케이션 종속성을 추상화 Datanucleus의 API 종속성을 제거 Native API를 사용할 경우 Entity 클래스를 이용하여 데이터 처리 데이터를 클래스에 맵핑하기 어려움
16. Datastore 구성 모든 Entity는 Kind가 지정 Entity는 하나이상의 Property를 포함 특정 Kind에포함된 Entity는 동일한 Property를 갖지 않음 Entity의 Property는 이름은 동일하지만 데이터 유형이 다를수 있음 Schemaless의 특성 ID는 지정하지 않을 경우 자동 할당 됨
17. Entity App Engine Datastore에서 관리하는 객체는 Entity Entity는 하나의 Key를 포함 모든 Entity 중 유일한 구분자 Key 의 구성 패스 Parent Entity의 key Entity의 Kind Entity에 할당된 이름 App이 할당한 값 Datastore가 지정한 numeric ID 지원 데이터 타임: integers, floating point values, strings, dates, binary data 등, 각 엔티티는 하나이상의 Property를 포함 하나의 Property에 복수의 데이터 타입 저장 가능 하나의 Property에는 복수의 값이 저장 가능 복수의 값들의 데이터 유형은 다를 수 있음
18. Datastore 저장 모델 주요 구성 Kind : Table Key : Primary Key Entity Group : Partitioning Property : column
19. Low Level API com.google.appengine.api.datastore.DatastoreService; com.google.appengine.api.datastore.DatastoreServiceFactory; com.google.appengine.api.datastore.Entity; com.google.appengine.api.datastore.Key; com.google.appengine.api.datastore.KeyFactory;
20. Entity 클래스 주요 메서드 com.google.appengine.api.datastore.Entity 생성자 public Entity(Key key) public Entity(String kind) public Entity(String kind, Key parent) public Entity(String kind, String keyName) public Entity(String kind, String keyName, Key parent) 주요 Property 관련 메서드 public Map<String,Object> getProperties() public Object getProperty(String propertyName) public void removeProperty(String propertyName) public void setPropertiesFrom(Entity src) public void setProperty(String propertyName, Object value)
21. Entity 생성 DatastoreServicedatastore = DatastoreServiceFactory.getDatastoreService(); Entity player = new Entity("Player"); player.setProperty("name", "kimyuna"); player.setProperty("age", 20); datastore.put(player); Entity player2 = new Entity("Player"); player2.setProperty("name", "Park Taehwan"); player2.setProperty("age", 21); datastore.put(player2);
22. Entity 생성 -schema-free DatastoreServicedatastore = DatastoreServiceFactory.getDatastoreService(); Entity player = new Entity("Player"); player.setProperty("name", ”kimchanho"); player.setProperty(”position", “pitcher”); datastore.put(player);
27. Root & Parent Entity & Key Root Entity Parent Entity employee Entity emp1= new Entity("Employee"); datastore.put(employee); Group Entity Employee:8261 Entity emp1= new Entity("Employee"); datastore.put(employee); Entity address = new Entity("Address", employee.getKey()); datastore.put(address); employee, address Group Entity Employee:8261 Employee:8261 / Address:1 employee Entity emp2= new Entity("Employee"); datastore.put(employee); Group Entity Employee:8262
28. Entity Group & Transaction Transaction의 최대 범위는 Entity Group Entity Group은 동일한 Tablet 서버에 위치 employee Entity emp1= new Entity("Employee"); datastore.put(employee); Group Entity Employee:8261 Entity emp1= new Entity("Employee"); datastore.put(employee); Entity address = new Entity("Address", employee.getKey()); datastore.put(address); employee, address Group Entity Employee:8261 Employee:8261 / Address:1 employee Entity emp2= new Entity("Employee"); datastore.put(employee); Group Entity Employee:8262
29. Entity Group 하나의 트랜잭션에서 여러 Entity를 조회, 생성, 수정, 삭제 할 수 가능하지만 그 범위는 단일 Entity Group에 국한 Entity Group는 부모 엔티티를 갖는 엔티티의 그룹 부모 엔티티를 가지 않은 엔티티를Root 엔티티 라고 함 Entity Group은 하나의 Root Entity와 Child Entity로 구성 하나의 엔티티 그룹은 동일한 분산 네트웍 서버에 저장됨 (Tablet 서버)
31. Batch Operation import java.util.Arrays; import java.util.List; // 코드 생략 Entity employee1 = new Entity("Employee"); Entity employee2 = new Entity("Employee"); Entity employee3 = new Entity("Employee"); //코드 생략 List<Entity> employees = Arrays.asList (employee1, employee2, employee3); datastore.put(employees);
32. Entity & Key Class com.google.appengine.api.datastore.Entity public Entity(Key key) public Entity(java.lang.String kind) public Entity(java.lang.String kind, Key parent) public Entity(java.lang.String kind, java.lang.StringkeyName) public Entity(java.lang.String kind, java.lang.StringkeyName, Key parent) com.google.appengine.api.datastore.KeyFactory public static Key createKey(Key parent, java.lang.String kind, long id) public static Key createKey(Key parent, java.lang.String kind, java.lang.String name) public static Key createKey(java.lang.String kind, long id) public static Key createKey(java.lang.String kind, java.lang.String name)
38. JPA와 JDO어노테이션으로ORM 설정 가능 두 표준간의 기능적인 차이는 없음 JDO-QL과 JPA-QL 사용 가능 JPA 2.0 (Data Nucleus JDO 구현체를 Provider로 사용) JDO 2.3 Data Nucleus 의 JDO Provider Low Level API Datastore Interface (JDO vs JPA) Google Datastore
39. Datastore Interface (JDO & JPA) JPA(Java Persistence API) RDBMS를 저장소로 테이블과 객체 맵핑 표준 스펙 JDO(Java Data Object) Non-RDBMS를 포함하는 저장소를 대상으로 하는 객체 맵핑 표준
40. App Engine의 JDO App Engine Java SDK는 JDO 구현체를 포함 Datastore의 영속성 인터페이스로 지원 Version: JDO 2.3 DataNucleus Access Platform의 구현체 사용
41. JDO 설치-jdoconfig.xml & JAR war/WEB-INF/classes/META-INF/jdoconfig.xml 라이브러리 추가 war/WEB-INF/lib/appengine-api.jar
42. JDO 설치-Enhance 프로세스 적용 클래스 컴파일 후 POJO Enhance 프로세스 적용 java -cpclasspathcom.google.appengine.tools.enhancer.Enhanceclass-files appengine-java-sdk/lib/appengine-tools-api.jar