1919
2020import javax .inject .Inject ;
2121import javax .ws .rs .GET ;
22+ import javax .ws .rs .POST ;
2223import javax .ws .rs .Path ;
2324import javax .ws .rs .Produces ;
2425import javax .ws .rs .core .MediaType ;
2526import javax .ws .rs .core .Response ;
27+ import org .apache .hadoop .hdds .scm .server .OzoneStorageContainerManager ;
28+ import org .apache .hadoop .ozone .recon .scm .ReconStorageContainerManagerFacade ;
2629import org .apache .hadoop .ozone .recon .spi .OzoneManagerServiceProvider ;
2730
2831/**
3437public class TriggerDBSyncEndpoint {
3538
3639 private OzoneManagerServiceProvider ozoneManagerServiceProvider ;
40+ private ReconStorageContainerManagerFacade reconScm ;
3741
3842 @ Inject
3943 public TriggerDBSyncEndpoint (
40- OzoneManagerServiceProvider ozoneManagerServiceProvider ) {
44+ OzoneManagerServiceProvider ozoneManagerServiceProvider ,
45+ OzoneStorageContainerManager reconScm ) {
4146 this .ozoneManagerServiceProvider = ozoneManagerServiceProvider ;
47+ this .reconScm = (ReconStorageContainerManagerFacade ) reconScm ;
4248 }
4349
4450 @ GET
@@ -48,4 +54,30 @@ public Response triggerOMDBSync() {
4854 ozoneManagerServiceProvider .triggerSyncDataFromOMImmediately ();
4955 return Response .ok (isSuccess ).build ();
5056 }
57+
58+ @ POST
59+ @ Path ("scm/snapshot" )
60+ public Response triggerSCMDBSnapshotSync () {
61+ ReconStorageContainerManagerFacade .ScmDbSnapshotTriggerResponse response =
62+ reconScm .triggerScmDbSnapshotSync ();
63+ return response .isAccepted ()
64+ ? Response .accepted (response ).build ()
65+ : Response .status (Response .Status .CONFLICT ).entity (response ).build ();
66+ }
67+
68+ @ GET
69+ @ Path ("scm/snapshot/status" )
70+ public Response getSCMDBSnapshotSyncStatus () {
71+ return Response .ok (reconScm .getScmDbSnapshotSyncStatus ()).build ();
72+ }
73+
74+ @ POST
75+ @ Path ("scm/snapshot/cancel" )
76+ public Response cancelSCMDBSnapshotSync () {
77+ ReconStorageContainerManagerFacade .ScmDbSnapshotCancelResponse response =
78+ reconScm .cancelScmDbSnapshotSync ();
79+ return response .isCancelled ()
80+ ? Response .ok (response ).build ()
81+ : Response .status (Response .Status .CONFLICT ).entity (response ).build ();
82+ }
5183}
0 commit comments