인덱스 통계를 보려면 _stats 또는 인덱스이름/_stats를 사용하면 된다.


https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html




curl localhost:9200/wikinews/_stats?pretty=true

{

  "_shards" : {

    "total" : 10,

    "successful" : 5,

    "failed" : 0

  },

  "_all" : {

    "primaries" : {

      "docs" : {

        "count" : 21067,

        "deleted" : 0

      },

      "store" : {

        "size_in_bytes" : 373355243,

        "throttle_time_in_millis" : 0

      },

      "indexing" : {

        "index_total" : 42134,

        "index_time_in_millis" : 110295,

        "index_current" : 0,

        "index_failed" : 0,

        "delete_total" : 0,

        "delete_time_in_millis" : 0,

        "delete_current" : 0,

        "noop_update_total" : 0,

        "is_throttled" : false,

        "throttle_time_in_millis" : 0

      },

      "get" : {

        "total" : 0,

        "time_in_millis" : 0,

        "exists_total" : 0,

        "exists_time_in_millis" : 0,

        "missing_total" : 0,

        "missing_time_in_millis" : 0,

        "current" : 0

      },

      "search" : {

        "open_contexts" : 0,

        "query_total" : 0,

        "query_time_in_millis" : 0,

        "query_current" : 0,

        "fetch_total" : 0,

        "fetch_time_in_millis" : 0,

        "fetch_current" : 0,

        "scroll_total" : 0,

        "scroll_time_in_millis" : 0,

        "scroll_current" : 0,

        "suggest_total" : 0,

        "suggest_time_in_millis" : 0,

        "suggest_current" : 0

      },

      "merges" : {

        "current" : 0,

        "current_docs" : 0,

        "current_size_in_bytes" : 0,

        "total" : 0,

        "total_time_in_millis" : 0,

        "total_docs" : 0,

        "total_size_in_bytes" : 0,

        "total_stopped_time_in_millis" : 0,

        "total_throttled_time_in_millis" : 0,

        "total_auto_throttle_in_bytes" : 104857600

      },

      "refresh" : {

        "total" : 59,

        "total_time_in_millis" : 30946,

        "listeners" : 0

      },

      "flush" : {

        "total" : 10,

        "total_time_in_millis" : 284

      },

      "warmer" : {

        "current" : 0,

        "total" : 74,

        "total_time_in_millis" : 18

      },

      "query_cache" : {

        "memory_size_in_bytes" : 0,

        "total_count" : 0,

        "hit_count" : 0,

        "miss_count" : 0,

        "cache_size" : 0,

        "cache_count" : 0,

        "evictions" : 0

      },

      "fielddata" : {

        "memory_size_in_bytes" : 0,

        "evictions" : 0

      },

      "completion" : {

        "size_in_bytes" : 0

      },

      "segments" : {

        "count" : 24,

        "memory_in_bytes" : 1619215,

        "terms_memory_in_bytes" : 1435245,

        "stored_fields_memory_in_bytes" : 42880,

        "term_vectors_memory_in_bytes" : 0,

        "norms_memory_in_bytes" : 26112,

        "points_memory_in_bytes" : 1106,

        "doc_values_memory_in_bytes" : 113872,

        "index_writer_memory_in_bytes" : 0,

        "version_map_memory_in_bytes" : 0,

        "fixed_bit_set_memory_in_bytes" : 0,

        "max_unsafe_auto_id_timestamp" : -1,

        "file_sizes" : { }

      },

      "translog" : {

        "operations" : 0,

        "size_in_bytes" : 215

      },

      "request_cache" : {

        "memory_size_in_bytes" : 0,

        "evictions" : 0,

        "hit_count" : 0,

        "miss_count" : 0

      },

      "recovery" : {

        "current_as_source" : 0,

        "current_as_target" : 0,

        "throttle_time_in_millis" : 0

      }

    },

    "total" : {

      "docs" : {

        "count" : 21067,

        "deleted" : 0

      },

      "store" : {

        "size_in_bytes" : 373355243,

        "throttle_time_in_millis" : 0

      },

      "indexing" : {

        "index_total" : 42134,

        "index_time_in_millis" : 110295,

        "index_current" : 0,

        "index_failed" : 0,

        "delete_total" : 0,

        "delete_time_in_millis" : 0,

        "delete_current" : 0,

        "noop_update_total" : 0,

        "is_throttled" : false,

        "throttle_time_in_millis" : 0

      },

      "get" : {

        "total" : 0,

        "time_in_millis" : 0,

        "exists_total" : 0,

        "exists_time_in_millis" : 0,

        "missing_total" : 0,

        "missing_time_in_millis" : 0,

        "current" : 0

      },

      "search" : {

        "open_contexts" : 0,

        "query_total" : 0,

        "query_time_in_millis" : 0,

        "query_current" : 0,

        "fetch_total" : 0,

        "fetch_time_in_millis" : 0,

        "fetch_current" : 0,

        "scroll_total" : 0,

        "scroll_time_in_millis" : 0,

        "scroll_current" : 0,

        "suggest_total" : 0,

        "suggest_time_in_millis" : 0,

        "suggest_current" : 0

      },

      "merges" : {

        "current" : 0,

        "current_docs" : 0,

        "current_size_in_bytes" : 0,

        "total" : 0,

        "total_time_in_millis" : 0,

        "total_docs" : 0,

        "total_size_in_bytes" : 0,

        "total_stopped_time_in_millis" : 0,

        "total_throttled_time_in_millis" : 0,

        "total_auto_throttle_in_bytes" : 104857600

      },

      "refresh" : {

        "total" : 59,

        "total_time_in_millis" : 30946,

        "listeners" : 0

      },

      "flush" : {

        "total" : 10,

        "total_time_in_millis" : 284

      },

      "warmer" : {

        "current" : 0,

        "total" : 74,

        "total_time_in_millis" : 18

      },

      "query_cache" : {

        "memory_size_in_bytes" : 0,

        "total_count" : 0,

        "hit_count" : 0,

        "miss_count" : 0,

        "cache_size" : 0,

        "cache_count" : 0,

        "evictions" : 0

      },

      "fielddata" : {

        "memory_size_in_bytes" : 0,

        "evictions" : 0

      },

      "completion" : {

        "size_in_bytes" : 0

      },

      "segments" : {

        "count" : 24,

        "memory_in_bytes" : 1619215,

        "terms_memory_in_bytes" : 1435245,

        "stored_fields_memory_in_bytes" : 42880,

        "term_vectors_memory_in_bytes" : 0,

        "norms_memory_in_bytes" : 26112,

        "points_memory_in_bytes" : 1106,

        "doc_values_memory_in_bytes" : 113872,

        "index_writer_memory_in_bytes" : 0,

        "version_map_memory_in_bytes" : 0,

        "fixed_bit_set_memory_in_bytes" : 0,

        "max_unsafe_auto_id_timestamp" : -1,

        "file_sizes" : { }

      },

      "translog" : {

        "operations" : 0,

        "size_in_bytes" : 215

      },

      "request_cache" : {

        "memory_size_in_bytes" : 0,

        "evictions" : 0,

        "hit_count" : 0,

        "miss_count" : 0

      },

      "recovery" : {

        "current_as_source" : 0,

        "current_as_target" : 0,

        "throttle_time_in_millis" : 0

      }

    }

  },

  "indices" : {

    "wikinews" : {

      "primaries" : {

        "docs" : {

          "count" : 21067,

          "deleted" : 0

        },

        "store" : {

          "size_in_bytes" : 373355243,

          "throttle_time_in_millis" : 0

        },

        "indexing" : {

          "index_total" : 42134,

          "index_time_in_millis" : 110295,

          "index_current" : 0,

          "index_failed" : 0,

          "delete_total" : 0,

          "delete_time_in_millis" : 0,

          "delete_current" : 0,

          "noop_update_total" : 0,

          "is_throttled" : false,

          "throttle_time_in_millis" : 0

        },

        "get" : {

          "total" : 0,

          "time_in_millis" : 0,

          "exists_total" : 0,

          "exists_time_in_millis" : 0,

          "missing_total" : 0,

          "missing_time_in_millis" : 0,

          "current" : 0

        },

        "search" : {

          "open_contexts" : 0,

          "query_total" : 0,

          "query_time_in_millis" : 0,

          "query_current" : 0,

          "fetch_total" : 0,

          "fetch_time_in_millis" : 0,

          "fetch_current" : 0,

          "scroll_total" : 0,

          "scroll_time_in_millis" : 0,

          "scroll_current" : 0,

          "suggest_total" : 0,

          "suggest_time_in_millis" : 0,

          "suggest_current" : 0

        },

        "merges" : {

          "current" : 0,

          "current_docs" : 0,

          "current_size_in_bytes" : 0,

          "total" : 0,

          "total_time_in_millis" : 0,

          "total_docs" : 0,

          "total_size_in_bytes" : 0,

          "total_stopped_time_in_millis" : 0,

          "total_throttled_time_in_millis" : 0,

          "total_auto_throttle_in_bytes" : 104857600

        },

        "refresh" : {

          "total" : 59,

          "total_time_in_millis" : 30946,

          "listeners" : 0

        },

        "flush" : {

          "total" : 10,

          "total_time_in_millis" : 284

        },

        "warmer" : {

          "current" : 0,

          "total" : 74,

          "total_time_in_millis" : 18

        },

        "query_cache" : {

          "memory_size_in_bytes" : 0,

          "total_count" : 0,

          "hit_count" : 0,

          "miss_count" : 0,

          "cache_size" : 0,

          "cache_count" : 0,

          "evictions" : 0

        },

        "fielddata" : {

          "memory_size_in_bytes" : 0,

          "evictions" : 0

        },

        "completion" : {

          "size_in_bytes" : 0

        },

        "segments" : {

          "count" : 24,

          "memory_in_bytes" : 1619215,

          "terms_memory_in_bytes" : 1435245,

          "stored_fields_memory_in_bytes" : 42880,

          "term_vectors_memory_in_bytes" : 0,

          "norms_memory_in_bytes" : 26112,

          "points_memory_in_bytes" : 1106,

          "doc_values_memory_in_bytes" : 113872,

          "index_writer_memory_in_bytes" : 0,

          "version_map_memory_in_bytes" : 0,

          "fixed_bit_set_memory_in_bytes" : 0,

          "max_unsafe_auto_id_timestamp" : -1,

          "file_sizes" : { }

        },

        "translog" : {

          "operations" : 0,

          "size_in_bytes" : 215

        },

        "request_cache" : {

          "memory_size_in_bytes" : 0,

          "evictions" : 0,

          "hit_count" : 0,

          "miss_count" : 0

        },

        "recovery" : {

          "current_as_source" : 0,

          "current_as_target" : 0,

          "throttle_time_in_millis" : 0

        }

      },

      "total" : {

        "docs" : {

          "count" : 21067,

          "deleted" : 0

        },

        "store" : {

          "size_in_bytes" : 373355243,

          "throttle_time_in_millis" : 0

        },

        "indexing" : {

          "index_total" : 42134,

          "index_time_in_millis" : 110295,

          "index_current" : 0,

          "index_failed" : 0,

          "delete_total" : 0,

          "delete_time_in_millis" : 0,

          "delete_current" : 0,

          "noop_update_total" : 0,

          "is_throttled" : false,

          "throttle_time_in_millis" : 0

        },

        "get" : {

          "total" : 0,

          "time_in_millis" : 0,

          "exists_total" : 0,

          "exists_time_in_millis" : 0,

          "missing_total" : 0,

          "missing_time_in_millis" : 0,

          "current" : 0

        },

        "search" : {

          "open_contexts" : 0,

          "query_total" : 0,

          "query_time_in_millis" : 0,

          "query_current" : 0,

          "fetch_total" : 0,

          "fetch_time_in_millis" : 0,

          "fetch_current" : 0,

          "scroll_total" : 0,

          "scroll_time_in_millis" : 0,

          "scroll_current" : 0,

          "suggest_total" : 0,

          "suggest_time_in_millis" : 0,

          "suggest_current" : 0

        },

        "merges" : {

          "current" : 0,

          "current_docs" : 0,

          "current_size_in_bytes" : 0,

          "total" : 0,

          "total_time_in_millis" : 0,

          "total_docs" : 0,

          "total_size_in_bytes" : 0,

          "total_stopped_time_in_millis" : 0,

          "total_throttled_time_in_millis" : 0,

          "total_auto_throttle_in_bytes" : 104857600

        },

        "refresh" : {

          "total" : 59,

          "total_time_in_millis" : 30946,

          "listeners" : 0

        },

        "flush" : {

          "total" : 10,

          "total_time_in_millis" : 284

        },

        "warmer" : {

          "current" : 0,

          "total" : 74,

          "total_time_in_millis" : 18

        },

        "query_cache" : {

          "memory_size_in_bytes" : 0,

          "total_count" : 0,

          "hit_count" : 0,

          "miss_count" : 0,

          "cache_size" : 0,

          "cache_count" : 0,

          "evictions" : 0

        },

        "fielddata" : {

          "memory_size_in_bytes" : 0,

          "evictions" : 0

        },

        "completion" : {

          "size_in_bytes" : 0

        },

        "segments" : {

          "count" : 24,

          "memory_in_bytes" : 1619215,

          "terms_memory_in_bytes" : 1435245,

          "stored_fields_memory_in_bytes" : 42880,

          "term_vectors_memory_in_bytes" : 0,

          "norms_memory_in_bytes" : 26112,

          "points_memory_in_bytes" : 1106,

          "doc_values_memory_in_bytes" : 113872,

          "index_writer_memory_in_bytes" : 0,

          "version_map_memory_in_bytes" : 0,

          "fixed_bit_set_memory_in_bytes" : 0,

          "max_unsafe_auto_id_timestamp" : -1,

          "file_sizes" : { }

        },

        "translog" : {

          "operations" : 0,

          "size_in_bytes" : 215

        },

        "request_cache" : {

          "memory_size_in_bytes" : 0,

          "evictions" : 0,

          "hit_count" : 0,

          "miss_count" : 0

        },

        "recovery" : {

          "current_as_source" : 0,

          "current_as_target" : 0,

          "throttle_time_in_millis" : 0

        }

      }

    }

  }

}





