Skip to content

Commit

Permalink
Improve processing of int props
Browse files Browse the repository at this point in the history
  • Loading branch information
phet committed Oct 31, 2023
1 parent c6338a7 commit 7961e0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@

package org.apache.gobblin.temporal.loadgen.launcher;

import io.temporal.client.WorkflowOptions;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import lombok.extern.slf4j.Slf4j;
import io.temporal.client.WorkflowOptions;
import org.apache.hadoop.fs.Path;

import org.apache.gobblin.annotation.Alpha;
import org.apache.gobblin.metrics.Tag;
import org.apache.gobblin.runtime.JobLauncher;
Expand All @@ -35,7 +37,7 @@
import org.apache.gobblin.temporal.util.nesting.work.WorkflowAddr;
import org.apache.gobblin.temporal.util.nesting.work.Workload;
import org.apache.gobblin.temporal.util.nesting.workflow.NestingExecWorkflow;
import org.apache.hadoop.fs.Path;
import org.apache.gobblin.util.PropertiesUtils;

import static org.apache.gobblin.temporal.GobblinTemporalConfigurationKeys.GOBBLIN_TEMPORAL_JOB_LAUNCHER_ARG_PREFIX;

Expand Down Expand Up @@ -67,9 +69,9 @@ public GenArbitraryLoadJobLauncher(

@Override
public void submitJob(List<WorkUnit> workunits) {
int numActivities = Integer.parseInt(this.jobProps.getProperty(GOBBLIN_TEMPORAL_JOB_LAUNCHER_ARG_NUM_ACTIVITIES, "<<not-set>>"));
int maxBranchesPerTree = Integer.parseInt(this.jobProps.getProperty(GOBBLIN_TEMPORAL_JOB_LAUNCHER_ARG_MAX_BRANCHES_PER_TREE, "<<not-set>>"));
int maxSubTreesPerTree = Integer.parseInt(this.jobProps.getProperty(GOBBLIN_TEMPORAL_JOB_LAUNCHER_ARG_MAX_SUB_TREES_PER_TREE, "<<not-set>>"));
int numActivities = PropertiesUtils.getRequiredPropAsInt(this.jobProps, GOBBLIN_TEMPORAL_JOB_LAUNCHER_ARG_NUM_ACTIVITIES);
int maxBranchesPerTree = PropertiesUtils.getRequiredPropAsInt(this.jobProps, GOBBLIN_TEMPORAL_JOB_LAUNCHER_ARG_MAX_BRANCHES_PER_TREE);
int maxSubTreesPerTree = PropertiesUtils.getRequiredPropAsInt(this.jobProps, GOBBLIN_TEMPORAL_JOB_LAUNCHER_ARG_MAX_SUB_TREES_PER_TREE);

Workload<IllustrationItem> workload = SimpleGeneratedWorkload.createAs(numActivities);
WorkflowOptions options = WorkflowOptions.newBuilder().setTaskQueue(this.queueName).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ public static int getPropAsInt(Properties properties, String key, int defaultVal
return Integer.parseInt(properties.getProperty(key, Integer.toString(defaultValue)));
}

/** @throws {@link NullPointerException} when `key` not in `properties` */
public static int getRequiredPropAsInt(Properties properties, String key) {
String value = properties.getProperty(key);
Preconditions.checkNotNull(value, "'" + key + "' must be set (to an integer)");
return Integer.parseInt(value);
}

public static long getPropAsLong(Properties properties, String key, long defaultValue) {
return Long.parseLong(properties.getProperty(key, Long.toString(defaultValue)));
}
Expand Down

0 comments on commit 7961e0c

Please sign in to comment.