Skip to content

Commit

Permalink
fix: fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikRevich committed Dec 8, 2024
1 parent eb81b5b commit f282498
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 42 deletions.
6 changes: 4 additions & 2 deletions cli/src/main/java/com/objectstorage/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
import com.objectstorage.service.config.ConfigService;
import com.objectstorage.service.visualization.VisualizationService;
import com.objectstorage.service.visualization.label.apply.ApplyCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.clean.CleanCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.clean.object.CleanObjectCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.cleanall.CleanAllCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.content.ContentCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.download.backup.DownloadBackupCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.download.object.DownloadObjectCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.upload.object.UploadObjectCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.withdraw.WithdrawCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.version.VersionCommandVisualizationLabel;
import com.objectstorage.service.visualization.state.VisualizationState;
Expand Down Expand Up @@ -52,11 +53,12 @@
ConfigService.class,
ApplyCommandVisualizationLabel.class,
WithdrawCommandVisualizationLabel.class,
CleanCommandVisualizationLabel.class,
CleanObjectCommandVisualizationLabel.class,
CleanAllCommandVisualizationLabel.class,
ContentCommandVisualizationLabel.class,
DownloadObjectCommandVisualizationLabel.class,
DownloadBackupCommandVisualizationLabel.class,
UploadObjectCommandVisualizationLabel.class,
VersionCommandVisualizationLabel.class,
VisualizationService.class,
VisualizationState.class
Expand Down
20 changes: 10 additions & 10 deletions cli/src/main/java/com/objectstorage/entity/PropertiesEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public class PropertiesEntity {
@Value(value = "${progress.visualization.withdraw-response}")
private String progressVisualizationWithdrawResponseLabel;

@Value(value = "${progress.visualization.clean-request}")
private String progressVisualizationCleanRequestLabel;
@Value(value = "${progress.visualization.clean-object-request}")
private String progressVisualizationCleanObjectRequestLabel;

@Value(value = "${progress.visualization.clean-response}")
private String progressVisualizationCleanResponseLabel;
@Value(value = "${progress.visualization.clean-object-response}")
private String progressVisualizationCleanObjectResponseLabel;

@Value(value = "${progress.visualization.clean-all-request}")
private String progressVisualizationCleanAllRequestLabel;
Expand All @@ -55,12 +55,6 @@ public class PropertiesEntity {

@Value(value = "${progress.visualization.content-response}")
private String progressVisualizationContentResponseLabel;

@Value(value = "${progress.visualization.upload-request}")
private String progressVisualizationUploadRequestLabel;

@Value(value = "${progress.visualization.upload-response}")
private String progressVisualizationUploadResponseLabel;

@Value(value = "${progress.visualization.download-object-request}")
private String progressVisualizationDownloadObjectRequestLabel;
Expand All @@ -74,6 +68,12 @@ public class PropertiesEntity {
@Value(value = "${progress.visualization.download-backup-response}")
private String progressVisualizationDownloadBackupResponseLabel;

@Value(value = "${progress.visualization.upload-object-request}")
private String progressVisualizationUploadObjectRequestLabel;

@Value(value = "${progress.visualization.upload-object-response}")
private String progressVisualizationUploadObjectResponseLabel;

@Value(value = "${progress.visualization.version-request}")
private String progressVisualizationVersionRequestLabel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import com.objectstorage.service.config.ConfigService;
import com.objectstorage.service.visualization.VisualizationService;
import com.objectstorage.service.visualization.label.apply.ApplyCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.clean.CleanCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.clean.object.CleanObjectCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.cleanall.CleanAllCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.content.ContentCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.download.object.DownloadObjectCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.upload.object.UploadObjectCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.withdraw.WithdrawCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.version.VersionCommandVisualizationLabel;
import com.objectstorage.service.visualization.state.VisualizationState;
Expand Down Expand Up @@ -90,7 +91,7 @@ public class BaseCommandService {
private WithdrawCommandVisualizationLabel withdrawCommandVisualizationLabel;

@Autowired
private CleanCommandVisualizationLabel cleanCommandVisualizationLabel;
private CleanObjectCommandVisualizationLabel cleanCommandVisualizationLabel;

@Autowired
private CleanAllCommandVisualizationLabel cleanAllCommandVisualizationLabel;
Expand All @@ -101,6 +102,9 @@ public class BaseCommandService {
@Autowired
private DownloadObjectCommandVisualizationLabel downloadCommandVisualizationLabel;

@Autowired
private UploadObjectCommandVisualizationLabel uploadObjectCommandVisualizationLabel;

@Autowired
private VersionCommandVisualizationLabel versionCommandVisualizationLabel;

Expand Down Expand Up @@ -204,13 +208,13 @@ private void withdraw(
* Provides access to clean command service.
*
* @param configLocation given custom configuration file location.
* @param location given remote content location name.
* @param location given uploaded content location name.
*/
@Command(description = "Clean remote content")
private void clean(
@Command(description = "Clean uploaded content object")
private void cleanObject(
@Option(names = {"--config"}, description = "A location of configuration file", defaultValue = "null")
String configLocation,
@Option(names = {"--location"}, description = "A name of remote content location", required = true)
@Option(names = {"--location"}, description = "A name of uploaded content location", required = true)
String location) {
if (Objects.equals(configLocation, "null")) {
configLocation = properties.getConfigDefaultLocation();
Expand Down Expand Up @@ -253,7 +257,7 @@ private void clean(
*
* @param configLocation given custom configuration file location.
*/
@Command(description = "Clean all remote content")
@Command(description = "Clean all object and backup content")
private void cleanAll(
@Option(names = {"--config"}, description = "A location of configuration file", defaultValue = "null")
String configLocation) {
Expand Down Expand Up @@ -342,22 +346,22 @@ private void content(
* Provides access to upload object command service.
*
* @param configLocation given custom configuration file location.
* @param location given remote content object location name.
* @param location given object content object location name.
* @param file given input file location.
*/
@Command(description = "Upload selected content object")
private void uploadObject(
@Option(names = {"--config"}, description = "A location of configuration file", defaultValue = "null")
String configLocation,
@Option(names = {"--location"}, description = "A name of remote content location", required = true)
@Option(names = {"--location"}, description = "A name of object content location", required = true)
String location,
@Option(names = {"--file"}, description = "A path for the file to be upload", required = true)
String file) {
if (Objects.equals(configLocation, "null")) {
configLocation = properties.getConfigDefaultLocation();
}

visualizationState.setLabel(downloadCommandVisualizationLabel);
visualizationState.setLabel(uploadObjectCommandVisualizationLabel);

visualizationService.process();

Expand Down Expand Up @@ -398,15 +402,15 @@ private void uploadObject(
* @param configLocation given custom configuration file location.
* @param provider given selected provider name.
* @param outputLocation given output file location.
* @param location given remote content object location name.
* @param location given object content object location name.
*/
@Command(description = "Download selected content object")
private void downloadObject(
@Option(names = {"--config"}, description = "A location of configuration file", defaultValue = "null")
String configLocation,
@Option(names = {"--provider"}, description = "A name of selected provider", required = true) String provider,
@Option(names = {"--output"}, description = "A path for the file to be downloaded", required = true) String outputLocation,
@Option(names = {"--location"}, description = "A name of remote content location", required = true)
@Option(names = {"--location"}, description = "A name of object content location", required = true)
String location) {
if (Objects.equals(configLocation, "null")) {
configLocation = properties.getConfigDefaultLocation();
Expand Down Expand Up @@ -453,14 +457,14 @@ private void downloadObject(
*
* @param configLocation given custom configuration file location.
* @param outputLocation given output file location.
* @param location given remote content backup location name.
* @param location given backup content backup location name.
*/
@Command(description = "Download selected content backup")
private void downloadBackup(
@Option(names = {"--config"}, description = "A location of configuration file", defaultValue = "null")
String configLocation,
@Option(names = {"--output"}, description = "A path for the file to be downloaded", required = true) String outputLocation,
@Option(names = {"--location"}, description = "A name of remote content location", required = true)
@Option(names = {"--location"}, description = "A name of backup content location", required = true)
String location) {
if (Objects.equals(configLocation, "null")) {
configLocation = properties.getConfigDefaultLocation();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.objectstorage.service.visualization.label.clean;
package com.objectstorage.service.visualization.label.clean.object;

import com.objectstorage.dto.VisualizationLabelDto;
import com.objectstorage.entity.PropertiesEntity;
Expand All @@ -11,17 +11,17 @@
import java.util.concurrent.locks.ReentrantLock;

/**
* Represents label set used for clean command service.
* Represents label set used for clean object command service.
*/
@Service
public class CleanCommandVisualizationLabel implements IVisualizationLabel {
public class CleanObjectCommandVisualizationLabel implements IVisualizationLabel {
private final ArrayDeque<VisualizationLabelDto> stepsQueue = new ArrayDeque<>();

private final ArrayDeque<String> batchQueue = new ArrayDeque<>();

private final ReentrantLock mutex = new ReentrantLock();

public CleanCommandVisualizationLabel(@Autowired PropertiesEntity properties) {
public CleanObjectCommandVisualizationLabel(@Autowired PropertiesEntity properties) {
stepsQueue.addAll(
List.of(
VisualizationLabelDto.of(
Expand All @@ -32,9 +32,9 @@ public CleanCommandVisualizationLabel(@Autowired PropertiesEntity properties) {
properties.getProgressVisualizationVersionRequestLabel(), 40),
VisualizationLabelDto.of(
properties.getProgressVisualizationVersionResponseLabel(), 60),
VisualizationLabelDto.of(properties.getProgressVisualizationCleanRequestLabel(), 70),
VisualizationLabelDto.of(properties.getProgressVisualizationCleanObjectRequestLabel(), 70),
VisualizationLabelDto.of(
properties.getProgressVisualizationCleanResponseLabel(), 100)));
properties.getProgressVisualizationCleanObjectResponseLabel(), 100)));
}

/**
Expand Down
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();
}
}
}
20 changes: 10 additions & 10 deletions cli/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ progress.visualization.withdraw-request=Sending configuration withdraw request
# Describes visualization label used for configuration withdraw response.
progress.visualization.withdraw-response=Withdrawal of configuration has been completed

# Describes visualization label used for content clean request.
progress.visualization.clean-request=Sending content clean request
# Describes visualization label used for content clean object request.
progress.visualization.clean-object-request=Sending content clean object request

# Describes visualization label used for content clean response.
progress.visualization.clean-response=Cleaning of content has been completed
# Describes visualization label used for content clean object response.
progress.visualization.clean-object-response=Cleaning of content object has been completed

# Describes visualization label used for content clean all request.
progress.visualization.clean-all-request=Sending content clean all request
Expand All @@ -40,12 +40,6 @@ progress.visualization.content-request=Sending content retrieval request
# Describes visualization label used for content retrieval response.
progress.visualization.content-response=Content retrieval has been completed

# Describes visualization label used for content upload request.
progress.visualization.upload-request=Sending content upload request

# Describes visualization label used for content upload response.
progress.visualization.upload-response=Content upload has been completed

# Describes visualization label used for content object download request.
progress.visualization.download-object-request=Sending content object download request

Expand All @@ -58,6 +52,12 @@ progress.visualization.download-backup-request=Sending content backup download r
# Describes visualization label used for content backup download response.
progress.visualization.download-backup-response=Content backup download has been completed

# Describes visualization label used for content object upload request.
progress.visualization.upload-object-request=Sending content object upload request

# Describes visualization label used for content object upload response.
progress.visualization.upload-object-response=Content object upload has been completed

# Describes visualization label used for version request.
progress.visualization.version-request=Sending request to retrieve ObjectStorage API Server version information

Expand Down

0 comments on commit f282498

Please sign in to comment.