From: <tho...@us...> - 2010-10-13 20:44:34
|
Revision: 3792 http://bigdata.svn.sourceforge.net/bigdata/?rev=3792&view=rev Author: thompsonbry Date: 2010-10-13 20:44:28 +0000 (Wed, 13 Oct 2010) Log Message: ----------- 1. Added a cache miss handler to AbstractServiceCache#getService(UUID serviceUUID). This parallels the existing cache miss handling logic for other methods on this class. This addresses a problem where a test in BigdataFederationSparqlTest would sometimes fail due to a service not yet being in the JiniFederation's local cache. 2. Made _fed an instance field in BigdataFederationSparqlTest. All tests are now passing for me against two data services. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-jini/src/java/com/bigdata/service/jini/lookup/AbstractCachingServiceClient.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataFederationSparqlTest.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-jini/src/java/com/bigdata/service/jini/lookup/AbstractCachingServiceClient.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-jini/src/java/com/bigdata/service/jini/lookup/AbstractCachingServiceClient.java 2010-10-13 19:39:49 UTC (rev 3791) +++ branches/QUADS_QUERY_BRANCH/bigdata-jini/src/java/com/bigdata/service/jini/lookup/AbstractCachingServiceClient.java 2010-10-13 20:44:28 UTC (rev 3792) @@ -341,28 +341,102 @@ } - /** - * Return the {@link ServiceItem} associated with the {@link UUID}. - * - * @param serviceUUID - * The service {@link UUID}. - * - * @return The service item iff it is found in the cache and - * <code>null</code> otherwise. - */ + /** + * Return the {@link ServiceItem} associated with the {@link UUID}. -or- + * <code>null</code> if there is no such service in the cache and a remote + * lookup times out. + * + * @param serviceUUID + * The service {@link UUID}. + * + * @return The service item iff it is found in the cache and + * <code>null</code> otherwise. + */ final public ServiceItem getServiceItem(final UUID serviceUUID) { if (serviceUUID == null) throw new IllegalArgumentException(); - final ServiceItem serviceItem = serviceCache - .getServiceItemByID(JiniUtil.uuid2ServiceID(serviceUUID)); + final ServiceID serviceId = JiniUtil.uuid2ServiceID(serviceUUID); + ServiceItem serviceItem = serviceCache + .getServiceItemByID(serviceId); + + if (serviceItem == null) { + + if (log.isInfoEnabled()) + log.info("Cache miss."); + + serviceItem = handleCacheMiss(serviceId); + + if (serviceItem == null) { + + log.warn("No matching service."); + + return null; + + } + + } + return serviceItem; } /** + * Handles a cache miss by a remote query on the managed set of service + * registrars. + * + * @param filter + * The specific filter to be applied. + */ + final private ServiceItem handleCacheMiss(final ServiceID serviceId) { + + ServiceItem item = null; + + try { + + final ServiceTemplate template = new ServiceTemplate(serviceId, + null/* serviceTypes */, null/* attrSetTemplates */); + + item = serviceDiscoveryManager.lookup(template, filter, + cacheMissTimeout); + + } catch (RemoteException ex) { + + log.error(ex); + + return null; + + } catch (InterruptedException ex) { + + if (log.isInfoEnabled()) + log.info("Interrupted - no match."); + + return null; + + } + + if (item == null) { + + // Could not discover a matching service. + + log.warn("Could not discover matching service: serviceID=" + + serviceId + ", template=" + template + ", filter=" + + filter + ", timeout=" + cacheMissTimeout); + + return null; + + } + + if (log.isInfoEnabled()) + log.info("Found: " + item); + + return item; + + } + + /** * Return an array {@link ServiceItem}s for up to <i>maxCount</i> * discovered services which satisify the optional <i>filter</i>. * Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataFederationSparqlTest.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataFederationSparqlTest.java 2010-10-13 19:39:49 UTC (rev 3791) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataFederationSparqlTest.java 2010-10-13 20:44:28 UTC (rev 3792) @@ -128,15 +128,6 @@ throws Exception { super.tearDown () ; - /* - * @todo We should destroy the triple store here, but this is causing - * problems with tear down of the query while it is still running. Once - * that issue has been fixed, uncomment both the line to destroy the - * triple store and the line to shutdown the federation (the latter is - * really optional - it should be Ok to leave the federation up across - * the test runs, but then we will never take it down cleanly when the - * test suite is done. Again, that should be Ok.) - */ if (_ts != null) { _ts.destroy(); _ts = null; @@ -313,8 +304,11 @@ private static final Logger _logger = Logger.getLogger ( BigdataFederationSparqlTest.class ) ; - private static JiniFederation<Object> _fed = null ; - + /* + * Instance fields for the current test. + */ + + private JiniFederation<Object> _fed = null ; private ScaleOutTripleStore _ts = null ; private BigdataSail _sail = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |