test_class.declarator: redisServer
test_class.modifier: private
test_class.original_string: private RedisServer redisServer;
test_class.type: RedisServer
test_class.var_name: redisServer
test_class.declarator: ioMonitorAdapter
test_class.modifier: private
test_class.original_string: private IOMonitorAdapter ioMonitorAdapter;
test_class.type: IOMonitorAdapter
test_class.var_name: ioMonitorAdapter
test_class.file: oak-segment-remote/src/test/java/org/apache/jackrabbit/oak/segment/remote/persistentcache/PersistentRedisCacheTest.java
test_class.identifier: PersistentRedisCacheTest
test_class.superclass: extends AbstractPersistentCacheTest
test_case.body: @Test
      public void testIOMonitor() throws IOException, InterruptedException {
  
          UUID segmentUUID = UUID.randomUUID();
          long msb = segmentUUID.getMostSignificantBits();
          long lsb = segmentUUID.getLeastSignificantBits();
  
          persistentCache.readSegment(msb, lsb, () -> null);
  
          //Segment not in cache, monitor methods not invoked
          verify(ioMonitorAdapter, never()).afterSegmentRead(any(), anyLong(), anyLong(), anyInt(), anyLong());
  
          persistentCache.writeSegment(msb, lsb, Buffer.wrap("segment_content".getBytes()));
  
          Thread.sleep(300);
  
          persistentCache.readSegment(msb, lsb, () -> null);
  
          verify(ioMonitorAdapter, times(1)).afterSegmentRead(any(), eq(msb), eq(lsb), anyInt(), anyLong());
      }
