mapreduce 프로그래밍을 하면 counter가 필요한 곳은 대부분 reducer 이다

counter 는 job 안에 존재하며,

reducer의 context 가 가진 counter 를 조회한다면 그 값은 mapper 들에서 취합된 값이 아니므로 항상 0 이 나온다

 

따라서, reducer 를 동작중인 job 을 획득하여 counter 를 조회하여야 한다.

보통 reduce 메소드가 돌기전에 획득해 놓고 사용하기 때문에 setup 에서 구현한다.

 

 long totalVal = 0;


 @Override

 public void setup(Context context) throws IOException, InterruptedException{

   Configuration conf = context.getConfiguration();

   Cluster cluster = new Cluster(conf);

  Job currentJob = cluster.getJob(context.getJobID());

  totalCount = currentJob.getCounters().findCounter(MATCH_COUNTER.TOTAL_COUNT).getValue();  }

 

jquery 의 when 은 deferreds 에 대한 처리 이후 실행될 함수를 정의하여 사용한다.
deferreds 란 ?
처리가 바로 완료되지 않는 작업들로 생각하면 된다. 대표적인 ajax 가 이에 포함된다.

기본 사용법
ex>

$.when($.ajax("/when.jsp")).done(function(){

console.log("완료 후 실행");
})


ajax 가 처리된 이후 done 에서 구현거나 참조된 function 이 실행됨

두개의 작업이 모두 처리된 후 수행되기를 원할 경우에는
ex>
$.when( $.ajax("/one.jsp")$.ajax("/two.jsp")).done(function(){
console.log("one, two 처리 후 실행");
});
 
 
해당 deferreds  가 실패시에 처리가 필요할 경우에는
$.when($.ajax("when.jsp")).then(successCallbackFn, errorCallbackFn);
var successCallbackFn = function(){
console.log("성공 처리 후 실행");
};
var errorCallbackFn= function(){
console.log("성공 처리 후 실행");
};
이와 같이 사용할 수 있다


'IT > jquery' 카테고리의 다른 글

[제이쿼리(jQuery)] lesson 5  (0) 2014.11.24
[제이쿼리(jQuery)] lesson 4  (0) 2014.11.24
[제이쿼리(jQuery)] lesson 3  (0) 2014.11.24
[제이쿼리(jQuery)] lesson 2  (0) 2014.11.24
[제이쿼리(jQuery)] lesson 1  (0) 2014.11.24

+ Recent posts