만약 다큐먼트 개수만 보고 싶다면 _stats/docs를 호출하면 된다.


 curl localhost:9200/wikinews/_stats/docs?pretty=true

{

  "_shards" : {

    "total" : 10,

    "successful" : 5,

    "failed" : 0

  },

  "_all" : {

    "primaries" : {

      "docs" : {

        "count" : 21067,

        "deleted" : 0

      }

    },

    "total" : {

      "docs" : {

        "count" : 21067,

        "deleted" : 0

      }

    }

  },

  "indices" : {

    "wikinews" : {

      "primaries" : {

        "docs" : {

          "count" : 21067,

          "deleted" : 0

        }

      },

      "total" : {

        "docs" : {

          "count" : 21067,

          "deleted" : 0

        }

      }

    }

  }

}

Posted by '김용환'
,

shell script에서 간단하게 한 줄로 표현하고 싶은 line이 있을 수 있다. 


$ echo  xxx: ; printf "mm"

xxx:

mm




echo 매개 변수에 -n을 추가하면 원하는 대로 한 줄로 표현할 수 있다. 


$ echo -n xxx: ; printf "mm"

xxx:mm


Posted by '김용환'
,


맥 OS에서는 zcat을 사용하면 파일이 없다는 에러가 나온다. 


$ zcat ../$dump 

