// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/utils/DateUtils.java
// public class DateUtils {
//   private static DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC();
// 
//   public static String now() {
//     return formatter.print(System.currentTimeMillis());
//   }
// 
//   public static String time(long millis) {
//     return formatter.print(millis);
//   }
// }


import com.google.ce.media.contentuploader.message.*;
import com.google.ce.media.contentuploader.utils.DateUtils;
import com.google.cloud.WriteChannel;
import com.google.cloud.storage.Blob;
import com.google.cloud.storage.BlobInfo;
import com.google.cloud.storage.Storage;
import org.springframework.context.ApplicationEventPublisher;
import java.io.FileInputStream;
import java.nio.ByteBuffer;
import java.nio.file.Files;
        double mibs = den == 0 ? 0 : ((count * 8d) / den) / (1024d * 1024d);
        taskInfo.setMbps(mibs);
        taskInfo.updateUploaded(count);
        taskInfo.setEndTime(segEnd);
        total += count;
      }
      writeChannel.close();

      long endTime = System.currentTimeMillis();
      taskInfo.setEndTime(endTime);

      long time = (endTime - startTime) / 1000;
      time = time == 0 ? 1 : time;
      double mbps = ((total * 8) / time) / (1024 * 1024);
      taskInfo.setMbps(mbps);

      if (!taskInfo.isCancelling()) {
        taskInfo.setStatus(TaskStatus.FINISHED);

        AnalyticsMessage m2 = AnalyticsMessage.from(taskInfo, AnalyticsMessage.Event.SINGLE_FILE_END, "End Single Upload");
        m2.setStartTime(m1.getStartTime());
        m2.setEndTime(DateUtils.time(endTime));
        m2.setTimeTaken(time);
        m2.setMbps((int) mbps);
        AnalyticsService.getInstance().enqueue(taskInfo.getAuthConfig().getAuthInfo(), m2);

        AnalyticsMessage m_complete = AnalyticsMessage.from(taskInfo,
                                                            AnalyticsMessage.Event.COMPLETE,
                                                            "Complete Single Upload");
        m_complete.setStartTime(m2.getStartTime());
// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/utils/DateUtils.java
// public class DateUtils {
//   private static DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC();
// 
//   public static String now() {
//     return formatter.print(System.currentTimeMillis());
//   }
// 
//   public static String time(long millis) {
//     return formatter.print(millis);
//   }
// }


// Path: app-desktop/src/main/java/com/google/ce/media/contentuploader/exec/UploadTask.java
import com.google.ce.media.contentuploader.message.*;
import com.google.ce.media.contentuploader.utils.DateUtils;
import com.google.cloud.WriteChannel;
import com.google.cloud.storage.Blob;
import com.google.cloud.storage.BlobInfo;
import com.google.cloud.storage.Storage;
import org.springframework.context.ApplicationEventPublisher;
import java.io.FileInputStream;
import java.nio.ByteBuffer;
import java.nio.file.Files;

        double mibs = den == 0 ? 0 : ((count * 8d) / den) / (1024d * 1024d);
        taskInfo.setMbps(mibs);
        taskInfo.updateUploaded(count);
        taskInfo.setEndTime(segEnd);
        total += count;
      }
      writeChannel.close();

      long endTime = System.currentTimeMillis();
      taskInfo.setEndTime(endTime);

      long time = (endTime - startTime) / 1000;
      time = time == 0 ? 1 : time;
      double mbps = ((total * 8) / time) / (1024 * 1024);
      taskInfo.setMbps(mbps);

      if (!taskInfo.isCancelling()) {
        taskInfo.setStatus(TaskStatus.FINISHED);

        AnalyticsMessage m2 = AnalyticsMessage.from(taskInfo, AnalyticsMessage.Event.SINGLE_FILE_END, "End Single Upload");
        m2.setStartTime(m1.getStartTime());
        m2.setEndTime(DateUtils.time(endTime));
        m2.setTimeTaken(time);
        m2.setMbps((int) mbps);
        AnalyticsService.getInstance().enqueue(taskInfo.getAuthConfig().getAuthInfo(), m2);

        AnalyticsMessage m_complete = AnalyticsMessage.from(taskInfo,
                                                            AnalyticsMessage.Event.COMPLETE,
                                                            "Complete Single Upload");
        m_complete.setStartTime(m2.getStartTime());
        m_complete.setEndTime(m2.getEndTime());