@Override public Properties getProperties() { Properties props = new Properties(); props.putAll(this.jobState.getProperties()); props.putAll(this.workUnit.getProperties()); props.putAll(super.getProperties()); return props; }
/** * Compose meta data when limiter fails to acquire permit * The meta data key list is passed from source layer * A prefix matching is used because some work unit {@link gobblin.source.workunit.MultiWorkUnit} have packing strategy, which * can append additional string after the key name * * @return String map representing all the meta data need to report. Return null if no meta data was found. */ private ImmutableMap<String, String> getLimiterStopMetadata() { WorkUnit workUnit = this.taskState.getWorkunit(); Properties properties = workUnit.getProperties(); String metadataKeyList = properties.getProperty(LimiterConfigurationKeys.LIMITER_REPORT_KEY_LIST, LimiterConfigurationKeys.DEFAULT_LIMITER_REPORT_KEY_LIST); List<String> keyList = Splitter.on(',').omitEmptyStrings().trimResults() .splitToList(metadataKeyList); if (keyList.isEmpty()) return ImmutableMap.of(); Set<String> names = properties.stringPropertyNames(); TreeMap<String, String> orderedProperties = new TreeMap<>(); for (String name : names) { orderedProperties.put(name, properties.getProperty(name)); } ImmutableMap.Builder builder = ImmutableMap.<String, String>builder(); for (String oldKey : keyList) { builder.putAll(orderedProperties.subMap(oldKey, oldKey + Character.MAX_VALUE)); } builder.put(LIMITER_STOP_CAUSE_KEY, LIMITER_STOP_CAUSE_VALUE); return builder.build(); }
private void getTaskStateWithCommonAndSpecWuProps(int numTaskStates, DataInput in) throws IOException { Properties commonWuProps = new Properties(); for (int i = 0; i < numTaskStates; i++) { TaskState taskState = new TaskState(); taskState.readFields(in); if (i == 0) { commonWuProps.putAll(taskState.getWorkunit().getProperties()); } else { Properties newCommonWuProps = new Properties(); newCommonWuProps .putAll(Maps.difference(commonWuProps, taskState.getWorkunit().getProperties()).entriesInCommon()); commonWuProps = newCommonWuProps; } this.taskStates.put(taskState.getTaskId().intern(), taskState); } ImmutableProperties immutableCommonProperties = new ImmutableProperties(commonWuProps); for (TaskState taskState : this.taskStates.values()) { Properties newSpecProps = new Properties(); newSpecProps.putAll( Maps.difference(immutableCommonProperties, taskState.getWorkunit().getProperties()).entriesOnlyOnRight()); taskState.setWuProperties(immutableCommonProperties, newSpecProps); } }