-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e636884
commit 4260001
Showing
4 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 33 additions & 10 deletions
43
api-server/src/main/java/com/objectstorage/service/state/watcher/WatcherService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,47 @@ | ||
package com.objectstorage.service.state.watcher; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.apache.commons.io.FileUtils; | ||
|
||
/** | ||
* Service used to track state metrics for the current session in the application. | ||
*/ | ||
public class WatcherService { | ||
|
||
/** | ||
* Represents amount of files uploaded to ObjectStorage Temporate Storage in the current session. | ||
*/ | ||
@Getter | ||
@Setter | ||
private static Double filesUploadCounter = (double) 0; | ||
private Integer filesUploadCounter = 0; | ||
|
||
/** | ||
* Increases amount of files uploaded to ObjectStorage Temporate Storage in the current session. | ||
*/ | ||
public void increaseFilesUploadCounter() { | ||
filesUploadCounter++; | ||
} | ||
|
||
/** | ||
* Represents global amount of files content uploaded in the current session. | ||
* Represents global files size uploaded in the current session. | ||
*/ | ||
@Getter | ||
@Setter | ||
private static Double uploadedFilesSize = (double) 0; | ||
private Integer uploadedFilesSize = 0; | ||
|
||
/** | ||
* Increases global files size uploaded in the current session with the given value. | ||
* | ||
* @param value given value of uploaded file size. | ||
*/ | ||
public void increaseUploadedFilesSize(Integer value) { | ||
uploadedFilesSize += value; | ||
} | ||
|
||
/** | ||
* Calculates average file size in the current session. | ||
* | ||
* @return calculated average file size. | ||
*/ | ||
public Double getAverageFileSize() { | ||
if (filesUploadCounter > 0) { | ||
return Double.valueOf(uploadedFilesSize) / Double.valueOf(filesUploadCounter) / 1024 / 1024; | ||
} | ||
|
||
return (double) 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters