congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
EntryCache.insert
Code IndexAdd Tabnine to your IDE (free)

How to use
insert
method
in
org.apache.bookkeeper.mledger.impl.EntryCache

Best Java code snippets using org.apache.bookkeeper.mledger.impl.EntryCache.insert (Showing top 12 results out of 315)

origin: apache/pulsar

@Test(timeOut = 5000)
void testReadMissingMultiple() throws Exception {
  ReadHandle lh = getLedgerHandle();
  when(lh.getId()).thenReturn((long) 0);
  EntryCacheManager cacheManager = factory.getEntryCacheManager();
  EntryCache entryCache = cacheManager.getEntryCache(ml);
  byte[] data = new byte[10];
  entryCache.insert(EntryImpl.create(0, 0, data));
  entryCache.insert(EntryImpl.create(0, 2, data));
  entryCache.insert(EntryImpl.create(0, 5, data));
  entryCache.insert(EntryImpl.create(0, 8, data));
  final CountDownLatch counter = new CountDownLatch(1);
  entryCache.asyncReadEntry(lh, 0, 9, false, new ReadEntriesCallback() {
    public void readEntriesComplete(List<Entry> entries, Object ctx) {
      assertEquals(entries.size(), 10);
      counter.countDown();
    }
    public void readEntriesFailed(ManagedLedgerException exception, Object ctx) {
      Assert.fail("should not have failed");
    }
  }, null);
  counter.await();
}
origin: apache/pulsar

@Test(timeOut = 5000)
void testReadMissingMiddle() throws Exception {
  ReadHandle lh = getLedgerHandle();
  when(lh.getId()).thenReturn((long) 0);
  EntryCacheManager cacheManager = factory.getEntryCacheManager();
  EntryCache entryCache = cacheManager.getEntryCache(ml);
  byte[] data = new byte[10];
  entryCache.insert(EntryImpl.create(0, 0, data));
  entryCache.insert(EntryImpl.create(0, 1, data));
  entryCache.insert(EntryImpl.create(0, 8, data));
  entryCache.insert(EntryImpl.create(0, 9, data));
  final CountDownLatch counter = new CountDownLatch(1);
  entryCache.asyncReadEntry(lh, 0, 9, false, new ReadEntriesCallback() {
    public void readEntriesComplete(List<Entry> entries, Object ctx) {
      assertEquals(entries.size(), 10);
      counter.countDown();
    }
    public void readEntriesFailed(ManagedLedgerException exception, Object ctx) {
      Assert.fail("should not have failed");
    }
  }, null);
  counter.await();
}
origin: apache/pulsar

@Test
void doubleInsert() throws Exception {
  ManagedLedgerFactoryConfig config = new ManagedLedgerFactoryConfig();
  config.setMaxCacheSize(10);
  config.setCacheEvictionWatermark(0.8);
  factory = new ManagedLedgerFactoryImpl(bkc, bkc.getZkHandle(), config);
  EntryCacheManager cacheManager = factory.getEntryCacheManager();
  EntryCache cache1 = cacheManager.getEntryCache(ml1);
  assertEquals(cache1.insert(EntryImpl.create(1, 1, new byte[4])), true);
  assertEquals(cache1.insert(EntryImpl.create(1, 0, new byte[3])), true);
  assertEquals(cache1.getSize(), 7);
  assertEquals(cacheManager.getSize(), 7);
  assertEquals(cache1.insert(EntryImpl.create(1, 0, new byte[5])), false);
  assertEquals(cache1.getSize(), 7);
  assertEquals(cacheManager.getSize(), 7);
}
origin: apache/pulsar