zcat: can't stat: ../file.json.gz (../files.gz.Z): No such file or directory



zcat 대신 gzcat을 사용하면 잘 동작한다. 

Posted by '김용환'
,


매트릭스 집계는 일래스틱서치 5.0 버전과 함께 일래스틱서치 집계 범주에 포함된다. 메트릭스 집계는 여러 필드에서 작업하고 해당 필드에서 추출한 값을 기반으로 결과 행렬을 생성하는 방법을 제공한다.

현재 매트릭스 집계 카테고리에서 지원되는 집계 타입은 매트릭스 통계(Matrix Stats) 하나뿐이다.

매트릭스 집계는 주어진 필드 집합에 대한 수치 통계를 계산한다. 


연봉과 만족도 간의 관계를 통핸 수치 통계를 매트릭트 통계로 진행할 수 있다. 

예제는 다음과 같다.


curl -XGET "http://localhost:9200/members/_search?pretty" -d'

{

  "aggs": {

    "matrixstats": {

      "matrix_stats": {

        "fields": [

          "salary",

          "self_esteem"

        ]

      }

    }

  },"size": 0

}'



이렇게 호출하면 다음 값이 나온다.  필드의 대한 자세한 내용은 아래 url에 설명되어 있다.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-matrix-stats-aggregation.html


