Package org.jets3t.service.multithread

Examples of org.jets3t.service.multithread.ThreadWatcher


     *
     * @param event
     */
    public void s3ServiceEventPerformed(DownloadObjectsEvent event) {
        if (ServiceEvent.EVENT_STARTED == event.getEventCode()) {   
            ThreadWatcher watcher = event.getThreadWatcher();
           
            // Show percentage of bytes transferred, if this info is available.
            if (watcher.isBytesTransferredInfoAvailable()) {
                startProgressDialog("Downloaded " +
                    watcher.getCompletedThreads() + "/" + watcher.getThreadCount() + " - " +                   
                    byteFormatter.formatByteSize(watcher.getBytesTransferred())
                    + " of " + byteFormatter.formatByteSize(watcher.getBytesTotal()),
                    "", 0, 100, "Cancel Download",
                    watcher.getCancelEventListener());
            // ... otherwise just show the number of completed threads.
            } else {
                startProgressDialog("Downloaded " + watcher.getCompletedThreads()
                    + " of " + watcher.getThreadCount() + " objects",
                    "", 0, (int) watcher.getThreadCount()"Cancel Download",
                    watcher.getCancelEventListener());
            }
        }
        else if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) {
            ThreadWatcher watcher = event.getThreadWatcher();
           
            // Show percentage of bytes transferred, if this info is available.
            if (watcher.isBytesTransferredInfoAvailable()) {
                String bytesCompletedStr = byteFormatter.formatByteSize(watcher.getBytesTransferred());
                String bytesTotalStr = byteFormatter.formatByteSize(watcher.getBytesTotal());
                String statusText = "Downloaded " +
                    watcher.getCompletedThreads() + "/" + watcher.getThreadCount() + " - " +                   
                    bytesCompletedStr + " of " + bytesTotalStr;
               
                String detailsText = formatTransferDetails(watcher);
               
                int percentage = (int)
                    (((double)watcher.getBytesTransferred() / watcher.getBytesTotal()) * 100);
                updateProgressDialog(statusText, detailsText, percentage);
            }
            // ... otherwise just show the number of completed threads.
            else {
                ThreadWatcher progressStatus = event.getThreadWatcher();
                String statusText = "Downloaded " + progressStatus.getCompletedThreads()
                    + " of " + progressStatus.getThreadCount() + " objects";                   
                updateProgressDialog(statusText, "", (int) progressStatus.getCompletedThreads());                   
            }           
        } else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode()) {
            stopProgressDialog();               
        }
        else if (ServiceEvent.EVENT_CANCELLED == event.getEventCode()) {
View Full Code Here


     *
     * @param event
     */
    public void s3ServiceEventPerformed(final CreateObjectsEvent event) {
        if (ServiceEvent.EVENT_STARTED == event.getEventCode()) {   
            ThreadWatcher watcher = event.getThreadWatcher();
           
            // Show percentage of bytes transferred, if this info is available.
            if (watcher.isBytesTransferredInfoAvailable()) {
                String bytesTotalStr = byteFormatter.formatByteSize(watcher.getBytesTotal());
                String statusText = "Uploaded " +
                    watcher.getCompletedThreads() + "/" + watcher.getThreadCount() + " - " +                   
                    "0 of " + bytesTotalStr;               
                startProgressDialog(statusText, " ", 0, 100, "Cancel Upload",
                    event.getThreadWatcher().getCancelEventListener());
            }
            // ... otherwise show the number of completed threads.
            else {
                startProgressDialog(
                    "Uploaded 0 of " + watcher.getThreadCount() + " objects",
                    "", (int) watcher.getCompletedThreads(), (int) watcher.getThreadCount(),
                    "Cancel upload", event.getThreadWatcher().getCancelEventListener());               
            }
        }
        else if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {           
                    for (int i = 0; i < event.getCreatedObjects().length; i++) {
                        S3Object object = event.getCreatedObjects()[i];
                        object.setBucketName(getCurrentSelectedBucket().getName());
                        objectTableModel.addObject(object);
                    }
                    if (event.getCreatedObjects().length > 0) {
                        updateObjectsSummary(true);
                    }
                }
            });
           
            ThreadWatcher watcher = event.getThreadWatcher();
           
            // Show percentage of bytes transferred, if this info is available.
            if (watcher.isBytesTransferredInfoAvailable()) {
                if (watcher.getBytesTransferred() >= watcher.getBytesTotal()) {
                    // Upload is completed, just waiting on resonse from S3.
                    String statusText = "Upload completed, awaiting confirmation";
                    updateProgressDialog(statusText, "", 100);
                } else {                   
                    String bytesCompletedStr = byteFormatter.formatByteSize(watcher.getBytesTransferred());
                    String bytesTotalStr = byteFormatter.formatByteSize(watcher.getBytesTotal());
                    String statusText = "Uploaded " +
                        watcher.getCompletedThreads() + "/" + watcher.getThreadCount() + " - " +                   
                        bytesCompletedStr + " of " + bytesTotalStr;
                    int percentage = (int)
                        (((double)watcher.getBytesTransferred() / watcher.getBytesTotal()) * 100);
                   
                    String detailsText = formatTransferDetails(watcher);

                    updateProgressDialog(statusText, detailsText, percentage);
                }
            }
            // ... otherwise show the number of completed threads.
            else {
                ThreadWatcher progressStatus = event.getThreadWatcher();
                String statusText = "Uploaded " + progressStatus.getCompletedThreads() +
                    " of " + progressStatus.getThreadCount() + " objects";                   
                updateProgressDialog(statusText, "", (int) progressStatus.getCompletedThreads());                   
            }
        }
        else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode()) {
            stopProgressDialog();       

View Full Code Here

     *
     * @param event
     */
    public void s3ServiceEventPerformed(final CopyObjectsEvent event) {
        if (ServiceEvent.EVENT_STARTED == event.getEventCode()) {   
            ThreadWatcher watcher = event.getThreadWatcher();           
            startProgressDialog("Copied 0 of " + watcher.getThreadCount() + " objects",
                "", 0, (int) watcher.getThreadCount(),
                "Cancel Copy", event.getThreadWatcher().getCancelEventListener());               
        }
        else if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) {
            ThreadWatcher watcher = event.getThreadWatcher();
            String statusText = "Copied " + watcher.getCompletedThreads()
                + " of " + watcher.getThreadCount() + " objects";                   
            updateProgressDialog(statusText, "", (int) watcher.getCompletedThreads());                   
        }
        else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode()
            || ServiceEvent.EVENT_CANCELLED == event.getEventCode())
        {
            stopProgressDialog();       
View Full Code Here

                        updateObjectsSummary(true);
                    }
                }
            });
           
            ThreadWatcher progressStatus = event.getThreadWatcher();
            String statusText = "Deleted " + progressStatus.getCompletedThreads()
                + " of " + progressStatus.getThreadCount() + " objects";
            updateProgressDialog(statusText, "", (int) progressStatus.getCompletedThreads());               
        }
        else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode()) {
            stopProgressDialog();               
        }
        else if (ServiceEvent.EVENT_CANCELLED == event.getEventCode()) {
View Full Code Here

                    "", 0, (int) event.getThreadWatcher().getThreadCount(), "Cancel Retrieval",
                    event.getThreadWatcher().getCancelEventListener());
            }
        }
        else if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) {
            final ThreadWatcher progressStatus = event.getThreadWatcher();

            // Store detail-complete objects in table.
            runInDispatcherThreadImmediately(new Runnable() {
                public void run() {
                    // Update object in table with the retrieved details.
                    for (int i = 0; i < event.getCompletedObjects().length; i++) {
                        S3Object objectWithDetails = event.getCompletedObjects()[i];
                        S3Object originalObject = objectTableModel.getObjectByKey(
                            objectWithDetails.getKey());
                       
                        originalObject.replaceAllMetadata(objectWithDetails.getMetadataMap());
                        originalObject.setMetadataComplete(true);
                        log.debug("Updated table with " + originalObject.getKey()
                            + ", content-type=" + originalObject.getContentType());
                    }
                }
            });
           
            // Update progress of GetObject requests.
            String statusText = "Retrieved details for " + progressStatus.getCompletedThreads()
                + " of " + progressStatus.getThreadCount() + " objects";
            updateProgressDialog(statusText, "", (int) progressStatus.getCompletedThreads());                   
        }
        else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode()) {
            // Stop GetObjectHead progress display.
            stopProgressDialog();                   
        }
