리액트 웹앱 제작 총론(learning react)의 14장 예시에 화면 리프레시를 안하는 기능이 있어서 정리한다. 



var destination = document.querySelector("#container");
var TodoItems = React.createClass({
render() {
var todoEntries = this.props.entries;
function createTasks(item) {
return <li key={item.key}>{item.text}</li>
}

console.log("aaa")
var listItems = todoEntries.map(createTasks);
return (
<ul className="theList">
{listItems}
</ul>
);
}
});
var TodoList = React.createClass({
getInitialState: function() {
return {
items: []
};
},
addItem(e) {
var itemArray = this.state.items;
itemArray.push(
{
text: this._inputElement.value,
key: Date.now()
}
);
this.setState({
items: itemArray
});

this._inputElement.value = ""
this._inputElement.focus
e.preventDefault();
},
render() {
return (
<div className="todoListMain">
<div className="header">
<form onSubmit={this.addItem}>
<input ref={(a) => this._inputElement = a}
placeholder="enter task">
</input>
<button type="submit">add</button>
</form>
</div>
<TodoItems entries={this.state.items}/>
</div>
);
}
});

ReactDOM.render(
<div>
<TodoList/>
</div>,
destination
);



html에서 form onSubmit을 호출할 때는 무조건 페이지가 로딩된다.


그러나, addItem() 아래 부분에 아래를 추가하면.. 클릭 이벤트를 실행하지만 웹 브라우져는 이동하지 말라는 뜻이다. 


e.preventDefault();



java script에서 이벤트 전파를 중단하는 4가지 방법을 설명한 내용은 다음 블로그에 있다.



http://programmingsummaries.tistory.com/313


- event.preventDefault()

- event.stopPropagation()

- eventstopImmediatePropagation()

- return false


Posted by '김용환'
,


자바스크립트 지식이 전무해서 리액 웹앱 제작 총론(learning react)를 공부하고 있다.


책의 내용이 조금 다르지만 원래는 블로그였다. 중간까지는 거의 같은데, 뒷부분부터는 조금씩 달라진다. 


https://www.kirupa.com/react/




12장 내용은 저자 블로그에 아예 없는데,  중국 블로거 싸이트에 소스가 있으니 참조할 수 있다. 


http://www.zcfy.cc/article/1558





실제 책 소스는 아래를 참조한다. 


https://github.com/kirupa/kirupa/tree/master/reactjs






Posted by '김용환'
,

NIFI 팁

Cloud 2017. 12. 8. 10:59


NIFI 공부에 도움되는 문서


https://nifi.apache.org/docs/nifi-docs/html/user-guide.html


https://www.slideshare.net/KojiKawamura/apache-nifi-10-in-nutshell


https://nifi.apache.org/docs/nifi-docs/html/user-guide.html#Reporting_Tasks





* nifi 1.4 (최신) 설치


https://nifi.apache.org/download.html



* 설정

미리 zk 설정되야 한다. 



<nifi.properties 수정>



nifi.web.http.host=장비 이름


nifi.cluster.is.node=true

nifi.cluster.node.address=장비 이름



nifi.zookeeper.connect.string=zk서버들

nifi.zookeeper.connect.timeout=3 secs

nifi.zookeeper.session.timeout=3 secs

nifi.zookeeper.root.node=/samuel-nifi




<bootstrap.conf 수정>


# JVM memory settings

java.arg.2=-Xms16g

java.arg.3=-Xmx16g





* 시작


5대를 클러스터링할 수 있도록 설정을 수정하니 약 3분 정도 소요된다. (완전 좋은 장비를 이용했다)

클러스터링 시작 시간은 3분(디폴트)이며 수정가능하다. 수정한 내용은 뒤에서 설명..




$ bin/nifi.sh start


Java home: /usr/java/default

NiFi home: /home/deploy/nifi-1.4.0


Bootstrap Config File: /home/deploy/nifi-1.4.0/conf/bootstrap.conf




* 확인하기 


$ bin/nifi.sh  status


Java home: /usr/java/default

NiFi home: /home/deploy/nifi-1.4.0


Bootstrap Config File: /home/deploy/nifi-1.4.0/conf/bootstrap.conf


2017-12-07 15:30:32,753 INFO [main] org.apache.nifi.bootstrap.Command Apache NiFi is currently running, listening to Bootstrap on port 57300, PID=60012


로그(logs)를 보면서 정상적으로 동작하는 지 확인할 수 있다. 




* 중지/재시작 후 


$ bin/nifi.sh stop

$ bin/nifi.sh start





* 설정 수정 


1. master election 시간은 5 mins이라서 수정하는 것이 좋다.


nifi.cluster.flow.election.max.wait.time=1 mins



2. nifi 웹에서의 디폴트 타임아웃이 응근히 짧다. 5초인데.. single web application으로 구현된 UI라 좀 걸릴 수 있어서 느리게 해도 된다.


nifi.cluster.node.connection.timeout=30 sec

nifi.cluster.node.read.timeout=30 sec




