method2testcases
stringlengths
118
6.63k
### Question: EnvironmentServicesFinder { public CfJdbcService findJdbcService(String name) { if (StringUtils.isEmpty(name)) { return null; } try { return env.findJdbcServiceByName(name); } catch (IllegalArgumentException e) { return null; } } EnvironmentServicesFinder(); EnvironmentServicesFinder(CfJdbcEnv env); CfJd...
### Question: DatabaseFileService extends FileService { @Override public <T> T processFileContent(String space, String id, FileContentProcessor<T> fileContentProcessor) throws FileStorageException { try { return getSqlQueryExecutor().execute(getSqlFileQueryProvider().getProcessFileWithContentQuery(space, id, fileConten...
### Question: DatabaseFileService extends FileService { @Override public int deleteBySpaceAndNamespace(String space, String namespace) throws FileStorageException { return deleteFileAttributesBySpaceAndNamespace(space, namespace); } DatabaseFileService(DataSourceWithDialect dataSourceWithDialect); DatabaseFileService(...
### Question: DatabaseFileService extends FileService { @Override public int deleteBySpace(String space) throws FileStorageException { return deleteFileAttributesBySpace(space); } DatabaseFileService(DataSourceWithDialect dataSourceWithDialect); DatabaseFileService(String tableName, DataSourceWithDialect dataSourceWit...
### Question: DatabaseFileService extends FileService { @Override public boolean deleteFile(String space, String id) throws FileStorageException { return deleteFileAttribute(space, id); } DatabaseFileService(DataSourceWithDialect dataSourceWithDialect); DatabaseFileService(String tableName, DataSourceWithDialect dataS...
### Question: DatabaseFileService extends FileService { @Override public int deleteModifiedBefore(Date modificationTime) throws FileStorageException { return deleteFileAttributesModifiedBefore(modificationTime); } DatabaseFileService(DataSourceWithDialect dataSourceWithDialect); DatabaseFileService(String tableName, D...
### Question: AliOSSBlobStore extends BaseBlobStore { @Override public boolean blobExists(String container, String name) { return doOssOperation(oss -> oss.doesObjectExist(container, name)); } @Inject protected AliOSSBlobStore(AliOSSApi aliOSSApi, BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defau...
### Question: AliOSSBlobStore extends BaseBlobStore { @Override public String putBlob(String container, Blob blob) { return doOssOperation(oss -> { try { ObjectMetadata objectMetadata = createObjectMetadataFromBlob(blob); PutObjectRequest request = new PutObjectRequest(container, blob.getMetadata() .getProviderId(), bl...
### Question: AliOSSBlobStore extends BaseBlobStore { @Override public Blob getBlob(String container, String name, GetOptions options) { return doOssOperation(oss -> { GetObjectRequest req = toGetObjectRequest(container, name, options); OSSObject object = oss.getObject(req); return convertToBlob(object); }, false); } @...
### Question: AliOSSBlobStore extends BaseBlobStore { @Override public void removeBlob(String container, String name) { doOssOperation(oss -> { oss.deleteObject(container, name); return null; }); } @Inject protected AliOSSBlobStore(AliOSSApi aliOSSApi, BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> ...
### Question: AliOSSBlobStore extends BaseBlobStore { @Override public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) { return doOssOperation(oss -> { ListObjectsRequest request = toListObjectRequest(container, options); ObjectListing objectListing = oss.listObjects(request); Li...
### Question: FlowableHistoricDataCleaner implements Cleaner { @Override public void execute(Date expirationTime) { long deletedProcessesCount = 0; long expiredProcessesPages = getExpiredProcessesPageCount(expirationTime); for (int i = 0; i < expiredProcessesPages; i++) { deletedProcessesCount += deleteExpiredProcesses...
### Question: ProgressMessagesCleaner implements Cleaner { @Override public void execute(Date expirationTime) { LOGGER.debug(CleanUpJob.LOG_MARKER, format(Messages.DELETING_PROGRESS_MESSAGES_STORED_BEFORE_0, expirationTime)); int removedProgressMessages = progressMessageService.createQuery() .olderThan(expirationTime) ...
### Question: AbortedOperationsCleaner implements Cleaner { @Override public void execute(Date expirationTime) { Instant instant = Instant.now() .minus(30, ChronoUnit.MINUTES); List<HistoricOperationEvent> abortedOperations = historicOperationEventService.createQuery() .type(HistoricOperationEvent.EventType.ABORTED) .o...
### Question: TokensCleaner implements Cleaner { @Override public void execute(Date expirationTime) { Collection<OAuth2AccessToken> tokens = tokenStore.findTokensByClientId(SecurityUtil.CLIENT_ID); LOGGER.debug(CleanUpJob.LOG_MARKER, Messages.REMOVING_EXPIRED_TOKENS_FROM_TOKEN_STORE); int removedTokens = removeTokens(t...
### Question: FilesCleaner implements Cleaner { @Override public void execute(Date expirationTime) { LOGGER.debug(CleanUpJob.LOG_MARKER, format(Messages.DELETING_FILES_MODIFIED_BEFORE_0, expirationTime)); try { int removedOldFilesCount = fileService.deleteModifiedBefore(expirationTime); LOGGER.info(CleanUpJob.LOG_MARKE...
### Question: ProcessLogsCleaner implements Cleaner { @Override public void execute(Date expirationTime) { LOGGER.debug(CleanUpJob.LOG_MARKER, format(Messages.DELETING_PROCESS_LOGS_MODIFIED_BEFORE_0, expirationTime)); try { int deletedProcessLogs = processLogsPersistenceService.deleteModifiedBefore(expirationTime); LOG...
### Question: CleanUpJob implements Job { @Override public void execute(JobExecutionContext context) { LOGGER.info(LOG_MARKER, format(Messages.CLEAN_UP_JOB_STARTED_BY_APPLICATION_INSTANCE_0_AT_1, configuration.getApplicationInstanceIndex(), Instant.now())); Date expirationTime = computeExpirationTime(); LOGGER.info(LOG...
### Question: ErrorProcessListener extends AbstractFlowableEngineEventListener { @Override protected void jobExecutionFailure(FlowableEngineEntityEvent event) { if (event instanceof FlowableExceptionEvent) { handleWithCorrelationId(event, () -> handle(event, (FlowableExceptionEvent) event)); } } @Inject ErrorProcessLi...
### Question: ErrorProcessListener extends AbstractFlowableEngineEventListener { @Override protected void entityCreated(FlowableEngineEntityEvent event) { Object entity = event.getEntity(); if (entity instanceof DeadLetterJobEntity) { handleWithCorrelationId(event, () -> handle(event, (DeadLetterJobEntity) entity)); } ...
### Question: SetBeforeApplicationStopPhaseListener implements ExecutionListener { @Override public void notify(DelegateExecution execution) { VariableHandling.set(execution, Variables.SUBPROCESS_PHASE, SubprocessPhase.BEFORE_APPLICATION_STOP); } @Override void notify(DelegateExecution execution); }### Answer: @Test ...
### Question: SetBeforeApplicationStartPhaseListener implements ExecutionListener { @Override public void notify(DelegateExecution execution) { VariableHandling.set(execution, Variables.SUBPROCESS_PHASE, SubprocessPhase.BEFORE_APPLICATION_START); } @Override void notify(DelegateExecution execution); }### Answer: @Tes...
### Question: EndProcessListener extends AbstractProcessExecutionListener { @Override protected void notifyInternal(DelegateExecution execution) { if (isRootProcess(execution)) { eventHandler.handle(execution, Operation.State.FINISHED); } } @Inject EndProcessListener(OperationInFinalStateHandler eventHandler); }### ...
### Question: SetUndeployPhaseListener implements ExecutionListener { @Override public void notify(DelegateExecution execution) { VariableHandling.set(execution, Variables.PHASE, Phase.UNDEPLOY); } @Override void notify(DelegateExecution execution); }### Answer: @Test void testNotify() { setUndeployPhaseListener.noti...
### Question: SetAfterResumePhaseListener implements ExecutionListener { @Override public void notify(DelegateExecution execution) { VariableHandling.set(execution, Variables.PHASE, Phase.AFTER_RESUME); } @Override void notify(DelegateExecution execution); }### Answer: @Test void testNotify() { setResumePhaseListener...
### Question: ApplicationZipBuilder { public Path extractApplicationInNewArchive(ApplicationArchiveContext applicationArchiveContext) { Path appPath = null; try { appPath = createTempFile(); saveAllEntries(appPath, applicationArchiveContext); return appPath; } catch (Exception e) { FileUtils.cleanUp(appPath, LOGGER); t...
### Question: OperationInErrorStateHandler { HistoricOperationEvent.EventType toEventType(Throwable throwable) { return hasCause(throwable, ContentException.class) ? HistoricOperationEvent.EventType.FAILED_BY_CONTENT_ERROR : HistoricOperationEvent.EventType.FAILED_BY_INFRASTRUCTURE_ERROR; } @Inject OperationInErrorSta...
### Question: OperationInErrorStateHandler { public void handle(FlowableEngineEvent event, String errorMessage) { handle(event, HistoricOperationEvent.EventType.FAILED_BY_INFRASTRUCTURE_ERROR, errorMessage); } @Inject OperationInErrorStateHandler(ProgressMessageService progressMessageService, FlowableFacade flowableFa...
### Question: OperationInErrorStateHandler { private String getCurrentTaskId(FlowableEngineEvent flowableEngineEvent) { Execution currentExecutionForProcess = findCurrentExecution(flowableEngineEvent); return currentExecutionForProcess != null ? currentExecutionForProcess.getActivityId() : flowableFacade.getCurrentTask...
### Question: TopicEnsure { public boolean topicExists(TopicSpec spec, Integer timeOut) throws Exception { try { DescribeTopicsResult topicDescribeResult = adminClient.describeTopics( Collections.singletonList(spec.name()), new DescribeTopicsOptions().timeoutMs(timeOut) ); topicDescribeResult.all().get().get(spec.name(...
### Question: TopicEnsure { public boolean validateTopic(TopicSpec spec, int timeOut) throws Exception { DescribeTopicsResult topicDescribeResult = adminClient.describeTopics( Collections.singletonList(spec.name()), new DescribeTopicsOptions().timeoutMs(timeOut) ); TopicDescription topic = topicDescribeResult.all().get...
### Question: ClusterStatus { public static boolean isZookeeperReady(String zkConnectString, int timeoutMs) { log.debug("Check if Zookeeper is ready: {} ", zkConnectString); ZooKeeper zookeeper = null; try { CountDownLatch waitForConnection = new CountDownLatch(1); boolean isSaslEnabled = false; if (System.getProperty(...
### Question: ClusterStatus { public static boolean isKafkaReady( Map<String, String> config, int minBrokerCount, int timeoutMs ) { log.debug("Check if Kafka is ready: {}", config); AdminClient adminClient = AdminClient.create(new HashMap<String, Object>(config)); long begin = System.currentTimeMillis(); long remaining...
### Question: OnHeapCachingTier implements CachingTier<K, V> { @Override public V get(final K key, final Callable<V> source, final boolean updateStats) { if (updateStats) { getObserver.begin(); } Object cachedValue = backEnd.get(key); if (cachedValue == null) { if (updateStats) { getObserver.end(GetOutcome.MISS); } Fau...
### Question: CountBasedBackEnd extends ConcurrentHashMap<K, V> implements HeapCacheBackEnd<K, V> { @Override public V putIfAbsent(final K key, final V value) { final V v = super.putIfAbsent(key, value); if (v == null) { try { evictIfRequired(key, value); } catch (Throwable e) { LOG.warn("Caught throwable while evictin...
### Question: CacheManager { public Cache getCache(String name) throws IllegalStateException, ClassCastException { checkStatus(); Ehcache ehcache = ehcaches.get(name); return ehcache instanceof Cache ? (Cache) ehcache : null; } CacheManager(Configuration configuration); CacheManager(String configurationFileName); Cac...
### Question: Element implements Serializable, Cloneable { public final boolean isSerializable() { return isKeySerializable() && (value instanceof Serializable || value == null); } Element(final Serializable key, final Serializable value, final long version); Element(final Object key, final Object value, final long ve...
### Question: Element implements Serializable, Cloneable { @Override public final boolean equals(final Object object) { if (object == null || !(object instanceof Element)) { return false; } Element element = (Element) object; if (key == null || element.getObjectKey() == null) { return false; } return key.equals(element...
### Question: UpdateChecker extends TimerTask { public void checkForUpdate() { try { if (!Boolean.getBoolean("net.sf.ehcache.skipUpdateCheck")) { doCheck(); } } catch (Throwable t) { LOG.log(Level.WARNING, "Update check failed: " + t.toString()); } } @Override void run(); void checkForUpdate(); }### Answer: @Test pub...
### Question: BlockingCache implements Ehcache { protected Ehcache getCache() { return cache; } BlockingCache(final Ehcache cache, int numberOfStripes); BlockingCache(final Ehcache cache); String getName(); void setName(String name); boolean isExpired(Element element); @Override Object clone(); RegisteredEventListener...
### Question: CacheManager { public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "CacheManager already shutdown"); } return; } for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.va...
### Question: CacheManager { public static CacheManager create() throws CacheException { if (singleton != null) { return singleton; } synchronized (CacheManager.class) { if (singleton == null) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "Creating new CacheManager with default config"); } singleton = new Cac...
### Question: ApplicationEhCache extends DefaultApplication { @Override public Set<Class<?>> getClasses() { Set<Class<?>> s = new HashSet<Class<?>>(super.getClasses()); s.add(net.sf.ehcache.management.resource.services.ElementsResourceServiceImpl.class); s.add(net.sf.ehcache.management.resource.services.CacheStatisticS...
### Question: WANUtil { public void addCurrentOrchestrator(String cacheManagerName, String cacheName, String orchestrator) { final ConcurrentMap<String, Serializable> cacheConfigMap = getCacheConfigMap(cacheManagerName, cacheName); cacheConfigMap.put(WAN_CURRENT_ORCHESTRATOR, orchestrator); LOGGER.info("Added '{}' as o...
### Question: DfltSamplerRepositoryServiceV2 implements SamplerRepositoryServiceV2, EntityResourceFactoryV2, CacheManagerServiceV2, CacheServiceV2, AgentServiceV2, EventServiceV2 { @Override public ResponseEntityV2<CacheStatisticSampleEntityV2> createCacheStatisticSampleEntity(Set<String> cacheManagerNames, Set...
### Question: DfltSamplerRepositoryServiceV2 implements SamplerRepositoryServiceV2, EntityResourceFactoryV2, CacheManagerServiceV2, CacheServiceV2, AgentServiceV2, EventServiceV2 { @Override public void clearCache(String cacheManagerName, String cacheName) { cacheManagerSamplerRepoLock.readLock().lock(); Sample...
### Question: ConfigurationFactory { static Set extractPropertyTokens(String sourceDocument) { Set propertyTokens = new HashSet(); Pattern pattern = Pattern.compile("\\$\\{.+?\\}"); Matcher matcher = pattern.matcher(sourceDocument); while (matcher.find()) { String token = matcher.group(); propertyTokens.add(token); } r...
### Question: CacheManager { public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "CacheManager already shutdown"); } return; } for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.va...
### Question: CacheManager { public static CacheManager create() throws CacheException { if (singleton != null) { return singleton; } synchronized (CacheManager.class) { if (singleton == null) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "Creating new CacheManager with default config"); } singleton = new Cac...
### Question: CacheManager { public Cache getCache(String name) throws IllegalStateException, ClassCastException { checkStatus(); return (Cache) caches.get(name); } CacheManager(Configuration configuration); CacheManager(String configurationFileName); CacheManager(URL configurationURL); CacheManager(InputStream conf...
### Question: CacheManager { public void removeCache(String cacheName) throws IllegalStateException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } Ehcache cache = (Ehcache) ehcaches.remove(cacheName); if (cache != null && cache.getStatus().equals(Status.STATUS_ALIVE)) { cache.dispose(); ...
### Question: CacheManager { public void addCache(String cacheName) throws IllegalStateException, ObjectExistsException, CacheException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } if (ehcaches.get(cacheName) != null) { throw new ObjectExistsException("Cache " + cacheName + " already e...
### Question: SelfPopulatingCache extends BlockingCache { @Override public Element get(final Object key) throws LockTimeoutException { try { Element element = super.get(key); if (element == null) { Object value = factory.createEntry(key); element = makeAndCheckElement(key, value); put(element); } return element; } catc...
### Question: Statistics implements Serializable { public void clearStatistics() { if (cache == null) { throw new IllegalStateException("This statistics object no longer references a Cache."); } cache.clearStatistics(); } Statistics(Ehcache cache, int statisticsAccuracy, long cacheHits, long onDiskHits, long offHeapHit...
### Question: ValueModeHandlerSerialization implements ValueModeHandler { @Override public ElementData createElementData(Element element) { if(element.isEternal()) { return new EternalElementData(element); } else { return new NonEternalElementData(element); } } @Override Object getRealKeyObject(String portableKey); @O...
### Question: BlockingCache implements Ehcache { protected Ehcache getCache() { return cache; } BlockingCache(final Ehcache cache, int numberOfStripes); BlockingCache(final Ehcache cache); String getName(); void setName(String name); boolean isExpired(Element element); @Override Object clone(); RegisteredEventListener...
### Question: BlockingCache implements Ehcache { public Element getWithLoader(Object key, CacheLoader loader, Object loaderArgument) throws CacheException { throw new CacheException("This method is not appropriate for a Blocking Cache"); } BlockingCache(final Ehcache cache, int numberOfStripes); BlockingCache(final Eh...
### Question: CacheManager { public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { LOG.debug("CacheManager already shutdown"); return; } for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.values()) { if (cacheManagerPeerProvider != null...
### Question: CacheManager { public static CacheManager create() throws CacheException { if (singleton != null) { return singleton; } synchronized (CacheManager.class) { if (singleton == null) { LOG.debug("Creating new CacheManager with default config"); singleton = new CacheManager(); } else { LOG.debug("Attempting to...
### Question: CacheManager { public Cache getCache(String name) throws IllegalStateException, ClassCastException { checkStatus(); return (Cache) caches.get(name); } CacheManager(Configuration configuration); CacheManager(String configurationFileName); CacheManager(URL configurationURL); CacheManager(InputStream conf...
### Question: CacheManager { public void removeCache(String cacheName) throws IllegalStateException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } Ehcache cache = (Ehcache) ehcaches.remove(cacheName); if (cache != null && cache.getStatus().equals(Status.STATUS_ALIVE)) { cache.dispose(); ...
### Question: CacheManager { public void addCache(String cacheName) throws IllegalStateException, ObjectExistsException, CacheException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } if (ehcaches.get(cacheName) != null) { throw new ObjectExistsException("Cache " + cacheName + " already e...
### Question: CacheManager { public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { LOG.debug("CacheManager already shutdown"); return; } for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.values()) { if (cacheManagerPeerProvider != null...
### Question: PayloadUtil { public static byte[] gzip(byte[] ungzipped) { final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); try { final GZIPOutputStream gzipOutputStream = new GZIPOutputStream(bytes); gzipOutputStream.write(ungzipped); gzipOutputStream.close(); } catch (IOException e) { LOG.error("Could ...
### Question: CacheManager { public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { LOG.debug("CacheManager already shutdown"); return; } for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.values()) { if (cacheManagerPeerProvider != null...
### Question: CacheManager { public static CacheManager create() throws CacheException { if (singleton != null) { return singleton; } synchronized (CacheManager.class) { if (singleton == null) { LOG.debug("Creating new CacheManager with default config"); singleton = new CacheManager(); } else { LOG.debug("Attempting to...
### Question: CacheManager { public Cache getCache(String name) throws IllegalStateException, ClassCastException { checkStatus(); return (Cache) caches.get(name); } CacheManager(Configuration configuration); CacheManager(String configurationFileName); CacheManager(URL configurationURL); CacheManager(InputStream conf...
### Question: CacheManager { public void removeCache(String cacheName) throws IllegalStateException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } Ehcache cache = (Ehcache) ehcaches.remove(cacheName); if (cache != null && cache.getStatus().equals(Status.STATUS_ALIVE)) { cache.dispose(); ...
### Question: CacheManager { public void addCache(String cacheName) throws IllegalStateException, ObjectExistsException, CacheException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } if (ehcaches.get(cacheName) != null) { throw new ObjectExistsException("Cache " + cacheName + " already e...
### Question: ManagementService implements CacheManagerEventListener { public void init() throws CacheException { CacheManager cacheManager = new CacheManager(backingCacheManager); try { registerCacheManager(cacheManager); registerPeerProviders(); List caches = cacheManager.getCaches(); for (int i = 0; i < caches.size(...
### Question: ManagementService implements CacheManagerEventListener { private void registerCacheManager(CacheManager cacheManager) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { if (registerCacheManager) { mBeanServer.registerMBean(cacheManager, cacheManager.getObjectNa...
### Question: CacheManager { public void removeCache(String cacheName) throws IllegalStateException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } Ehcache cache = ehcaches.remove(cacheName); if (cache != null && cache.getStatus().equals(Status.STATUS_ALIVE)) { cache.dispose(); cacheManag...
### Question: CacheManager { public void addCache(String cacheName) throws IllegalStateException, ObjectExistsException, CacheException { checkStatus(); if (cacheName == null || cacheName.length() == 0) { return; } if (ehcaches.get(cacheName) != null) { throw new ObjectExistsException("Cache " + cacheName + " already e...
### Question: CacheKeySet implements Set<E> { public int size() { int size = 0; for (Collection keySet : keySets) { size += keySet.size(); } return size; } CacheKeySet(final Collection<E>... keySets); int size(); boolean isEmpty(); boolean contains(final Object o); Iterator<E> iterator(); Object[] toArray(); T[] toArra...
### Question: CacheKeySet implements Set<E> { public boolean contains(final Object o) { for (Collection keySet : keySets) { if (keySet.contains(o)) { return true; } } return false; } CacheKeySet(final Collection<E>... keySets); int size(); boolean isEmpty(); boolean contains(final Object o); Iterator<E> iterator(); Obj...
### Question: CacheKeySet implements Set<E> { public boolean isEmpty() { for (Collection keySet : keySets) { if (!keySet.isEmpty()) { return false; } } return true; } CacheKeySet(final Collection<E>... keySets); int size(); boolean isEmpty(); boolean contains(final Object o); Iterator<E> iterator(); Object[] toArray();...
### Question: OnHeapCachingTier implements CachingTier<K, V> { @Override public V get(final K key, final Callable<V> source, final boolean updateStats) { if (updateStats) { getObserver.begin(); } Object cachedValue = backEnd.get(key); if (cachedValue == null) { if (updateStats) { getObserver.end(GetOutcome.MISS); } Fau...
### Question: Segment extends ReentrantReadWriteLock { Element put(Object key, int hash, Element element, boolean onlyIfAbsent, boolean faulted) { boolean installed = false; DiskSubstitute encoded = disk.create(element); final long incomingHeapSize = onHeapPoolAccessor.add(key, encoded, NULL_HASH_ENTRY, cachePinned || ...
### Question: CopyStrategyHandler { boolean isCopyActive() { return copyOnRead || copyOnWrite; } CopyStrategyHandler(boolean copyOnRead, boolean copyOnWrite, ReadWriteCopyStrategy<Element> copyStrategy, ClassLoader loader); Element copyElementForReadIfNeeded(Element element); }### Answer: @Test public void given_no_co...
### Question: ValueModeHandlerSerialization implements ValueModeHandler { @Override public Element createElement(Object key, Serializable value) { return value == null ? null : ((ElementData) value).createElement(key); } @Override Object getRealKeyObject(String portableKey); @Override String createPortableKey(Object k...
### Question: CopyStrategyHandler { public Element copyElementForReadIfNeeded(Element element) { if (element == null) { return null; } if (copyOnRead && copyOnWrite) { return copyStrategy.copyForRead(element, loader); } else if (copyOnRead) { return copyStrategy.copyForRead(copyStrategy.copyForWrite(element, loader), l...
### Question: CopyStrategyHandler { Element copyElementForWriteIfNeeded(Element element) { if (element == null) { return null; } if (copyOnRead && copyOnWrite) { return copyStrategy.copyForWrite(element, loader); } else if (copyOnWrite) { return copyStrategy.copyForRead(copyStrategy.copyForWrite(element, loader), loade...
### Question: CopyStrategyHandler { Element copyElementForRemovalIfNeeded(Element element) { if (element == null) { return null; } if (copyOnRead && copyOnWrite) { return copyStrategy.copyForWrite(element, loader); } else { return element; } } CopyStrategyHandler(boolean copyOnRead, boolean copyOnWrite, ReadWriteCopySt...
### Question: ScheduledRefreshCacheExtension implements CacheExtension { @Override public void init() { if (config.getUniqueNamePart() != null) { this.name = "scheduledRefresh_" + underlyingCache.getCacheManager().getName() + "_" + underlyingCache.getName() + "_" + config.getUniqueNamePart(); } else { this.name = "sche...
### Question: ClusteredStore implements TerracottaStore, StoreListener { @Override public Element putIfAbsent(Element element) throws NullPointerException { String pKey = generatePortableKeyFor(element.getObjectKey()); ElementData value = valueModeHandler.createElementData(element); Serializable data = backend.putIfAbs...
### Question: TxCopyingCacheStore extends AbstractCopyingCacheStore<T> { private static <T extends Store> TxCopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyS...
### Question: MemoryLimitedCacheLoader implements BootstrapCacheLoader, Cloneable { protected boolean isInMemoryLimitReached(final Ehcache cache, final int loadedElements) { long maxBytesInMem; long maxElementsInMem; final boolean overflowToOffHeap = cache.getCacheConfiguration().isOverflowToOffHeap(); maxElementsInMem...
### Question: ClusteredStore implements TerracottaStore, StoreListener { @Override public Element putIfAbsent(Element element) throws NullPointerException { if (isEventual && !EVENTUAL_CAS_ENABLED) { throw new UnsupportedOperationException("CAS operations are not supported in eventual consistency mode, consider using a...
### Question: ClusteredStore implements TerracottaStore, StoreListener { @Override public boolean replace(Element old, Element element, ElementValueComparator comparator) throws NullPointerException, IllegalArgumentException { if (isEventual && !EVENTUAL_CAS_ENABLED) { throw new UnsupportedOperationException("CAS opera...
### Question: ClusteredStore implements TerracottaStore, StoreListener { @Override public Element removeElement(Element element, ElementValueComparator comparator) throws NullPointerException { if (isEventual && !EVENTUAL_CAS_ENABLED) { throw new UnsupportedOperationException("CAS operations are not supported in eventu...
### Question: ToolkitInstanceFactoryImpl implements ToolkitInstanceFactory { void addCacheEntityInfo(final String cacheName, final CacheConfiguration ehcacheConfig, String toolkitCacheName) { if (clusteredCacheManagerEntity == null) { throw new IllegalStateException(format("ClusteredCacheManger entity not configured fo...
### Question: ElementResource { @DELETE public void deleteElement() throws NotFoundException { LOG.debug("DELETE element {}", element); net.sf.ehcache.Cache ehcache = lookupCache(); if (element.equals("*")) { ehcache.removeAll(); } else { boolean removed = ehcache.remove(element); if (!removed) { throw new NotFoundExce...
### Question: ElementResource { @GET public Response getElement() throws NotFoundException { LOG.debug("GET element {}", element); net.sf.ehcache.Cache ehcache = lookupCache(); net.sf.ehcache.Element ehcacheElement = lookupElement(ehcache); Element localElement = new Element(ehcacheElement, uriInfo.getAbsolutePath().to...
### Question: CacheResource { @GET public Cache getCache() { LOG.debug("GET Cache {}" + cache); net.sf.ehcache.Cache ehcache = MANAGER.getCache(cache); if (ehcache == null) { throw new NotFoundException("Cache not found"); } String cacheAsString = ehcache.toString(); cacheAsString = cacheAsString.substring(0, cacheAsSt...
### Question: CacheResource { @DELETE public Response deleteCache() { LOG.debug("DELETE Cache {}" + cache); net.sf.ehcache.Cache ehcache = MANAGER.getCache(cache); Response response; if (ehcache == null) { throw new NotFoundException("Cache not found " + cache); } else { CacheManager.getInstance().removeCache(cache); r...
### Question: CachesResource { @GET public Caches getCaches() { LOG.info("GET Caches"); String[] cacheNames = MANAGER.getCacheNames(); List<Cache> cacheList = new ArrayList<Cache>(); for (String cacheName : cacheNames) { Ehcache ehcache = MANAGER.getCache(cacheName); URI cacheUri = uriInfo.getAbsolutePathBuilder().path...
### Question: ExplicitLockingCache implements Ehcache { public boolean putIfAbsent(Element element) { try { acquireWriteLockOnKey(element.getKey()); if (!isKeyInCache(element.getKey())) { this.put(element); return true; } return false; } finally { releaseWriteLockOnKey(element.getKey()); } } ExplicitLockingCache(Ehcach...
### Question: CacheWriterConfiguration implements Cloneable { public CacheWriterConfiguration writeMode(String writeMode) { setWriteMode(writeMode); return this; } @Override CacheWriterConfiguration clone(); void setWriteMode(String writeMode); CacheWriterConfiguration writeMode(String writeMode); CacheWriterConfigura...
### Question: CacheManager { public void shutdown() { synchronized (CacheManager.class) { if (status.equals(Status.STATUS_SHUTDOWN)) { LOG.debug("CacheManager already shutdown"); return; } for (CacheManagerPeerProvider cacheManagerPeerProvider : cacheManagerPeerProviders.values()) { if (cacheManagerPeerProvider != null...
### Question: DiskStorePathManager { public File getFile(String cacheName, String suffix) { return getFile(safeName(cacheName) + suffix); } DiskStorePathManager(String initialPath); DiskStorePathManager(); boolean resolveAndLockIfExists(String file); boolean isAutoCreated(); boolean isDefault(); synchronized void rele...