-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HIVE-28533: Fix compaction with custom pools (Dmitriy Fingerman, revi…
…ewed by Denys Kuzmenko) Closes #5466
- Loading branch information
Showing
11 changed files
with
336 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactionException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* 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.classification.InterfaceAudience; | ||
import org.apache.hadoop.hive.common.classification.InterfaceStability; | ||
import org.apache.hadoop.hive.ql.ErrorMsg; | ||
|
||
@InterfaceAudience.Public | ||
@InterfaceStability.Stable | ||
public class CompactionException extends RuntimeException { | ||
|
||
/** | ||
* Standard predefined message with error code and possibly SQL State, etc. | ||
*/ | ||
private final ErrorMsg canonicalErrorMsg; | ||
|
||
/** | ||
* Error Messages returned from remote exception (eg. hadoop error) | ||
*/ | ||
private final String remoteErrorMsg; | ||
|
||
public CompactionException() { | ||
this(null, null, ErrorMsg.GENERIC_ERROR); | ||
} | ||
|
||
public CompactionException(String message) { | ||
this(message, null); | ||
} | ||
|
||
public CompactionException(Throwable cause) { | ||
this(cause, null, ErrorMsg.GENERIC_ERROR); | ||
} | ||
|
||
public CompactionException(String message, Throwable cause) { | ||
super(message, cause); | ||
canonicalErrorMsg = ErrorMsg.GENERIC_ERROR; | ||
remoteErrorMsg = null; | ||
} | ||
|
||
public CompactionException(ErrorMsg message, String... msgArgs) { | ||
this(null, null, message, msgArgs); | ||
} | ||
|
||
public CompactionException(Throwable cause, ErrorMsg errorMsg, String... msgArgs) { | ||
this(cause, null, errorMsg, msgArgs); | ||
} | ||
|
||
public CompactionException(Throwable cause, ErrorMsg errorMsg) { | ||
this(cause, null, errorMsg); | ||
} | ||
|
||
public CompactionException(ErrorMsg errorMsg) { | ||
this(null, null, errorMsg); | ||
} | ||
|
||
/** | ||
* This is the recommended constructor to use since it helps use | ||
* canonical messages throughout and propagate remote errors. | ||
* | ||
* @param errorMsg Canonical error message | ||
* @param msgArgs message arguments if message is parametrized; must be {@code null} is message takes no arguments | ||
*/ | ||
public CompactionException(Throwable cause, String remErrMsg, ErrorMsg errorMsg, String... msgArgs) { | ||
super(errorMsg.format(msgArgs), cause); | ||
canonicalErrorMsg = errorMsg; | ||
remoteErrorMsg = remErrMsg; | ||
} | ||
|
||
/** | ||
* @return {@link ErrorMsg#GENERIC_ERROR} by default | ||
*/ | ||
public ErrorMsg getCanonicalErrorMsg() { | ||
return canonicalErrorMsg; | ||
} | ||
|
||
public String getRemoteErrorMsg() { return remoteErrorMsg; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCompactorUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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.conf.HiveConf; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.Map; | ||
|
||
public class TestCompactorUtil { | ||
|
||
@Test | ||
public void testGetPoolConf() { | ||
HiveConf conf = new HiveConf(); | ||
conf.setInt("hive.compactor.worker.iceberg1.threads", 4); | ||
conf.setInt("hive.compactor.worker.iceberg2", 4); | ||
conf.setInt("hive.compactor.worker.iceberg3.thread.zzz", 4); | ||
conf.setInt("aaa.hive.compactor.worker.iceberg4.threads", 4); | ||
|
||
Map<String, Integer> entries = CompactorUtil.getPoolConf(conf); | ||
|
||
Assert.assertEquals(1, entries.size()); | ||
Assert.assertEquals(Integer.valueOf(4), entries.get("iceberg1")); | ||
} | ||
} |
Oops, something went wrong.