Skip to content

Commit

Permalink
fix: fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikRevich committed Nov 29, 2024
1 parent 06cbf1f commit e636884
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,13 @@ public void process() throws TemporateStoragePeriodRetrievalFailureException {
return;
}

StateService.getTransactionProcessorGuard().lock();

try {
repositoryExecutor.beginTransaction();
} catch (TransactionInitializationFailureException e) {
StateService.getTransactionProcessorGuard().unlock();

StateService.getTemporateStorageProcessorGuard().unlock();

telemetryService.increaseCloudServiceUploadRetries();
Expand All @@ -132,13 +136,17 @@ public void process() throws TemporateStoragePeriodRetrievalFailureException {
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

StateService.getTemporateStorageProcessorGuard().unlock();

logger.error(e2.getMessage());

return;
}

StateService.getTransactionProcessorGuard().unlock();

StateService.getTemporateStorageProcessorGuard().unlock();

logger.error(e1.getMessage());
Expand All @@ -162,13 +170,17 @@ public void process() throws TemporateStoragePeriodRetrievalFailureException {
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

StateService.getTemporateStorageProcessorGuard().unlock();

logger.error(e2.getMessage());

return;
}

StateService.getTransactionProcessorGuard().unlock();

StateService.getTemporateStorageProcessorGuard().unlock();

logger.error(e1.getMessage());
Expand All @@ -194,13 +206,17 @@ public void process() throws TemporateStoragePeriodRetrievalFailureException {
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

StateService.getTemporateStorageProcessorGuard().unlock();

logger.error(e2.getMessage());

return;
}

StateService.getTransactionProcessorGuard().unlock();

StateService.getTemporateStorageProcessorGuard().unlock();

logger.info(e1.getMessage());
Expand All @@ -217,13 +233,17 @@ public void process() throws TemporateStoragePeriodRetrievalFailureException {
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

StateService.getTemporateStorageProcessorGuard().unlock();

logger.error(e2.getMessage());

return;
}

StateService.getTransactionProcessorGuard().unlock();

StateService.getTemporateStorageProcessorGuard().unlock();

logger.error(e1.getMessage());
Expand All @@ -234,6 +254,8 @@ public void process() throws TemporateStoragePeriodRetrievalFailureException {
try {
repositoryExecutor.commitTransaction();
} catch (TransactionCommitFailureException e) {
StateService.getTransactionProcessorGuard().unlock();

StateService.getTemporateStorageProcessorGuard().unlock();

telemetryService.increaseCloudServiceUploadRetries();
Expand All @@ -243,6 +265,8 @@ public void process() throws TemporateStoragePeriodRetrievalFailureException {
return;
}

StateService.getTransactionProcessorGuard().unlock();

telemetryService.increaseCurrentCloudServiceUploads();

StateService.getTemporateStorageProcessorGuard().unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.objectstorage.model.*;
import com.objectstorage.repository.executor.RepositoryExecutor;
import com.objectstorage.repository.facade.RepositoryFacade;
import com.objectstorage.service.state.StateService;
import com.objectstorage.service.telemetry.TelemetryService;
import com.objectstorage.service.vendor.VendorFacade;
import com.objectstorage.service.vendor.common.VendorConfigurationHelper;
Expand Down Expand Up @@ -101,9 +102,13 @@ public ContentRetrievalResult retrieveContent(ValidationSecretsApplication valid
*/
public void apply(ContentApplication contentApplication, ValidationSecretsApplication validationSecretsApplication)
throws ProcessorContentApplicationFailureException {
StateService.getTransactionProcessorGuard().lock();

try {
repositoryExecutor.beginTransaction();
} catch (TransactionInitializationFailureException e) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentApplicationFailureException(e.getMessage());
}

Expand All @@ -114,9 +119,13 @@ public void apply(ContentApplication contentApplication, ValidationSecretsApplic
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentApplicationFailureException(e2.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentApplicationFailureException(e1.getMessage());
}

Expand All @@ -136,18 +145,26 @@ public void apply(ContentApplication contentApplication, ValidationSecretsApplic
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentApplicationFailureException(e2.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentApplicationFailureException(e1.getMessage());
}
}

try {
repositoryExecutor.commitTransaction();
} catch (TransactionCommitFailureException e) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentApplicationFailureException(e.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();
}

/**
Expand All @@ -159,9 +176,13 @@ public void apply(ContentApplication contentApplication, ValidationSecretsApplic
*/
public void withdraw(ValidationSecretsApplication validationSecretsApplication)
throws ProcessorContentWithdrawalFailureException {
StateService.getTransactionProcessorGuard().lock();

try {
repositoryExecutor.beginTransaction();
} catch (TransactionInitializationFailureException e) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentWithdrawalFailureException(e.getMessage());
}

Expand All @@ -174,9 +195,13 @@ public void withdraw(ValidationSecretsApplication validationSecretsApplication)
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentWithdrawalFailureException(e2.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentWithdrawalFailureException(e1.getMessage());
}

Expand All @@ -186,9 +211,13 @@ public void withdraw(ValidationSecretsApplication validationSecretsApplication)
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentWithdrawalFailureException(e2.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentWithdrawalFailureException(e1.getMessage());
}

Expand All @@ -208,18 +237,26 @@ public void withdraw(ValidationSecretsApplication validationSecretsApplication)
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentWithdrawalFailureException(e2.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentWithdrawalFailureException(e1.getMessage());
}
}

try {
repositoryExecutor.commitTransaction();
} catch (TransactionCommitFailureException e) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentWithdrawalFailureException(e.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();
}

/**
Expand All @@ -235,9 +272,13 @@ public void uploadObject(String location, InputStream file, ValidationSecretsApp
throws ProcessorContentUploadFailureException {
logger.info(String.format("Uploading content at '%s' location", location));

StateService.getTransactionProcessorGuard().lock();

try {
repositoryExecutor.beginTransaction();
} catch (TransactionInitializationFailureException e) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentUploadFailureException(e.getMessage());
}

Expand All @@ -253,9 +294,13 @@ public void uploadObject(String location, InputStream file, ValidationSecretsApp
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentUploadFailureException(e2.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentUploadFailureException(e1.getMessage());
}
}
Expand All @@ -266,17 +311,24 @@ public void uploadObject(String location, InputStream file, ValidationSecretsApp
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentUploadFailureException(e2.getMessage());
}
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentUploadFailureException(e1.getMessage());
}

try {
repositoryExecutor.commitTransaction();
} catch (TransactionCommitFailureException e) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentUploadFailureException(e.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();
}

/**
Expand Down Expand Up @@ -397,9 +449,13 @@ public void removeObject(
throws ProcessorContentRemovalFailureException {
logger.info(String.format("Removing content object of '%s' location", location));

StateService.getTransactionProcessorGuard().lock();

try {
repositoryExecutor.beginTransaction();
} catch (TransactionInitializationFailureException e) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e.getMessage());
}

Expand All @@ -412,9 +468,13 @@ public void removeObject(
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e2.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e1.getMessage());
}

Expand All @@ -426,9 +486,13 @@ public void removeObject(
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e2.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e1.getMessage());
}

Expand All @@ -445,9 +509,13 @@ public void removeObject(
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e2.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e1.getMessage());
}

Expand All @@ -462,9 +530,13 @@ public void removeObject(
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e2.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e1.getMessage());
}

Expand All @@ -478,9 +550,13 @@ public void removeObject(
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e2.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e1.getMessage());
}

Expand All @@ -493,9 +569,13 @@ public void removeObject(
try {
repositoryExecutor.rollbackTransaction();
} catch (TransactionRollbackFailureException e2) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e2.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e1.getMessage());
}
}
Expand All @@ -504,8 +584,12 @@ public void removeObject(
try {
repositoryExecutor.commitTransaction();
} catch (TransactionCommitFailureException e) {
StateService.getTransactionProcessorGuard().unlock();

throw new ProcessorContentRemovalFailureException(e.getMessage());
}

StateService.getTransactionProcessorGuard().unlock();
}

/**
Expand Down
Loading

0 comments on commit e636884

Please sign in to comment.