asolimando commented on a change in pull request #3027:
URL: https://github.com/apache/hive/pull/3027#discussion_r806613146
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactorUtil.java
##########
@@ -22,16 +22,29 @@
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hadoop.hive.metastore.txn.CompactionInfo;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinWorkerThread;
+import java.util.function.Function;
import static java.lang.String.format;
public class CompactorUtil {
public static final String COMPACTOR = "compactor";
- static final String COMPACTOR_PREFIX = "compactor.";
- static final String MAPRED_QUEUE_NAME = "mapred.job.queue.name";
+ /**
+ * List of accepted properties for defining the compactor's job queue.
+ *
+ * The order is important and defines which property has precedence over the
other if multiple properties are defined
+ * at the same time.
+ */
+ private static final List<String> QUEUE_PROPERTIES = Arrays.asList(
+ "compactor."+HiveConf.ConfVars.COMPACTOR_JOB_QUEUE.varname,
Review comment:
Nitpick: missing spaces around "+"
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactorUtil.java
##########
@@ -22,16 +22,29 @@
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hadoop.hive.metastore.txn.CompactionInfo;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinWorkerThread;
+import java.util.function.Function;
import static java.lang.String.format;
public class CompactorUtil {
public static final String COMPACTOR = "compactor";
- static final String COMPACTOR_PREFIX = "compactor.";
- static final String MAPRED_QUEUE_NAME = "mapred.job.queue.name";
+ /**
+ * List of accepted properties for defining the compactor's job queue.
+ *
+ * The order is important and defines which property has precedence over the
other if multiple properties are defined
+ * at the same time.
+ */
+ private static final List<String> QUEUE_PROPERTIES = Arrays.asList(
Review comment:
Can't we import them from `HiveConf` to be sure we keep in sync if they
change?
##########
File path:
ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCompactorMRJobQueueConfiguration.java
##########
@@ -0,0 +1,262 @@
+/*
+ * 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.ql.txn.compactor;
+
+import org.apache.hadoop.hive.common.StringableMap;
+import org.apache.hadoop.hive.common.ValidReaderWriteIdList;
+import org.apache.hadoop.hive.common.ValidWriteIdList;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.api.CompactionType;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.txn.CompactionInfo;
+import org.apache.hadoop.mapred.JobConf;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.time.LocalDate;
+import java.time.ZoneOffset;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Stream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests for {@link CompactorMR#createBaseJobConf(HiveConf, String, Table,
StorageDescriptor, ValidWriteIdList, CompactionInfo)}.
+ */
+public class TestCompactorMRJobQueueConfiguration {
+
+ @ParameterizedTest
+ @MethodSource("generateBaseJobConfSetup")
+ void testCreateBaseJobConfHasCorrectJobQueue(ConfSetup input) {
+ Table tbl = createPersonTable();
+ tbl.setParameters(input.tableProperties);
+ CompactorMR compactor = new CompactorMR();
+ CompactionInfo ci = new CompactionInfo(tbl.getDbName(),
tbl.getTableName(), null, CompactionType.MAJOR);
+ ci.properties = new StringableMap(input.compactionProperties).toString();
+ HiveConf conf = new HiveConf();
+ input.confProperties.forEach(conf::set);
+ JobConf c = compactor.createBaseJobConf(conf, "test-job", tbl,
tbl.getSd(), new ValidReaderWriteIdList(), ci);
+ assertEquals(input.expectedQueue, c.getQueueName(), "Test failed for the
following input:" + input);
+ }
+
+ private static Stream<ConfSetup> generateBaseJobConfSetup() {
+ List<ConfSetup> inputs = new ArrayList<>();
+ String mrProperty = "mapreduce.job.queuename";
Review comment:
Same comment as before, can't we link this to the string defined in
HiveConf?
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactorUtil.java
##########
@@ -22,16 +22,29 @@
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hadoop.hive.metastore.txn.CompactionInfo;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinWorkerThread;
+import java.util.function.Function;
import static java.lang.String.format;
public class CompactorUtil {
public static final String COMPACTOR = "compactor";
- static final String COMPACTOR_PREFIX = "compactor.";
- static final String MAPRED_QUEUE_NAME = "mapred.job.queue.name";
+ /**
+ * List of accepted properties for defining the compactor's job queue.
+ *
+ * The order is important and defines which property has precedence over the
other if multiple properties are defined
+ * at the same time.
+ */
+ private static final List<String> QUEUE_PROPERTIES = Arrays.asList(
Review comment:
You are right, in this case consistency can backfire, it's preferable to
see test failures in case of a breaking change
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]