-
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
eb81b5b
commit f282498
Showing
6 changed files
with
135 additions
and
42 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
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
87 changes: 87 additions & 0 deletions
87
...rage/service/visualization/label/upload/object/UploadObjectCommandVisualizationLabel.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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.objectstorage.service.visualization.label.upload.object; | ||
|
||
import com.objectstorage.dto.VisualizationLabelDto; | ||
import com.objectstorage.entity.PropertiesEntity; | ||
import com.objectstorage.service.visualization.common.IVisualizationLabel; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.ArrayDeque; | ||
import java.util.List; | ||
import java.util.concurrent.locks.ReentrantLock; | ||
|
||
/** | ||
* Represents label set used for upload object command service. | ||
*/ | ||
@Service | ||
public class UploadObjectCommandVisualizationLabel implements IVisualizationLabel { | ||
private final ArrayDeque<VisualizationLabelDto> stepsQueue = new ArrayDeque<>(); | ||
|
||
private final ArrayDeque<String> batchQueue = new ArrayDeque<>(); | ||
|
||
private final ReentrantLock mutex = new ReentrantLock(); | ||
|
||
public UploadObjectCommandVisualizationLabel(@Autowired PropertiesEntity properties) { | ||
stepsQueue.addAll( | ||
List.of( | ||
VisualizationLabelDto.of( | ||
properties.getProgressVisualizationHealthCheckRequestLabel(), 10), | ||
VisualizationLabelDto.of( | ||
properties.getProgressVisualizationHealthCheckResponseLabel(), 30), | ||
VisualizationLabelDto.of( | ||
properties.getProgressVisualizationVersionRequestLabel(), 40), | ||
VisualizationLabelDto.of( | ||
properties.getProgressVisualizationVersionResponseLabel(), 60), | ||
VisualizationLabelDto.of(properties.getProgressVisualizationUploadObjectRequestLabel(), 70), | ||
VisualizationLabelDto.of( | ||
properties.getProgressVisualizationUploadObjectResponseLabel(), 100))); | ||
} | ||
|
||
/** | ||
* @see IVisualizationLabel | ||
*/ | ||
@Override | ||
public Boolean isEmpty() { | ||
return stepsQueue.isEmpty(); | ||
} | ||
|
||
/** | ||
* @see IVisualizationLabel | ||
*/ | ||
@Override | ||
public Boolean isNext() { | ||
mutex.lock(); | ||
|
||
try { | ||
return !batchQueue.isEmpty(); | ||
} finally { | ||
mutex.unlock(); | ||
} | ||
} | ||
|
||
/** | ||
* @see IVisualizationLabel | ||
*/ | ||
@Override | ||
public void pushNext() { | ||
mutex.lock(); | ||
|
||
batchQueue.push(stepsQueue.pop().toString()); | ||
|
||
mutex.unlock(); | ||
} | ||
|
||
/** | ||
* @see IVisualizationLabel | ||
*/ | ||
@Override | ||
public String getCurrent() { | ||
mutex.lock(); | ||
|
||
try { | ||
return batchQueue.pollLast(); | ||
} finally { | ||
mutex.unlock(); | ||
} | ||
} | ||
} |
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