화면에 존재하는 id가 item_table인 테이블의 자식들을 모두 지우고

순서를 변경해서 모두 다시 add 하는 예제. (가상의 data라는 정보를 이용해서 추가함)

(예쁘게 add하기 위해 colspan을 항상 조정 함.)


이 때, tr은 매번 만들어서 추가하는 방식 임.

테이블은 한 row당 4개의 항목 (th+td가 한항목)까지 max로 들어가므로 총 12개의 colspan을 이용해 추가함.



               var table = $('#item_table');

    var itemsTh = $('#item_table th');

var itemsTd = $('#item_table td');


//remove all

table.children().remove();

var items = []; //sorted MenuItem data

//sort

        for (var i = 1; i <= data.length; i++) { //itemOrd는 1부터 시작.

        for (var j = 0; j < data.length; j++)

        if(data[j].itemOrd == i && data[j].useYn == 'Y') //useYn도 여기서 check필요.

        items.push(data[j]);

        }

        var newTr = $('<tr> </tr>');

        var sumColspan = 0;

        var colspan;

        var tdIdx;

    //items 다시add to tr -> table

        for (var i = 0; i < items.length; i++) {

        //find th/td

        tdIdx = findTdNum(items[i].itemCd, itemsTd);

       

        //add to tr, td는 colspan setting max 12개 td기준. 

        itemsTh.eq(tdIdx).text(items[i].itemNm);

        sumColspan += 1;

        newTr.append(itemsTh[tdIdx]);

       

        colspan = getColspan(items[i].itemStep);

       

        //colspan 조정.(여분 tr을 꽉 채우기) max=12

        var nextColspan = getNextColspan(items.length, i+1, items );

        colspan = adjustColspan(colspan, sumColspan, nextColspan );

       

        sumColspan += colspan;

        itemsTd.eq(tdIdx).attr('colspan', colspan);

        newTr.append(itemsTd[tdIdx]);

       

        //tr이 꽉차면 add tr 2 table

        if (sumColspan >= 12) {

        table.append(newTr); //test

        newTr = $('<tr> </tr>');

        sumColspan = 0;

        }

        } //items LOOPS

       

        if (sumColspan != 0) {

        //마지막 colSpan정리

        var finalColspan = adjustColspan(colspan, sumColspan-colspan, 99);

        itemsTd.eq(tdIdx).attr('colspan', finalColspan); //마지막 colspan재설정.

        table.append(newTr); //마지막 남은 tr add

        }

Posted by yongary
,

.attr 호출시 dom.eq(idx)

jquery 2017. 12. 7. 15:26


상식적으로는 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') );

Posted by yongary
,

ajax 예제 (jquery)

jquery 2017. 12. 6. 17:27

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,

Posted by yongary
,

Web Service-SOAP

IT 2017. 11. 28. 09:40

요즘은 REST가 대세이긴 하지만,

SOAP도 나름대로의 장점이 있다. 이 기종간 명확한 spec기반의 통신이 가능하다.


SOAP을 위해서, WSDL을 먼저 생성하는 게 좋은데

eclipse나 IDEA에서도 생성이 가능하지만


oXygen XML 에디터가 좋아보인다.



생성된 WSDL기반으로 테스트 하기에는 SOAP UI라는 툴이 좋아 보인다.  REF

다운로드는 https://www.soapui.org/  에서 Download로 들어가면 SoapUI OpenSource가 있다. 

Posted by yongary
,

login 관리

Spring 2017. 11. 20. 21:59

Login구현시에는 cookie + session을 섞어서 쓰는게 일반적이다. REF


쿠키는  날짜를 지정가능

세션은  id/비번등 주요정보 저장 가능.  단 브라우저 종료시 사라짐. 


즉,

세션이 브라우저 종료시 사라지는 문제가 있으므로, 

쿠키를 이용해 이를 보완해야 한다.  쿠키에 날짜/시간이 지정 가능하므로 이를 이용해서 세션ID등을 저장해 보완하면된다.




Posted by yongary
,

Column

Hadoop 2017. 11. 18. 20:42

 String은 ENCODING STRING으로

 숫자는   ENCODING BINARY로 하는 게 속도가 빠름.


REF

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
);


Posted by yongary
,

가벼운(lightweight) 확장가능한 data shippers.  data를 수집하고 shipping.

  (logstash가 무겁기 때문에 가볍게 만든 agent?)



Libbeat - 기본 라이브러리 

   Config

   Setup

   Run  - 데이타를 elasticSearch나  logstash로 전송. 

   CleanUp

   Stop  

   의 함수들을 구현(override)하면 새로운 beat을 만들 수 있음.



Packetbeat - 클라이언트에서 서버로 보내지는 데이타를 수집 

Topbeat - 시스템정보 수집

 -> 5.0부터 MetricBeat로 바뀜.


그외에도 각종 beat들이 만들어지고 있음.



  나만의 beats만들기 REF REFY



Posted by yongary
,

Pheonix

Hadoop 2017. 11. 16. 10:18

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추가 가능.   

  

  REF


======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 가로 출력 길이 세팅.


!sql                Execute a SQL command
!tables             List all the tables in the database
!typeinfo           Display the type map for the current connection
!verbose            Set verbose mode on


Posted by yongary
,

HBase & Hive

Hadoop 2017. 11. 14. 17:35

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테이블을 생성. 

Posted by yongary
,

hortonworks sandbox

Hadoop 2017. 11. 8. 17:31


실습REF   REF

===> 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)  로 접속도 가능하다.





Posted by yongary
,