Hi.

2015-09-09 12:04 GMT+02:00 xeonmailinglist <xeonmailingl...@gmail.com>:

> [2] My mapreduce aspects
>
>
> package org.apache.hadoop.mapred.aspects;
>
> import org.aspectj.lang.JoinPoint;
> import org.aspectj.lang.annotation.Aspect;
> import org.aspectj.lang.annotation.Before;
>
> @Aspect
> public class MapReduceAspects {
>     @Before("execution(* map(..))")
>     public void mymap(JoinPoint joinPoint) {
>         System.out.println("My Map Execution: " + joinPoint.getArgs() + ":" + 
> joinPoint.getTarget());
>         Object[] obj = joinPoint.getArgs();
>         for (Object o : obj){
>             System.out.println(o.toString());
>         }
>     }
>
>     @Before("execution(* reduce(..))")
>     public void myreduce() { System.out.println("My Reduce Execution"); }
>
>     @Before("execution(* collect(..))")
>     public void updatehash(JoinPoint joinPoint) {
>         System.out.println("Output collect: Args: " + joinPoint.getArgs());
>
>     }
> }
>
>  [...]

> I can intercept the map and reduce function calls with AspectJ, but I
> can’t intercept the collect call in the instruction output.collect(word,
> one) that is in the map function. Why this happens? Didn`t I configure
> the Aspects correctly?
>
No, actually, you're not intercepting the *calls* (at the call site), but
the *executions* (in the implementing class), as noted in your pointcuts.
Which is why you can't intercept collect(): it's not implemented by any of
your classes, and you're not weaving the Hadoop classes themselves.

You can intercept the call, by changing the pointcut from execution(...) to
call(...), though you probably want to qualify the method with the type to
avoid intercepting other calls to methods with the same (generic) name:
  call(* org.apache.hadoop.mapred.OutputCollector+.collect(..))

Regards,
Frank
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to