@Test public void shouldNotReimportUnlessCacheTeiidHasExpired() throws Exception { mockTeiidInstance(); UnitOfWork sysTx = sysTx(); cachedTeiid = this.teiid.importContent(sysTx); Long origTimestamp = cachedTeiid.getTimestamp(sysTx); assertNotNull(origTimestamp); cachedTeiid = this.teiid.importContent(sysTx); Long newTimestamp = cachedTeiid.getTimestamp(sysTx); assertEquals(origTimestamp, newTimestamp); }
@Override public CachedTeiid importContent(UnitOfWork transaction) throws KException { ArgCheck.isNotNull( transaction, "transaction" ); ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); ArgCheck.isTrue(RepositoryImpl.isSystemTx(transaction), "transaction should be owned by " + Repository.SYSTEM_USER); KomodoObject teiidCache = getRepository().komodoTeiidCache(transaction); long expireThreshold = CachedTeiid.DEFAULT_TEIID_CACHE_THRESHOLD; Property expProp = teiidCache.getProperty(transaction, KomodoLexicon.TeiidCache.EXPIRATION_THRESHOLD); if (expProp == null) teiidCache.setProperty(transaction, KomodoLexicon.TeiidCache.EXPIRATION_THRESHOLD, expireThreshold); else expireThreshold = expProp.getLongValue(transaction); final String id = getName(transaction); if (teiidCache.hasChild(transaction, id)) { KomodoObject child = teiidCache.getChild(transaction, id); CachedTeiidImpl currCTeiid = new CachedTeiidImpl(transaction, getRepository(), child.getAbsolutePath()); Long timestamp = currCTeiid.getTimestamp(transaction); Long current = System.currentTimeMillis(); if ((timestamp + expireThreshold) > current) return currCTeiid; } ServerManager mgr = ServerManager.getInstance(getRepository()); CachedTeiid cachedTeiid = mgr.createCachedTeiid(transaction, this); TeiidInstance teiidInstance = getConnectedTeiidInstance(transaction); try { cachedTeiid.refreshVdbs(transaction, teiidInstance); cachedTeiid.refreshConnections(transaction, teiidInstance); cachedTeiid.refreshTranslators(transaction, teiidInstance); cachedTeiid.refreshDrivers(transaction, teiidInstance); cachedTeiid.refreshTemplates(transaction, teiidInstance); } catch (Exception ex) { throw new KException(ex); } return cachedTeiid; }
TeiidImpl extends RelationalChildRestrictedObject implements Teiid, TeiidParent, EventManager { @Override public CachedTeiid importContent(UnitOfWork transaction) throws KException { ArgCheck.isNotNull( transaction, "transaction" ); ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); ArgCheck.isTrue(RepositoryImpl.isSystemTx(transaction), "transaction should be owned by " + Repository.SYSTEM_USER); KomodoObject teiidCache = getRepository().komodoTeiidCache(transaction); long expireThreshold = CachedTeiid.DEFAULT_TEIID_CACHE_THRESHOLD; Property expProp = teiidCache.getProperty(transaction, KomodoLexicon.TeiidCache.EXPIRATION_THRESHOLD); if (expProp == null) teiidCache.setProperty(transaction, KomodoLexicon.TeiidCache.EXPIRATION_THRESHOLD, expireThreshold); else expireThreshold = expProp.getLongValue(transaction); final String id = getName(transaction); if (teiidCache.hasChild(transaction, id)) { KomodoObject child = teiidCache.getChild(transaction, id); CachedTeiidImpl currCTeiid = new CachedTeiidImpl(transaction, getRepository(), child.getAbsolutePath()); Long timestamp = currCTeiid.getTimestamp(transaction); Long current = System.currentTimeMillis(); if ((timestamp + expireThreshold) > current) return currCTeiid; } ServerManager mgr = ServerManager.getInstance(getRepository()); CachedTeiid cachedTeiid = mgr.createCachedTeiid(transaction, this); TeiidInstance teiidInstance = getConnectedTeiidInstance(transaction); try { cachedTeiid.refreshVdbs(transaction, teiidInstance); cachedTeiid.refreshConnections(transaction, teiidInstance); cachedTeiid.refreshTranslators(transaction, teiidInstance); cachedTeiid.refreshDrivers(transaction, teiidInstance); cachedTeiid.refreshTemplates(transaction, teiidInstance); } catch (Exception ex) { throw new KException(ex); } return cachedTeiid; } }
TeiidImpl extends RelationalChildRestrictedObject implements Teiid, TeiidParent, EventManager { @Override public CachedTeiid importContent(UnitOfWork transaction) throws KException { ArgCheck.isNotNull( transaction, "transaction" ); ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); ArgCheck.isTrue(RepositoryImpl.isSystemTx(transaction), "transaction should be owned by " + Repository.SYSTEM_USER); KomodoObject teiidCache = getRepository().komodoTeiidCache(transaction); long expireThreshold = CachedTeiid.DEFAULT_TEIID_CACHE_THRESHOLD; Property expProp = teiidCache.getProperty(transaction, KomodoLexicon.TeiidCache.EXPIRATION_THRESHOLD); if (expProp == null) teiidCache.setProperty(transaction, KomodoLexicon.TeiidCache.EXPIRATION_THRESHOLD, expireThreshold); else expireThreshold = expProp.getLongValue(transaction); final String id = getName(transaction); if (teiidCache.hasChild(transaction, id)) { KomodoObject child = teiidCache.getChild(transaction, id); CachedTeiidImpl currCTeiid = new CachedTeiidImpl(transaction, getRepository(), child.getAbsolutePath()); Long timestamp = currCTeiid.getTimestamp(transaction); Long current = System.currentTimeMillis(); if ((timestamp + expireThreshold) > current) return currCTeiid; } ServerManager mgr = ServerManager.getInstance(getRepository()); CachedTeiid cachedTeiid = mgr.createCachedTeiid(transaction, this); TeiidInstance teiidInstance = getConnectedTeiidInstance(transaction); try { cachedTeiid.refreshVdbs(transaction, teiidInstance); cachedTeiid.refreshConnections(transaction, teiidInstance); cachedTeiid.refreshTranslators(transaction, teiidInstance); cachedTeiid.refreshDrivers(transaction, teiidInstance); cachedTeiid.refreshTemplates(transaction, teiidInstance); } catch (Exception ex) { throw new KException(ex); } return cachedTeiid; } TeiidImpl( final UnitOfWork uow,
                      final Repository repository,
                      final String path ); }
