Package com.tangosol.net

Examples of com.tangosol.net.NamedCache


   
    TxManager txman = TxLite.getManager();
    TxSession writer = txman.openReadWriteSession();
   
    TxSession reader = txman.openReadOnlySession();
    NamedCache rrA = reader.connect(cacheA);
    NamedCache rcA = txman.toReadCommited(cacheA);
    NamedCache dirtyA = txman.toDirtyRead(cacheA);
   
    NamedCache writerA = writer.connect(cacheA);
    writerA.put("A", "A");
    writerA.put("B", "B");
    writerA.put("C", "C");
    writerA.put("D", "D");
   
    FirstCharExtractor extractor = new FirstCharExtractor();
    Filter f = new EqualsFilter(extractor, "A");
   
    Assert.assertEquals("[A]", writerA.keySet(f).toString());
    Assert.assertEquals("[A]", dirtyA.keySet(f).toString());
    Assert.assertEquals("[]", rrA.keySet(f).toString());
    Assert.assertEquals("[]", rcA.keySet(f).toString());
   
    writer.commit();
   
    Assert.assertEquals("[A]", writerA.keySet(f).toString());
    Assert.assertEquals("[A]", dirtyA.keySet(f).toString());
    Assert.assertEquals("[]", rrA.keySet(f).toString());
    Assert.assertEquals("[A]", rcA.keySet(f).toString());
   
    reader.commit();
   
    Assert.assertEquals("[A]", writerA.keySet(f).toString());
    Assert.assertEquals("[A]", dirtyA.keySet(f).toString());
    Assert.assertEquals("[A]", rrA.keySet(f).toString());
    Assert.assertEquals("[A]", rcA.keySet(f).toString());
   
    writer.commit();
View Full Code Here


   
    TxManager txman = TxLite.getManager();
   
    TxSession rsession = txman.openReadOnlySession();
    TxSession wsession = txman.openReadWriteSession();
    NamedCache writeA = wsession.connect(cacheA);
    NamedCache rrA = rsession.connect(cacheA);
    NamedCache rcA = txman.toReadCommited(cacheA);

    Assert.assertThat(rrA.get("A"), IsNull.nullValue());
    Assert.assertThat(rcA.get("A"), IsNull.nullValue());
    Assert.assertThat(cacheA.get("A"), IsNull.nullValue());
    Assert.assertThat(writeA.get("A"), IsNull.nullValue());
   
    writeA.put("A", "A");
 
    Assert.assertThat(rrA.get("A"), IsNull.nullValue());
    Assert.assertThat(rcA.get("A"), IsNull.nullValue());
    Assert.assertThat((String)cacheA.get("A"), Is.is("A"));
    Assert.assertThat((String)writeA.get("A"), Is.is("A"));

    wsession.commit();
   
    Assert.assertThat(rrA.get("A"), IsNull.nullValue());
    Assert.assertThat((String)rcA.get("A"), Is.is("A"));

    rsession.commit();

    Assert.assertThat((String)rrA.get("A"), Is.is("A"));
  }
