Advertisement
Guest User

Untitled

a guest
May 20th, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. package de.hpi.cloudraid.service;
  2.  
  3. import java.io.File;
  4. import java.text.SimpleDateFormat;
  5. import java.util.ArrayList;
  6. import java.util.Date;
  7. import java.util.List;
  8.  
  9. import javax.inject.Inject;
  10.  
  11. import org.aspectj.lang.ProceedingJoinPoint;
  12. import org.aspectj.lang.annotation.Around;
  13. import org.aspectj.lang.annotation.Aspect;
  14.  
  15. @Aspect
  16. public class MeasurementAspect {
  17.  
  18. final File FileUploadCSV = new File(String.format("target/Result Measurement Aspect Upload.csv"));
  19. final File FileDownloadCSV = new File(String.format("target/Result Measurement Aspect Download.csv"));
  20. SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
  21. int i = 0;
  22. public long start, end, duration, fileSizeUpload, fileSizeDownload, durationKeyGen, durationEncConfig,
  23. durationEncryptTime, durationChunk, durationUploadInfo, durationUploadEach, durationUploadTotal,
  24. durationUploadTotal2, durationSharingConfig, durationEncShareData, durationUploadMetadata,
  25. durationRetrieveConfig, durationFetchChunk, durationDecrypt, durationDeerasureChunk, durationRecovChunk,
  26. durationTestChunk, durationFetchChunks, durationFetchChunkStreams, durationTestChunks, durationDecryptAsym,
  27. durationUploadAChunk, durationDownloadAChunk, durationDecryptAChunk, durationDownloadTotal;
  28.  
  29. // Size of provider used for upload
  30. public long durationUploadEachChunk[] = new long[4];
  31. // Size of provider used for download
  32. public long durationDownloadEachChunk[] = new long[3];
  33. // Number of chunks used for decryption
  34. public long durationDecryptEachChunk[] = new long[2];
  35.  
  36. public List<Long> durUploadEachChunk = new ArrayList<Long>();
  37. public List<Long> durDownloadEachChunk = new ArrayList<Long>();
  38.  
  39. public List<Long> durDecryptEachChunk = new ArrayList<Long>();
  40.  
  41. private @Inject RemoteStatisticService remoteStatisticService;
  42.  
  43. // private @Inject MeasureDownloadDto measureDownloadDto;
  44. // private @Inject MeasureUploadDto measureUploadDto;
  45.  
  46. // private final MeasurementService measurementService = new
  47. // MeasurementService();
  48. // private @Inject MeasurementService measurementService;
  49. private final MeasurementAspectService measurementAspectService = new MeasurementAspectService();
  50.  
  51. private final MeasureDownloadDto measureDownloadDto = new MeasureDownloadDto();
  52. private final MeasureUploadDto measureUploadDto = new MeasureUploadDto();
  53.  
  54.  
  55.  
  56. // Calculate time for uploading meta data
  57. @Around("execution(* *.storeFile(long, long, List<PubKeyRestoreInfoSecretContainer>,TrustLevel, String, String, long )) && args(folderId, encryptedFileSize, encryptedInformation, trustlevel, hashIdentifier, fileName, antecessorId)")
  58. public Object CalculateUploadMetadata(ProceedingJoinPoint joinPoint, long folderId, long encryptedFileSize,
  59. List<PubKeyRestoreInfoSecretContainer> encryptedInformation, TrustLevel trustlevel, String hashIdentifier,
  60. String fileName, long antecessorId) throws Throwable {
  61. start = System.nanoTime();
  62. Object result = joinPoint.proceed();
  63. end = System.nanoTime();
  64. duration = end - start;
  65. setDurationUploadMetadata(duration);
  66. // System.err.println(folderId);
  67. // System.err.println(antecessorId);
  68. measureUploadDto.setDurationUploadMetadata(duration);
  69. System.err.println(
  70. SDF.format(new Date()) + " Elapsed time for uploading meta data (ns) = " + getDurationUploadMetadata());
  71. // if (!FileUploadCSV.exists()) {
  72. // logUpload();
  73. // } else {
  74. // logUploadAppend();
  75. // }
  76. i = 0;
  77. // System.err.println("remoteStatisticService: " +
  78. // remoteStatisticService);
  79. remoteStatisticService.postUploadStatistic(measureUploadDto);
  80. // System.err.println("measurementService " + measurementAspectService);
  81. // measurementAspectService.storeUploadDto(measureUploadDto);
  82. durUploadEachChunk.clear();
  83. return result;
  84. }
  85.  
  86. public void setRemoteStatisticService(RemoteStatisticService remoteStatisticService) {
  87. this.remoteStatisticService = remoteStatisticService;
  88. }
  89.  
  90. public RemoteStatisticService getRemoteStatisticService() {
  91. return remoteStatisticService;
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement