private static SpaceURL[] prepareUrl(String[] urls, Properties customProperties) throws FinderException { //011205 Gershon - moved only to embedded space scenario and that is after loading //potential sys props from the custom properties. //JSpaceUtilities.setXMLImplSystemProps(); if (urls == null) throw new FinderException(new SpaceURLValidationException("Invalid space url - SpaceURL value must be supplied to this method.")); if (urls.length == 0) throw new FinderException(new SpaceURLValidationException("Invalid space url - Invalid array size of SpaceURLs " + urls.length)); SpaceURL[] spaceUrls = new SpaceURL[urls.length]; for (int i = 0; i < urls.length; i++) { try { spaceUrls[i] = parseURL(urls[i], customProperties); } catch (Exception ex) { if (i == urls.length - 1) throw new FinderException(ex.getMessage(), ex); } } return spaceUrls; }
/** * Main for standalone service tests */ public static void main(String[] args) { IJSpace space = null; try { space = (IJSpace) SpaceFinder.find(args[0]); } catch (FinderException e) { if (_logger.isLoggable(Level.SEVERE)) { _logger.log(Level.SEVERE, e.toString(), e); } } new JMSDurableSubService(space); }
public LookupDistributedTransactionManagerProvider(LookupTransactionManagerConfiguration config) throws TransactionException { try { LookupRequest request = LookupRequest.TransactionManager() .setServiceName(config.getLookupTransactionName()) .setLocators(config.getLookupTransactionLocators()) .setGroups(config.getLookupTransactionGroups()) .setTimeout(config.getLookupTransactionTimeout()); _transactionManager = (TransactionManager) LookupFinder.find(request); } catch (FinderException e) { throw new TransactionException(e.getMessage(), e); } }
protected Object findService(String url, Properties customProperties, LifeCycle lifeCycle, CredentialsProvider credentialsProvider) throws FinderException { if (url == null) throw new FinderException(new SpaceURLValidationException("Invalid space url - SpaceURL value must be supplied to this method.")); StringTokenizer st = new StringTokenizer(url, ";"); String[] urls = new String[st.countTokens()]; for (int i = 0; st.hasMoreTokens(); i++) urls[i] = st.nextToken(); SpaceURL[] spaceURLs = prepareUrl(urls, customProperties); Properties customProps = spaceURLs[spaceURLs.length - 1].getCustomProperties(); return findService(spaceURLs, customProps, lifeCycle, credentialsProvider); }
/** * Finds a space proxy at the specified URL. * * @param spaceURL the space URL * @return A space proxy instance * @throws JMSException if failed to find the space */ private IJSpace findSpace(String spaceURL) throws JMSException { IJSpace spaceProxy = null; try { spaceProxy = (IJSpace) SpaceFinder.find(spaceURL); if (_logger.isLoggable(Level.INFO)) { _logger.info("GSJMSAdmin.findSpace() Found space <" + spaceProxy.getName() + "> " + " using SpaceURL: " + spaceURL); } } catch (FinderException ex) { ResourceAllocationException rae = new ResourceAllocationException( "GSJMSAdmin - ERROR: Could not find space: " + spaceURL + ex.toString() + "\n"); rae.setLinkedException(ex); throw rae; } return spaceProxy; }
private static EvictionStrategy loadEvictionStrategy(SpaceConfigReader dcacheConfigReader) throws FinderException { String evictionStrategyName = dcacheConfigReader.getSpaceProperty( Constants.DCache.EVICTION_STRATEGY_PROP, Constants.DCache.EVICTION_STRATEGY_DEFUALT); try { EvictionStrategy evictionStrategy = (EvictionStrategy) ClassLoaderHelper.loadClass(evictionStrategyName).newInstance(); if (evictionStrategy instanceof AbstractEvictionStrategy) { // eviction quota int batchSize = dcacheConfigReader.getIntSpaceProperty( Constants.Engine.ENGINE_MEMORY_USAGE_EVICTION_BATCH_SIZE_PROP, Constants.Engine.ENGINE_MEMORY_USAGE_EVICTION_BATCH_SIZE_DEFAULT); ((AbstractEvictionStrategy) evictionStrategy).setBatchSize(batchSize); } return evictionStrategy; } catch (java.lang.ClassNotFoundException e) { Logger logger = Logger.getLogger(com.gigaspaces.logger.Constants.LOGGER_SPACEFINDER); if (logger.isLoggable(Level.WARNING)) logger.log(Level.WARNING, "Failed to find eviction strategy implementation using NoneEvictionStrategy.", e); return new NoneEvictionStrategy(); } catch (InstantiationException e) { throw new FinderException("Failed to create eviction strategy: " + evictionStrategyName, e); } catch (IllegalAccessException e) { throw new FinderException("Failed to create eviction strategy: " + evictionStrategyName, e); } }
public TransactionManager getDistributedTransactionManager() throws JMSException { if (dtm == null) { try { LookupRequest request = LookupRequest.TransactionManager() .setLocators(getSpaceURL().getProperty(SpaceURL.LOCATORS)) .setGroups(getSpaceURL().getProperty(SpaceURL.GROUPS)) .setTimeout(10 * 1000); dtm = (TransactionManager) LookupFinder.find(request); if (_logger.isLoggable(Level.FINE)) _logger.fine("Created Distributed Transaction Manager: " + dtm.toString()); } catch (FinderException fe) { if (_logger.isLoggable(Level.SEVERE)) _logger.log(Level.SEVERE, "Failed to create Exception Distributed Transaction Manager.", fe); JMSException e = new JMSException("FinderException: " + fe.toString()); e.setLinkedException(fe); throw e; } } return dtm; }
private static SpaceConfigReader getDCacheConfigReader(IJSpace space) throws FinderException { try { return JProperties.loadDCacheConfig((ISpaceProxy) space, space.getFinderURL().getCustomProperties(), Constants.DCache.SPACE_SUFFIX); } catch (SpaceInitializationException e) { throw new FinderException("Failed to initialize map configuration", e); } } }
_logger.log(Level.FINE, ex.toString(), ex);
protected Object findService(SpaceURL[] spaceURLs, Properties customProperties, LifeCycle lifeCycle, CredentialsProvider credentialsProvider) throws FinderException { if (spaceURLs == null || spaceURLs.length == 0) throw new FinderException(new SpaceURLValidationException("Invalid space url - SpaceURL value must be supplied to this method.")); Properties actualCustomProperties; for (int i = 0; i < spaceURLs.length; i++) { try { actualCustomProperties = customProperties != null ? customProperties : spaceURLs[i].getCustomProperties(); long timeout = Long.parseLong(spaceURLs[i].getProperty(SpaceURL.TIMEOUT, "-1")); return findService(spaceURLs[i], actualCustomProperties, lifeCycle, credentialsProvider, timeout, null /* lookupType */); } catch (FinderException ex) { if (i == spaceURLs.length - 1) throw ex; } } // Should not happen - Satisfy the compiler throw new FinderException("find finished without returning result."); }
public static Object find(SpaceURL spaceURL, CredentialsProvider credentialsProvider, long timeout, LookupType lookupType) throws FinderException { if (spaceURL == null) throw new FinderException(new SpaceURLValidationException("Invalid space url - SpaceURL value must be supplied to this method.")); return spaceFinder.findService(spaceURL, spaceURL.getCustomProperties(), null /*lifeCycle*/, credentialsProvider, timeout, lookupType); }
/** * <pre> * The general format for this URL is as follows: * Protocol://[host]:[port]/[container_name]/[space_name]?[query_string] * Protocol: [ RMI | JINI | JAVA ] * This method also supports multiple URLs separate by ";", * e.i. jini://localhost/containerName/SpaceName;jini://'*'/containerName/SpaceName; * It is useful when Jini URL for locating services on the network is not available. * If the first space URL is unavailable, SpaceFinder will try the next one until a live proxy * will be found. * If all URLs are unavailable this method throws FinderException * </pre> * * @param credentialsProvider credentials to be used for authentication against a remote secured * space; may be <code>null</code>. * @return Returns single Space or Container proxy. * @throws FinderException During finding space or container. */ public static Object find(SpaceURL spaceURL, CredentialsProvider credentialsProvider) throws FinderException { if (spaceURL == null) throw new FinderException(new SpaceURLValidationException("Invalid space url - SpaceURL value must be supplied to this method.")); long timeout = Long.parseLong(spaceURL.getProperty(SpaceURL.TIMEOUT, "-1")); return spaceFinder.findService(spaceURL, spaceURL.getCustomProperties(), null /*lifeCycle*/, credentialsProvider, timeout, null /* lookupType */); }
final String spaceName = url.getSpaceName(); if (JSpaceUtilities.isEmpty(spaceName)) throw new FinderException("Using java:// protocol SpaceName should be defined in SpaceFinder URL"); final String containerName = url.getContainerName(); if (JSpaceUtilities.isEmpty(containerName)) throw new FinderException("Using java:// protocol ContainerName should be defined in SpaceFinder URL");
throw e; } catch (Exception e) { throw new FinderException("Failed to find: " + url, e);
_logger.config(report); throw new FinderException(report, exception); } finally { if (sdm != null) {
public static IMap createMapWithCache(IJSpace space, Integer updateMode) throws FinderException { SpaceConfigReader dcacheConfigReader = getDCacheConfigReader(space); boolean putFirst = dcacheConfigReader.getBooleanSpaceProperty(Constants.DCache.PUT_FIRST_PROP, Constants.DCache.PUT_FIRST_DEFUALT); int compression = dcacheConfigReader.getIntSpaceProperty(Constants.DCache.COMPRESSION_PROP, Constants.DCache.COMPRESSION_DEFUALT); boolean versioned = dcacheConfigReader.getBooleanSpaceProperty(Constants.DCache.VERSIONED_PROP, Constants.DCache.VERSIONED_DEFUALT); int sizeLimit = dcacheConfigReader.getIntSpaceProperty(Constants.CacheManager.CACHE_MANAGER_SIZE_PROP, Constants.CacheManager.CACHE_MANAGER_SIZE_DEFAULT); EvictionStrategy evictionStrategy = loadEvictionStrategy(dcacheConfigReader); if (updateMode == null) updateMode = dcacheConfigReader.getIntSpaceProperty(Constants.DCache.UPDATE_MODE_PROP, Constants.DCache.UPDATE_MODE_DEFUALT); space.setOptimisticLocking(versioned); try { return new MapCache(space, versioned, updateMode, evictionStrategy, putFirst, sizeLimit, compression); } catch (RemoteException e) { throw new FinderException("Failed to create MapCache", e); } }