{

  "took" : 7,

  "timed_out" : false,

  "_shards" : {

    "total" : 1,

    "successful" : 1,

    "failed" : 0

  },

  "hits" : {

    "total" : 10,

    "max_score" : 0.0,

    "hits" : [ ]

  },

  "aggregations" : {

    "matrixstats" : {

      "fields" : [

        {

          "name" : "self_esteem",

          "count" : 10,

          "mean" : 6.109999990463257,

          "variance" : 1.1721109714508229,

          "skewness" : 0.2987179705001951,

          "kurtosis" : 2.1800689946867364,

          "covariance" : {

            "self_esteem" : 1.1721109714508229,

            "salary" : 8.953332879808212

          },

          "correlation" : {

            "self_esteem" : 1.0,

            "salary" : 0.9734162963071288

          }

        },

        {

          "name" : "salary",

          "count" : 10,

          "mean" : 159.20000000000002,

          "variance" : 72.17777777777786,

          "skewness" : 0.1035519897524805,

          "kurtosis" : 2.685063487344997,

          "covariance" : {

            "self_esteem" : 8.953332879808212,

            "salary" : 72.17777777777786

          },

          "correlation" : {

            "self_esteem" : 0.9734162963071288,

            "salary" : 1.0

          }

        }

      ]

    }

  }

}



