/** * Checks if the configuration (and the transaction manager) is able to handle client transactions. */ private void validateConfiguration(AdvancedCache<byte[], byte[]> cache) { Configuration configuration = cache.getCacheConfiguration(); if (!configuration.transaction().transactionMode().isTransactional()) { throw log.expectedTransactionalCache(cache.getName()); } if (configuration.locking().isolationLevel() != IsolationLevel.REPEATABLE_READ) { throw log.unexpectedIsolationLevel(cache.getName()); } //TODO because of ISPN-7672, optimistic and total order transactions needs versions. however, versioning is currently broken if (configuration.transaction().lockingMode() == LockingMode.OPTIMISTIC || configuration.transaction().transactionProtocol() == TransactionProtocol.TOTAL_ORDER) { //no Log. see comment above throw new IllegalStateException( String.format("Cache '%s' cannot use Optimistic neither Total Order transactions.", cache.getName())); } }
private void createQueryInterceptorIfNeeded(ComponentRegistry cr, Configuration cfg, SearchIntegrator searchFactory) { QueryInterceptor queryInterceptor = cr.getComponent(QueryInterceptor.class); if (queryInterceptor == null) { queryInterceptor = buildQueryInterceptor(cfg, searchFactory, cr.getComponent(Cache.class)); // Interceptor registration not needed, core configuration handling // already does it for all custom interceptors - UNLESS the InterceptorChain already exists in the component registry! AsyncInterceptorChain ic = cr.getComponent(AsyncInterceptorChain.class); ConfigurationBuilder builder = new ConfigurationBuilder().read(cfg); InterceptorConfigurationBuilder interceptorBuilder = builder.customInterceptors().addInterceptor(); interceptorBuilder.interceptor(queryInterceptor); boolean txVersioned = Configurations.isTxVersioned(cfg); boolean isTotalOrder = cfg.transaction().transactionProtocol().isTotalOrder(); Class<? extends DDAsyncInterceptor> wrappingInterceptor = EntryWrappingInterceptor.class; if (txVersioned) { wrappingInterceptor = isTotalOrder ? TotalOrderVersionedEntryWrappingInterceptor.class : VersionedEntryWrappingInterceptor.class; } if (ic != null) ic.addInterceptorAfter(queryInterceptor, wrappingInterceptor); interceptorBuilder.after(wrappingInterceptor); if (ic != null) { cr.registerComponent(queryInterceptor, QueryInterceptor.class); cr.registerComponent(queryInterceptor, queryInterceptor.getClass().getName(), true); } cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors()); } }
assertEquals(TransactionProtocol.TOTAL_ORDER, c.transaction().transactionProtocol());