diff --git a/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/GetOpenTxnsRequest.java b/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/GetOpenTxnsRequest.java index 2bb1710b4f..bc70dcf871 100644 --- a/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/GetOpenTxnsRequest.java +++ b/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/GetOpenTxnsRequest.java @@ -46,7 +46,7 @@ schemes.put(TupleScheme.class, new GetOpenTxnsRequestTupleSchemeFactory()); } - private List excludeTxnTypes; // required + private List excludeTxnTypes; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @@ -107,10 +107,11 @@ public String getFieldName() { } // isset id assignments + private static final _Fields optionals[] = {_Fields.EXCLUDE_TXN_TYPES}; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.EXCLUDE_TXN_TYPES, new org.apache.thrift.meta_data.FieldMetaData("excludeTxnTypes", org.apache.thrift.TFieldRequirementType.REQUIRED, + tmpMap.put(_Fields.EXCLUDE_TXN_TYPES, new org.apache.thrift.meta_data.FieldMetaData("excludeTxnTypes", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TxnType.class)))); metaDataMap = Collections.unmodifiableMap(tmpMap); @@ -120,13 +121,6 @@ public String getFieldName() { public GetOpenTxnsRequest() { } - public GetOpenTxnsRequest( - List excludeTxnTypes) - { - this(); - this.excludeTxnTypes = excludeTxnTypes; - } - /** * Performs a deep copy on other. */ @@ -297,23 +291,21 @@ public String toString() { StringBuilder sb = new StringBuilder("GetOpenTxnsRequest("); boolean first = true; - sb.append("excludeTxnTypes:"); - if (this.excludeTxnTypes == null) { - sb.append("null"); - } else { - sb.append(this.excludeTxnTypes); + if (isSetExcludeTxnTypes()) { + sb.append("excludeTxnTypes:"); + if (this.excludeTxnTypes == null) { + sb.append("null"); + } else { + sb.append(this.excludeTxnTypes); + } + first = false; } - first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields - if (!isSetExcludeTxnTypes()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'excludeTxnTypes' is unset! Struct:" + toString()); - } - // check for sub-struct validity } @@ -383,16 +375,18 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, GetOpenTxnsRequest oprot.writeStructBegin(STRUCT_DESC); if (struct.excludeTxnTypes != null) { - oprot.writeFieldBegin(EXCLUDE_TXN_TYPES_FIELD_DESC); - { - oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.excludeTxnTypes.size())); - for (TxnType _iter1291 : struct.excludeTxnTypes) + if (struct.isSetExcludeTxnTypes()) { + oprot.writeFieldBegin(EXCLUDE_TXN_TYPES_FIELD_DESC); { - oprot.writeI32(_iter1291.getValue()); + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.excludeTxnTypes.size())); + for (TxnType _iter1291 : struct.excludeTxnTypes) + { + oprot.writeI32(_iter1291.getValue()); + } + oprot.writeListEnd(); } - oprot.writeListEnd(); + oprot.writeFieldEnd(); } - oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); @@ -411,11 +405,18 @@ public GetOpenTxnsRequestTupleScheme getScheme() { @Override public void write(org.apache.thrift.protocol.TProtocol prot, GetOpenTxnsRequest struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; - { - oprot.writeI32(struct.excludeTxnTypes.size()); - for (TxnType _iter1292 : struct.excludeTxnTypes) + BitSet optionals = new BitSet(); + if (struct.isSetExcludeTxnTypes()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetExcludeTxnTypes()) { { - oprot.writeI32(_iter1292.getValue()); + oprot.writeI32(struct.excludeTxnTypes.size()); + for (TxnType _iter1292 : struct.excludeTxnTypes) + { + oprot.writeI32(_iter1292.getValue()); + } } } } @@ -423,17 +424,20 @@ public void write(org.apache.thrift.protocol.TProtocol prot, GetOpenTxnsRequest @Override public void read(org.apache.thrift.protocol.TProtocol prot, GetOpenTxnsRequest struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - { - org.apache.thrift.protocol.TList _list1293 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.excludeTxnTypes = new ArrayList(_list1293.size); - TxnType _elem1294; - for (int _i1295 = 0; _i1295 < _list1293.size; ++_i1295) + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { { - _elem1294 = org.apache.hadoop.hive.metastore.api.TxnType.findByValue(iprot.readI32()); - struct.excludeTxnTypes.add(_elem1294); + org.apache.thrift.protocol.TList _list1293 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.excludeTxnTypes = new ArrayList(_list1293.size); + TxnType _elem1294; + for (int _i1295 = 0; _i1295 < _list1293.size; ++_i1295) + { + _elem1294 = org.apache.hadoop.hive.metastore.api.TxnType.findByValue(iprot.readI32()); + struct.excludeTxnTypes.add(_elem1294); + } } + struct.setExcludeTxnTypesIsSet(true); } - struct.setExcludeTxnTypesIsSet(true); } } diff --git a/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py b/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py index 8e183fda61..115322c6ce 100644 --- a/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py +++ b/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py @@ -28836,8 +28836,6 @@ def write(self, oprot): oprot.writeStructEnd() def validate(self): - if self.excludeTxnTypes is None: - raise TProtocol.TProtocolException(message='Required field excludeTxnTypes is unset!') return diff --git a/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb b/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb index 307b924d0c..7d85e30084 100644 --- a/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb +++ b/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb @@ -6400,13 +6400,12 @@ class GetOpenTxnsRequest EXCLUDETXNTYPES = 1 FIELDS = { - EXCLUDETXNTYPES => {:type => ::Thrift::Types::LIST, :name => 'excludeTxnTypes', :element => {:type => ::Thrift::Types::I32, :enum_class => ::TxnType}} + EXCLUDETXNTYPES => {:type => ::Thrift::Types::LIST, :name => 'excludeTxnTypes', :element => {:type => ::Thrift::Types::I32, :enum_class => ::TxnType}, :optional => true} } def struct_fields; FIELDS; end def validate - raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field excludeTxnTypes is unset!') unless @excludeTxnTypes end ::Thrift::Struct.generate_accessors self diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index 0e1f891386..a8d37c5aa3 100644 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -3244,22 +3244,30 @@ public boolean removeMasterKey(Integer keySeq) throws TException { @Override public GetOpenTxnsResponse getOpenTxns() throws TException { - return client.get_open_txns(); + GetOpenTxnsRequest getOpenTxnsRequest = new GetOpenTxnsRequest(); + getOpenTxnsRequest.setExcludeTxnTypes(Arrays.asList(TxnType.READ_ONLY)); + return client.get_open_txns_req(getOpenTxnsRequest); } @Override public ValidTxnList getValidTxns() throws TException { - return TxnCommonUtils.createValidReadTxnList(client.get_open_txns(), 0); + GetOpenTxnsRequest getOpenTxnsRequest = new GetOpenTxnsRequest(); + getOpenTxnsRequest.setExcludeTxnTypes(Arrays.asList(TxnType.READ_ONLY)); + return TxnCommonUtils.createValidReadTxnList(client.get_open_txns_req(getOpenTxnsRequest), 0); } @Override public ValidTxnList getValidTxns(long currentTxn) throws TException { - return TxnCommonUtils.createValidReadTxnList(client.get_open_txns(), currentTxn); + GetOpenTxnsRequest getOpenTxnsRequest = new GetOpenTxnsRequest(); + getOpenTxnsRequest.setExcludeTxnTypes(Arrays.asList(TxnType.READ_ONLY)); + return TxnCommonUtils.createValidReadTxnList(client.get_open_txns_req(getOpenTxnsRequest), currentTxn); } @Override public ValidTxnList getValidTxns(long currentTxn, List excludeTxnTypes) throws TException { - return TxnCommonUtils.createValidReadTxnList(client.get_open_txns_req(new GetOpenTxnsRequest(excludeTxnTypes)), + GetOpenTxnsRequest getOpenTxnsRequest = new GetOpenTxnsRequest(); + getOpenTxnsRequest.setExcludeTxnTypes(excludeTxnTypes); + return TxnCommonUtils.createValidReadTxnList(client.get_open_txns_req(getOpenTxnsRequest), currentTxn); } diff --git a/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift b/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift index e814e51198..d4e428ef8e 100644 --- a/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift +++ b/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift @@ -2067,7 +2067,7 @@ struct GetReplicationMetricsRequest { } struct GetOpenTxnsRequest { - 1: required list excludeTxnTypes; + 1: optional list excludeTxnTypes; } // Exceptions. @@ -2651,6 +2651,7 @@ PartitionsResponse get_partitions_req(1:PartitionsRequest req) // Transaction and lock management calls // Get just list of open transactions + //Deprecated use get_open_txns_req GetOpenTxnsResponse get_open_txns() // Get list of open transactions with state (open, aborted) GetOpenTxnsInfoResponse get_open_txns_info() diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/OpenTxnList.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/OpenTxnList.java index 2718f5ca68..4d7244e4f2 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/OpenTxnList.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/OpenTxnList.java @@ -23,7 +23,6 @@ import java.nio.ByteBuffer; import java.util.ArrayList; -import java.util.Arrays; import java.util.BitSet; import java.util.List; @@ -46,9 +45,6 @@ public OpenTxnList(long hwm, List openTxnList) { public GetOpenTxnsInfoResponse toOpenTxnsInfoResponse() { return new GetOpenTxnsInfoResponse(getHwm(), openTxnList.stream().map(OpenTxn::toTxnInfo).collect(toList())); } - public GetOpenTxnsResponse toOpenTxnsResponse() { - return toOpenTxnsResponse(Arrays.asList(TxnType.READ_ONLY)); - } public long getHwm() { return hwm; diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java index 8fd44c4716..0b2a35d40f 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java @@ -400,7 +400,7 @@ public GetOpenTxnsInfoResponse getOpenTxnsInfo() throws MetaException { @Override @RetrySemantics.ReadOnly public GetOpenTxnsResponse getOpenTxns() throws MetaException { - return getOpenTxnsList(false).toOpenTxnsResponse(); + return getOpenTxnsList(false).toOpenTxnsResponse(Arrays.asList(TxnType.READ_ONLY)); } @Override diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java index 16e6533fa5..24c73ea171 100644 --- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java +++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java @@ -2313,22 +2313,30 @@ public boolean removeMasterKey(Integer keySeq) throws TException { @Override public GetOpenTxnsResponse getOpenTxns() throws TException { - return client.get_open_txns(); + GetOpenTxnsRequest getOpenTxnsRequest = new GetOpenTxnsRequest(); + getOpenTxnsRequest.setExcludeTxnTypes(Arrays.asList(TxnType.READ_ONLY)); + return client.get_open_txns_req(getOpenTxnsRequest); } @Override public ValidTxnList getValidTxns() throws TException { - return TxnCommonUtils.createValidReadTxnList(client.get_open_txns(), 0); + GetOpenTxnsRequest getOpenTxnsRequest = new GetOpenTxnsRequest(); + getOpenTxnsRequest.setExcludeTxnTypes(Arrays.asList(TxnType.READ_ONLY)); + return TxnCommonUtils.createValidReadTxnList(client.get_open_txns_req(getOpenTxnsRequest), 0); } @Override public ValidTxnList getValidTxns(long currentTxn) throws TException { - return TxnCommonUtils.createValidReadTxnList(client.get_open_txns(), currentTxn); + GetOpenTxnsRequest getOpenTxnsRequest = new GetOpenTxnsRequest(); + getOpenTxnsRequest.setExcludeTxnTypes(Arrays.asList(TxnType.READ_ONLY)); + return TxnCommonUtils.createValidReadTxnList(client.get_open_txns_req(getOpenTxnsRequest), currentTxn); } @Override public ValidTxnList getValidTxns(long currentTxn, List excludeTxnTypes) throws TException { - return TxnCommonUtils.createValidReadTxnList(client.get_open_txns_req(new GetOpenTxnsRequest(excludeTxnTypes)), + GetOpenTxnsRequest getOpenTxnsRequest = new GetOpenTxnsRequest(); + getOpenTxnsRequest.setExcludeTxnTypes(excludeTxnTypes); + return TxnCommonUtils.createValidReadTxnList(client.get_open_txns_req(getOpenTxnsRequest), currentTxn); } diff --git a/standalone-metastore/metastore-tools/tools-common/src/main/java/org/apache/hadoop/hive/metastore/tools/HMSClient.java b/standalone-metastore/metastore-tools/tools-common/src/main/java/org/apache/hadoop/hive/metastore/tools/HMSClient.java index 8913cb2414..d5fdfbbb32 100644 --- a/standalone-metastore/metastore-tools/tools-common/src/main/java/org/apache/hadoop/hive/metastore/tools/HMSClient.java +++ b/standalone-metastore/metastore-tools/tools-common/src/main/java/org/apache/hadoop/hive/metastore/tools/HMSClient.java @@ -36,6 +36,7 @@ import org.apache.hadoop.hive.metastore.api.Partition; import org.apache.hadoop.hive.metastore.api.RequestPartsSpec; import org.apache.hadoop.hive.metastore.api.Table; +import org.apache.hadoop.hive.metastore.api.GetOpenTxnsRequest; import org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore; import org.apache.hadoop.hive.metastore.api.TxnInfo; import org.apache.hadoop.hive.metastore.api.TxnType; @@ -335,7 +336,9 @@ void appendPartition(@NotNull String dbName, @NotNull String tableName, } List getOpenTxns() throws TException { - GetOpenTxnsResponse txns = client.get_open_txns(); + GetOpenTxnsRequest getOpenTxnsRequest = new GetOpenTxnsRequest(); + getOpenTxnsRequest.setExcludeTxnTypes(Arrays.asList(TxnType.READ_ONLY)); + GetOpenTxnsResponse txns = client.get_open_txns_req(getOpenTxnsRequest); List openTxns = new ArrayList<>(); BitSet abortedBits = BitSet.valueOf(txns.getAbortedBits()); int i = 0;