Package org.infinispan.manager

Examples of org.infinispan.manager.EmbeddedCacheManager


            }
            TestKey key = new TestKey(random.nextInt(KEY_RANGE));
            try {

                log.info("Submitting a task " + key);
                EmbeddedCacheManager cacheManager = cacheManagers.get(random.nextInt(cacheManagers.size()));
                DistributedExecutorService ispnExecutor = new DefaultExecutorService(cacheManager.getCache("serviceGroup"));

                Future<String> z = ispnExecutor.submit(new TransactionTask(), key);
                log.info("Task result=" + z.get());
            } catch (Exception ex) {
                log.warn("error during executing task " + key, ex);
View Full Code Here


        @Override
        public void run() {
            try {
                int size = cacheManagers.size();
                int index = random.nextInt(size);
                EmbeddedCacheManager cacheManager = cacheManagers.remove(index); //This is not thread safe, but should be ok for this test since the main thread is the only writrer to this list.


            log.info("Shutting down " + cacheManager.getAddress());
                cacheManager.stop();
            log.info("Shut down " + cacheManager.getAddress() + " complete");
            } catch (Exception e) {
            log.warn("Error during node removal", e);
            }
        }
View Full Code Here

        @Override
        public void run() {
            try {

            log.info("Starting a new cache manager");
                EmbeddedCacheManager cacheManager = buildCacheManager();
                cacheManager.getCache("serviceGroup");
                cacheManagers.addLast(cacheManager);

            } catch (Exception e) {
            log.warn("Error during node addition", e);
            }
View Full Code Here

      boolean created = file.createNewFile();
      file.deleteOnExit();

      assert created;

      final EmbeddedCacheManager cacheManager = initializeInfinispan(file);
      TestingUtil.withCacheManager(new CacheManagerCallable(cacheManager) {
         @Override
         public void call() {
            Directory directory = null;
            try {
               Cache cache = cacheManager.getCache();
               directory = DirectoryBuilder.newDirectoryInstance(cache, cache, cache, indexName).create();
            } finally {
               if(directory != null) {
                  try {
                     directory.close();
View Full Code Here

   }

   public void testLuceneCacheLoaderWithNonReadableDir() throws IOException {
      boolean isReadOff = rootDir.setReadable(false);
      if(isReadOff) {
         final EmbeddedCacheManager cacheManager = initializeInfinispan(rootDir);
         TestingUtil.withCacheManager(new CacheManagerCallable(cacheManager) {
            @Override
            public void call() {
               try {
                  Cache cache = cacheManager.getCache();
                  DirectoryBuilder.newDirectoryInstance(cache, cache, cache, indexName).create();
               } catch(Exception ex) {
                  assert ex instanceof CacheException;
               } finally {
                  rootDir.setReadable(true);
View Full Code Here

      }
   }

   public void testContainsKeyWithNoExistentRootDir() {
      final File rootDir = new File(new File(parentDir).getAbsoluteFile(), getIndexPathName() + "___");
      final EmbeddedCacheManager cacheManager = initializeInfinispan(rootDir);
      try {
         TestingUtil.withCacheManager(new CacheManagerCallable(cacheManager) {
            @Override
            public void call() {
               Cache cache = cacheManager.getCache();
               Directory directory = DirectoryBuilder.newDirectoryInstance(cache, cache, cache, indexName).create();

               try {
                  TestHelper.createIndex(rootDir, indexName, elementCount, true);
                  TestHelper.verifyOnDirectory(directory, elementCount, true);

                  String[] fileNamesFromIndexDir = TestHelper.getFileNamesFromDir(rootDir, indexName);

                  LuceneCacheLoader cacheLoader = (LuceneCacheLoader) TestingUtil.getFirstLoader(cacheManager.getCache());
                  for(String fileName : fileNamesFromIndexDir) {
                     FileCacheKey key = new FileCacheKey(indexName, fileName);
                     assert cacheLoader.contains(key);

                     //Testing non-existent keys with non-acceptable type
View Full Code Here

      TestHelper.verifyIndex(rootDir, "index-B", 20 * SCALE, false);
      verifyDirectory(rootDir, "index-B", 20 * SCALE, false);
   }

   private void verifyDirectory (final File rootDir, final String indexName, final int termsAdded, final boolean inverted) {
      final EmbeddedCacheManager cacheManager = initializeInfinispan(rootDir);

      TestingUtil.withCacheManager(new CacheManagerCallable(cacheManager) {
         public void call() {
            Cache<Object, Object> cache = cacheManager.getCache();
            Directory directory = DirectoryBuilder.newDirectoryInstance(cache, cache, cache, indexName).create();

            try {
               TestHelper.verifyOnDirectory(directory, termsAdded, inverted);
            } catch(Exception ex) {
View Full Code Here

                          "Should have thrown a CacheException reporting that no id has been set");
   }

   public void testForeignExternalizerConfigIdWins() throws Exception {
      GlobalConfiguration globalCfg = createForeignExternalizerGlobalConfig(3456);
      EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(globalCfg);
      try {
         cm.getCache();
         ExternalizerTable extTable = TestingUtil.extractExtTable(cm);
         assertEquals(3456, extTable.getExternalizerId(new IdViaBothObj()));
      } finally {
         cm.stop();
      }
   }
View Full Code Here

   }

   public void testForeignExternalizerMultiClassTypesViaSameExternalizer() {
      GlobalConfiguration globalCfg = GlobalConfiguration.getNonClusteredDefault();
      globalCfg.fluent().serialization().addAdvancedExternalizer(new MultiIdViaClassExternalizer());
      EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(globalCfg);
      try {
         cm.getCache();
         ExternalizerTable extTable = TestingUtil.extractExtTable(cm);
         assert 767 == extTable.getExternalizerId(new IdViaConfigObj());
         assert 767 == extTable.getExternalizerId(new IdViaAnnotationObj());
         assert 767 == extTable.getExternalizerId(new IdViaBothObj());
      } finally {
         cm.stop();
      }
   }
View Full Code Here

   }

   public void testForeignExternalizerMultiClassNameTypesViaSameExternalizer() {
      GlobalConfiguration globalCfg = GlobalConfiguration.getNonClusteredDefault();
      globalCfg.fluent().serialization().addAdvancedExternalizer(868, new MultiIdViaClassNameExternalizer());
      EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(globalCfg);
      try {
         cm.getCache();
         ExternalizerTable extTable = TestingUtil.extractExtTable(cm);
         assert 868 == extTable.getExternalizerId(new IdViaConfigObj());
         assert 868 == extTable.getExternalizerId(new IdViaAnnotationObj());
         assert 868 == extTable.getExternalizerId(new IdViaBothObj());
      } finally {
         cm.stop();
      }
   }
View Full Code Here

TOP

Related Classes of org.infinispan.manager.EmbeddedCacheManager

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.