Commit b22a77e8 authored by Rustam Lotsmanenko (EPAM)'s avatar Rustam Lotsmanenko (EPAM)
Browse files

GONRG-864

Changes:
Docs
parent 7c4d941a
......@@ -4,77 +4,14 @@ Backup service provide a set of APIs to schedule backups for different Assets (
list registered Schedules, list available Backups, restore Asset state from Backup.
## Core Interfaces
###AssetBackupManager
```
void exportBackup(BackupSchedule backupSchedule);
BackupStamp importBackup(String backupId);
void deleteBackups(List<BackupStamp> currentDate);
```
Provide backup managing access to current Asset, based on AssetType of schedule
###SchedulerService
```
void addTaskToScheduler(BackupSchedule backupSchedule);
boolean cancelScheduledTask(BackupSchedule backupSchedule);
void updateTask(BackupSchedule backupSchedule);
```
Holds ThreadPool with scheduled tasks , and provide control
###BackupService
```
BackupSchedule submitBackupSchedule(BackupSchedule backupSchedule);
BackupSchedule updateBackupSchedule(BackupSchedule backupSchedule);
BackupSchedule getBackupSchedule(String id);
BackupStamp submitBackupImportRequest(BackupImportRequest importRequest);
List<BackupSchedule> listSchedules();
EnumMap<Asset, List<BackupStamp>> listBackups();
```
Main service interface
![Core](./docs/core.png)
## Data Repositories
![Repo](./docs/datarepos.png)
## Sequence diagram
Submit schedule workflow
###BackupStampRepository
```
EnumMap<Asset, List<BackupStamp>> findBackupStampsByTearDownBeforeCurrentDate(LocalDateTime toDate);
BackupStamp submitBackupStamp(BackupStamp backupStamp);
EnumMap<Asset, List<BackupStamp>> listAvailableBackupStamps();
void deleteBackupStamps(List<BackupStamp> currentDate);
BackupStamp findBackupByStampId(String backupStampId);
```
A backup stamp's repository ,
backup stamp is a model of created backup entity
which provide additional info about it : lifetime, location etc :
```
BackupStamp
String stampId;
String backupRepository;
Asset assetType;
LocalDateTime tearDownDate;
Map<String, String> assetContext;
```
###ScheduleRepository
```
List<BackupSchedule> listBackupSchedules();
BackupSchedule submitSchedule(BackupSchedule backupSchedule);
BackupSchedule updateSchedule(BackupSchedule backupSchedule);
BackupSchedule findByAssetContext(Map<String, String> assetContext);
BackupSchedule save(BackupSchedule backupSchedule);
BackupSchedule findById(String scheduleId);
```
## Diagram
![Diagram](./docs/schema.png)
![Diagram](./docs/sequence.png)
## GCP Implementation
All documentation for the GCP implementation of Backup service lives [here](./provider/backup-gcp/README.md)
......
......@@ -10,5 +10,5 @@ public interface AssetBackupManager {
BackupStamp importBackup(String backupId);
void deleteBackups(List<BackupStamp> currentDate);
void deleteBackups(List<BackupStamp> backupStamps);
}
@startuml
package backup.core <<Rectangle>> {
interface AssetBackupManager{
exportBackup(BackupSchedule backupSchedule);
importBackup(String backupId);
deleteBackups(List<BackupStamp> backupStamps);
}
note right
Provide backup managing access to current Asset,
based on AssetType of schedule
end note
interface SchedulerService{
addTaskToScheduler(BackupSchedule backupSchedule);
cancelScheduledTask(BackupSchedule backupSchedule);
updateTask(BackupSchedule backupSchedule);
}
note right
Holds ThreadPool with scheduled tasks ,
and provide control
end note
interface BackupService{
submitBackupSchedule(BackupSchedule backupSchedule);
updateBackupSchedule(BackupSchedule backupSchedule);
getBackupSchedule(String id);
submitBackupImportRequest(BackupImportRequest importRequest);
listSchedules();
listBackups();
}
class BackupServiceImpl implements BackupService
class SchedulerServiceImpl implements SchedulerService{
ThreadPoolTaskScheduler poolTaskScheduler
}
enum AssetType {
DATASTORE
ELASTIC
etc
}
package backup.gcp <<Rectangle>> {
class DatastoreBackupManager implements AssetBackupManager
class ElasticBackupManager implements AssetBackupManager
DatastoreBackupManager *-- AssetType
ElasticBackupManager *-- AssetType
}
@enduml
\ No newline at end of file
@startuml
package backup.core <<Rectangle>> {
interface BackupStampRepository{
findBackupStampsByTearDownBeforeCurrentDate(LocalDateTime toDate);
submitBackupStamp(BackupStamp backupStamp);
listAvailableBackupStamps();
deleteBackupStamps(List<BackupStamp> currentDate);
findBackupByStampId(String backupStampId);
}
note right
A backup stamp's repository ,
backup stamp is a model of created backup entity
which provide additional info about it : lifetime, location etc :
end note
interface ScheduleRepository{
listBackupSchedules();
submitSchedule(BackupSchedule backupSchedule);
updateSchedule(BackupSchedule backupSchedule);
findByAssetContext(Map<String, String> assetContext);
save(BackupSchedule backupSchedule);
findById(String scheduleId);
}
class BackupStamp{
String stampId;
String backupRepository;
Asset assetType;
LocalDateTime tearDownDate;
Map<String, String> assetContext;
}
class BackupSchedule{
private String scheduleId;
Asset assetType;
int backupPeriod;
boolean active;
int lifetime;
Map<String, String> assetContext;
}
package backup.gcp <<Rectangle>> {
class DatastoreBackupStampRepository implements BackupStampRepository
class DatastoreScheduleRepository implements ScheduleRepository
}
@enduml
\ No newline at end of file
@startuml
BackupSchedule -> BackupService : submit schedule
BackupService -> ScheduleRepository : save schedule
BackupService -> SchedulerService : add scheduled task
SchedulerService -> ScheduledTask
ScheduledTask --> ScheduledTask
ScheduledTask -> AssetManager : export backup
AssetManager -> BackupStampsRepository : submit backup stamp
@enduml
@startuml
actor User
User -> BackupService : submit schedule
activate BackupService
BackupService -> ScheduleRepository : save schedule
database DB
ScheduleRepository -> DB
BackupService -> Scheduler : add task
ScheduleRepository -> BackupService
BackupService -> User : saved schedule(with id)
deactivate BackupService
control ScheduledTask
activate ScheduledTask
Scheduler -> ScheduledTask
ScheduledTask -> ScheduledTask : run by schedule
activate AssetBackupManager
ScheduledTask -> AssetBackupManager : export()
database BackupStorage
AssetBackupManager -> BackupStorage : save backup
AssetBackupManager -> BackupStampRepository : save export stamp
BackupStampRepository -> DB
deactivate AssetBackupManager
deactivate ScheduledTask
User -> BackupService : list backup stamps
@enduml
activate BackupService
activate ScheduleRepository
ScheduleRepository -> BackupSchedule :saved schedule
database DB
ScheduleRepository -> ProviderStorage
BackupService -> ScheduleRepository : save schedule
BackupService -> SchedulerService : add scheduled task
SchedulerService -> ScheduledTask
alt successful case
activate ScheduledTask
ScheduledTask --> ScheduledTask
deactivate ScheduledTask
ScheduledTask -> AssetManager : export backup
AssetManager -> BackupStampsRepository : submit backup stamp
BackupStampsRepository -> ProviderStorage
\ No newline at end of file
......@@ -24,7 +24,7 @@ public class ElasticBackupManager implements AssetBackupManager {
}
@Override
public void deleteBackups(List<BackupStamp> currentDate) {
public void deleteBackups(List<BackupStamp> backupStamps) {
throw new UnsupportedOperationException();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment