Package org.infinispan.marshall.core

Examples of org.infinispan.marshall.core.MarshalledEntryImpl


      assertStoreAccess(0, 0, 1);

      cache.remove("no_such_key");
      assertStoreAccess(0, 1, 1);

      store.write(new MarshalledEntryImpl("a", "b", null, marshaller()));
      assert cache.remove("a").equals("b");
      assertStoreAccess(1, 1, 1);
   }
View Full Code Here


      assertStoreAccess(0, 0, 1);

      assert cache.replace("key", "value2").equals("value");
      assertStoreAccess(0, 0, 2);

      store.write(new MarshalledEntryImpl("a", "b", null, marshaller()));
      assert cache.replace("a", "c").equals("b");
      assertStoreAccess(1, 0, 3);

      assert cache.replace("no_such_key", "c") == null;
      assertStoreAccess(1, 1, 3);
View Full Code Here

   }

   private int insertData() {
      numEntries = 12000;
      for (int i = 0; i < numEntries; i++) {
         MarshalledEntryImpl me = new MarshalledEntryImpl(i, i, null, sm);
         store.write(me);
      }
      return numEntries;
   }
View Full Code Here

   public static Set<MarshalledEntry> allEntries(AdvancedLoadWriteStore cl) {
      return allEntries(cl, null);
   }

   public static MarshalledEntry marshalledEntry(InternalCacheEntry ice, StreamingMarshaller marshaller) {
      return new MarshalledEntryImpl(ice.getKey(), ice.getValue(), PersistenceUtil.internalMetadata(ice), marshaller);
   }
View Full Code Here

   public static <K, V> void writeToAllStores(K key, V value, Cache<K, V> cache) {
      AdvancedCache<K, V> advCache = cache.getAdvancedCache();
      PersistenceManager pm = advCache.getComponentRegistry().getComponent(PersistenceManager.class);
      StreamingMarshaller marshaller = advCache.getComponentRegistry().getCacheMarshaller();
      pm.writeToAllStores(new MarshalledEntryImpl(key, value, null, marshaller), BOTH);
   }
View Full Code Here

   public void testStoreSizeExceeded() throws Exception {
      assertStoreSize(0, 0);
      TestObjectStreamMarshaller sm = new TestObjectStreamMarshaller();
      try {
         store.write(new MarshalledEntryImpl(1, "v1", null, sm));
         store.write(new MarshalledEntryImpl(2, "v2", null, sm));
         assertStoreSize(1, 1);
      } finally {
         sm.stop();
      }
   }
View Full Code Here

      TestObjectStreamMarshaller sm = new TestObjectStreamMarshaller();
      PersistenceManager pm = null;
      try {
         MagicKey loaderKey = new MagicKey(cache2);
         String loaderValue = "loader-value";
         store.write(new MarshalledEntryImpl(loaderKey, loaderValue, null, sm));
         if (includeLoaderEntry) {
            originalValues.put(loaderKey, loaderValue);
         }
      } finally {
         sm.stop();
View Full Code Here

      final List<String> keys = new ArrayList<String>(NUM_KEYS);
      for (int j = 0; j < NUM_KEYS; j++) {
         String key = "key" + j;
         String value = key + "_value_" + j;
         keys.add(key);
         MarshalledEntryImpl entry = new MarshalledEntryImpl<String, String>(key, value, null, marshaller);
         store.write(entry);
      }

      final CountDownLatch stopLatch = new CountDownLatch(1);
      Future[] writeFutures = new Future[NUM_WRITER_THREADS];
View Full Code Here

      // Since entry sizes increase during each iteration, new entries won't fit in old free entries
      for (int i = 0; i < TIMES; i++) {
         for (int j = 0; j < NUM_KEYS; j++) {
            String key = "key" + j;
            String value = key + "_value_" + j + "_" + times("123456789_", i);
            MarshalledEntryImpl entry = new MarshalledEntryImpl<String, String>(key, value, null, marshaller);
            store.write(entry);
         }
         fileSizesWithoutPurge[i] = file.length();
      }

      // Clear the store so that we can start fresh again
      store.clear();

      ExecutorService executor = Executors.newSingleThreadExecutor();
      // Repeat the same logic as above
      // Just that, in this case we will call purge after each iteration
      for (int i = 0; i < TIMES; i++) {
         for (int j = 0; j < NUM_KEYS; j++) {
            String key = "key" + j;
            String value = key + "_value_" + j + "_" + times("123456789_", i);
            MarshalledEntryImpl entry = new MarshalledEntryImpl<String, String>(key, value, null, marshaller);
            store.write(entry);
         }
         // Call purge so that the entries are coalesced
         // Since this will merge and make bigger free entries available, new entries should get some free slots (unlike earlier case)
         // This should prove that the file size increases slowly
View Full Code Here

      final List<String> keys = new ArrayList<String>(NUM_KEYS);
      for (int j = 0; j < NUM_KEYS; j++) {
         String key = "key" + j;
         String value = key + "_value_" + j;
         keys.add(key);
         MarshalledEntryImpl entry = new MarshalledEntryImpl<String, String>(key, value, null, marshaller);
         store.write(entry);
      }

      // Do some reading/writing entries with random size
      final CountDownLatch stopLatch = new CountDownLatch(1);
      Future[] writeFutures = new Future[NUM_WRITER_THREADS];
      for (int i = 0; i < NUM_WRITER_THREADS; i++) {
         writeFutures[i] = fork(stopOnException(new WriteTask(store, marshaller, keys, stopLatch), stopLatch));
      }

      Future[] readFutures = new Future[NUM_READER_THREADS];
      for (int i = 0; i < NUM_READER_THREADS; i++) {
         readFutures[i] = fork(stopOnException(new ReadTask(store, keys, false, stopLatch), stopLatch));
      }

      stopLatch.await(TEST_DURATION_SECONDS, SECONDS);
      stopLatch.countDown();

      for (int i = 0; i < NUM_WRITER_THREADS; i++) {
         writeFutures[i].get();
      }
      for (int i = 0; i < NUM_READER_THREADS; i++) {
         readFutures[i].get();
      }

      File file = new File(location, CACHE_NAME + ".dat");
      long length1 = file.length();

      ExecutorService executor = Executors.newSingleThreadExecutor();
      store.purge(executor, null);
      // Give some time for the purge thread to finish
      MILLISECONDS.sleep(200);
      long length2 = file.length();

      // Again write entries with smaller size
      for (int j = 0; j < NUM_KEYS; j++) {
         String key = "key" + j;
         String value = key + "_value_" + j;
         keys.add(key);
         MarshalledEntryImpl entry = new MarshalledEntryImpl<String, String>(key, value, null, marshaller);
         store.write(entry);
      }

      store.purge(executor, null);
      // Give some time for the purge thread to finish
View Full Code Here

TOP

Related Classes of org.infinispan.marshall.core.MarshalledEntryImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.