Search in sources :

Example 1 with SharedRestClientFactory

use of org.apache.gobblin.restli.SharedRestClientFactory in project incubator-gobblin by apache.

the class MRStressTest method main.

public static void main(String[] args) throws Exception {
    CommandLine cli = StressTestUtils.parseCommandLine(OPTIONS, args);
    Configuration configuration = new Configuration();
    if (cli.hasOption(THROTTLING_SERVER_URI.getOpt())) {
        configuration.setBoolean(USE_THROTTLING_SERVER, true);
        String resourceLimited = cli.getOptionValue(RESOURCE_ID_OPT.getOpt(), "MRStressTest");
        configuration.set(RESOURCE_ID, resourceLimited);
        configuration.set(BrokerConfigurationKeyGenerator.generateKey(new SharedRestClientFactory(), new SharedRestClientKey(RestliLimiterFactory.RESTLI_SERVICE_NAME), null, SharedRestClientFactory.SERVER_URI_KEY), cli.getOptionValue(THROTTLING_SERVER_URI.getOpt()));
    }
    if (cli.hasOption(LOCAL_QPS_OPT.getOpt())) {
        configuration.set(LOCALLY_ENFORCED_QPS, cli.getOptionValue(LOCAL_QPS_OPT.getOpt()));
    }
    Job job = Job.getInstance(configuration, "ThrottlingStressTest");
    job.getConfiguration().setBoolean("mapreduce.job.user.classpath.first", true);
    job.getConfiguration().setBoolean("mapreduce.map.speculative", false);
    job.getConfiguration().set(NUM_MAPPERS, cli.getOptionValue(NUM_MAPPERS_OPT.getOpt(), DEFAULT_MAPPERS));
    StressTestUtils.populateConfigFromCli(job.getConfiguration(), cli);
    job.setJarByClass(MRStressTest.class);
    job.setMapperClass(StresserMapper.class);
    job.setReducerClass(AggregatorReducer.class);
    job.setInputFormatClass(MyInputFormat.class);
    job.setOutputKeyClass(LongWritable.class);
    job.setOutputValueClass(DoubleWritable.class);
    FileOutputFormat.setOutputPath(job, new Path("/tmp/MRStressTest" + System.currentTimeMillis()));
    System.exit(job.waitForCompletion(true) ? 0 : 1);
}
Also used : Path(org.apache.hadoop.fs.Path) CommandLine(org.apache.commons.cli.CommandLine) Configuration(org.apache.hadoop.conf.Configuration) SharedRestClientFactory(org.apache.gobblin.restli.SharedRestClientFactory) SharedRestClientKey(org.apache.gobblin.restli.SharedRestClientKey) Job(org.apache.hadoop.mapreduce.Job)

Example 2 with SharedRestClientFactory

use of org.apache.gobblin.restli.SharedRestClientFactory in project incubator-gobblin by apache.

the class RedirectAwareRestClientRequestSender method updateRestClient.

@VisibleForTesting
void updateRestClient(String uri, String reason) throws NotConfiguredException {
    log.info(String.format("Switching to server prefix %s due to: %s", uri, reason));
    this.currentServerPrefix = uri;
    this.restClient = (RestClient) this.broker.getSharedResource(new SharedRestClientFactory(), new UriRestClientKey(RestliLimiterFactory.RESTLI_SERVICE_NAME, uri));
}
Also used : UriRestClientKey(org.apache.gobblin.restli.UriRestClientKey) SharedRestClientFactory(org.apache.gobblin.restli.SharedRestClientFactory) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

SharedRestClientFactory (org.apache.gobblin.restli.SharedRestClientFactory)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 CommandLine (org.apache.commons.cli.CommandLine)1 SharedRestClientKey (org.apache.gobblin.restli.SharedRestClientKey)1 UriRestClientKey (org.apache.gobblin.restli.UriRestClientKey)1 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 Job (org.apache.hadoop.mapreduce.Job)1