diff options
author | Simon Rettberg | 2015-07-17 13:35:32 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-07-17 13:35:32 +0200 |
commit | 649b88385fcc630ee526fa671f61c63fd91bbd09 (patch) | |
tree | aca1f9adb63b65b9f935c5e811843ed8e29adeb2 /src | |
parent | Added missing exceptions in declarations (diff) | |
download | master-sync-shared-649b88385fcc630ee526fa671f61c63fd91bbd09.tar.gz master-sync-shared-649b88385fcc630ee526fa671f61c63fd91bbd09.tar.xz master-sync-shared-649b88385fcc630ee526fa671f61c63fd91bbd09.zip |
Add TransferState to thrift api
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/openslx/bwlp/thrift/iface/TransferState.java | 51 | ||||
-rw-r--r-- | src/main/java/org/openslx/bwlp/thrift/iface/TransferStatus.java | 124 | ||||
-rw-r--r-- | src/main/thrift/bwlp.thrift | 8 |
3 files changed, 179 insertions, 4 deletions
diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/TransferState.java b/src/main/java/org/openslx/bwlp/thrift/iface/TransferState.java new file mode 100644 index 0000000..b0c7bd0 --- /dev/null +++ b/src/main/java/org/openslx/bwlp/thrift/iface/TransferState.java @@ -0,0 +1,51 @@ +/** + * Autogenerated by Thrift Compiler (0.9.1) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.openslx.bwlp.thrift.iface; + + +import java.util.Map; +import java.util.HashMap; +import org.apache.thrift.TEnum; + +public enum TransferState implements org.apache.thrift.TEnum { + IDLE(0), + WORKING(1), + FINISHED(2), + ERROR(3); + + private final int value; + + private TransferState(int value) { + this.value = value; + } + + /** + * Get the integer value of this enum value, as defined in the Thrift IDL. + */ + public int getValue() { + return value; + } + + /** + * Find a the enum type by its integer value, as defined in the Thrift IDL. + * @return null if the value is not found. + */ + public static TransferState findByValue(int value) { + switch (value) { + case 0: + return IDLE; + case 1: + return WORKING; + case 2: + return FINISHED; + case 3: + return ERROR; + default: + return null; + } + } +} diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/TransferStatus.java b/src/main/java/org/openslx/bwlp/thrift/iface/TransferStatus.java index ee881ae..7d695dc 100644 --- a/src/main/java/org/openslx/bwlp/thrift/iface/TransferStatus.java +++ b/src/main/java/org/openslx/bwlp/thrift/iface/TransferStatus.java @@ -36,6 +36,7 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TransferStatus"); private static final org.apache.thrift.protocol.TField BLOCK_STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("blockStatus", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField STATE_FIELD_DESC = new org.apache.thrift.protocol.TField("state", org.apache.thrift.protocol.TType.I32, (short)2); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -44,10 +45,20 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T } public ByteBuffer blockStatus; // required + /** + * + * @see TransferState + */ + public TransferState state; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { - BLOCK_STATUS((short)1, "blockStatus"); + BLOCK_STATUS((short)1, "blockStatus"), + /** + * + * @see TransferState + */ + STATE((short)2, "state"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -64,6 +75,8 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T switch(fieldId) { case 1: // BLOCK_STATUS return BLOCK_STATUS; + case 2: // STATE + return STATE; default: return null; } @@ -109,6 +122,8 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.BLOCK_STATUS, new org.apache.thrift.meta_data.FieldMetaData("blockStatus", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); + tmpMap.put(_Fields.STATE, new org.apache.thrift.meta_data.FieldMetaData("state", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TransferState.class))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TransferStatus.class, metaDataMap); } @@ -117,10 +132,12 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T } public TransferStatus( - ByteBuffer blockStatus) + ByteBuffer blockStatus, + TransferState state) { this(); this.blockStatus = blockStatus; + this.state = state; } /** @@ -131,6 +148,9 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T this.blockStatus = org.apache.thrift.TBaseHelper.copyBinary(other.blockStatus); ; } + if (other.isSetState()) { + this.state = other.state; + } } public TransferStatus deepCopy() { @@ -140,6 +160,7 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T @Override public void clear() { this.blockStatus = null; + this.state = null; } public byte[] getBlockStatus() { @@ -176,6 +197,38 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T } } + /** + * + * @see TransferState + */ + public TransferState getState() { + return this.state; + } + + /** + * + * @see TransferState + */ + public TransferStatus setState(TransferState state) { + this.state = state; + return this; + } + + public void unsetState() { + this.state = null; + } + + /** Returns true if field state is set (has been assigned a value) and false otherwise */ + public boolean isSetState() { + return this.state != null; + } + + public void setStateIsSet(boolean value) { + if (!value) { + this.state = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case BLOCK_STATUS: @@ -186,6 +239,14 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T } break; + case STATE: + if (value == null) { + unsetState(); + } else { + setState((TransferState)value); + } + break; + } } @@ -194,6 +255,9 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T case BLOCK_STATUS: return getBlockStatus(); + case STATE: + return getState(); + } throw new IllegalStateException(); } @@ -207,6 +271,8 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T switch (field) { case BLOCK_STATUS: return isSetBlockStatus(); + case STATE: + return isSetState(); } throw new IllegalStateException(); } @@ -233,6 +299,15 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T return false; } + boolean this_present_state = true && this.isSetState(); + boolean that_present_state = true && that.isSetState(); + if (this_present_state || that_present_state) { + if (!(this_present_state && that_present_state)) + return false; + if (!this.state.equals(that.state)) + return false; + } + return true; } @@ -259,6 +334,16 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T return lastComparison; } } + lastComparison = Boolean.valueOf(isSetState()).compareTo(other.isSetState()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetState()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.state, other.state); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -286,6 +371,14 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T org.apache.thrift.TBaseHelper.toString(this.blockStatus, sb); } first = false; + if (!first) sb.append(", "); + sb.append("state:"); + if (this.state == null) { + sb.append("null"); + } else { + sb.append(this.state); + } + first = false; sb.append(")"); return sb.toString(); } @@ -337,6 +430,14 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 2: // STATE + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.state = TransferState.findByValue(iprot.readI32()); + struct.setStateIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -357,6 +458,11 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T oprot.writeBinary(struct.blockStatus); oprot.writeFieldEnd(); } + if (struct.state != null) { + oprot.writeFieldBegin(STATE_FIELD_DESC); + oprot.writeI32(struct.state.getValue()); + oprot.writeFieldEnd(); + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -378,20 +484,30 @@ public class TransferStatus implements org.apache.thrift.TBase<TransferStatus, T if (struct.isSetBlockStatus()) { optionals.set(0); } - oprot.writeBitSet(optionals, 1); + if (struct.isSetState()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); if (struct.isSetBlockStatus()) { oprot.writeBinary(struct.blockStatus); } + if (struct.isSetState()) { + oprot.writeI32(struct.state.getValue()); + } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, TransferStatus struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(1); + BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.blockStatus = iprot.readBinary(); struct.setBlockStatusIsSet(true); } + if (incoming.get(1)) { + struct.state = TransferState.findByValue(iprot.readI32()); + struct.setStateIsSet(true); + } } } diff --git a/src/main/thrift/bwlp.thrift b/src/main/thrift/bwlp.thrift index 076da49..34b6461 100644 --- a/src/main/thrift/bwlp.thrift +++ b/src/main/thrift/bwlp.thrift @@ -54,6 +54,13 @@ enum Role { TUTOR } +enum TransferState { + IDLE, + WORKING, + FINISHED, + ERROR +} + // ############## STRUCT ############### struct UserInfo { @@ -283,6 +290,7 @@ struct TransferInformation { // 0 = complete, 1 = missing, 2 = uploading, 3 = queued for copying, 4 = copying struct TransferStatus { 1: binary blockStatus, + 2: TransferState state, } // ############ EXCEPTION ###################### |