test_case.class_method_signature: PersistentRedisCacheTest.testIOMonitor()
test_case.full_signature: @Test public void testIOMonitor()
test_case.identifier: testIOMonitor
test_case.invocations: randomUUID getMostSignificantBits getLeastSignificantBits readSegment afterSegmentRead verify never any anyLong anyLong anyInt anyLong writeSegment wrap getBytes sleep readSegment afterSegmentRead verify times any eq eq anyInt anyLong
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testIOMonitor()
focal_class.declarator: logger = LoggerFactory.getLogger(PersistentRedisCache.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(PersistentRedisCache.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: DEFAULT_REDIS_CACHE_EXPIRE_SECONDS = 3600 * 24 * 2
focal_class.modifier: public static final
focal_class.original_string: public static final int DEFAULT_REDIS_CACHE_EXPIRE_SECONDS = 3600 * 24 * 2;
focal_class.type: int
focal_class.var_name: DEFAULT_REDIS_CACHE_EXPIRE_SECONDS
focal_class.declarator: NAME = "Segment Redis Cache"
focal_class.modifier: public static final
focal_class.original_string: public static final String NAME = "Segment Redis Cache";
focal_class.type: String
focal_class.var_name: NAME
focal_class.declarator: REDIS_PREFIX = "SEGMENT"
focal_class.modifier: private static final
focal_class.original_string: private static final String REDIS_PREFIX = "SEGMENT";
focal_class.type: String
focal_class.var_name: REDIS_PREFIX
focal_class.declarator: redisCacheIOMonitor
focal_class.modifier: private final
focal_class.original_string: private final IOMonitor redisCacheIOMonitor;
focal_class.type: IOMonitor
focal_class.var_name: redisCacheIOMonitor
focal_class.declarator: redisPool
focal_class.modifier: private
focal_class.original_string: private JedisPool redisPool;
focal_class.type: JedisPool
focal_class.var_name: redisPool
focal_class.declarator: setParamsWithExpire
focal_class.modifier: private
focal_class.original_string: private SetParams setParamsWithExpire;
focal_class.type: SetParams
focal_class.var_name: setParamsWithExpire
focal_class.file: oak-segment-remote/src/main/java/org/apache/jackrabbit/oak/segment/remote/persistentcache/PersistentRedisCache.java
focal_class.identifier: PersistentRedisCache
focal_class.class_method_signature: PersistentRedisCache.PersistentRedisCache(String redisHost, int redisPort, int redisExpireSeconds, int redisSocketTimeout,
              int redisConnectionTimeout, int redisMinConnections, int redisMaxConnections, int redisMaxTotalConnections,
              int redisDBIndex, IOMonitor redisCacheIOMonitor)
focal_class.full_signature: public  PersistentRedisCache(String redisHost, int redisPort, int redisExpireSeconds, int redisSocketTimeout,
              int redisConnectionTimeout, int redisMinConnections, int redisMaxConnections, int redisMaxTotalConnections,
              int redisDBIndex, IOMonitor redisCacheIOMonitor)
focal_class.identifier: PersistentRedisCache
focal_class.modifiers: public
focal_class.parameters: (String redisHost, int redisPort, int redisExpireSeconds, int redisSocketTimeout,
              int redisConnectionTimeout, int redisMinConnections, int redisMaxConnections, int redisMaxTotalConnections,
              int redisDBIndex, IOMonitor redisCacheIOMonitor)
focal_class.signature:  PersistentRedisCache(String redisHost, int redisPort, int redisExpireSeconds, int redisSocketTimeout,
              int redisConnectionTimeout, int redisMinConnections, int redisMaxConnections, int redisMaxTotalConnections,
              int redisDBIndex, IOMonitor redisCacheIOMonitor)
focal_class.class_method_signature: PersistentRedisCache.getCacheElementCount()
focal_class.full_signature: private long getCacheElementCount()
focal_class.identifier: getCacheElementCount
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getCacheElementCount()
focal_class.class_method_signature: PersistentRedisCache.getRedisMaxMemory()
focal_class.full_signature: private long getRedisMaxMemory()
focal_class.identifier: getRedisMaxMemory
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getRedisMaxMemory()
focal_class.class_method_signature: PersistentRedisCache.getCurrentWeight()
focal_class.full_signature: private long getCurrentWeight()
focal_class.identifier: getCurrentWeight
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getCurrentWeight()
focal_class.class_method_signature: PersistentRedisCache.getNumberOfEvictedKeys()
focal_class.full_signature: private long getNumberOfEvictedKeys()
focal_class.identifier: getNumberOfEvictedKeys
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getNumberOfEvictedKeys()
focal_class.class_method_signature: PersistentRedisCache.getRedisProperty(String section, String propertyName)
focal_class.full_signature: private String getRedisProperty(String section, String propertyName)
focal_class.identifier: getRedisProperty
focal_class.modifiers: private
focal_class.parameters: (String section, String propertyName)
focal_class.return: String
focal_class.signature: String getRedisProperty(String section, String propertyName)
focal_class.class_method_signature: PersistentRedisCache.readSegmentInternal(long msb, long lsb)
focal_class.full_signature: @Override protected Buffer readSegmentInternal(long msb, long lsb)
focal_class.identifier: readSegmentInternal
focal_class.modifiers: @Override protected
focal_class.parameters: (long msb, long lsb)
focal_class.return: Buffer
focal_class.signature: Buffer readSegmentInternal(long msb, long lsb)
focal_class.class_method_signature: PersistentRedisCache.containsSegment(long msb, long lsb)
focal_class.full_signature: @Override public boolean containsSegment(long msb, long lsb)
focal_class.identifier: containsSegment
focal_class.modifiers: @Override public
focal_class.parameters: (long msb, long lsb)
focal_class.return: boolean
focal_class.signature: boolean containsSegment(long msb, long lsb)
focal_class.class_method_signature: PersistentRedisCache.writeSegment(long msb, long lsb, Buffer buffer)
focal_class.full_signature: @Override public void writeSegment(long msb, long lsb, Buffer buffer)
focal_class.identifier: writeSegment
focal_class.modifiers: @Override public
focal_class.parameters: (long msb, long lsb, Buffer buffer)
focal_class.return: void
focal_class.signature: void writeSegment(long msb, long lsb, Buffer buffer)
focal_class.class_method_signature: PersistentRedisCache.cleanUp()
focal_class.full_signature: @Override public void cleanUp()
focal_class.identifier: cleanUp
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void cleanUp()
focal_class.superclass: extends AbstractPersistentCache
focal_method.body: @Override
      public void writeSegment(long msb, long lsb, Buffer buffer) {
          String segmentId = new UUID(msb, lsb).toString();
          Buffer bufferCopy = buffer.duplicate();
  
          Runnable task = () -> {
              if (writesPending.add(segmentId)) {
                  final ByteArrayOutputStream bos = new ByteArrayOutputStream();
                  try (WritableByteChannel channel = Channels.newChannel(bos); Jedis redis = redisPool.getResource()) {
                      while (bufferCopy.hasRemaining()) {
                          bufferCopy.write(channel);
                      }
                      final byte[] key = (REDIS_PREFIX + ":" + segmentId).getBytes();
                      redis.set(key, bos.toByteArray(), setParamsWithExpire);
                      cacheSize.addAndGet(bos.size());
                  } catch (Throwable t) {
                      logger.debug("Unable to write segment {} to cache: {}", segmentId, t.getMessage());
                  } finally {
                      writesPending.remove(segmentId);
                  }
              }
          };
  
          executor.execute(task);
      }
focal_method.class_method_signature: PersistentRedisCache.writeSegment(long msb, long lsb, Buffer buffer)
focal_method.full_signature: @Override public void writeSegment(long msb, long lsb, Buffer buffer)
focal_method.identifier: writeSegment
focal_method.invocations: toString duplicate add newChannel getResource hasRemaining write getBytes set toByteArray addAndGet size debug getMessage remove execute
focal_method.modifiers: @Override public
focal_method.parameters: (long msb, long lsb, Buffer buffer)
focal_method.return: void
focal_method.signature: void writeSegment(long msb, long lsb, Buffer buffer)