4141import  org .opensearch .common .io .stream .StreamOutput ;
4242import  org .opensearch .common .logging .DeprecationLogger ;
4343import  org .opensearch .common .settings .Settings ;
44+ import  org .opensearch .common .util .FeatureFlags ;
4445import  org .opensearch .core .common .Strings ;
4546import  org .opensearch .core .xcontent .ToXContentObject ;
4647import  org .opensearch .core .xcontent .XContentBuilder ;
@@ -150,7 +151,7 @@ public RestoreSnapshotRequest(StreamInput in) throws IOException {
150151        if  (in .getVersion ().onOrAfter (Version .V_2_7_0 )) {
151152            storageType  = in .readEnum (StorageType .class );
152153        }
153-         if  (in .getVersion ().onOrAfter (Version .V_2_9_0 )) {
154+         if  (FeatureFlags . isEnabled ( FeatureFlags . REMOTE_STORE ) &&  in .getVersion ().onOrAfter (Version .V_2_9_0 )) {
154155            sourceRemoteStoreRepository  = in .readOptionalString ();
155156        }
156157    }
@@ -174,7 +175,7 @@ public void writeTo(StreamOutput out) throws IOException {
174175        if  (out .getVersion ().onOrAfter (Version .V_2_7_0 )) {
175176            out .writeEnum (storageType );
176177        }
177-         if  (out .getVersion ().onOrAfter (Version .V_2_9_0 )) {
178+         if  (FeatureFlags . isEnabled ( FeatureFlags . REMOTE_STORE ) &&  out .getVersion ().onOrAfter (Version .V_2_9_0 )) {
178179            out .writeOptionalString (sourceRemoteStoreRepository );
179180        }
180181    }
@@ -614,6 +615,11 @@ public RestoreSnapshotRequest source(Map<String, Object> source) {
614615                }
615616
616617            } else  if  (name .equals ("source_remote_store_repository" )) {
618+                 if  (!FeatureFlags .isEnabled (FeatureFlags .REMOTE_STORE )) {
619+                     throw  new  IllegalArgumentException (
620+                         "Unsupported parameter "  + name  + ". Please enable remote store feature flag for this experimental feature" 
621+                     );
622+                 }
617623                if  (entry .getValue () instanceof  String ) {
618624                    setSourceRemoteStoreRepository ((String ) entry .getValue ());
619625                } else  {
@@ -664,7 +670,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
664670        if  (storageType  != null ) {
665671            storageType .toXContent (builder );
666672        }
667-         if  (sourceRemoteStoreRepository  != null ) {
673+         if  (FeatureFlags . isEnabled ( FeatureFlags . REMOTE_STORE ) &&  sourceRemoteStoreRepository  != null ) {
668674            builder .field ("source_remote_store_repository" , sourceRemoteStoreRepository );
669675        }
670676        builder .endObject ();
@@ -681,7 +687,7 @@ public boolean equals(Object o) {
681687        if  (this  == o ) return  true ;
682688        if  (o  == null  || getClass () != o .getClass ()) return  false ;
683689        RestoreSnapshotRequest  that  = (RestoreSnapshotRequest ) o ;
684-         return  waitForCompletion  == that .waitForCompletion 
690+         boolean   equals  =  waitForCompletion  == that .waitForCompletion 
685691            && includeGlobalState  == that .includeGlobalState 
686692            && partial  == that .partial 
687693            && includeAliases  == that .includeAliases 
@@ -694,27 +700,48 @@ public boolean equals(Object o) {
694700            && Objects .equals (indexSettings , that .indexSettings )
695701            && Arrays .equals (ignoreIndexSettings , that .ignoreIndexSettings )
696702            && Objects .equals (snapshotUuid , that .snapshotUuid )
697-             && Objects .equals (storageType , that .storageType )
698-             && Objects .equals (sourceRemoteStoreRepository , that .sourceRemoteStoreRepository );
703+             && Objects .equals (storageType , that .storageType );
704+         if  (FeatureFlags .isEnabled (FeatureFlags .REMOTE_STORE )) {
705+             equals  = Objects .equals (sourceRemoteStoreRepository , that .sourceRemoteStoreRepository );
706+         }
707+         return  equals ;
699708    }
700709
701710    @ Override 
702711    public  int  hashCode () {
703-         int  result  = Objects .hash (
704-             snapshot ,
705-             repository ,
706-             indicesOptions ,
707-             renamePattern ,
708-             renameReplacement ,
709-             waitForCompletion ,
710-             includeGlobalState ,
711-             partial ,
712-             includeAliases ,
713-             indexSettings ,
714-             snapshotUuid ,
715-             storageType ,
716-             sourceRemoteStoreRepository 
717-         );
712+         int  result ;
713+         if  (FeatureFlags .isEnabled (FeatureFlags .REMOTE_STORE )) {
714+             result  = Objects .hash (
715+                 snapshot ,
716+                 repository ,
717+                 indicesOptions ,
718+                 renamePattern ,
719+                 renameReplacement ,
720+                 waitForCompletion ,
721+                 includeGlobalState ,
722+                 partial ,
723+                 includeAliases ,
724+                 indexSettings ,
725+                 snapshotUuid ,
726+                 storageType ,
727+                 sourceRemoteStoreRepository 
728+             );
729+         } else  {
730+             result  = Objects .hash (
731+                 snapshot ,
732+                 repository ,
733+                 indicesOptions ,
734+                 renamePattern ,
735+                 renameReplacement ,
736+                 waitForCompletion ,
737+                 includeGlobalState ,
738+                 partial ,
739+                 includeAliases ,
740+                 indexSettings ,
741+                 snapshotUuid ,
742+                 storageType 
743+             );
744+         }
718745        result  = 31  * result  + Arrays .hashCode (indices );
719746        result  = 31  * result  + Arrays .hashCode (ignoreIndexSettings );
720747        return  result ;
0 commit comments