TeiidImpl extends RelationalChildRestrictedObject implements Teiid, TeiidParent, EventManager { @Override public CachedTeiid importContent(UnitOfWork transaction) throws KException { ArgCheck.isNotNull( transaction, "transaction" ); ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); ArgCheck.isTrue(RepositoryImpl.isSystemTx(transaction), "transaction should be owned by " + Repository.SYSTEM_USER); KomodoObject teiidCache = getRepository().komodoTeiidCache(transaction); long expireThreshold = CachedTeiid.DEFAULT_TEIID_CACHE_THRESHOLD; Property expProp = teiidCache.getProperty(transaction, KomodoLexicon.TeiidCache.EXPIRATION_THRESHOLD); if (expProp == null) teiidCache.setProperty(transaction, KomodoLexicon.TeiidCache.EXPIRATION_THRESHOLD, expireThreshold); else expireThreshold = expProp.getLongValue(transaction); final String id = getName(transaction); if (teiidCache.hasChild(transaction, id)) { KomodoObject child = teiidCache.getChild(transaction, id); CachedTeiidImpl currCTeiid = new CachedTeiidImpl(transaction, getRepository(), child.getAbsolutePath()); Long timestamp = currCTeiid.getTimestamp(transaction); Long current = System.currentTimeMillis(); if ((timestamp + expireThreshold) > current) return currCTeiid; } ServerManager mgr = ServerManager.getInstance(getRepository()); CachedTeiid cachedTeiid = mgr.createCachedTeiid(transaction, this); TeiidInstance teiidInstance = getConnectedTeiidInstance(transaction); try { cachedTeiid.refreshVdbs(transaction, teiidInstance); cachedTeiid.refreshConnections(transaction, teiidInstance); cachedTeiid.refreshTranslators(transaction, teiidInstance); cachedTeiid.refreshDrivers(transaction, teiidInstance); cachedTeiid.refreshTemplates(transaction, teiidInstance); } catch (Exception ex) { throw new KException(ex); } return cachedTeiid; } TeiidImpl( final UnitOfWork uow,
                      final Repository repository,
                      final String path ); @Override KomodoType getTypeIdentifier(UnitOfWork uow); @Override TeiidInstance getTeiidInstance(TeiidVersion teiidVersion); @Override TeiidInstance getTeiidInstance(UnitOfWork uow); @Override QueryService getQueryService(UnitOfWork uow); @Override TeiidVersion getVersion( UnitOfWork uow ); @Override void setVersion(UnitOfWork uow, TeiidVersion version); @Override String getId( final UnitOfWork transaction ); @Override String getHost( UnitOfWork uow ); @Override void setHost(UnitOfWork uow, String host); @Override int getAdminPort( UnitOfWork uow ); @Override void setAdminPort( UnitOfWork uow, int port ); @Override String getAdminUser( UnitOfWork uow ); @Override void setAdminUser( UnitOfWork uow, String userName ); @Override String getAdminPassword( UnitOfWork uow ); @Override void setAdminPassword( UnitOfWork uow,
                                  String password ); @Override int getTypeId(); @Override boolean isAdminSecure( UnitOfWork uow ); @Override void setAdminSecure( UnitOfWork uow, boolean secure ); @Override int getJdbcPort( UnitOfWork uow ); @Override void setJdbcPort( UnitOfWork uow, int port ); @Override String getJdbcUsername( UnitOfWork uow ); @Override void setJdbcUsername( UnitOfWork uow, String userName ); @Override String getJdbcPassword( UnitOfWork uow ); @Override void setJdbcPassword( UnitOfWork uow, String password ); @Override boolean isJdbcSecure( UnitOfWork uow ); @Override void setJdbcSecure( UnitOfWork uow, boolean secure ); @Override boolean isConnected(UnitOfWork uow); @Override CachedTeiid importContent(UnitOfWork transaction); @Override boolean addListener( ExecutionConfigurationListener listener ); @Override void permitListeners( boolean enable ); @Override void notifyListeners( ExecutionConfigurationEvent event ); @Override boolean removeListener( ExecutionConfigurationListener listener ); @Override boolean isSound(); @Override String getHost(); @Override int getPort(); @Override Object getParentObject(); @Override String getId(); @Override String getName(); @Override String getUsername(); @Override String getPassword(); @Override boolean isSecure(); @Override EventManager getEventManager(); @Override int hashCode(); @Override boolean equals(Object obj); }
TeiidImpl extends RelationalChildRestrictedObject implements Teiid, TeiidParent, EventManager { @Override public CachedTeiid importContent(UnitOfWork transaction) throws KException { ArgCheck.isNotNull( transaction, "transaction" ); ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); ArgCheck.isTrue(RepositoryImpl.isSystemTx(transaction), "transaction should be owned by " + Repository.SYSTEM_USER); KomodoObject teiidCache = getRepository().komodoTeiidCache(transaction); long expireThreshold = CachedTeiid.DEFAULT_TEIID_CACHE_THRESHOLD; Property expProp = teiidCache.getProperty(transaction, KomodoLexicon.TeiidCache.EXPIRATION_THRESHOLD); if (expProp == null) teiidCache.setProperty(transaction, KomodoLexicon.TeiidCache.EXPIRATION_THRESHOLD, expireThreshold); else expireThreshold = expProp.getLongValue(transaction); final String id = getName(transaction); if (teiidCache.hasChild(transaction, id)) { KomodoObject child = teiidCache.getChild(transaction, id); CachedTeiidImpl currCTeiid = new CachedTeiidImpl(transaction, getRepository(), child.getAbsolutePath()); Long timestamp = currCTeiid.getTimestamp(transaction); Long current = System.currentTimeMillis(); if ((timestamp + expireThreshold) > current) return currCTeiid; } ServerManager mgr = ServerManager.getInstance(getRepository()); CachedTeiid cachedTeiid = mgr.createCachedTeiid(transaction, this); TeiidInstance teiidInstance = getConnectedTeiidInstance(transaction); try { cachedTeiid.refreshVdbs(transaction, teiidInstance); cachedTeiid.refreshConnections(transaction, teiidInstance); cachedTeiid.refreshTranslators(transaction, teiidInstance); cachedTeiid.refreshDrivers(transaction, teiidInstance); cachedTeiid.refreshTemplates(transaction, teiidInstance); } catch (Exception ex) { throw new KException(ex); } return cachedTeiid; } TeiidImpl( final UnitOfWork uow,
                      final Repository repository,
                      final String path ); @Override KomodoType getTypeIdentifier(UnitOfWork uow); @Override TeiidInstance getTeiidInstance(TeiidVersion teiidVersion); @Override TeiidInstance getTeiidInstance(UnitOfWork uow); @Override QueryService getQueryService(UnitOfWork uow); @Override TeiidVersion getVersion( UnitOfWork uow ); @Override void setVersion(UnitOfWork uow, TeiidVersion version); @Override String getId( final UnitOfWork transaction ); @Override String getHost( UnitOfWork uow ); @Override void setHost(UnitOfWork uow, String host); @Override int getAdminPort( UnitOfWork uow ); @Override void setAdminPort( UnitOfWork uow, int port ); @Override String getAdminUser( UnitOfWork uow ); @Override void setAdminUser( UnitOfWork uow, String userName ); @Override String getAdminPassword( UnitOfWork uow ); @Override void setAdminPassword( UnitOfWork uow,
                                  String password ); @Override int getTypeId(); @Override boolean isAdminSecure( UnitOfWork uow ); @Override void setAdminSecure( UnitOfWork uow, boolean secure ); @Override int getJdbcPort( UnitOfWork uow ); @Override void setJdbcPort( UnitOfWork uow, int port ); @Override String getJdbcUsername( UnitOfWork uow ); @Override void setJdbcUsername( UnitOfWork uow, String userName ); @Override String getJdbcPassword( UnitOfWork uow ); @Override void setJdbcPassword( UnitOfWork uow, String password ); @Override boolean isJdbcSecure( UnitOfWork uow ); @Override void setJdbcSecure( UnitOfWork uow, boolean secure ); @Override boolean isConnected(UnitOfWork uow); @Override CachedTeiid importContent(UnitOfWork transaction); @Override boolean addListener( ExecutionConfigurationListener listener ); @Override void permitListeners( boolean enable ); @Override void notifyListeners( ExecutionConfigurationEvent event ); @Override boolean removeListener( ExecutionConfigurationListener listener ); @Override boolean isSound(); @Override String getHost(); @Override int getPort(); @Override Object getParentObject(); @Override String getId(); @Override String getName(); @Override String getUsername(); @Override String getPassword(); @Override boolean isSecure(); @Override EventManager getEventManager(); @Override int hashCode(); @Override boolean equals(Object obj);  }