5050import com .fasterxml .jackson .databind .DeserializationFeature ;
5151import com .fasterxml .jackson .databind .JavaType ;
5252import com .fasterxml .jackson .databind .ObjectMapper ;
53- import com .fasterxml .jackson .databind .type .CollectionType ;
5453import com .fasterxml .jackson .databind .type .SimpleType ;
54+ import com .redis .enterprise .Database .ModuleConfig ;
5555import com .redis .enterprise .rest .Action ;
5656import com .redis .enterprise .rest .Bootstrap ;
57- import com .redis .enterprise .rest .Command ;
5857import com .redis .enterprise .rest .CommandResponse ;
59- import com .redis .enterprise .rest .Database ;
60- import com .redis .enterprise .rest .Database .ModuleConfig ;
61- import com .redis .enterprise .rest .Module ;
58+ import com .redis .enterprise .rest .InstalledModule ;
6259import com .redis .enterprise .rest .ModuleInstallResponse ;
6360
6461public class Admin implements AutoCloseable {
@@ -163,6 +160,7 @@ private <T> T post(String path, Object request, Class<T> responseType) throws Pa
163160 private <T > T post (String path , Object request , JavaType responseType ) throws ParseException , IOException {
164161 HttpPost post = new HttpPost (uri (path ));
165162 String json = objectMapper .writeValueAsString (request );
163+ log .debug ("POST {}" , json );
166164 post .setEntity (new StringEntity (json ));
167165 return read (header (post ), responseType , HttpStatus .SC_OK );
168166 }
@@ -183,14 +181,14 @@ private <T> T read(ClassicHttpRequest request, JavaType type, int successCode) t
183181 throw new HttpResponseException (response .getCode (), response .getReasonPhrase () + " " + json );
184182 }
185183
186- public List <Module > getModules () throws ParseException , IOException {
187- CollectionType type = objectMapper . getTypeFactory (). constructCollectionType ( List . class , Module . class );
188- return get ( v1 ( MODULES ), type );
184+ public List <InstalledModule > getModules () throws ParseException , IOException {
185+ return get ( v1 ( MODULES ),
186+ objectMapper . getTypeFactory (). constructCollectionType ( List . class , InstalledModule . class ) );
189187 }
190188
191189 public Database createDatabase (Database database ) throws ParseException , IOException {
192- Map <String , Module > installedModules = new HashMap <>();
193- for (Module module : getModules ()) {
190+ Map <String , InstalledModule > installedModules = new HashMap <>();
191+ for (InstalledModule module : getModules ()) {
194192 installedModules .put (module .getName (), module );
195193 }
196194 for (ModuleConfig moduleConfig : database .getModules ()) {
@@ -201,7 +199,7 @@ public Database createDatabase(Database database) throws ParseException, IOExcep
201199 }
202200 Database response = post (v1 (BDBS ), database , Database .class );
203201 long uid = response .getUid ();
204- Awaitility .await ().until (() -> {
202+ Awaitility .await ().pollInterval ( Duration . ofSeconds ( 1 )). until (() -> {
205203 Command command = new Command ();
206204 command .setCommand ("PING" );
207205 try {
@@ -215,12 +213,11 @@ public Database createDatabase(Database database) throws ParseException, IOExcep
215213 }
216214
217215 public List <Database > getDatabases () throws ParseException , IOException {
218- CollectionType type = objectMapper .getTypeFactory ().constructCollectionType (List .class , Database .class );
219- return get (v1 (BDBS ), type );
216+ return get (v1 (BDBS ), objectMapper .getTypeFactory ().constructCollectionType (List .class , Database .class ));
220217 }
221218
222219 public void deleteDatabase (long uid ) {
223- Awaitility .await ().timeout ( Duration . ofSeconds ( 30 )). pollInterval (Duration .ofSeconds (1 )).until (() -> {
220+ Awaitility .await ().pollInterval (Duration .ofSeconds (1 )).until (() -> {
224221 try {
225222 delete (v1 (BDBS , String .valueOf (uid )), Database .class );
226223 return true ;
@@ -246,7 +243,7 @@ public ModuleInstallResponse installModule(String filename, InputStream inputStr
246243 ModuleInstallResponse response = read (post , SimpleType .constructUnsafe (ModuleInstallResponse .class ),
247244 HttpStatus .SC_ACCEPTED );
248245 baos .close ();
249- Awaitility .await ().timeout (Duration .ofSeconds ( 30 )).pollInterval (Duration .ofSeconds (3 )).until (() -> {
246+ Awaitility .await ().timeout (Duration .ofMinutes ( 1 )).pollInterval (Duration .ofSeconds (1 )).until (() -> {
250247 log .info ("Checking status of action {}" , response .getActionUid ());
251248 Action status = getAction (response .getActionUid ());
252249 if ("completed" .equals (status .getStatus ())) {
@@ -259,7 +256,7 @@ public ModuleInstallResponse installModule(String filename, InputStream inputStr
259256 }
260257
261258 public void waitForBoostrap () {
262- Awaitility .await ().pollInterval (Duration .ofSeconds (3 )).timeout (Duration .ofMinutes (1 ))
259+ Awaitility .await ().pollInterval (Duration .ofSeconds (1 )).timeout (Duration .ofMinutes (1 ))
263260 .until (() -> "idle" .equals (getBootstrap ().getStatus ().getState ()));
264261
265262 }
@@ -268,7 +265,7 @@ private Bootstrap getBootstrap() throws ParseException, IOException {
268265 return get (v1 (BOOTSTRAP ), Bootstrap .class );
269266 }
270267
271- public Action getAction (String uid ) throws ParseException , IOException {
268+ private Action getAction (String uid ) throws ParseException , IOException {
272269 return get (v1 (ACTIONS , uid ), Action .class );
273270 }
274271
0 commit comments