View Full Code Here

                    boolean isXmlSummaryUpload = includeXmlSummaryDoc && uploadingFinalObject;
                    cancelUploadButton.setEnabled(!isXmlSummaryUpload);
                }
            });
           
            ThreadWatcher watcher = event.getThreadWatcher();
            uploadCancelEventTrigger = watcher.getCancelEventListener();
           
            // Show percentage of bytes transferred.
            String bytesTotalStr = byteFormatter.formatByteSize(watcher.getBytesTotal());
            final String statusText = "Uploaded 0 of " + bytesTotalStr;               

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    progressStatusTextLabel.setText(replaceMessageVariables(statusText));
                    progressBar.setValue(0);
                }
            });
        }
        else if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) {
            ThreadWatcher watcher = event.getThreadWatcher();
           
            if (watcher.getBytesTransferred() >= watcher.getBytesTotal()) {
                // Upload is completed, just waiting on resonse from S3.
                String statusText = "Upload completed, awaiting confirmation";
               
                progressBar.setValue(100);
                progressStatusTextLabel.setText(replaceMessageVariables(statusText));
                progressTransferDetailsLabel.setText("");
            } else {                   
                String bytesCompletedStr = byteFormatter.formatByteSize(watcher.getBytesTransferred());
                String bytesTotalStr = byteFormatter.formatByteSize(watcher.getBytesTotal());
                String statusText = "Uploaded " + bytesCompletedStr + " of " + bytesTotalStr;
                int percentage = (int)
                    (((double)watcher.getBytesTransferred() / watcher.getBytesTotal()) * 100);
               
                long bytesPerSecond = watcher.getBytesPerSecond();
                String transferDetailsText = "Speed: " + byteFormatter.formatByteSize(bytesPerSecond) + "/s";

                if (watcher.isTimeRemainingAvailable()) {
                    long secondsRemaining = watcher.getTimeRemaining();
                    if (transferDetailsText.trim().length() > 0) {
                        transferDetailsText += " - ";
                    }
                    transferDetailsText += "Time remaining: " + timeFormatter.formatTime(secondsRemaining);
                }
View Full Code Here

                "Privacy update 0/" + event.getThreadWatcher().getThreadCount(),
                (int) event.getThreadWatcher().getThreadCount()
                event.getThreadWatcher().getCancelEventListener());
        }
        else if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) {
            ThreadWatcher progressStatus = event.getThreadWatcher();
            String statusText = "Privacy update " + progressStatus.getCompletedThreads()
                + "/" + progressStatus.getThreadCount();
            updateProgressPanel(event.getUniqueOperationId(), statusText,
                (int) progressStatus.getCompletedThreads());

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {           
                    S3Object[] objects = event.getObjectsWithUpdatedACL();
                    for (int i = 0; i < objects.length; i++) {
View Full Code Here

     *
     * @param event
     */
    public void s3ServiceEventPerformed(DownloadObjectsEvent event) {
        if (ServiceEvent.EVENT_STARTED == event.getEventCode()) {   
            ThreadWatcher watcher = event.getThreadWatcher();
           
            // Show percentage of bytes transferred, if this info is available.
            if (watcher.isBytesTransferredInfoAvailable()) {
                startProgressPanel(event.getUniqueOperationId(),
                    "Download " +
                    byteFormatterTerse.formatByteSize(watcher.getBytesTransferred())
                    + "/" + byteFormatterTerse.formatByteSize(watcher.getBytesTotal()),
                    100, event.getThreadWatcher().getCancelEventListener());
            // ... otherwise just show the number of completed threads.
            } else {
                startProgressPanel(event.getUniqueOperationId(),
                    "Download " + event.getThreadWatcher().getCompletedThreads()
                    + "/" + event.getThreadWatcher().getThreadCount(),
                    (int) event.getThreadWatcher().getThreadCount(),
                    event.getThreadWatcher().getCancelEventListener());
            }
        }
        else if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) {
            ThreadWatcher watcher = event.getThreadWatcher();
           
            // Show percentage of bytes transferred, if this info is available.
            if (watcher.isBytesTransferredInfoAvailable()) {
                int percentage = (int)
                    (((double)watcher.getBytesTransferred() / watcher.getBytesTotal()) * 100);
                updateProgressPanel(event.getUniqueOperationId(),
                    "Download " +
                    byteFormatterTerse.formatByteSize(watcher.getBytesTransferred())
                    + "/" + byteFormatterTerse.formatByteSize(watcher.getBytesTotal())
                    + " ("
                    byteFormatterTerse.formatByteSize(watcher.getBytesPerSecond()) + "/s, "
                    + timeFormatterTerse.formatTime(watcher.getTimeRemaining())
                    + ")",
                    percentage);
            }
            // ... otherwise just show the number of completed threads.
            else {
                ThreadWatcher progressStatus = event.getThreadWatcher();
                String statusText = "Download " + progressStatus.getCompletedThreads()
                    + " of " + progressStatus.getThreadCount() + " objects";                   
                updateProgressPanel(event.getUniqueOperationId(), statusText, (int) progressStatus.getCompletedThreads());                   
            }           
        } else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode()) {
            stopProgressPanel(event.getUniqueOperationId());               
        }
        else if (ServiceEvent.EVENT_CANCELLED == event.getEventCode()) {
View Full Code Here

     *
     * @param event
     */
    public void s3ServiceEventPerformed(final CreateObjectsEvent event) {
        if (ServiceEvent.EVENT_STARTED == event.getEventCode()) {   
            ThreadWatcher watcher = event.getThreadWatcher();
           
            // Show percentage of bytes transferred, if this info is available.
            if (watcher.isBytesTransferredInfoAvailable()) {
                startProgressPanel(event.getUniqueOperationId(),
                    "Upload " +
                    byteFormatterTerse.formatByteSize(watcher.getBytesTransferred())
                    + "/" + byteFormatterTerse.formatByteSize(watcher.getBytesTotal()),
                    100, event.getThreadWatcher().getCancelEventListener());
            }
            // ... otherwise show the number of completed threads.
            else {
                startProgressPanel(event.getUniqueOperationId(),
                    "Upload 0/" + watcher.getThreadCount(),
                    (int) watcher.getThreadCount(),
                    event.getThreadWatcher().getCancelEventListener());               
            }
        }
        else if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {           
                    for (int i = 0; i < event.getCreatedObjects().length; i++) {
                        objectTableModel.addObject(event.getCreatedObjects()[i]);
                    }
                }
            });
           
            ThreadWatcher watcher = event.getThreadWatcher();
           
            // Show percentage of bytes transferred, if this info is available.
            if (watcher.isBytesTransferredInfoAvailable()) {
                if (watcher.getBytesTransferred() >= watcher.getBytesTotal()) {
                    // Upload is completed, just waiting on resonse from S3.
                    updateProgressPanel(event.getUniqueOperationId(), "Confirming", 100);
                } else {                   
                    int percentage = (int)
                        (((double)watcher.getBytesTransferred() / watcher.getBytesTotal()) * 100);
                   
                    updateProgressPanel(event.getUniqueOperationId(),
                        "Upload " +
                        byteFormatterTerse.formatByteSize(watcher.getBytesTransferred())
                        + "/" + byteFormatterTerse.formatByteSize(watcher.getBytesTotal())
                        + " ("
                        byteFormatterTerse.formatByteSize(watcher.getBytesPerSecond()) + "/s, "
                        + timeFormatterTerse.formatTime(watcher.getTimeRemaining())
                        + ")", percentage);
                }
            }
            // ... otherwise show the number of completed threads.
            else {
                ThreadWatcher progressStatus = event.getThreadWatcher();
                updateProgressPanel(event.getUniqueOperationId(),
                    "Upload " + progressStatus.getCompletedThreads()
                    + "/" + progressStatus.getThreadCount(),
                    (int) progressStatus.getCompletedThreads());                   
            }
        }
        else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode()) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
View Full Code Here

                            event.getDeletedObjects()[i]);
                    }
                }
            });
           
            ThreadWatcher progressStatus = event.getThreadWatcher();
            String statusText = "Deleted " + progressStatus.getCompletedThreads()
                + " of " + progressStatus.getThreadCount() + " object(s)";
            updateProgressDialog(statusText, "", (int) progressStatus.getCompletedThreads());               
        }
        else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode()) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    updateObjectsSummary();
View Full Code Here

TOP

Related Classes of org.jets3t.service.multithread.ThreadWatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.