Remove @Parameter from RdeStagingReducer

The "lenient" bit must be the same between RdeStagingMapper and
RdeStagingReducer, but this is hidden by the Reducer receiving the bit in a
completely different way than the mapper.

There are 2 ways to do this:
- add a "setLenient" function to RdeStagingReducer that we MUST call, or else
  get a runtime error. This is the simplest solution
- have a RdeStagingReducerBuilder you can inject, and that requires the
  "lenient" value to actually build the RdeStagingReducer. This prevents bugs
  at compile-time but is "more complicated"

I'm going with the second one here, but feel free to ask for the first one.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=229423590
This commit is contained in:
guyben 2019-01-15 12:56:17 -08:00 committed by jianglai
parent 035b9149e0
commit 3e0eaecc9b
3 changed files with 44 additions and 21 deletions

View file

@ -131,14 +131,13 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
action.clock = clock;
action.mrRunner = makeDefaultRunner();
action.lenient = false;
action.reducer = new RdeStagingReducer(
new TaskQueueUtils(new Retrier(new SystemSleeper(), 1)), // taskQueueUtils
new FakeLockHandler(true),
0, // gcsBufferSize
"rde-bucket", // bucket
Duration.standardHours(1), // lockTimeout
PgpHelper.convertPublicKeyToBytes(encryptKey), // stagingKeyBytes
false); // lenient
action.reducerFactory = new RdeStagingReducer.Factory();
action.reducerFactory.taskQueueUtils = new TaskQueueUtils(new Retrier(new SystemSleeper(), 1));
action.reducerFactory.lockHandler = new FakeLockHandler(true);
action.reducerFactory.gcsBufferSize = 0;
action.reducerFactory.bucket = "rde-bucket";
action.reducerFactory.lockTimeout = Duration.standardHours(1);
action.reducerFactory.stagingKeyBytes = PgpHelper.convertPublicKeyToBytes(encryptKey);
action.pendingDepositChecker = new PendingDepositChecker();
action.pendingDepositChecker.brdaDayOfWeek = DateTimeConstants.TUESDAY;
action.pendingDepositChecker.brdaInterval = Duration.standardDays(7);