여기서 size는 실제 데이터 정보를 포함하는 영역이다. 실제 데이터를 볼 마음이 없다면 항상 size=0을 넣어야 한다.


누락된 값에 대한 디폴트 값을 지정할 수 있다. 


curl -XGET "http://localhost:9200/members/_search?pretty" -d'

  "aggs": { 

    "matrixstats": { 

      "matrix_stats": { 

        "fields": [ 

          "salary", 

          "self_esteem" 

        ], 

    "missing": {"self_esteem" : 5} 

      } 

    } 

  },"size": 0 

}








Posted by '김용환'
,

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline.html


형제 파이프 라인 집계 

  • avg 버킷 집계
  • max 버킷 집계
  • min 버킷 집계
  • sum 버킷 집계
  • stats 버킷 집계
  • extended stats 버킷 집계
  • percentile 버킷 집계
  • moving average  집계

부모 파이프 라인 집계 

  • derivative 집계
  • cumulative 합계
  • bucket script 집계
  • bucket selector 집계
  • serial differencing 집계

파이프 라인 집계는 하위 집계를 지원하지 않지만 bucket_path 매개 변수를 사용하는 집계 체인을 지원하기 때문에 파이프 라인 집계 체인에서 최종 출력은 체인의 각 집계 출력이 포함된다. bucket_path의 구문은 다음과 같다.
AGG_SEPARATOR       =  '>' 
METRIC_SEPARATOR    =  '.' 
AGG_NAME            =  <the name of the aggregation> 
METRIC              =  <the name of the metric (in case of multi-value metrics aggregation)>
PATH                =  <AGG_NAME> [ <AGG_SEPARATOR>, <AGG_NAME> ]* [ <METRIC_SEPARATOR>, <METRIC> ]