@Test(timeOut = 5000)
void testReadMissingBefore() throws Exception {
  ReadHandle lh = getLedgerHandle();
  when(lh.getId()).thenReturn((long) 0);
  EntryCacheManager cacheManager = factory.getEntryCacheManager();
  EntryCache entryCache = cacheManager.getEntryCache(ml);
  byte[] data = new byte[10];
  for (int i = 3; i < 10; i++) {
    entryCache.insert(EntryImpl.create(0, i, data));
  }
  final CountDownLatch counter = new CountDownLatch(1);
  entryCache.asyncReadEntry(lh, 0, 9, false, new ReadEntriesCallback() {
    public void readEntriesComplete(List<Entry> entries, Object ctx) {
      assertEquals(entries.size(), 10);
      counter.countDown();
    }
    public void readEntriesFailed(ManagedLedgerException exception, Object ctx) {
      Assert.fail("should not have failed");
    }
  }, null);
  counter.await();
}
origin: apache/pulsar

@Test(timeOut = 5000)
void testReadMissingAfter() throws Exception {
  ReadHandle lh = getLedgerHandle();
  when(lh.getId()).thenReturn((long) 0);
  EntryCacheManager cacheManager = factory.getEntryCacheManager();
  EntryCache entryCache = cacheManager.getEntryCache(ml);
  byte[] data = new byte[10];
  for (int i = 0; i < 8; i++) {
    entryCache.insert(EntryImpl.create(0, i, data));
  }
  final CountDownLatch counter = new CountDownLatch(1);
  entryCache.asyncReadEntry(lh, 0, 9, false, new ReadEntriesCallback() {
    public void readEntriesComplete(List<Entry> entries, Object ctx) {
      assertEquals(entries.size(), 10);
      counter.countDown();
    }
    public void readEntriesFailed(ManagedLedgerException exception, Object ctx) {
      Assert.fail("should not have failed");
    }
  }, null);
  counter.await();
}
origin: apache/pulsar

@Test(timeOut = 5000)
void testReadWithError() throws Exception {
  final ReadHandle lh = getLedgerHandle();
  when(lh.getId()).thenReturn((long) 0);
  doAnswer((invocation) -> {
      CompletableFuture<LedgerEntries> future = new CompletableFuture<>();
      future.completeExceptionally(new BKNoSuchLedgerExistsException());
      return future;
    }).when(lh).readAsync(anyLong(), anyLong());
  EntryCacheManager cacheManager = factory.getEntryCacheManager();
  EntryCache entryCache = cacheManager.getEntryCache(ml);
  byte[] data = new byte[10];
  entryCache.insert(EntryImpl.create(0, 2, data));
  final CountDownLatch counter = new CountDownLatch(1);
  entryCache.asyncReadEntry(lh, 0, 9, false, new ReadEntriesCallback() {
    public void readEntriesComplete(List<Entry> entries, Object ctx) {
      Assert.fail("should not complete");
    }
    public void readEntriesFailed(ManagedLedgerException exception, Object ctx) {
      counter.countDown();
    }
  }, null);
  counter.await();
}
origin: apache/pulsar

@Test(timeOut = 5000)
void testRead() throws Exception {
  ReadHandle lh = getLedgerHandle();
  when(lh.getId()).thenReturn((long) 0);
  EntryCacheManager cacheManager = factory.getEntryCacheManager();
  EntryCache entryCache = cacheManager.getEntryCache(ml);
  byte[] data = new byte[10];
  for (int i = 0; i < 10; i++) {
    entryCache.insert(EntryImpl.create(0, i, data));
  }
  final CountDownLatch counter = new CountDownLatch(1);
  entryCache.asyncReadEntry(lh, 0, 9, false, new ReadEntriesCallback() {
    public void readEntriesComplete(List<Entry> entries, Object ctx) {
      assertEquals(entries.size(), 10);
      entries.forEach(e -> e.release());
      counter.countDown();
    }
    public void readEntriesFailed(ManagedLedgerException exception, Object ctx) {
      Assert.fail("should not have failed");
    }
  }, null);
  counter.await();
  // Verify no entries were read from bookkeeper
  verify(lh, never()).readAsync(anyLong(), anyLong());
}
origin: apache/pulsar

