user collections에 data가 아래와 같을 때:

  {name:"kim", phone:{mobile:"010-1234", office:"02-1234" }}

  {name:"lee",  phone:{mobie:"010-2222", office:"02-2222" }}

 

Sub Document

>  db.user.find(  {phone:{mobile:"010-1234", office:"02-1234"}  } )       : mobile, office 순서가 일치해야지만 찾음. Exact match

 

result:  kim user 1 line.

>  db.user.find(  {phone:{mobile:"010-1234" }}) 

result: no result

 

Cursor

>  

cur=db.user.find();null;  (null 이 잠시대기함)> while (cur.hasNext()) printjson(cur.next());

result: all 2users. 2 line
 
 ( Doc 조회 이전 or empty일 때,  설정 가능한 작업들)
> cur.sort( {name:-1}  );null;                       //  reverse order -> return new Cursor. so need null;

> cur.sort( {name:-1}  ).limit(3); ;null;     // limit 3. -> return new Cursor. so need null;

 

update

대표예제:  db.b2bRawCncity.updateMany({cmId:{$gt:240400007}}, {$set:{cmId:null}} );

 

>  db.user.update(  {name:"kim"},   { name:"kim2"} )     //문서 전체 udpate. 

result:  kim->kim2  phone은 날아감. (disappear)

  $set

  >  db.user.update(  {name:"kim"},   { $set: { name:"kim2"} )  //just update

 result:  kim->kim2  phone remain.

  $unset

  >  db.user.update(  {name:"kim"},   { $unset: { phone:1} )

  field  phone remove

  $upsert : true   means  => 없을 때 insert 하라는 의미.

  $multi : true   means  => 여러건 update 할 때  필수. default는 한 건만 update.

 

$type:2    string을 의미함. bson의 저장방식으로 숫자마다 다른 type을 의미함.

 

 

Posted by yongary
,

user collections에 data가 아래와 같을 때:

  {name:"kim", food:["rice","water" ]}

  {name:"lee", food:["rice","orange" ]}

 

Field Display : _id는 default.

> db.user.find( {name:"kim"}, {food:false, _id:false } )

result: {"name":"kim"}

 

 

array

>  db.user.find( {food:"rice"} )       : array 1depth까지 바로 탐색.

result:  all user 2 line. 

  update array { $push (rightmost),  $pop:1(rightmost),       $pull (remove),  $addToSet(work like set) 

  >  db.user.update( {name:"kim", {food: { $pop:1}} )      

 

 

 

$or,

> db.user.find( { $or:[ { name:"kim"}, {name:"lee"} ] } )

 


$and

 and는 보통 필요가 없다.

> db.user.find( {name:"kim", food:"rice"}  ) ?

result: kim user 1 line. 


$regex, 

> db.user.find(  {name:  {$regex:" ^k"}   } )

result: kim user 1 line.


$exists (=field exists )

> db.user.find(  {name:  {$exists:true}   } )

result: all user 2line


$all,

> db.user.find ( {rice: {$all ["rice","water] }} )

result: kim user 1 line.


$in,  (sql 의 in과 유사)

> db.user.find ( {rice: {$in ["orange","water] }} )

result: all user 2 line.

Posted by yongary
,

commands: traceroute

Linux 2015. 10. 21. 10:16

UDP traceroute:

 

traceroute 125.152.0.117 -s 220.75.130.5 -p 5160 -U

Posted by yongary
,

SIP stack

IMS 2015. 10. 15. 10:27

SIP stack is process&Library for dealing with SIP.(Sessin Initiation Protocol)

 

Open Source SIP Stack for JAVA:

 -

1) PJSIP-JNI  which is java bindings for the C PJSIP library

2) JAIN-SIP  http://users.cis.fiu.edu/~ege/JAIN/

    https://github.com/Mobicents/jain-sip 

    https://jsip.ci.cloudbees.com/job/jsip/javadoc/ 

    http://www.oracle.com/technetwork/java/introduction-jain-sip-090386.html      (Oracle introduction)

    https://developer.opencloud.com/devportal/devportal/apis/jainsip/1.1/docs/index.html 

    http://www.worldlibrary.org/articles/mobicents 

    http://www.mobicents.org/products.html 

 

    RFC 3261 functionality and the following SIP extensions; the INFO method (RFC 2976), Reliability of provisional responses (RFC 3262), Event Notification Framework (RFC 3265), the UPDATE method (RFC 3311), the Reason Header (RFC 3326), the Message method (RFC 3428) defined for instant messaging and the REFER method (RFC 3515), Distributing Authoritative Name Servers via Shared Unicast Addresses (RFC 3581), the PUBLISH method (RFC3903).

   SDP API(JSR 141) is property of Dynamic Soft. => under JCP License

 

3) MjSip        http://www.mjsip.org

4) javaforce   http://sourceforge.net/projects/javaforce/

5) jSIP          http://jsip.java.net  http://jsip.sourceforge.net/

6) openjsip    http://code.google.com/p/openjsip/

 

 

 

SIP Stack for C

1) reSIPRocate    http://www.resiprocate.org, http://svn.resiprocate.org/dox/ 

 

 

2) Spirent IMS SIP stack = Radvision SIP Stack.   REF-SITE

   - (Avaya m&a Radvision(2012),   spirent m&a Radvision Tech Biz Unit(2014) )

 

  • P-headers: private SIP headers for IMS
  • IPv6 support: the mandatory IMS transportation level
  • Signaling compression: mandatory IMS request for signaling between UE and P-CSCF
  • Support for IM URI, PRES URI, and TEL URI
  • ENUM: translation between phone numbers or TEL URI to SIP URI
  • Support for different event packages, such as presence, reg-event
  • Support for instant messaging (IM)
  • HTTP DIGEST using 3GPP AKA Authentication -"AKAv1-MD5"
  • IPsec: IP security
  • Security agreement negotiation, as defined in RFC 3329
  • Support for mobile registration using Service-route and Path headers
  •  

    Posted by yongary
    ,

    maven

    java core 2015. 10. 15. 09:10

    maven is project management tool for  autobuild & dependency management.


    INSTALL: just download and unzip.  add bin path to $PATH.


    RUN:  $mvn archetype:generate

    => defalt select.

    => groupID,package..etc:  com.ky

    $cd com.ky

    $mvn compile exec:java -Dexec.mainClass=com.ky.App


    Posted by yongary
    ,

    mongoDB

    mongoDB, redis 2015. 10. 13. 22:14

    Functionality vs scalability&performance :

      -mongoDB achievs both. But missing some functionality because of scalibility&performance.


    Not exists in mongoDB:

     -Join, transaction., schema, SQL


    Exists in mongoDB:

      Index, secondary Index



    Command:

      db

      show tables

      db.things.find ().pretty()

      db.things.insert (..json..)  or .save(json)


    SchemaLess example:

    > db.user.insert( {name:"kim"})

    > db.user.insert( {name:"lee", age:11} )

    > var j = db.user.findOne( {name:"kim"} )

    > j.age = 11

    > db.user.save(j)



    Posted by yongary
    ,

    Actor & Future

    scala 2015. 10. 12. 23:31

    Actor is Thread+Queue, while

    Future provide a way to reason about performing many operations in paralle


       http://la-stranger.tistory.com/m/post/entry/Scala-Future-Tutorial

    Posted by yongary
    ,

    linux에서 c로 개발한 후, 코드를 검사하는 방법 몇가지.. 

     

     

    ValgrindREF-SITE

     - 메모리 오류 체크, 메모리 leak 체크.

       특히 메모리 오류가 가장 짜증나는 부분인데 이런 부분을 제법 잡아주므로 꼭 돌릴 필요가 있다.

     

    - 사용법:

    $gcc test.c -o app_test

    $valgrind --leak-check=yes ./app_test

        

     

    CppCheck   http://cppcheck.sourceforge.net/

    -  Linux버전도 있고, pc버전도 있으며, 파일 단위나 폴더단위로 소스를 검사.

       메모리 누수/배열 범위/멀티 Thread 등이 check됨.

     

     

     

    gcov REF-SITE

    - 사용(혹은 TEST) 이 안되고 있는 코드 체크, 코드별 실행 횟수 및 %가 나온다.

     

    - 사용법:

      $gcc -fprofile-arcs -ftest-coverage tmp.c
      $./a.out
      $gcov tmp.c

     

     

    gprof

    - 코드 성능 분석

    Posted by yongary
    ,

    SIP & IMS

    IMS 2015. 10. 6. 14:04

    SIP is protocol like HTTP. while

    IMS is telco System Architecture which uses SIP.

     

     

    <SIP History>


    1998년에 H.323 이 나오고  -( 최초로 RTP사용.)

    1999년에 SIP가 나오면서 혼용되다가,  2008년경부터 본격 사용됨.
        -SIP는 1996년에 나온 HTTP1.0을 차용하여 Text-based로 정의.


    2002년 RFC3261.


    2012년에 8월(skt,lgt) 12월(kt) VoLTE 최초 상용화.




    <IMS>

    - 3G에서부터 HLR, 통화 등을 수용하기 위한 텔코의 시스템 구조로 발전.

          UNI: user to Network Interface (단말과 망 사이)

          NBI : North Border (AS 경계)

          NNI : Network to Network ( 타이통사간 경계)


    - IFC Chaining을 통해서 호가 흘러가는 구조 임.(IFC를 S-CSCF가 HSS로부터 받아오는 게 핵심.)

     

    - PSI 는 최종 서비스 혹은 trigger의 경우 최종 서비스로 바로가는 방법.  

      즉,IFC 는 체이닝이 되어야 효과를 발생하는 과정이고 차이가 큼..


    -  ISC (IMS Service Control )Reference Point 임. 여기서 IFC가 처리됨.


     

    Posted by yongary
    ,

    Ant 자동빌드

    java core 2015. 10. 1. 14:40

    Eclipse에서 프로젝트를 하나 골라서

    -> Export  ->  General 밑에 Ant Buildfiles 로 하면  build.xml 이 생성된다.

     

    Windows -> Show View메뉴에서 -> Ant를 고르면 우측에 Ant 작업창이 뜨고,

    그곳으로 build.xml을 drag하면 build.xml로 빌드가 가능하다

     

     

    장점: jenkins와 연동한 자동 build가 가능하다.  

    Jenkins연동 시에  Build->Add Build Step ->Invoke Ant.

    Posted by yongary
    ,