예를 들어 "buckets_path": "AGG_NAME>METRIC"은 bucket_path는 집계와 해당 집계의 메트릭을 참조함을 알려준다.


https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-matrix-stats-aggregation.html

Posted by '김용환'
,


5월 1/2일에 goto 2017 세션이 있었다. 자료는 아래 링크에 가면 자료를 다운받을 수 있다.


https://gotochgo.com/2017/schedule





* 세션 중 재미있는 것을 정리


1) Fast Data Architectures for Streaming Applications


https://conf-assets.s3.eu-central-1.amazonaws.com/uploads/slides/conference_3/37/original/DeanW-GOTOChicago-2017.pdf





--> (결국 여기 접속) http://lightbend.com/fast-data-platform





2) Apache Beam 소개

https://conf-assets.s3.eu-central-1.amazonaws.com/uploads/slides/conference_3/27/original/Beam_Intro.pdf



3) 개발 문화에 대한 얘기https://conf-assets.s3.eu-central-1.amazonaws.com/uploads/slides/conference_3/81/original/Video%20Transcoding%20at%20the%20ABC%20with%20Microservices%20-%20GOTO%20Chicago.pdf

https://conf-assets.s3.eu-central-1.amazonaws.com/uploads/slides/conference_3/43/original/Tim-Gross.pdf


4) microservice

https://conf-assets.s3.eu-central-1.amazonaws.com/uploads/slides/conference_3/74/original/gotochicago_from_a_startup_perspective.pdf


ABC 방송국의 microservice

https://conf-assets.s3.eu-central-1.amazonaws.com/uploads/slides/conference_3/81/original/Video%20Transcoding%20at%20the%20ABC%20with%20Microservices%20-%20GOTO%20Chicago.pdf



5) python-베이지안

https://conf-assets.s3.eu-central-1.amazonaws.com/uploads/slides/conference_3/121/original/LORENAMESA_GOTO%20Conf%20-%20Predicting%20free%20pizza%20with%20Python.%20Cowabunga%20dude!.pdf


6) jdk9

https://conf-assets.s3.eu-central-1.amazonaws.com/uploads/slides/conference_3/54/original/Javalution.pdf




'scribbling' 카테고리의 다른 글

[성과] OKR  (0) 2017.05.23
[펌] uber 아키텍처  (0) 2017.05.22
간단한 http client - okhttp  (0) 2017.04.28
아파치 오로라(Apache Aurora)  (0) 2017.04.21
[메소스] DRF 알고리즘  (0) 2017.04.20
Posted by '김용환'
,


해외에서 착신전환 서비스 이용하기 



1. 글로벌 유심을 사용해서 글로벌 유심 업체를 사용해 착신전환하는 방법 (돈 11,000원 드는 것 같음)



2. 내 핸드폰 번호를 다른 곳으로 받을 수 있도록 하기


내가 한 방법은 070 번호로 착신전환 되도록 했다. 

(내 상황은 전화를 하기 위해 070 무선 핸드폰만 챙겼을 뿐. 로밍을 신청하지 않았다. 해외 유심만 따로 사서 꼈을 뿐.. 그런데. 결제/뱅킹을 위해서 급하게 필요하게 되었다.)




나는 skt사용자로서 인터넷 tworld 에서 착신전환 서비스 신청을 할 수 있다.


실제 착신 전화번호를 입력하려면 리모콘 서비스를 신청하고 입력해야 한다.(약 월 1600원어치)


해외에 있으면 리모콘 서비스를 사용하는 게 쉽지 않다. (실제 착신 번호를 넣으려면 공인인증서를 사용해서 변경해야 한다.)114로 전화해서 리모콘 서비스 요청을 진행한 후..


011 200 8282 여기로 전화해서 착신 전화를 설정한다.