@Test
void cacheDisabled() throws Exception {
  ManagedLedgerFactoryConfig config = new ManagedLedgerFactoryConfig();
  config.setMaxCacheSize(0);
  config.setCacheEvictionWatermark(0.8);
  factory = new ManagedLedgerFactoryImpl(bkc, bkc.getZkHandle(), config);
  EntryCacheManager cacheManager = factory.getEntryCacheManager();
  EntryCache cache1 = cacheManager.getEntryCache(ml1);
  EntryCache cache2 = cacheManager.getEntryCache(ml2);
  assertTrue(cache1 instanceof EntryCacheManager.EntryCacheDisabled);
  assertTrue(cache2 instanceof EntryCacheManager.EntryCacheDisabled);
  cache1.insert(EntryImpl.create(1, 1, new byte[4]));
  cache1.insert(EntryImpl.create(1, 0, new byte[3]));
  assertEquals(cache1.getSize(), 0);
  assertEquals(cacheManager.getSize(), 0);
  cacheManager.mlFactoryMBean.refreshStats(1, TimeUnit.SECONDS);
  assertEquals(cacheManager.mlFactoryMBean.getCacheMaxSize(), 0);
  assertEquals(cacheManager.mlFactoryMBean.getCacheUsedSize(), 0);
  assertEquals(cacheManager.mlFactoryMBean.getCacheHitsRate(), 0.0);
  assertEquals(cacheManager.mlFactoryMBean.getCacheMissesRate(), 0.0);
  assertEquals(cacheManager.mlFactoryMBean.getCacheHitsThroughput(), 0.0);
  assertEquals(cacheManager.mlFactoryMBean.getNumberOfCacheEvictions(), 0);
  cache2.insert(EntryImpl.create(2, 0, new byte[1]));
  cache2.insert(EntryImpl.create(2, 1, new byte[1]));
  cache2.insert(EntryImpl.create(2, 2, new byte[1]));
  assertEquals(cache2.getSize(), 0);
  assertEquals(cacheManager.getSize(), 0);
}
origin: apache/pulsar

ml.entryCache.insert(entry);
entry.release();
origin: apache/pulsar

EntryCache cache2 = cacheManager.getEntryCache(ml2);
cache1.insert(EntryImpl.create(1, 1, new byte[4]));
cache1.insert(EntryImpl.create(1, 0, new byte[3]));
assertEquals(cacheManager.mlFactoryMBean.getNumberOfCacheEvictions(), 0);
cache2.insert(EntryImpl.create(2, 0, new byte[1]));
cache2.insert(EntryImpl.create(2, 1, new byte[1]));
cache2.insert(EntryImpl.create(2, 2, new byte[1]));
cache2.insert(EntryImpl.create(2, 3, new byte[1]));
origin: org.apache.pulsar/managed-ledger-original

ml.entryCache.insert(entry);
entry.release();
origin: com.yahoo.pulsar/managed-ledger

ml.entryCache.insert(entry);
entry.release();
org.apache.bookkeeper.mledger.implEntryCacheinsert

Javadoc

Insert an entry in the cache.

If the overall limit have been reached, this will triggered the eviction of other entries, possibly from other EntryCache instances

Popular methods of EntryCache

  • asyncReadEntry
    Read entry at given position from the cache or from bookkeeper.Get the entry data either from cache
  • clear
    Remove all the entries from the cache.
  • getSize
    Get the total size in bytes of all the entries stored in this cache.
  • invalidateAllEntries
    Remove from the cache all the entries belonging to a specific ledger.
  • invalidateEntries
    Remove from cache all the entries related to a ledger up to lastPosition included.
  • evictEntries
    Force the cache to drop entries to free space.
  • getName

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getContentResolver (Context)
  • setContentView (Activity)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • JFileChooser (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Option (scala)
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now