3. 그룹 Thread 디폴트 값은 1이라서 그룹 Thread 크기를 늘리는 것이 좋다. 


Maximum Timer Driven Thread Count 

Maximum Event Driven Thread Count 





4. 커보로스 파일 설정은 다음과 같다. 


nifi.kerberos.krb5.file=/etc/krb5.conf



5. 재시작시 자동 플레이(autoresume)이 안되게 한다.

빅 데이터 처리로 이미 클러스터링이 깨진 상태에서 


nifi.flowcontroller.autoResumeState=false



 


* 주의 할 점


1. 

하둡 관련된 부분을 수정하면 nifi 전체 재시작을 해야 한다. 바로 동작되지 않는다. 




2.

클러스터링이 끊어진 상태에서 특정 서버에서만 설정을 바꾼 경우.. 다

서버 상태는 Status라고 나오지만,, 다음과 같은 에러가 발생할 수 있다. 



2017-12-07 19:22:40,170 ERROR [main] o.a.nifi.controller.StandardFlowService Failed to load flow from cluster due to: org.apache.nifi.controller.UninheritableFlowException: Failed to connect node to cluster because local flow is different than cluster flow.

org.apache.nifi.controller.UninheritableFlowException: Failed to connect node to cluster because local flow is different than cluster flow.

at org.apache.nifi.controller.StandardFlowService.loadFromConnectionResponse(StandardFlowService.java:937)



문제된 서버에 클러스터링된 conf/flow.xml.gz을 삭제하고 다른 서버의 conf/flow.xml.gz을 복사한 후, 재시작하면 잘 연결된다. 


nifi.properties에 설정 파일을 가르킬 수 있다. 

nifi.flow.configuration.file=./conf/flow.xml.gz



3. 


스토리지가 죽으면 nifi는 열리지 않는다.. bottleneck은 스토리지이다. 최대 개수의 효과를 누리고 싶지만 잘못하고 connection 수가 너무 많아 storage 죽을 수 있다는 점을 명심할 필요가 있다. 



4.  

nifi web이 동작하지 못할 정도로 문제가 되어 강제 재시작하면 다음 에러가 발생할 수 있다. 


2017-12-07 20:43:38,006 ERROR [NiFi logging handler] org.apache.nifi.StdErr

2017-12-07 20:43:38,007 ERROR [NiFi logging handler] org.apache.nifi.StdErr Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "logback-1"

2017-12-07 20:44:32,213 ERROR [NiFi logging handler] org.apache.nifi.StdErr

2017-12-07 20:44:32,213 ERROR [NiFi logging handler] org.apache.nifi.StdErr Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "cluster1-timeouter-0"

2017-12-07 20:44:56,169 ERROR [NiFi logging handler] org.apache.nifi.StdErr

2017-12-07 20:44:56,169 ERROR [NiFi logging handler] org.apache.nifi.StdErr Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Listen to Bootstrap"

2017-12-07 20:45:08,175 ERROR [NiFi logging handler] org.apache.nifi.StdErr

2017-12-07 20:45:08,175 ERROR [NiFi logging handler] org.apache.nifi.StdErr Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Provenance Maintenance Thread-2"

2017-12-07 20:46:08,291 ERROR [NiFi logging handler] org.apache.nifi.StdErr

2017-12-07 20:46:08,292 ERROR [NiFi logging handler] org.apache.nifi.StdErr Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "StandardProcessScheduler Thread-7"

2017-12-07 20:46:14,292 ERROR [NiFi logging handler] org.apache.nifi.StdErr

2017-12-07 20:46:14,293 ERROR [NiFi logging handler] org.apache.nifi.StdErr Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Provenance Maintenance Thread-3"

2017-12-07 20:47:14,481 ERROR [NiFi logging handler] org.apache.nifi.StdErr

2017-12-07 20:47:14,482 ERROR [NiFi logging handler] org.apache.nifi.StdErr Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Timer-Driven Process Thread-37"




그래도 안되면 재시작하고.. 다시 재시작하면 된다.

그러면서 NIFI는 split brain (split network)이 생기기도 하니.. 

최대한 NIFI를 죽지 않게 잘 운영하는 것이 중요한 부분이 되지 않을까 생각되었다. cpu 부하가 50%를 넘게 하지 않는 운영의 묘가 필요한 것 같다. 




5. 모니터링 정보는 다음과 같다. 


https://nifi.apache.org/docs/nifi-docs/rest-api/

 

https://community.hortonworks.com/questions/69004/nifi-monitoring-processor-and-nifi-service.html


'Cloud' 카테고리의 다른 글

[fluentd] filter/record에 예약어 존재  (0) 2017.12.18
NIFI의 provenance 의 drop event  (0) 2017.12.12
[nifi] tail -> cassandra 저장 예제  (0) 2017.12.01
Bad neighbors/Noisy neighbors  (0) 2017.11.15
ha_proxy 인증서 pem 파일  (0) 2017.11.10
Posted by '김용환'
,