나의 경우는 070 핸드폰을 들고 가서 착신전환을 받았다. 대신 문자는 안된다.



Posted by '김용환'
,


(SparkContext 코드에는 다양한 rdd 생성 방식을 지원한다. 그 중 공부하는 내용을 살펴본다)


전통적인 spark의 rdd 생성 방식은 parallelize 메소드를 사용하는 것이었다.


scala> val rdd1 = sc.parallelize(List(1,2,3))

rdd1: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[0] at parallelize at <console>:24



spark2에서 rdd 생성할 수 있는 makeRDD라는 메소드가 추가되었다.


scala> val rdd2 = sc.makeRDD(List(1,2,3))

rdd2: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[1] at makeRDD at <console>:24



게다가 파티셔닝도 되는 메소드이다.



scala> val rdd3 = sc.makeRDD(List((1, List("a", "b", "c")), (2, List("d", "e", "f"))))

rdd3: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[3] at makeRDD at <console>:24



scala> rdd3.preferredLocations(rdd3.partitions(1))

res6: Seq[String] = List(d, e, f)


scala> rdd3.preferredLocations(rdd3.partitions(0))

res7: Seq[String] = List(a, b, c)




api를 살펴보면, 다음과 같다. parallelize 함수를 내부적으로 쓴다.


  /** Distribute a local Scala collection to form an RDD.
   *
   * This method is identical to `parallelize`.
   * @param seq Scala collection to distribute
   * @param numSlices number of partitions to divide the collection into
   * @return RDD representing distributed collection
   */
  def makeRDD[T: ClassTag](
      seq: Seq[T],
      numSlices: Int = defaultParallelism): RDD[T] = withScope {
    parallelize(seq, numSlices)
  }

  /**
   * Distribute a local Scala collection to form an RDD, with one or more
   * location preferences (hostnames of Spark nodes) for each object.
   * Create a new partition for each collection item.
   * @param seq list of tuples of data and location preferences (hostnames of Spark nodes)
   * @return RDD representing data partitioned according to location preferences
   */
  def makeRDD[T: ClassTag](seq: Seq[(T, Seq[String])]): RDD[T] = withScope {
    assertNotStopped()
    val indexToPrefs = seq.zipWithIndex.map(t => (t._2, t._1._2)).toMap
    new ParallelCollectionRDD[T](this, seq.map(_._1), math.max(seq.size, 1), indexToPrefs)
  }



Posted by '김용환'
,

cassandra3 모니터링을 telegraf로 사용하려 하는데. 

일부 중요 mbean 지표(/org.apache.cassandra.db:type=StorageService, /org.apache.cassandra.net:type=FailureDetector)를 telegraf로 보지 못한다. 


실제 telegraf-cassandra 모니터링 코드는 다음과 같다.


https://github.com/influxdata/telegraf/blob/master/plugins/inputs/cassandra/cassandra.go#L270-L280



if strings.HasPrefix(metric, "/java.lang:") {

m = newJavaMetric(serverTokens["host"], metric, acc)

} else if strings.HasPrefix(metric,

"/org.apache.cassandra.metrics:") {

m = newCassandraMetric(serverTokens["host"], metric, acc)

} else {

// unsupported metric type

acc.AddError(fmt.Errorf("E! Unsupported Cassandra metric [%s], skipping",

metric))

continue

}



telegraf 1.4에서 지원예정이라 한다.. (더 늦어질 지도.)


https://github.com/influxdata/telegraf/issues/2567









Posted by '김용환'
,

간단한 java http client 가 있다. android도 지원하는 경량 java http client이다. 


OkHttp - http://square.github.io/okhttp



public static final MediaType JSON

= MediaType.parse("application/json; charset=utf-8");

OkHttpClient client = new OkHttpClient();

String post(String url, String json) throws IOException {

RequestBody body = RequestBody.create(JSON, json);

Request request = new Request.Builder()

.url(url)

.post(body)

.build();

Response response = client.newCall(request).execute();

return response.body().string();

}





Posted by '김용환'
,