[ https://issues.apache.org/jira/browse/HIVE-21732?focusedWorklogId=245335&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-245335 ]
ASF GitHub Bot logged work on HIVE-21732: ----------------------------------------- Author: ASF GitHub Bot Created on: 20/May/19 17:01 Start Date: 20/May/19 17:01 Worklog Time Spent: 10m Work Description: odraese commented on pull request #634: HIVE-21732: Configurable injection of latency for LLAP task execution URL: https://github.com/apache/hive/pull/634#discussion_r285685088 ########## File path: llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapLoadGeneratorService.java ########## @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hive.llap.daemon.impl; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.service.AbstractService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +/** + * Extra load generator service for LLAP. + */ +public class LlapLoadGeneratorService extends AbstractService { + private static final Logger LOG = LoggerFactory.getLogger(LlapLoadGeneratorService.class); + private long interval; + private float threshold; + private String[] victimsHostName; + private Thread[] threads; + + public LlapLoadGeneratorService() { + super("LlapLoadGeneratorService"); + } + + @Override + protected void serviceInit(Configuration conf) throws Exception { + super.serviceInit(conf); + threshold = HiveConf.getFloatVar(conf, HiveConf.ConfVars.HIVE_TEST_LOAD_UTILIZATION); + victimsHostName = HiveConf.getTrimmedStringsVar(conf, HiveConf.ConfVars.HIVE_TEST_LOAD_HOSTNAMES); + interval = HiveConf.getTimeVar(conf, HiveConf.ConfVars.HIVE_TEST_LOAD_INTERVAL, TimeUnit.MILLISECONDS); + LOG.info("LlapLoadGeneratorService init with {} {} {}", interval, threshold, victimsHostName); + } + + @Override + protected void serviceStart() throws UnknownHostException { + String localHostName = InetAddress.getLocalHost().getHostName(); + LOG.debug("Local hostname is: {}", localHostName); + for (String hostName : victimsHostName) { + if (hostName.equalsIgnoreCase(localHostName)) { + LOG.debug("Starting load generator process on: {}", localHostName); + threads = new Thread[Runtime.getRuntime().availableProcessors()]; + Random random = new Random(); + for (int i = 0; i < threads.length; i++) { + threads[i] = new Thread(new Runnable() { + @Override + public void run() { + while (!Thread.interrupted()) { + if (random.nextFloat() <= threshold) { + // Keep it busy + long startTime = System.currentTimeMillis(); + while (System.currentTimeMillis() - startTime < interval) { Review comment: Pretty much all time here is going to be spent in the kernel call (do_gettimeofday). Should we try to actually spend some time within the Java loop ourself? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 245335) Time Spent: 4h 20m (was: 4h 10m) > Configurable injection of load for LLAP task execution > ------------------------------------------------------ > > Key: HIVE-21732 > URL: https://issues.apache.org/jira/browse/HIVE-21732 > Project: Hive > Issue Type: Test > Reporter: Peter Vary > Assignee: Peter Vary > Priority: Major > Labels: pull-request-available > Attachments: HIVE-21732.2.patch, HIVE-21732.3.patch, > HIVE-21732.4.patch, HIVE-21732.5.patch, HIVE-21732.6.patch, HIVE-21732.patch > > Time Spent: 4h 20m > Remaining Estimate: 0h > > For evaluating testing, it would be good to have a configurable way to inject > latency for LLAP tasks. > The configuration should be able to control how much latency is injected into > each daemon. -- This message was sent by Atlassian JIRA (v7.6.3#76005)