Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.hpi.cloudraid.service;
- import java.io.File;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import javax.inject.Inject;
- import org.aspectj.lang.ProceedingJoinPoint;
- import org.aspectj.lang.annotation.Around;
- import org.aspectj.lang.annotation.Aspect;
- @Aspect
- public class MeasurementAspect {
- final File FileUploadCSV = new File(String.format("target/Result Measurement Aspect Upload.csv"));
- final File FileDownloadCSV = new File(String.format("target/Result Measurement Aspect Download.csv"));
- SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- int i = 0;
- public long start, end, duration, fileSizeUpload, fileSizeDownload, durationKeyGen, durationEncConfig,
- durationEncryptTime, durationChunk, durationUploadInfo, durationUploadEach, durationUploadTotal,
- durationUploadTotal2, durationSharingConfig, durationEncShareData, durationUploadMetadata,
- durationRetrieveConfig, durationFetchChunk, durationDecrypt, durationDeerasureChunk, durationRecovChunk,
- durationTestChunk, durationFetchChunks, durationFetchChunkStreams, durationTestChunks, durationDecryptAsym,
- durationUploadAChunk, durationDownloadAChunk, durationDecryptAChunk, durationDownloadTotal;
- // Size of provider used for upload
- public long durationUploadEachChunk[] = new long[4];
- // Size of provider used for download
- public long durationDownloadEachChunk[] = new long[3];
- // Number of chunks used for decryption
- public long durationDecryptEachChunk[] = new long[2];
- public List<Long> durUploadEachChunk = new ArrayList<Long>();
- public List<Long> durDownloadEachChunk = new ArrayList<Long>();
- public List<Long> durDecryptEachChunk = new ArrayList<Long>();
- private @Inject RemoteStatisticService remoteStatisticService;
- // private @Inject MeasureDownloadDto measureDownloadDto;
- // private @Inject MeasureUploadDto measureUploadDto;
- // private final MeasurementService measurementService = new
- // MeasurementService();
- // private @Inject MeasurementService measurementService;
- private final MeasurementAspectService measurementAspectService = new MeasurementAspectService();
- private final MeasureDownloadDto measureDownloadDto = new MeasureDownloadDto();
- private final MeasureUploadDto measureUploadDto = new MeasureUploadDto();
- // Calculate time for uploading meta data
- @Around("execution(* *.storeFile(long, long, List<PubKeyRestoreInfoSecretContainer>,TrustLevel, String, String, long )) && args(folderId, encryptedFileSize, encryptedInformation, trustlevel, hashIdentifier, fileName, antecessorId)")
- public Object CalculateUploadMetadata(ProceedingJoinPoint joinPoint, long folderId, long encryptedFileSize,
- List<PubKeyRestoreInfoSecretContainer> encryptedInformation, TrustLevel trustlevel, String hashIdentifier,
- String fileName, long antecessorId) throws Throwable {
- start = System.nanoTime();
- Object result = joinPoint.proceed();
- end = System.nanoTime();
- duration = end - start;
- setDurationUploadMetadata(duration);
- // System.err.println(folderId);
- // System.err.println(antecessorId);
- measureUploadDto.setDurationUploadMetadata(duration);
- System.err.println(
- SDF.format(new Date()) + " Elapsed time for uploading meta data (ns) = " + getDurationUploadMetadata());
- // if (!FileUploadCSV.exists()) {
- // logUpload();
- // } else {
- // logUploadAppend();
- // }
- i = 0;
- // System.err.println("remoteStatisticService: " +
- // remoteStatisticService);
- remoteStatisticService.postUploadStatistic(measureUploadDto);
- // System.err.println("measurementService " + measurementAspectService);
- // measurementAspectService.storeUploadDto(measureUploadDto);
- durUploadEachChunk.clear();
- return result;
- }
- public void setRemoteStatisticService(RemoteStatisticService remoteStatisticService) {
- this.remoteStatisticService = remoteStatisticService;
- }
- public RemoteStatisticService getRemoteStatisticService() {
- return remoteStatisticService;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement