public void init() throws SipCacheException { executor = new ScheduledThreadPoolExecutor(1); final String configurationPath = configProperties.getProperty(INFINISPAN_CACHE_CONFIG_PATH, DEFAULT_FILE_CONFIG_PATH); if (configProperties.containsKey(INFINISPAN_CACHEMANAGER_JNDI_NAME)) { if (clusteredlogger.isLoggingEnabled(LogLevels.TRACE_INFO)) { clusteredlogger.logInfo( INFINISPAN_CACHEMANAGER_JNDI_NAME + " specified, trying to load Inifinispan CacheManager from JNDI " + configProperties.getProperty(INFINISPAN_CACHEMANAGER_JNDI_NAME)); } executor.scheduleAtFixedRate( new Runnable() { static final int MAX_ATTEMPTS = 30; int attempts = 0; public void run() { attempts++; // Init Infinispan CacheManager if (configProperties.containsKey(INFINISPAN_CACHEMANAGER_JNDI_NAME)) { try { InitialContext context = new InitialContext(); String cacheManagerJndiName = configProperties.getProperty(INFINISPAN_CACHEMANAGER_JNDI_NAME); cm = (CacheContainer) context.lookup(cacheManagerJndiName); if (clusteredlogger.isLoggingEnabled(LogLevels.TRACE_INFO)) { clusteredlogger.logInfo( "Found Inifinispan CacheManager: cacheManagerJndiName \"" + cacheManagerJndiName + "\" " + cm + " after attempts " + attempts); } executor.remove(this); executor.shutdown(); } catch (NamingException e) { // Inifinispan CacheManager JNDI lookup failed: could not get InitialContext or // lookup failed if (attempts > MAX_ATTEMPTS) { clusteredlogger.logError( "Inifinispan CacheManager JNDI lookup failed: could not get InitialContext or lookup failed after attempts " + attempts + " stopping there", e); executor.remove(this); executor.shutdown(); } else { if (clusteredlogger.isLoggingEnabled(LogLevels.TRACE_INFO)) { clusteredlogger.logInfo( "Inifinispan CacheManager JNDI lookup failed: could not get InitialContext or lookup failed after attempts " + attempts + ", retrying every second"); } } return; } } setupCacheStructures(); if (dialogCacheData != null) { dialogCacheData.setDialogs(dialogs); dialogCacheData.setAppDataMap(appDataMap); } if (serverTXCacheData != null) { serverTXCacheData.setServerTransactions(serverTransactions); serverTXCacheData.setServerTransactionsApp(serverTransactionsApp); } if (clientTXCacheData != null) { clientTXCacheData.setClientTransactions(clientTransactions); clientTXCacheData.setClientTransactionsApp(clientTransactionsApp); } } }, 0, 1, TimeUnit.SECONDS); } else { if (clusteredlogger.isLoggingEnabled(LogLevels.TRACE_INFO)) { clusteredlogger.logInfo( INFINISPAN_CACHEMANAGER_JNDI_NAME + " not specified, trying to load Inifinispan CacheManager from configuration file " + configurationPath); } try { if (cm == null) { cm = CacheManagerHolder.getManager(configurationPath); if (clusteredlogger.isLoggingEnabled(LogLevels.TRACE_INFO)) { clusteredlogger.logInfo( "Found Inifinispan CacheManager: configuration file from path \"" + configurationPath + "\" " + cm); } } setupCacheStructures(); } catch (IOException e) { clusteredlogger.logError( "Failed to init Inifinispan CacheManager: could not read configuration file from path \"" + configurationPath + "\"", e); } if (dialogCacheData != null) { dialogCacheData.setDialogs(dialogs); dialogCacheData.setAppDataMap(appDataMap); } if (serverTXCacheData != null) { serverTXCacheData.setServerTransactions(serverTransactions); serverTXCacheData.setServerTransactionsApp(serverTransactionsApp); } if (clientTXCacheData != null) { clientTXCacheData.setClientTransactions(clientTransactions); clientTXCacheData.setClientTransactionsApp(clientTransactionsApp); } } }
public void putServerTransaction(SIPServerTransaction serverTransaction) throws SipCacheException { if (serverTXCacheData != null) serverTXCacheData.putServerTransaction(serverTransaction); else throw new SipCacheException("No SIPServerTransactionCache"); }
public void removeServerTransaction(String txId) throws SipCacheException { if (serverTXCacheData != null) serverTXCacheData.removeServerTransaction(txId); else throw new SipCacheException("No SIPServerTransactionCache"); }
public SIPServerTransaction getServerTransaction(String txId) throws SipCacheException { if (serverTXCacheData != null) return serverTXCacheData.getServerTransaction(txId); else throw new SipCacheException("No SIPServerTransactionCache"); }