private void waitForVDBLoad(String vdbName) throws Exception { int timeoutInSecs = 30; // time out after 30secs long waitUntil = System.currentTimeMillis() + timeoutInSecs * 1000; if (timeoutInSecs < 0) { waitUntil = Long.MAX_VALUE; } boolean first = true; do { // Pause 5 sec before subsequent attempts if (!first) { try { Thread.sleep(5000); } catch (InterruptedException e) { break; } } else { first = false; } // Get the VDB using admin API ITeiidVdb vdb = getVdb(vdbName); // Determine if VDB is loading, or whether to wait if (vdb != null) { // return if no models in VDB, or VDB has errors (done loading) if (vdb.hasModels() || vdb.hasFailed() || vdb.wasRemoved() || vdb.isActive()) { refresh(); return; } // If the VDB Status is LOADING, but a validity error was found - return if (vdb.isLoading() && !vdb.getValidityErrors().isEmpty()) { refresh(); return; } } else { refresh(); return; } } while (System.currentTimeMillis() < waitUntil); refresh(); return; }