Package com.gemstone.gemfire.cache

Examples of com.gemstone.gemfire.cache.Cache


    }
    logger.info("Starting Cache Server");
    @SuppressWarnings("resource")
    FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(path);
    context.registerShutdownHook();
    Cache cache = context.getBean(Cache.class);
    ManagementService ms = ManagementService.getExistingManagementService(cache);
    CacheServerMXBean cacheServerManager = ms.getLocalCacheServerMXBean(port);
    if (!cacheServerManager.isRunning()) {
      System.out.println("failed to start cache server ");
      System.exit(1);
View Full Code Here


  /* (non-Javadoc)
   * @see com.gemstone.gemfire.cache.execute.Function#execute(com.gemstone.gemfire.cache.execute.FunctionContext)
   */
  @Override
  public void execute(FunctionContext functionContext) {
    Cache cache = CacheFactory.getAnyInstance();
    List<String> regionNames = new ArrayList<String>();
    for (Region<?, ?> region: cache.rootRegions()) {
      regionNames.add(region.getName());
    }
   
    functionContext.getResultSender().lastResult(regionNames);
  }
View Full Code Here

    assertTrue(factoryBean.isNotPersistent());
  }

  @Test
  public void testCreateRegionFactoryWithShortcut() {
    Cache mockCache = mock(Cache.class);
    RegionAttributes mockRegionAttributes = mock(RegionAttributes.class);

    final RegionFactory mockRegionFactory = createMockRegionFactory();

    when(mockCache.createRegionFactory(eq(RegionShortcut.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW)))
      .thenReturn(mockRegionFactory);

    final AtomicBoolean setDataPolicyCalled = new AtomicBoolean(false);

    RegionFactoryBean factoryBean = new RegionFactoryBean() {
View Full Code Here

    verify(mockCache).createRegionFactory(eq(RegionShortcut.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW));
  }

  @Test
  public void testCreateRegionFactoryWithAttributes() {
    Cache mockCache = mock(Cache.class);
    RegionAttributes mockRegionAttributes = mock(RegionAttributes.class);

    final RegionFactory mockRegionFactory = createMockRegionFactory();

    when(mockCache.createRegionFactory(eq(mockRegionAttributes))).thenReturn(mockRegionFactory);

    RegionFactoryBean factoryBean = new RegionFactoryBean() {
      @Override
      protected RegionFactory mergeRegionAttributes(RegionFactory regionFactory, RegionAttributes regionAttributes) {
        return mockRegionFactory;
View Full Code Here

    verify(mockCache).createRegionFactory(eq(mockRegionAttributes));
  }

  @Test
  public void testCreateRegionFactory() {
    Cache mockCache = mock(Cache.class);

    final RegionFactory mockRegionFactory = createMockRegionFactory();

    when(mockCache.createRegionFactory()).thenReturn(mockRegionFactory);

    RegionFactoryBean factoryBean = new RegionFactoryBean() {
      @Override
      protected RegionFactory mergeRegionAttributes(RegionFactory regionFactory, RegionAttributes regionAttributes) {
        return mockRegionFactory;
View Full Code Here

  @Override
  @SuppressWarnings("deprecation")
  protected Region<K, V> lookupFallback(GemFireCache gemfireCache, String regionName) throws Exception {
    Assert.isTrue(gemfireCache instanceof Cache, "Unable to create Regions from " + gemfireCache);

    Cache cache = (Cache) gemfireCache;

    RegionFactory<K, V> regionFactory = createRegionFactory(cache);

    if (hubId != null) {
      enableGateway = (enableGateway == null || enableGateway);
View Full Code Here

  @Override
  protected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException {
    CacheTransactionObject txObject = (CacheTransactionObject) transaction;

    Cache cache = null;

    try {
      cache = getCache();
      if (logger.isDebugEnabled()) {
        logger.debug("Acquired Cache [" + cache + "] for local Cache transaction");
      }

      txObject.setHolder(new CacheHolder());
      cache.getCacheTransactionManager().begin();
      TransactionSynchronizationManager.bindResource(cache, txObject.getHolder());
    }

    catch (IllegalStateException ex) {
      throw new CannotCreateTransactionException(
View Full Code Here

  @Autowired
  private ApplicationContext context;

    @Test
    public void testNestedRegionsCreated() {
        Cache cache = context.getBean(Cache.class);

        assertNotNull(cache.getRegion("parent"));
        assertNotNull(cache.getRegion("/parent/child"));
        assertNotNull(cache.getRegion("/parent/child/grandchild"));
    }
View Full Code Here

  @Test
  public void testNoNamedCache() throws Exception {
    assertTrue(context.containsBean("gemfireCache"));
    assertTrue(context.containsBean("gemfire-cache")); // assert alias is registered

    Cache gemfireCache = context.getBean("gemfireCache", Cache.class);

    assertNotNull(gemfireCache);
    assertNotNull(gemfireCache.getDistributedSystem());
    assertNotNull(gemfireCache.getDistributedSystem().getProperties());
    assertTrue(Boolean.parseBoolean(gemfireCache.getDistributedSystem().getProperties()
      .getProperty("disable-auto-reconnect")));

    CacheFactoryBean cacheFactoryBean = context.getBean("&gemfireCache", CacheFactoryBean.class);

    assertNull(TestUtils.readField("cacheXml", cacheFactoryBean));
View Full Code Here

    String configLocation = "/org/springframework/data/gemfire/config/MultipleCacheTest-context.xml";

    ConfigurableApplicationContext context1 = new ClassPathXmlApplicationContext(configLocation);
    ConfigurableApplicationContext context2 = new ClassPathXmlApplicationContext(configLocation);

    Cache cache1 = context1.getBean(Cache.class);
    Cache cache2 = context2.getBean(Cache.class);

    assertNotNull(cache1);
    assertSame(cache1, cache2);

    Region region1 = context1.getBean(Region.class);
View Full Code Here

TOP

Related Classes of com.gemstone.gemfire.cache.Cache

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.