apache commons에 CircularFifoBuffer 클래스가 있다. 



첫번째 예시 코드이다.



object Test extends App {

import org.apache.commons.collections.buffer.CircularFifoBuffer

val tasks = new CircularFifoBuffer(10)
tasks.add(1)
tasks.add(2)
tasks.add(5)
tasks.add(6)
println("max size : " + tasks.maxSize)
println("size: " + tasks.size)
println("--get")
println(tasks.get())
println(tasks.get())
println(tasks.get())
println(tasks.get())

println("--remove")
println(tasks.remove)
println(tasks.remove)
println(tasks.remove)
println(tasks.remove)

println("-- error")
println(tasks.remove)
}


가지고 있는 buffer보다 더 많이 remove하면 exception이 발생한다. 

get을 호출하면 계속 첫번째 엘리먼트를 리턴한다. 현재 값 확인할 때 좋을 듯 하다. 


max size : 10

size: 4

--get

1

1

1

1

--remove

1

2

5

6


at org.apache.commons.collections.buffer.BoundedFifoBuffer.remove(BoundedFifoBuffer.java:275)





두 번째 예시 코드이다. 


object Test extends App {

import org.apache.commons.collections.buffer.CircularFifoBuffer

val tasks = new CircularFifoBuffer(10)
tasks.add(1)
tasks.add(2)
tasks.add(3)
tasks.add(4)
tasks.add(5)
tasks.add(6)
tasks.add(7)
tasks.add(8)
tasks.add(9)
tasks.add(10)
tasks.add(11)
tasks.add(12)
println("max size : " + tasks.maxSize)
println("size: " + tasks.size)

for(i <- tasks.toArray) {
println(tasks.remove)
}
}


데이터를 계속 추가하면 처음에 들어온 데이터는 삭제된다. overflow가 발생되지 않는다. 



max size : 10

size: 10

3

4

5

6

7

8

9

10

11

12


Posted by '김용환'
,

intellij에서 scala App을 실행할 때 다음과 같은 에러가 발생할 수 있다. 


Error: scala: No 'scala-library*.jar' in Scala compiler library in test



Open File -> Project Structures -> Libraries(또는 맥이라면 cmd + ;를 누름) 화면에서 scala sdk를 삭제한다. 


그리고 코드 화면으로 넘어가면 scala setup을 해야 한다는 경고창이 코드 뷰 상단에 뜨는데. scala setup 버튼을 누르면 잘 동작한다. 



이렇게 잘 안되면..


Open File -> Project Structures -> Libraries(또는 맥이라면 cmd + ;를 누름) 화면에서 scala sdk를 삭제하고 +를 눌러 수동으로 scala sdk를 선택한다.



### 추가 2017.11

그래도 안되면...버그다.



build.properties에 보니 sbt.version=1.0.2로 되어 있다.

검색해보니. sbt 버그였나 보다.


https://github.com/sbt/sbt/issues/3560

https://youtrack.jetbrains.com/issue/SCL-12591


sbt를 1.0.3으로 변경하고 build.properties의 sbt.version을 1.0.3으로 수정하니 문제가 발생하지 않는다. (또는 0.13.16으로 변경해야 할듯..)


Posted by '김용환'
,


젠킨스에서 반복적인 job은 job dsl 플러그인을 쓰면 편하다~

multi-job 대신 쓸만할 수도. 


https://wiki.jenkins.io/display/JENKINS/Job+DSL+Plugin



Configuration As Code: The Job DSL Plugin de Daniel Spilker




Posted by '김용환'
,




jenkins pipeline 플러그인은 사용하면 각 단계로 로그를 상세히 볼 수 있다!!!





어디 단계에서 문제가 발생하는지 보니까 완전 좋다!!



한국 분의 설치 내용

https://shortstories.gitbooks.io/studybook/content/jenkins_pipeline_c0bd_c9c8_ae30.html



결과 내용


참조 : https://www.cloudbees.com/blog/top-10-best-practices-jenkins-pipeline-plugin


 



Posted by '김용환'
,



우버(uber)에서 apache flink와 apache calcite 기반으로 SQL 기반의 스트리밍 분석 플랫폼(athenaX)을 내어놓았다.


https://eng.uber.com/athenax/


https://github.com/uber/AthenaX







잼난 부분을 소개하면 다음과 같다.


우버 개발자가 apache flink에 윈도우 관련 내용과 complex 타입을 지원하도록 PR을 보냈다. 기여했다.

https://issues.apache.org/jira/browse/FLINK-6377

https://github.com/apache/flink/pull/3665










기타 : 볼만한 내용


https://data-artisans.com/blog/session-windowing-in-flink



Streaming SQL from Julian Hyde




Introduction to Apache Calcite from Jordan Halterman




apache phoenix에서 apche calcite로 넘어가는 일은 얼마 안남은 듯.. 

Posted by '김용환'
,

java8 stream 사용시 주의할 점을 작성한 좋은 블로그 내용이 있어서 링크를 건다.



https://blog.jooq.org/2014/06/13/java-8-friday-10-subtle-mistakes-when-using-the-streams-api/



이 내용을 이용진 블로거님이 번역한 블로그이다.


http://leeyongjin.tistory.com/entry/Java8-%EC%9E%90%EB%B0%948-Stream-API-%EC%A3%BC%EC%9D%98%EC%82%AC%ED%95%AD


Posted by '김용환'
,


VM 생성 때 못한 작업에 대한 후처리

1) youtube cloud init example


2) documentation

Automating Openstack with cloud init run a script on VM's first boot


https://raymii.org/s/tutorials/Automating_Openstack_with_Cloud_init_run_a_script_on_VMs_first_boot.html




3) example


https://arnesund.com/2015/02/05/how-to-use-cloud-init-to-customize-new-openstack-vms/

Posted by '김용환'
,



https://platform9.com/blog/kubernetes-vs-mesos-marathon/





Kubernetes offers significant advantages over Mesos + Marathon for three reasons:

  • Much wider adoption by the DevOps and containers community
  • Better scheduling options for pods, useful for complex application stacks
  • Based on over a decade of experience at Google

However, Kubernetes has been known to be difficult to deploy and manage. Platform9’s Managed Kubernetes product can fill this gap by letting organizations focus on deploying microservices on Kubernetes, instead of managing and upgrading a highly available Kubernetes deployment themselves. Further details on these and other deployment models for Kubernetes can be found in The Ultimate Guide to Deploy Kubernetes.

Posted by '김용환'
,