View Full Code Here

  public void testReadThenWrite() {
   
    TxManager txman = new TxManager(superviser);
   
    TxSession readSession = txman.openReadOnlySession();
    NamedCache readA = readSession.connect(cacheA);
    TxCacheWrapper dirtyA = new TxCacheWrapper(cacheA, new DirtyReadCacheAccessAdapter());
   
    TxSession writeSession = txman.openReadWriteSession();
    NamedCache writeA = writeSession.connect(cacheA);
   
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    Assert.assertThat(dirtyA.get("A"), IsNull.nullValue());
    Assert.assertThat(writeA.get("A"), IsNull.nullValue());
   
    writeA.put("A", "A");
   
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    Assert.assertThat((String)dirtyA.get("A"), Is.is("A"));
    Assert.assertThat((String)writeA.get("A"), Is.is("A"));
   
    writeSession.commit();
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    readSession.commit();
    Assert.assertThat((String)readA.get("A"), Is.is("A"));
View Full Code Here

    try {
     
      System.setProperty("tangosol.coherence.distributed.localstorage", "false");
      System.setProperty("tangosol.coherence.cacheconfig", "event-benchmark-cache-config.xml");
     
      final NamedCache out = CacheFactory.getCache("out-pool");
      final NamedCache in = CacheFactory.getCache("in-pool");
     
      out.clear();
      in.clear();
     
      long objectCount = 100000;
      int threadCount = 20;
     
      final Object value = new String[]{"ABC", "EFG", "123", "890", "QWERTY"};
     
      ExecutorService service = Executors.newFixedThreadPool(threadCount);

      Thread.sleep(500);
     
            System.out.println("Start test");
           
            long startTimestamp = System.nanoTime();
            for(long i = 0; i != objectCount; ++i) {
              final Object key = Long.valueOf(i);
              service.execute(new Runnable() {
          @Override
          public void run() {
            out.put(key, value);
          }
        });
            }
           
            while(true) {
              if (in.size() == objectCount) {
                break;
              }
              else {
                Thread.sleep(1);
              }
View Full Code Here

      System.setProperty("tangosol.coherence.cacheconfig", "tx-lite-test-cache-config.xml");
      System.setProperty("tangosol.coherence.distributed.localstorage", "false");
     
     
    try {
      final NamedCache cache = CacheFactory.getCache("t-objects");
      final ObjectGenerator<?, ?> generator = new SimpleDomainObjGenerator();
//      final ObjectGenerator<?, ?> generator = new SimpleDomainObjGenerator(100);
//      final ObjectGenerator<?, ?> generator = new SimpleDomainObjGenerator(400);
   
//      cache.addIndex(new ReflectionExtractor("getA0"), false, null);
//      cache.addIndex(new ReflectionExtractor("getAs"), false, null);     
     
//      System.out.println(CacheFactory.getClusterConfig().toString());
           
     
//      long objectCount = 1000000;
      long objectCount = 100000;
//      long objectCount = 200000;
//      long objectCount = 10000;
     
      long rangeStart = 1000000;
      long rangeFinish = 1000000 + objectCount;
     
      println("Loading " + objectCount + " objects ...");
      loadObjects(cache, generator, rangeStart, rangeFinish);     
     
      println("Loaded " + cache.size() + " objects");
      println("Key binary size: " + ExternalizableHelper.toBinary(generator.generate(1, 2).keySet().iterator().next()).length());
      println("Value binary size: " + ExternalizableHelper.toBinary(generator.generate(1, 2).values().iterator().next()).length());
      System.gc();
      println("Mem. usage " + ManagementFactory.getMemoryMXBean().getHeapMemoryUsage());
View Full Code Here

  public void testReadThenWriteThenRollback() {
   
    TxManager txman = new TxManager(superviser);
   
    TxSession readSession = txman.openReadOnlySession();
    NamedCache readA = readSession.connect(cacheA);
    TxCacheWrapper dirtyA = new TxCacheWrapper(cacheA, new DirtyReadCacheAccessAdapter());
   
    TxSession writeSession = txman.openReadWriteSession();
    NamedCache writeA = writeSession.connect(cacheA);
   
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    Assert.assertThat(dirtyA.get("A"), IsNull.nullValue());
    Assert.assertThat(writeA.get("A"), IsNull.nullValue());
   
    writeA.put("A", "A");
   
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    Assert.assertThat((String)dirtyA.get("A"), Is.is("A"));
    Assert.assertThat((String)writeA.get("A"), Is.is("A"));
   
    writeSession.rollback();
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    readSession.commit();
    Assert.assertThat(readA.get("A"), IsNull.nullValue());
    Assert.assertThat(dirtyA.get("A"), IsNull.nullValue());
    Assert.assertThat(writeA.get("A"), IsNull.nullValue());
    writeSession.rollback();
  }
View Full Code Here

  public static void main(String[] args) {
    try {

      System.setProperty("tangosol.coherence.cacheconfig", "event-benchmark-cache-config.xml");
     
      final NamedCache p1 = CacheFactory.getCache("pool-1");
      final NamedCache p2 = CacheFactory.getCache("pool-2");
      final NamedCache p3 = CacheFactory.getCache("pool-3");
      final NamedCache p4 = CacheFactory.getCache("pool-4");
     
      System.out.println("Storage node started");
     
      while(true) {
        Thread.sleep(100);
View Full Code Here

  public static void main(String[] args) {
    try {

      System.setProperty("tangosol.coherence.cacheconfig", "event-benchmark-cache-config.xml");
     
      final NamedCache out = CacheFactory.getCache("out-pool");
      final NamedCache in = CacheFactory.getCache("in-pool");
     
      out.addMapListener(new MapListener() {
     
        @Override
        public void entryUpdated(MapEvent evt) {
        }
     
        @Override
        public void entryInserted(MapEvent evt) {
          in.put(evt.getKey(), evt.getNewValue());
        }
     
        @Override
        public void entryDeleted(MapEvent evt) {
        }
View Full Code Here

      System.setProperty("tangosol.coherence.cacheconfig", "tx-lite-test-cache-config.xml");
      System.setProperty("tangosol.coherence.distributed.localstorage", "false");
     
     
    try {
      final NamedCache cache = CacheFactory.getCache("t-objects");
      final ObjectGenerator<?, ?> generator = new SimpleDomainObjGenerator();
//      final ObjectGenerator<?, ?> generator = new SimpleDomainObjGenerator(100);
//      final ObjectGenerator<?, ?> generator = new SimpleDomainObjGenerator(400);
   
//      cache.addIndex(new ReflectionExtractor("getA0"), false, null);
//      cache.addIndex(new ReflectionExtractor("getAs"), false, null);     
     
//      System.out.println(CacheFactory.getClusterConfig().toString());
           
     
//      long objectCount = 1000000;
      long objectCount = 100000;
//      long objectCount = 200000;
//      long objectCount = 10000;
     
      long rangeStart = 1000000;
      long rangeFinish = 1000000 + objectCount;
     
      println("Cache size: " + cache.size());
      println("Loading " + objectCount + " objects ...");
      loadObjects(cache, generator, rangeStart, rangeFinish);     
     
      println("Loaded " + cache.size() + " objects");
      println("Key binary size: " + ExternalizableHelper.toBinary(generator.generate(1, 2).keySet().iterator().next()).length());
      println("Value binary size: " + ExternalizableHelper.toBinary(generator.generate(1, 2).values().iterator().next()).length());
      System.gc();
      println("Mem. usage " + ManagementFactory.getMemoryMXBean().getHeapMemoryUsage());
View Full Code Here

 
  @Test
  public void singlePut() {
   
    // using default coherence-cache-config.xml
    NamedCache cache = CacheFactory.getCache("A");
    cache.clear();
   
    FlashUpdater fu = new FlashUpdater(cache);
    fu.put("A", "A");
    fu.commit();
   
    Assert.assertEquals("A", cache.get("A"));   
   
  }
View Full Code Here

TOP

Related Classes of com.tangosol.net.NamedCache

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.