/** * Creates the default {@link Path} for the {@link ConfigurationKeys#WRITER_FILE_PATH} key. * @param numBranches is the total number of branches for the given {@link State}. * @param branchId is the id for the specific branch that the {@link gobblin.writer.DataWriter} will write to. * @return a {@link Path} specifying the directory where the {@link gobblin.writer.DataWriter} will write to. */ public static Path getDefaultWriterFilePath(State state, int numBranches, int branchId) { if (state instanceof WorkUnitState) { WorkUnitState workUnitState = (WorkUnitState) state; return new Path(ForkOperatorUtils.getPathForBranch(workUnitState, workUnitState.getExtract().getOutputFilePath(), numBranches, branchId)); } else if (state instanceof WorkUnit) { WorkUnit workUnit = (WorkUnit) state; return new Path(ForkOperatorUtils.getPathForBranch(workUnit, workUnit.getExtract().getOutputFilePath(), numBranches, branchId)); } throw new RuntimeException("In order to get the default value for " + ConfigurationKeys.WRITER_FILE_PATH + " the given state must be of type " + WorkUnitState.class.getName() + " or " + WorkUnit.class.getName()); }