code: protected static void reportAndClearAccumulators(Environment env, Map<String, Accumulator<?, ?>> accumulators,
  			ArrayList<ChainedDriver<?, ?>> chainedTasks) {
  
  		// We can merge here the accumulators from the stub and the chained
  		// tasks. Type conflicts can occur here if counters with same name but
  		// different type were used.
  
  		for (ChainedDriver<?, ?> chainedTask : chainedTasks) {
  			Map<String, Accumulator<?, ?>> chainedAccumulators = chainedTask.getStub().getRuntimeContext().getAllAccumulators();
  			AccumulatorHelper.mergeInto(accumulators, chainedAccumulators);
  		}
  
  		// Don't report if the UDF didn't collect any accumulators
  		if (accumulators.size() == 0) {
  			return;
  		}
  
  		// Report accumulators to JobManager
  		synchronized (env.getAccumulatorProtocolProxy()) {
  			try {
  				env.getAccumulatorProtocolProxy().reportAccumulatorResult(
  						new AccumulatorEvent(env.getJobID(), accumulators, true));
  			} catch (IOException e) {
  				throw new RuntimeException("Communication with JobManager is broken. Could not send accumulators.", e);
  			}
  		}
  
  		// We also clear the accumulators, since stub instances might be reused
  		// (e.g. in iterations) and we don't want to count twice. This may not be
  		// done before sending
  		AccumulatorHelper.resetAndClearAccumulators(accumulators);
  		for (ChainedDriver<?, ?> chainedTask : chainedTasks) {
  			AccumulatorHelper.resetAndClearAccumulators(chainedTask.getStub().getRuntimeContext().getAllAccumulators());
  		}
  	}
docs: This method is called at the end of a task, receiving the accumulators of
  the task and the chained tasks. It merges them into a single map of
  accumulators and sends them to the JobManager.
  
  @param chainedTasks
  Each chained task might have accumulators which will be merged
  with the accumulators of the stub.