상식적으로는 itemsTd[0].attr('id') 가 될 것 같은데, 안되고 attr is not a function 오류가 발생한다.
itemsTd는 DOM이라 동작하지 않고, jquery Object를 가져와야 함.
==> .eq(idx) 이용.
var itemsTd = $('#item_table td');
console.log( itemsTd.eq(0).attr('id') );
상식적으로는 itemsTd[0].attr('id') 가 될 것 같은데, 안되고 attr is not a function 오류가 발생한다.
itemsTd는 DOM이라 동작하지 않고, jquery Object를 가져와야 함.
==> .eq(idx) 이용.
var itemsTd = $('#item_table td');
console.log( itemsTd.eq(0).attr('id') );
jquery를 이용한 ajax 예제입니다.
post 예제: ==> 이 경우 spring에서는 @RequestBody로 바로 받을 수 있음.
$.ajax({
url:'./misetStore.do',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(itemList), //JSON data를 string으로 넘기기.
success:function(data) {
alert('저장되었습니다');
},
fail:function(data) {
alert('저장 오류');
}
});//ajax
get 메서드 일 경우에는, url만 기입하면 됨.
url:'./getSubMenu.json?' + 'noMenuUp=' + noMenu,
요즘은 REST가 대세이긴 하지만,
SOAP도 나름대로의 장점이 있다. 이 기종간 명확한 spec기반의 통신이 가능하다.
SOAP을 위해서, WSDL을 먼저 생성하는 게 좋은데
eclipse나 IDEA에서도 생성이 가능하지만
oXygen XML 에디터가 좋아보인다.
생성된 WSDL기반으로 테스트 하기에는 SOAP UI라는 툴이 좋아 보인다. REF
다운로드는 https://www.soapui.org/ 에서 Download로 들어가면 SoapUI OpenSource가 있다.
Login구현시에는 cookie + session을 섞어서 쓰는게 일반적이다. REF
쿠키는 날짜를 지정가능
세션은 id/비번등 주요정보 저장 가능. 단 브라우저 종료시 사라짐.
즉,
세션이 브라우저 종료시 사라지는 문제가 있으므로,
쿠키를 이용해 이를 보완해야 한다. 쿠키에 날짜/시간이 지정 가능하므로 이를 이용해서 세션ID등을 저장해 보완하면된다.
String은 ENCODING STRING으로
숫자는 ENCODING BINARY로 하는 게 속도가 빠름.
CREATE HBASE TABLE enc_str (
ti TINYINT, si SMALLINT, i INT,
bi BIGINT, b BOOLEAN, f FLOAT,
d DOUBLE, s1 STRING, s2 STRING,
s3 STRING, s4 STRING, s5 STRING
)
COLUMN MAPPING (
KEY MAPPED BY (s1,ti,bi,i) ENCODING STRING,
f1:a MAPPED BY (si,s2,f) ENCODING STRING,
f1:b MAPPED BY (d,b,s3) ENCODING STRING,
f1:c MAPPED BY (s4,s5) ENCODING STRING
);가벼운(lightweight) 확장가능한 data shippers. data를 수집하고 shipping.
(logstash가 무겁기 때문에 가볍게 만든 agent?)
Libbeat - 기본 라이브러리
Config
Setup
Run - 데이타를 elasticSearch나 logstash로 전송.
CleanUp
Stop
의 함수들을 구현(override)하면 새로운 beat을 만들 수 있음.
Packetbeat - 클라이언트에서 서버로 보내지는 데이타를 수집
Topbeat - 시스템정보 수집
-> 5.0부터 MetricBeat로 바뀜.
그외에도 각종 beat들이 만들어지고 있음.
Hive가 batch오리엔티드인데 반해
Phoeix는 real-time Query도 수행하도록 만든 빠른 레이어이다.
-query를 HBase scan으로 만들어 빠르게 수행한다.
-HBase API를 바로 사용도 가능.
==> 그냥 jdbc 드라이버+SQL지원 정도의 용도로 많이 사용한다.
-----------------------------------
Phoenix : RDB 레이어 over hBase.
- Query engine + Metadata 저장소.
- JDBC driver 제공.
- Hive와 같이 join등 제공.
<Secondary index 방식 3가지>
- write only / + append 방식
- global for read-heavy mutable data
- local for write-heavy mutable or immutable
각종 join모두 지원.
Phoenix Calcite ?
----View생성 from HBase 테이블: 이름 transactions, ColumnFamily:transactions일때
CREATE VIEW "TransactionHistory" (k VARCHAR primary key, "Transactions"."transactionId" VARCHAR);.
=> Select "transactionId" from "Transactions"
그리고 ALTER VIEW명령어로 column추가 가능.
======Sqlline 사용한 shell 이용 방법====
$cd /usr/hdp/current/phoenix-client/bin/
$./sqlline.py
pnix> !tables
pnix> select * from MY.MY_TABLE
0: jdbc:phoenix:> help
!all Execute the specified SQL against all the current connections
!autocommit Set autocommit mode on or off
!batch Start or execute a batch of statements
!brief Set verbose mode off
!call Execute a callable statement
!close Close the current connection to the database
!closeall Close all current open connections
!columns List all the columns for the specified table
!commit Commit the current transaction (if autocommit is off)
!connect Open a new connection to the database.
!dbinfo Give metadata information about the database
!describe Describe a table
!dropall Drop all tables in the current database
!exportedkeys List all the exported keys for the specified table
!go Select the current connection
!help Print a summary of command usage
!history Display the command history
!importedkeys List all the imported keys for the specified table
!indexes List all the indexes for the specified table
!isolation Set the transaction isolation for this connection
!list List the current connections
!manual Display the SQLLine manual
!metadata Obtain metadata information
!nativesql Show the native SQL for the specified statement
!outputformat Set the output format for displaying results
(table,vertical,csv,tsv,xmlattrs,xmlelements)
!primarykeys List all the primary keys for the specified table
!procedures List all the procedures
!properties Connect to the database specified in the properties file(s)
!quit Exits the program
!reconnect Reconnect to the database
!record Record all output to the specified file
!rehash Fetch table and column names for command completion
!rollback Roll back the current transaction (if autocommit is off)
!run Run a script from the specified file
!save Save the current variabes and aliases
!scan Scan for installed JDBC drivers
!script Start saving a script to a file
!set Set a sqlline variable
=> !set maxWitdh 200 : Terminal 가로 출력 길이 세팅.
HBase는 ByteArray 베이스의 NoSQL이면서 [Columnal DBMS임] RefY
- MemStore와 HFile에 저장.
- Bloom Filter라는게 HFile마지막에 저장되면서 속도를 냄. (옵셔널)
- ColumnFamily라는 개념이 존재. (prefix맞춰서 columnFamily로 만들면.., 자동으로 timestamp같은게 기록된다고라)
sameID: (cf:name timestamp value=kim)
sameID: (cf:score timestamp value=50) 내부적으론 이런식으로 dup해서 기록된다고 하네요.. 흠. REFY
ColumnFamily는 저장소 분리 및 압축에 사용됨. (유사한 type들을 모아놓아야 columnFam단위로 압축이 되거나 안되거나 함)
- extremely Low Latency & Low time delay..
- MapReduce와는 별도로 실행도 가능하고, 동시에 실행도 가능하다. (not mutually exclusive)
실행) $sudo /etc/init.d/hadoop-hbase-master start
====hbase shell=============
$hbase shell
hbase> list (ALL hbase Table listing)
hbase> desc 'MY:TABLE'
hbase> scan 'MY:TABLE' ( log라는 테이블 전체 조회)
hbase>
설계 룰:
- 가능한 적은 table을 만든다
- up front디자인에 많은 시간 투자!
- data loading은 최소한으로 한다.(모아서)
(Java API 지원)
Put = new Put()
Get = new Get()
---------------
Hive 은 ETL(Extract, Transform, Load) 툴.-> query타임이 중요치 않을때 사용
Hbase 는 온라인 access가 가능한 DB. -> query타임이 중요할 때 사용.
hive 예제. $hive 이후에 REFY
hive> add jar file:///usr/lib/hive-0.13.1-bin/lib/hive-contrib-0.13.1.jar;
hive> load data inpath 'hdfs:/wiki-access.log'
hive> select * from access;
ㅁ hBase/hive mapping된 테이블 생성
hive에는 hbase_table_access테이블을, hbase에는 log테이블을 생성.
===> hadoopexam.com 에 가면 각종 예제 많이 있음.
아, 그리고 windows의 경우 BIOS셋업에서 Virtual Technology를 Enable시켜야 하는 경우 있음.
hortonworks의 sandbox는 HDP(hortonworks Data Platform) 및 관련된 sw들이 모두 다 설치되어 있는 VM으로서
다운로드 받아서 VirtualBox같은 환경에서 실행만 하면 HDP의 모든 서비스를 바로 사용할 수 있다.
(용도는 test용일까, 상용일까? 상용도 가능하겠지요.. 이부분 공부 중.)
centOS환경으로 제공되며, 실행후에는
localHost와 여러 포트가 portMapping이 되어 있으므로
http://localhost:8888 or 8080(Ambari) (maria_dev/maria_dev) 등으로 바로 실행가능하고,
ssh root@localhost -p 2222 (root/hadoop) 로 접속도 가능하다.
(spring에서 reactive 가능한 방식들)
1. DeferredResult + RxJava + CompleteFuture Ref
2. webFlux using Mono or Flux
===================================================
infoQ_lecture Ref1
- WebFlux에서 사용하는 reactor프로젝트의
Mono는 backPressure도 지원한다. (RxJava의 single은 지원하지 않음)
Flux는 RxJava의 observable과 비슷.. 무한개의 데이타를 지원함..(메모리 안쓰니까..)
그리고, RxJava는 foundation Level이고
WebFlux는 Functional Level이라서 당연히 섞어서 쓸 수 있을 것 같다.(아직 미테스트)
spring-boot-start-webflux를 사용하면 웹서버가 tomcat이 아니고 netty네요. (async를 더 잘지원하기 때문)
(16:00)
(26:00)
or Netty or UnderTow
Spring Web Flux - utubeRef