summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-04-18 18:01:03 +0200
committerSimon Rettberg2016-04-18 18:01:03 +0200
commit2b6cb079a7793536db9945b59749a3a6c9d726a4 (patch)
tree31a23d94c1e9df5af3dc33da0ea6924cc8c6aeab
parentMore additions for central image store (diff)
downloadmaster-sync-shared-2b6cb079a7793536db9945b59749a3a6c9d726a4.tar.gz
master-sync-shared-2b6cb079a7793536db9945b59749a3a6c9d726a4.tar.xz
master-sync-shared-2b6cb079a7793536db9945b59749a3a6c9d726a4.zip
Add queryUploadStatus to master server
-rw-r--r--src/main/java/org/openslx/bwlp/thrift/iface/MasterServer.java981
-rw-r--r--src/main/java/org/openslx/filetransfer/util/ChunkList.java2
-rw-r--r--src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java7
-rw-r--r--src/main/thrift/bwlp.thrift4
4 files changed, 991 insertions, 3 deletions
diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/MasterServer.java b/src/main/java/org/openslx/bwlp/thrift/iface/MasterServer.java
index e7f7b06..d086ddb 100644
--- a/src/main/java/org/openslx/bwlp/thrift/iface/MasterServer.java
+++ b/src/main/java/org/openslx/bwlp/thrift/iface/MasterServer.java
@@ -34,7 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-04-07")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-04-18")
public class MasterServer {
public interface Iface {
@@ -81,6 +81,8 @@ public class MasterServer {
public List<MasterSoftware> getSoftware(long startDate) throws TInvocationException, org.apache.thrift.TException;
+ public TransferStatus queryUploadStatus(String uploadToken) throws TInvalidTokenException, org.apache.thrift.TException;
+
}
public interface AsyncIface {
@@ -127,6 +129,8 @@ public class MasterServer {
public void getSoftware(long startDate, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
+ public void queryUploadStatus(String uploadToken, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
+
}
public static class Client extends org.apache.thrift.TServiceClient implements Iface {
@@ -733,6 +737,32 @@ public class MasterServer {
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getSoftware failed: unknown result");
}
+ public TransferStatus queryUploadStatus(String uploadToken) throws TInvalidTokenException, org.apache.thrift.TException
+ {
+ send_queryUploadStatus(uploadToken);
+ return recv_queryUploadStatus();
+ }
+
+ public void send_queryUploadStatus(String uploadToken) throws org.apache.thrift.TException
+ {
+ queryUploadStatus_args args = new queryUploadStatus_args();
+ args.setUploadToken(uploadToken);
+ sendBase("queryUploadStatus", args);
+ }
+
+ public TransferStatus recv_queryUploadStatus() throws TInvalidTokenException, org.apache.thrift.TException
+ {
+ queryUploadStatus_result result = new queryUploadStatus_result();
+ receiveBase(result, "queryUploadStatus");
+ if (result.isSetSuccess()) {
+ return result.success;
+ }
+ if (result.ex1 != null) {
+ throw result.ex1;
+ }
+ throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "queryUploadStatus failed: unknown result");
+ }
+
}
public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
@@ -1465,6 +1495,38 @@ public class MasterServer {
}
}
+ public void queryUploadStatus(String uploadToken, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
+ checkReady();
+ queryUploadStatus_call method_call = new queryUploadStatus_call(uploadToken, resultHandler, this, ___protocolFactory, ___transport);
+ this.___currentMethod = method_call;
+ ___manager.call(method_call);
+ }
+
+ public static class queryUploadStatus_call extends org.apache.thrift.async.TAsyncMethodCall {
+ private String uploadToken;
+ public queryUploadStatus_call(String uploadToken, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+ super(client, protocolFactory, transport, resultHandler, false);
+ this.uploadToken = uploadToken;
+ }
+
+ public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+ prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("queryUploadStatus", org.apache.thrift.protocol.TMessageType.CALL, 0));
+ queryUploadStatus_args args = new queryUploadStatus_args();
+ args.setUploadToken(uploadToken);
+ args.write(prot);
+ prot.writeMessageEnd();
+ }
+
+ public TransferStatus getResult() throws TInvalidTokenException, org.apache.thrift.TException {
+ if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
+ throw new IllegalStateException("Method call not finished!");
+ }
+ org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
+ org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
+ return (new Client(prot)).recv_queryUploadStatus();
+ }
+ }
+
}
public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
@@ -1499,6 +1561,7 @@ public class MasterServer {
processMap.put("getVirtualizers", new getVirtualizers());
processMap.put("getTags", new getTags());
processMap.put("getSoftware", new getSoftware());
+ processMap.put("queryUploadStatus", new queryUploadStatus());
return processMap;
}
@@ -2024,6 +2087,30 @@ public class MasterServer {
}
}
+ public static class queryUploadStatus<I extends Iface> extends org.apache.thrift.ProcessFunction<I, queryUploadStatus_args> {
+ public queryUploadStatus() {
+ super("queryUploadStatus");
+ }
+
+ public queryUploadStatus_args getEmptyArgsInstance() {
+ return new queryUploadStatus_args();
+ }
+
+ protected boolean isOneway() {
+ return false;
+ }
+
+ public queryUploadStatus_result getResult(I iface, queryUploadStatus_args args) throws org.apache.thrift.TException {
+ queryUploadStatus_result result = new queryUploadStatus_result();
+ try {
+ result.success = iface.queryUploadStatus(args.uploadToken);
+ } catch (TInvalidTokenException ex1) {
+ result.ex1 = ex1;
+ }
+ return result;
+ }
+ }
+
}
public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> {
@@ -2058,6 +2145,7 @@ public class MasterServer {
processMap.put("getVirtualizers", new getVirtualizers());
processMap.put("getTags", new getTags());
processMap.put("getSoftware", new getSoftware());
+ processMap.put("queryUploadStatus", new queryUploadStatus());
return processMap;
}
@@ -3307,6 +3395,63 @@ public class MasterServer {
}
}
+ public static class queryUploadStatus<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, queryUploadStatus_args, TransferStatus> {
+ public queryUploadStatus() {
+ super("queryUploadStatus");
+ }
+
+ public queryUploadStatus_args getEmptyArgsInstance() {
+ return new queryUploadStatus_args();
+ }
+
+ public AsyncMethodCallback<TransferStatus> getResultHandler(final AsyncFrameBuffer fb, final int seqid) {
+ final org.apache.thrift.AsyncProcessFunction fcall = this;
+ return new AsyncMethodCallback<TransferStatus>() {
+ public void onComplete(TransferStatus o) {
+ queryUploadStatus_result result = new queryUploadStatus_result();
+ result.success = o;
+ try {
+ fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+ return;
+ } catch (Exception e) {
+ LOGGER.error("Exception writing to internal frame buffer", e);
+ }
+ fb.close();
+ }
+ public void onError(Exception e) {
+ byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+ org.apache.thrift.TBase msg;
+ queryUploadStatus_result result = new queryUploadStatus_result();
+ if (e instanceof TInvalidTokenException) {
+ result.ex1 = (TInvalidTokenException) e;
+ result.setEx1IsSet(true);
+ msg = result;
+ }
+ else
+ {
+ msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+ msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+ }
+ try {
+ fcall.sendResponse(fb,msg,msgType,seqid);
+ return;
+ } catch (Exception ex) {
+ LOGGER.error("Exception writing to internal frame buffer", ex);
+ }
+ fb.close();
+ }
+ };
+ }
+
+ protected boolean isOneway() {
+ return false;
+ }
+
+ public void start(I iface, queryUploadStatus_args args, org.apache.thrift.async.AsyncMethodCallback<TransferStatus> resultHandler) throws TException {
+ iface.queryUploadStatus(args.uploadToken,resultHandler);
+ }
+ }
+
}
public static class ping_args implements org.apache.thrift.TBase<ping_args, ping_args._Fields>, java.io.Serializable, Cloneable, Comparable<ping_args> {
@@ -23593,4 +23738,838 @@ public class MasterServer {
}
+ public static class queryUploadStatus_args implements org.apache.thrift.TBase<queryUploadStatus_args, queryUploadStatus_args._Fields>, java.io.Serializable, Cloneable, Comparable<queryUploadStatus_args> {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("queryUploadStatus_args");
+
+ private static final org.apache.thrift.protocol.TField UPLOAD_TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("uploadToken", org.apache.thrift.protocol.TType.STRING, (short)1);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new queryUploadStatus_argsStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new queryUploadStatus_argsTupleSchemeFactory());
+ }
+
+ public String uploadToken; // 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 {
+ UPLOAD_TOKEN((short)1, "uploadToken");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // UPLOAD_TOKEN
+ return UPLOAD_TOKEN;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ 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.UPLOAD_TOKEN, new org.apache.thrift.meta_data.FieldMetaData("uploadToken", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , "Token")));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(queryUploadStatus_args.class, metaDataMap);
+ }
+
+ public queryUploadStatus_args() {
+ }
+
+ public queryUploadStatus_args(
+ String uploadToken)
+ {
+ this();
+ this.uploadToken = uploadToken;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public queryUploadStatus_args(queryUploadStatus_args other) {
+ if (other.isSetUploadToken()) {
+ this.uploadToken = other.uploadToken;
+ }
+ }
+
+ public queryUploadStatus_args deepCopy() {
+ return new queryUploadStatus_args(this);
+ }
+
+ @Override
+ public void clear() {
+ this.uploadToken = null;
+ }
+
+ public String getUploadToken() {
+ return this.uploadToken;
+ }
+
+ public queryUploadStatus_args setUploadToken(String uploadToken) {
+ this.uploadToken = uploadToken;
+ return this;
+ }
+
+ public void unsetUploadToken() {
+ this.uploadToken = null;
+ }
+
+ /** Returns true if field uploadToken is set (has been assigned a value) and false otherwise */
+ public boolean isSetUploadToken() {
+ return this.uploadToken != null;
+ }
+
+ public void setUploadTokenIsSet(boolean value) {
+ if (!value) {
+ this.uploadToken = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case UPLOAD_TOKEN:
+ if (value == null) {
+ unsetUploadToken();
+ } else {
+ setUploadToken((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case UPLOAD_TOKEN:
+ return getUploadToken();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case UPLOAD_TOKEN:
+ return isSetUploadToken();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof queryUploadStatus_args)
+ return this.equals((queryUploadStatus_args)that);
+ return false;
+ }
+
+ public boolean equals(queryUploadStatus_args that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_uploadToken = true && this.isSetUploadToken();
+ boolean that_present_uploadToken = true && that.isSetUploadToken();
+ if (this_present_uploadToken || that_present_uploadToken) {
+ if (!(this_present_uploadToken && that_present_uploadToken))
+ return false;
+ if (!this.uploadToken.equals(that.uploadToken))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ List<Object> list = new ArrayList<Object>();
+
+ boolean present_uploadToken = true && (isSetUploadToken());
+ list.add(present_uploadToken);
+ if (present_uploadToken)
+ list.add(uploadToken);
+
+ return list.hashCode();
+ }
+
+ @Override
+ public int compareTo(queryUploadStatus_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+
+ lastComparison = Boolean.valueOf(isSetUploadToken()).compareTo(other.isSetUploadToken());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetUploadToken()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.uploadToken, other.uploadToken);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("queryUploadStatus_args(");
+ boolean first = true;
+
+ sb.append("uploadToken:");
+ if (this.uploadToken == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.uploadToken);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ // check for sub-struct validity
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class queryUploadStatus_argsStandardSchemeFactory implements SchemeFactory {
+ public queryUploadStatus_argsStandardScheme getScheme() {
+ return new queryUploadStatus_argsStandardScheme();
+ }
+ }
+
+ private static class queryUploadStatus_argsStandardScheme extends StandardScheme<queryUploadStatus_args> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, queryUploadStatus_args struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // UPLOAD_TOKEN
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.uploadToken = iprot.readString();
+ struct.setUploadTokenIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, queryUploadStatus_args struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.uploadToken != null) {
+ oprot.writeFieldBegin(UPLOAD_TOKEN_FIELD_DESC);
+ oprot.writeString(struct.uploadToken);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class queryUploadStatus_argsTupleSchemeFactory implements SchemeFactory {
+ public queryUploadStatus_argsTupleScheme getScheme() {
+ return new queryUploadStatus_argsTupleScheme();
+ }
+ }
+
+ private static class queryUploadStatus_argsTupleScheme extends TupleScheme<queryUploadStatus_args> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, queryUploadStatus_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetUploadToken()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetUploadToken()) {
+ oprot.writeString(struct.uploadToken);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, queryUploadStatus_args struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ struct.uploadToken = iprot.readString();
+ struct.setUploadTokenIsSet(true);
+ }
+ }
+ }
+
+ }
+
+ public static class queryUploadStatus_result implements org.apache.thrift.TBase<queryUploadStatus_result, queryUploadStatus_result._Fields>, java.io.Serializable, Cloneable, Comparable<queryUploadStatus_result> {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("queryUploadStatus_result");
+
+ private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+ private static final org.apache.thrift.protocol.TField EX1_FIELD_DESC = new org.apache.thrift.protocol.TField("ex1", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new queryUploadStatus_resultStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new queryUploadStatus_resultTupleSchemeFactory());
+ }
+
+ public TransferStatus success; // required
+ public TInvalidTokenException ex1; // 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 {
+ SUCCESS((short)0, "success"),
+ EX1((short)1, "ex1");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 0: // SUCCESS
+ return SUCCESS;
+ case 1: // EX1
+ return EX1;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ 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.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TransferStatus.class)));
+ tmpMap.put(_Fields.EX1, new org.apache.thrift.meta_data.FieldMetaData("ex1", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(queryUploadStatus_result.class, metaDataMap);
+ }
+
+ public queryUploadStatus_result() {
+ }
+
+ public queryUploadStatus_result(
+ TransferStatus success,
+ TInvalidTokenException ex1)
+ {
+ this();
+ this.success = success;
+ this.ex1 = ex1;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public queryUploadStatus_result(queryUploadStatus_result other) {
+ if (other.isSetSuccess()) {
+ this.success = new TransferStatus(other.success);
+ }
+ if (other.isSetEx1()) {
+ this.ex1 = new TInvalidTokenException(other.ex1);
+ }
+ }
+
+ public queryUploadStatus_result deepCopy() {
+ return new queryUploadStatus_result(this);
+ }
+
+ @Override
+ public void clear() {
+ this.success = null;
+ this.ex1 = null;
+ }
+
+ public TransferStatus getSuccess() {
+ return this.success;
+ }
+
+ public queryUploadStatus_result setSuccess(TransferStatus success) {
+ this.success = success;
+ return this;
+ }
+
+ public void unsetSuccess() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been assigned a value) and false otherwise */
+ public boolean isSetSuccess() {
+ return this.success != null;
+ }
+
+ public void setSuccessIsSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public TInvalidTokenException getEx1() {
+ return this.ex1;
+ }
+
+ public queryUploadStatus_result setEx1(TInvalidTokenException ex1) {
+ this.ex1 = ex1;
+ return this;
+ }
+
+ public void unsetEx1() {
+ this.ex1 = null;
+ }
+
+ /** Returns true if field ex1 is set (has been assigned a value) and false otherwise */
+ public boolean isSetEx1() {
+ return this.ex1 != null;
+ }
+
+ public void setEx1IsSet(boolean value) {
+ if (!value) {
+ this.ex1 = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unsetSuccess();
+ } else {
+ setSuccess((TransferStatus)value);
+ }
+ break;
+
+ case EX1:
+ if (value == null) {
+ unsetEx1();
+ } else {
+ setEx1((TInvalidTokenException)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return getSuccess();
+
+ case EX1:
+ return getEx1();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case SUCCESS:
+ return isSetSuccess();
+ case EX1:
+ return isSetEx1();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof queryUploadStatus_result)
+ return this.equals((queryUploadStatus_result)that);
+ return false;
+ }
+
+ public boolean equals(queryUploadStatus_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.isSetSuccess();
+ boolean that_present_success = true && that.isSetSuccess();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ boolean this_present_ex1 = true && this.isSetEx1();
+ boolean that_present_ex1 = true && that.isSetEx1();
+ if (this_present_ex1 || that_present_ex1) {
+ if (!(this_present_ex1 && that_present_ex1))
+ return false;
+ if (!this.ex1.equals(that.ex1))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ List<Object> list = new ArrayList<Object>();
+
+ boolean present_success = true && (isSetSuccess());
+ list.add(present_success);
+ if (present_success)
+ list.add(success);
+
+ boolean present_ex1 = true && (isSetEx1());
+ list.add(present_ex1);
+ if (present_ex1)
+ list.add(ex1);
+
+ return list.hashCode();
+ }
+
+ @Override
+ public int compareTo(queryUploadStatus_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+
+ lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetSuccess()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetEx1()).compareTo(other.isSetEx1());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetEx1()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ex1, other.ex1);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("queryUploadStatus_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.success);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("ex1:");
+ if (this.ex1 == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.ex1);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ // check for sub-struct validity
+ if (success != null) {
+ success.validate();
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class queryUploadStatus_resultStandardSchemeFactory implements SchemeFactory {
+ public queryUploadStatus_resultStandardScheme getScheme() {
+ return new queryUploadStatus_resultStandardScheme();
+ }
+ }
+
+ private static class queryUploadStatus_resultStandardScheme extends StandardScheme<queryUploadStatus_result> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, queryUploadStatus_result struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 0: // SUCCESS
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.success = new TransferStatus();
+ struct.success.read(iprot);
+ struct.setSuccessIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 1: // EX1
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.ex1 = new TInvalidTokenException();
+ struct.ex1.read(iprot);
+ struct.setEx1IsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, queryUploadStatus_result struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.success != null) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ struct.success.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ if (struct.ex1 != null) {
+ oprot.writeFieldBegin(EX1_FIELD_DESC);
+ struct.ex1.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class queryUploadStatus_resultTupleSchemeFactory implements SchemeFactory {
+ public queryUploadStatus_resultTupleScheme getScheme() {
+ return new queryUploadStatus_resultTupleScheme();
+ }
+ }
+
+ private static class queryUploadStatus_resultTupleScheme extends TupleScheme<queryUploadStatus_result> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, queryUploadStatus_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetSuccess()) {
+ optionals.set(0);
+ }
+ if (struct.isSetEx1()) {
+ optionals.set(1);
+ }
+ oprot.writeBitSet(optionals, 2);
+ if (struct.isSetSuccess()) {
+ struct.success.write(oprot);
+ }
+ if (struct.isSetEx1()) {
+ struct.ex1.write(oprot);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, queryUploadStatus_result struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(2);
+ if (incoming.get(0)) {
+ struct.success = new TransferStatus();
+ struct.success.read(iprot);
+ struct.setSuccessIsSet(true);
+ }
+ if (incoming.get(1)) {
+ struct.ex1 = new TInvalidTokenException();
+ struct.ex1.read(iprot);
+ struct.setEx1IsSet(true);
+ }
+ }
+ }
+
+ }
+
}
diff --git a/src/main/java/org/openslx/filetransfer/util/ChunkList.java b/src/main/java/org/openslx/filetransfer/util/ChunkList.java
index e00aa0e..372b082 100644
--- a/src/main/java/org/openslx/filetransfer/util/ChunkList.java
+++ b/src/main/java/org/openslx/filetransfer/util/ChunkList.java
@@ -135,7 +135,7 @@ public class ChunkList
int index = 0;
for ( Boolean missing : statusList ) {
FileChunk chunk = allChunks.get( index );
- if ( fileLength != 0 && fileLength < chunk.range.endOffset )
+ if ( fileLength != -1 && fileLength < chunk.range.endOffset )
break; // Stop, file is shorter than end of this chunk
if ( missingChunks.remove( chunk ) || pendingChunks.remove( chunk ) ) {
completeChunks.add( chunk );
diff --git a/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java b/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java
index 9406c27..04ddc17 100644
--- a/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java
+++ b/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java
@@ -15,6 +15,7 @@ import java.util.concurrent.ExecutorService;
import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.TransferState;
+import org.openslx.bwlp.thrift.iface.TransferStatus;
import org.openslx.filetransfer.DataReceivedCallback;
import org.openslx.filetransfer.Downloader;
import org.openslx.filetransfer.FileRange;
@@ -107,7 +108,7 @@ public abstract class IncomingTransferBase extends AbstractTransfer implements H
download.cancel();
}
}
- lastActivityTime.set( 0 );
+ potentialFinishTime.set( 0 );
safeClose( tmpFileHandle );
}
@@ -154,6 +155,10 @@ public abstract class IncomingTransferBase extends AbstractTransfer implements H
return state;
}
+ public synchronized TransferStatus getStatus() {
+ return new TransferStatus(chunks.getStatusArray(), getState());
+ }
+
public final ChunkList getChunks()
{
return chunks;
diff --git a/src/main/thrift/bwlp.thrift b/src/main/thrift/bwlp.thrift
index 57afb0e..b0e866a 100644
--- a/src/main/thrift/bwlp.thrift
+++ b/src/main/thrift/bwlp.thrift
@@ -665,4 +665,8 @@ service MasterServer {
list<MasterSoftware> getSoftware(1:UnixTimestamp startDate)
throws (1:TInvocationException serverError),
+ // Client (maybe later server too) queries server-side status of an upload
+ TransferStatus queryUploadStatus(1: Token uploadToken)
+ throws (1:TInvalidTokenException ex1),
+
}