Codota Logo
NumericVersion.<init>
Code IndexAdd Codota to your IDE (free)

How to use
org.infinispan.container.versioning.NumericVersion
constructor

Best Java code snippets using org.infinispan.container.versioning.NumericVersion.<init> (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: org.infinispan/infinispan-core

@DataProvider(name = "sizeMatchData")
public Object[][] sizeMatchData() {
 return new Object[][] {
    { 10, 100, -1, -1, null },
    { 20, 313, -1, -1, null },
    { 10, 100, 4000, -1, null },
    { 20, 313, -1, 10000, null },
    { 10, 100, 4000, -1, new NumericVersion(1003)},
    { 20, 313, -1, 10000, new NumericVersion(81418) },
    { 10, 100, 4000, 738141, null},
    { 20, 313, 14141, 10000, new NumericVersion(8417) },
 };
}
origin: org.infinispan/infinispan-core

@Override
public Void apply(ReadWriteEntryView<K, String> rw) {
  rw.set("one", new MetaEntryVersion(new NumericVersion(100)));
  return null;
}
origin: org.infinispan/infinispan-core

@Test
public void testDuplicateParametersOnConstruction() {
 MetaEntryVersion versionParam1 = new MetaEntryVersion(new NumericVersion(100));
 MetaEntryVersion versionParam2 = new MetaEntryVersion(new NumericVersion(200));
 MetaParams metas = MetaParams.of(versionParam1, versionParam2);
 assertEquals(1, metas.size());
 assertEquals(Optional.of(new MetaEntryVersion(new NumericVersion(200))),
   metas.find(MetaEntryVersion.class));
}
origin: org.infinispan/infinispan-core

@Override
public ReadWriteEntryView<K, String> apply(ReadWriteEntryView<K, String> rw) {
  Optional<MetaEntryVersion> metaParam = rw.findMetaParam(MetaEntryVersion.class);
  metaParam.ifPresent(metaVersion -> {
   if (metaVersion.get().compareTo(new NumericVersion(version)) == EQUAL)
     rw.set("uno", new MetaEntryVersion(new NumericVersion(200)));
  });
  return rw;
}
origin: org.infinispan/infinispan-core

@Test
public void testDuplicateParametersOnAdd() {
 MetaEntryVersion versionParam1 = new MetaEntryVersion(new NumericVersion(100));
 MetaParams metas = MetaParams.of(versionParam1);
 assertEquals(1, metas.size());
 assertEquals(Optional.of(new MetaEntryVersion(new NumericVersion(100))),
   metas.find(MetaEntryVersion.class));
 MetaEntryVersion versionParam2 = new MetaEntryVersion(new NumericVersion(200));
 metas.add(versionParam2);
 assertEquals(1, metas.size());
 assertEquals(Optional.of(new MetaEntryVersion(new NumericVersion(200))),
   metas.find(MetaEntryVersion.class));
 MetaEntryVersion versionParam3 = new MetaEntryVersion(new NumericVersion(300));
 MetaEntryVersion versionParam4 = new MetaEntryVersion(new NumericVersion(400));
 metas.addMany(versionParam3, versionParam4);
 assertEquals(1, metas.size());
 assertEquals(Optional.of(new MetaEntryVersion(new NumericVersion(400))),
   metas.find(MetaEntryVersion.class));
}
origin: org.infinispan/infinispan-core

public void testPrimaryOwnerChangingDuringReplaceBasedOnMeta() throws Exception {
 // TODO: Move initial set and replace with meta logic to TestWriteOperation
 WriteOnlyMap<String, String> wo0 = wo(0);
 wo0.eval("testkey", wo -> wo.set("v0", new MetaEntryVersion(new NumericVersion(1))));
 doTest(TestWriteOperation.REPLACE_META_FUNCTIONAL);
}
origin: org.infinispan/infinispan-core

@Test
public void testAddFindMultipleMetaParams() {
 MetaParams metas = MetaParams.empty();
 metas.addMany(new MetaLifespan(1000), new MetaMaxIdle(1000), new MetaEntryVersion(new NumericVersion(12345)));
 assertFalse(metas.isEmpty());
 assertEquals(3, metas.size());
 Optional<MetaMaxIdle> maxIdle = metas.find(MetaMaxIdle.class);
 Optional<MetaEntryVersion> entryVersion = metas.find(MetaEntryVersion.class);
 assertEquals(Optional.of(new MetaMaxIdle(1000)), maxIdle);
 assertFalse(900 == maxIdle.get().get().longValue());
 assertEquals(new MetaEntryVersion(new NumericVersion(12345)), entryVersion.get());
 assertFalse(new MetaEntryVersion(new NumericVersion(23456)).equals(entryVersion.get()));
}
origin: org.infinispan/infinispan-core

@Override
protected Object perform(TestWriteOperation op, AdvancedCache<Object, Object> cache0, String key) {
 try {
   return super.perform(op, cache0, key);
 } catch (IllegalArgumentException e) {
   switch (op) {
    case REPLACE_META_FUNCTIONAL:
      return FunctionalTestUtils.await(rw(cache0).eval(key, "v1", (v, rw) -> {
         return rw.findMetaParam(MetaEntryVersion.class)
          .filter(ver -> ver.get().compareTo(new NumericVersion(1)) == EQUAL)
          .map(ver -> {
            rw.set(v, new MetaEntryVersion(new NumericVersion(2)));
            return true;
          }).orElse(false);
       }));
    default:
      throw new AssertionError("Unknown operation: " + op);
   }
 }
}
origin: org.infinispan/infinispan-core

public void testGenerateVersion() {
 NumericVersionGenerator vg = new NumericVersionGenerator().clustered(true);
 vg.resetCounter();
 TestAddress addr1 = new TestAddress(1);
 TestAddress addr2 = new TestAddress(2);
 TestAddress addr3 = new TestAddress(1);
 List<Address> members = Arrays.asList((Address)addr1, addr2, addr3);
 vg.calculateRank(addr2, members, 1);
 assertEquals(new NumericVersion(0x1000200000001L), vg.generateNew());
 assertEquals(new NumericVersion(0x1000200000002L), vg.generateNew());
 assertEquals(new NumericVersion(0x1000200000003L), vg.generateNew());
}
origin: org.infinispan/infinispan-core

public void testConditionalReplaceWithVersion() {
 final Integer key = 2;
 NumericVersion version = new NumericVersion(1);
 advCache.put(key, "v1", withVersion(version));
 NumericVersion newVersion = new NumericVersion(2);
 advCache.replace(key, "v1", "v2", withVersion(newVersion));
 CacheEntry cacheEntry = advCache.getCacheEntry(key);
 assertEquals(EQUAL, newVersion.compareTo(cacheEntry.getMetadata().version()));
}
origin: org.infinispan/infinispan-server-memcached

protected Object replaceIfUnmodified() {
 CacheEntry<byte[], byte[]> entry = cache.withFlags(Flag.SKIP_LISTENER_NOTIFICATION).getCacheEntry(key);
 if (entry != null) {
   byte[] prev = entry.getValue();
   NumericVersion streamVersion = new NumericVersion(params.streamVersion);
   if (entry.getMetadata().version().equals(streamVersion)) {
    byte[] v = createValue();
    // Generate new version only if key present and version has not changed, otherwise it's wasteful
    boolean replaced = cache.replace(key, prev, v, buildMetadata());
    if (replaced)
      return createSuccessResponse();
    else
      return createNotExecutedResponse();
   } else {
    return createNotExecutedResponse();
   }
 } else return createNotExistResponse();
}
origin: org.infinispan/infinispan-core

public void testReplaceWithVersion() {
 final Integer key = 7;
 NumericVersion version = new NumericVersion(1);
 advCache.put(key, "v1", withVersion(version));
 NumericVersion newVersion = new NumericVersion(2);
 advCache.replace(key, "v2", withVersion(newVersion));
 CacheEntry cacheEntry = advCache.getCacheEntry(key);
 assertEquals(EQUAL, newVersion.compareTo(cacheEntry.getMetadata().version()));
}
origin: org.infinispan/infinispan-core

@Test
public void testReplaceFindMultipleMetaParams() {
 MetaParams metas = MetaParams.empty();
 metas.addMany(new MetaLifespan(1000), new MetaMaxIdle(1000), new MetaEntryVersion(new NumericVersion(12345)));
 assertFalse(metas.isEmpty());
 assertEquals(3, metas.size());
 metas.addMany(new MetaLifespan(2000), new MetaMaxIdle(2000));
 assertFalse(metas.isEmpty());
 assertEquals(3, metas.size());
 assertEquals(Optional.of(new MetaMaxIdle(2000)), metas.find(MetaMaxIdle.class));
 assertEquals(Optional.of(new MetaLifespan(2000)), metas.find(MetaLifespan.class));
 assertEquals(Optional.of(new MetaEntryVersion(new NumericVersion(12345))),
   metas.find(MetaEntryVersion.class));
}
origin: org.infinispan/infinispan-core

public void testPutForExternalReadWithVersion() {
 final Integer key = 11;
 NumericVersion version = new NumericVersion(1);
 advCache.putForExternalRead(key, "v1", withVersion(version));
 CacheEntry cacheEntry = advCache.getCacheEntry(key);
 assertEquals(version, cacheEntry.getMetadata().version());
}
origin: org.infinispan/infinispan-core

public void testPutAsyncWithVersion() throws Exception {
 final Integer key = 4;
 NumericVersion version = new NumericVersion(1);
 Future<String> f = advCache.putAsync(key, "v1", withVersion(version));
 assertNotNull(f);
 assertFalse(f.isCancelled());
 assertNull(f.get());
 assertTrue(f.isDone());
 CacheEntry entry = advCache.getCacheEntry(key);
 assertEquals("v1", entry.getValue());
 assertEquals(EQUAL, version.compareTo(entry.getMetadata().version()));
}
origin: org.infinispan/infinispan-core

public void testPutWithVersion() {
 final Integer key = 1;
 NumericVersion version = new NumericVersion(1);
 advCache.put(key, "v1", withVersion(version));
 CacheEntry cacheEntry = advCache.getCacheEntry(key);
 assertEquals(EQUAL, version.compareTo(cacheEntry.getMetadata().version()));
}
origin: org.infinispan/infinispan-core

public void testPutForExternalReadInDecaratedCacheWithVersion() {
 final Integer key = 12;
 NumericVersion version = new NumericVersion(1);
 // Flag forces decorated cache, but doesn't affect processing
 AdvancedCache<Integer, String> decoratedCache = advCache.withFlags(Flag.SKIP_STATISTICS);
 decoratedCache.putForExternalRead(key, "v1", withVersion(version));
 CacheEntry cacheEntry = decoratedCache.getCacheEntry(key);
 assertEquals(version, cacheEntry.getMetadata().version());
}
origin: org.infinispan/infinispan-core

public void testPutIfAbsentWithVersion() {
 final Integer key = 3;
 NumericVersion version = new NumericVersion(1);
 assertEquals(null, advCache.putIfAbsent(key, "v1", withVersion(version)));
 CacheEntry cacheEntry = advCache.getCacheEntry(key);
 assertEquals(EQUAL, version.compareTo(cacheEntry.getMetadata().version()));
}
origin: org.infinispan/infinispan-core

public void testAllocatedAmountEqualWithVersionAndExpiration() {
 ConfigurationBuilder builder = new ConfigurationBuilder();
 builder.memory()
    .size(MemoryUnit.MEGABYTES.toBytes(20))
    .evictionType(EvictionType.MEMORY)
    .storageType(StorageType.OFF_HEAP);
 EmbeddedCacheManager manager = TestCacheManagerFactory.createCacheManager(builder);
 AdvancedCache<Object, Object> cache = manager.getCache().getAdvancedCache();
 cache.put("lifespan", 2, new EmbeddedMetadata.Builder()
    .lifespan(1, TimeUnit.MINUTES)
    .version(new NumericVersion(23)).build());
 cache.put("both", 2, new EmbeddedMetadata.Builder()
    .lifespan(1, TimeUnit.MINUTES)
    .maxIdle(1, TimeUnit.MINUTES)
    .version(new NumericVersion(23)).build());
 cache.put("maxidle", 2, new EmbeddedMetadata.Builder()
    .maxIdle(1, TimeUnit.MINUTES)
    .version(new NumericVersion(23)).build());
 OffHeapMemoryAllocator allocator = cache.getComponentRegistry().getComponent(
    OffHeapMemoryAllocator.class);
 BoundedOffHeapDataContainer container = (BoundedOffHeapDataContainer) getContainer(cache);
 assertEquals(allocator.getAllocatedAmount(), container.currentSize);
 cache.clear();
 assertEquals(allocator.getAllocatedAmount(), container.currentSize);
}
origin: org.infinispan/infinispan-core

public void testAllocatedAmountEqualWithVersion() {
 ConfigurationBuilder builder = new ConfigurationBuilder();
 builder.memory()
    .size(MemoryUnit.MEGABYTES.toBytes(20))
    .evictionType(EvictionType.MEMORY)
    .storageType(StorageType.OFF_HEAP);
 EmbeddedCacheManager manager = TestCacheManagerFactory.createCacheManager(builder);
 AdvancedCache<Object, Object> cache = manager.getCache().getAdvancedCache();
 cache.put(1, 2, new EmbeddedMetadata.Builder().version(new NumericVersion(23)).build());
 OffHeapMemoryAllocator allocator = cache.getComponentRegistry().getComponent(
    OffHeapMemoryAllocator.class);
 BoundedOffHeapDataContainer container = (BoundedOffHeapDataContainer) getContainer(cache);
 assertEquals(allocator.getAllocatedAmount(), container.currentSize);
 cache.clear();
 assertEquals(allocator.getAllocatedAmount(), container.currentSize);
}
org.infinispan.container.versioningNumericVersion<init>

Popular methods of NumericVersion

  • getVersion
  • compareTo

Popular in Java

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • onRequestPermissionsResult (Fragment)
  • getSystemService (Context)
  • Menu (java.awt)
  • Point (java.awt)
    A point representing a location in (x, y) coordinate space, specified in integer precision.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • BoxLayout (javax.swing)
  • JList (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now