diff options
author | Simon Rettberg | 2022-03-16 12:07:46 +0100 |
---|---|---|
committer | Simon Rettberg | 2022-03-16 12:07:46 +0100 |
commit | 864b6c21ae73788ce4dcaecb7ef2d386561cb20d (patch) | |
tree | 3b29ccd5c6e61edb5b6be06a999f0dab3bbe0e80 | |
parent | [server] Add MultiLib attribute to manifest (diff) | |
download | tutor-module-864b6c21ae73788ce4dcaecb7ef2d386561cb20d.tar.gz tutor-module-864b6c21ae73788ce4dcaecb7ef2d386561cb20d.tar.xz tutor-module-864b6c21ae73788ce4dcaecb7ef2d386561cb20d.zip |
[client] Better log cancel/failure reason for uploads
6 files changed, 28 insertions, 20 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/TransferTask.java b/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/TransferTask.java index 305ff50d..4fa06592 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/TransferTask.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/TransferTask.java @@ -100,6 +100,9 @@ public abstract class TransferTask implements Runnable, TransferEventEmitter { } private void fireEvent(TransferEvent event) { + if (event.errorMessage != null) { + LOGGER.warn("(" + this.getClass().getSimpleName() + ") fireEvent with error: " + event.errorMessage); + } synchronized (listeners) { for (int i = listeners.size() - 1; i >= 0; --i) { listeners.get(i).update(event); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/UploadTask.java b/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/UploadTask.java index f10e94ea..8471ca8f 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/UploadTask.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/filetransfer/UploadTask.java @@ -124,7 +124,8 @@ public class UploadTask extends TransferTask { consecutiveInitFails.set(0); } else { String err = uploader.getRemoteError(); - if (err != null) { + if (err != null && !err.equals(remoteError)) { + LOGGER.warn("Upload task remote error: " + err); remoteError = err; } consecutiveInitFails.incrementAndGet(); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/activity/UploadPanel.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/activity/UploadPanel.java index 000e004e..6b8c5a94 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/activity/UploadPanel.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/activity/UploadPanel.java @@ -66,7 +66,7 @@ public class UploadPanel extends TransferPanel implements QuitNotification { QuickTimer.scheduleOnce(new Task() { @Override public void fire() { - state.cancelError(); + state.cancelError("UploadPanel: Requested by user through button press"); } }); } @@ -117,6 +117,6 @@ public class UploadPanel extends TransferPanel implements QuitNotification { @Override public void onApplicationQuit() { // Application quit, tell server we cancel - state.cancelError(); + state.cancelError("Application quit (via UploadPanel)"); } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java index 11d3846a..6d310bf1 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java @@ -281,7 +281,7 @@ public class ImageCreationWizard extends Wizard implements UiFeedback, QuitNotif @Override protected boolean onCancelRequest() { if (state.uuid == null) - return true; + return true; // Allow closing - nothing in progress boolean confirmed = Gui.showMessageBox(this, I18n.WIZARD.getString("ImageCreation.Message.yesNo.cancelRequest"), MessageType.QUESTION_YESNO, null, null); @@ -289,7 +289,7 @@ public class ImageCreationWizard extends Wizard implements UiFeedback, QuitNotif QuickTimer.scheduleOnce(new Task() { @Override public void fire() { if (state.upload != null) { - state.upload.cancelError(); + state.upload.cancelError("Cancelled through aborting wizard"); } // As we're creating a new VM, delete base image aswell try { @@ -313,7 +313,7 @@ public class ImageCreationWizard extends Wizard implements UiFeedback, QuitNotif @Override public void onApplicationQuit() { if (state != null && state.upload != null) { - state.upload.cancelError(); + state.upload.cancelError("Application quit (redirected via wizard)"); } } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java index a82801ac..ccdf8d53 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java @@ -96,7 +96,7 @@ public class ImageUpdateWizard extends Wizard implements UiFeedback, QuitNotific QuickTimer.scheduleOnce(new Task() { @Override public void fire() { - state.upload.cancelError(); + state.upload.cancelError("ImageUploadWizard was cancelled by user"); } }); } @@ -121,7 +121,7 @@ public class ImageUpdateWizard extends Wizard implements UiFeedback, QuitNotific @Override public void onApplicationQuit() { if (state != null && state.upload != null) { - state.upload.cancelError(); + state.upload.cancelError("Application quit (via ImageUpdateWizard)"); } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/UploadInitiator.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/UploadInitiator.java index 777cfcc7..efa65bab 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/UploadInitiator.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/UploadInitiator.java @@ -113,19 +113,19 @@ public class UploadInitiator { Session.getSatelliteToken(), imageBaseId, fileSize, null, // TODO remove deprecated parameter machineDescription); } catch (TAuthorizationException e) { - cancelWithErrorMessage("Upload vom Server verweigert"); + cancelWithGuiErrorMessage("Upload vom Server verweigert"); this.cancel(); return; } catch (TTransferRejectedException e) { if (e.message != null && e.message.startsWith("Server busy")) { initState = UploadInitState.WAITING_FOR_SLOT; } else { - cancelWithErrorMessage("Upload-Anfrage gescheitert (" + e.message + ")"); + cancelWithGuiErrorMessage("Upload-Anfrage gescheitert (" + e.message + ")"); this.cancel(); } return; } catch (TException e) { - cancelWithErrorMessage("Upload-Anfrage gescheitert!"); + cancelWithGuiErrorMessage("Upload-Anfrage gescheitert!"); this.cancel(); return; } @@ -157,6 +157,7 @@ public class UploadInitiator { public void fire() { LOGGER.debug("launch upload task"); if (initState != UploadInitState.UPLOAD_STARTING) { + LOGGER.info("Huh. Upload state is " + initState + ". Stopping init watchdog."); this.cancel(); return; } @@ -167,7 +168,7 @@ public class UploadInitiator { uploadTask = new UploadTask(Session.getSatelliteAddress(), transferInformation.getPlainPort(), transferInformation.getToken(), diskFile); } catch (FileNotFoundException e) { - cancelWithErrorMessage("Kann VM nicht hochladen: Datei nicht gefunden\n\n" + cancelWithGuiErrorMessage("Kann VM nicht hochladen: Datei nicht gefunden\n\n" + diskFile.getAbsolutePath()); this.cancel(); return; @@ -185,22 +186,24 @@ public class UploadInitiator { } if (!uploadTask.isComplete() && uploadTask.getTransferCount() == 0) { // Init failed - cancelWithErrorMessage("Aufbau der Verbindung zum Hochladen fehlgeschlagen"); + cancelWithGuiErrorMessage("Aufbau der Verbindung zum Hochladen fehlgeschlagen"); this.cancel(); return; } // Init succeeded initState = UploadInitState.UPLOAD_STARTED; + LOGGER.info("Upload initiated"); this.cancel(); } }; /** - * Set state to cancelled and clean up + * Set state to cancelled and clean up. Given reason goes to log only. */ - public synchronized void cancelError() { + public synchronized void cancelError(String reason) { if (initState == UploadInitState.ERROR) return; + LOGGER.info("Upload was cancelled while in state " + initState + ": " + reason); initState = UploadInitState.ERROR; if (hashGen != null) { hashGen.cancel(); @@ -224,12 +227,13 @@ public class UploadInitiator { return errorMessage; } - public void cancelWithErrorMessage(String errorMessage) { - if (!errorMessage.equals(this.errorMessage)) { - LOGGER.warn(errorMessage); - } + /** + * Cancel upload, show given error message in GUI transfer activity. + * @param errorMessage + */ + public void cancelWithGuiErrorMessage(String errorMessage) { this.errorMessage = errorMessage; - cancelError(); + cancelError("cancelWithErrorMessage: " + errorMessage); } public AsyncHashGenerator getHasher() { |