Package com.gemstone.gemfire.cache

Examples of com.gemstone.gemfire.cache.Cache


    Properties gemfireProperties = new Properties();
    gemfireProperties.setProperty("name", "CqServer");
    gemfireProperties.setProperty("mcast-port", "0");
    gemfireProperties.setProperty("log-level", "warning");

    Cache cache = new CacheFactory(gemfireProperties).create();

    RegionFactory<String, Integer> regionFactory = cache.createRegionFactory();
    regionFactory.setDataPolicy(DataPolicy.REPLICATE);
    regionFactory.setScope(Scope.DISTRIBUTED_ACK);

    Region<String, Integer> testRegion = regionFactory.create("test-cq");

    System.out.printf("Test Region '%1$s' created in Cache '%2$s.%n", testRegion.getFullPath(), cache.getName());

    CacheServer server = cache.addCacheServer();
    server.setPort(40404);
    server.start();

    ForkUtil.createControlFile(CacheServerProcess.class.getName());
View Full Code Here


* @since 1.4.0
*/
public class GatewaySenderFactoryBeanTest {

  protected Cache createMockCacheWithGatewayInfrastructure(final GatewaySenderFactory gatewaySenderFactory) {
    Cache mockCache = mock(Cache.class);
    when(mockCache.createGatewaySenderFactory()).thenReturn(gatewaySenderFactory);
    return mockCache;
  }
View Full Code Here

      ContinuousQueryListenerContainer container2 = applicationContext.getBean("testContainerId",
        ContinuousQueryListenerContainer.class);

      assertSame(container, container2);

      Cache cache = applicationContext.getBean("gemfireCache", Cache.class);
      Pool pool = applicationContext.getBean("client", Pool.class);

      CqQuery[] cqs = cache.getQueryService().getCqs();
      CqQuery[] poolCqs = pool.getQueryService().getCqs();

      assertTrue(pool.getQueryService().getCq("test-bean-1") != null);
      assertEquals(3, cqs.length);
      assertEquals(3, poolCqs.length);
View Full Code Here

  }

  @Test
  public void testNoClose() {
    ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("/org/springframework/data/gemfire/client/client-cache-no-close.xml");
    Cache cache = ctx.getBean(Cache.class);
    ctx.close();
    assertFalse(cache.isClosed());
  }
View Full Code Here

  }

  @SuppressWarnings("unused")
  @Test
  public void testServerDataSource() {
    Cache cache = ctx.getBean("gemfireCache", Cache.class);
    Pool pool = ctx.getBean("gemfirePool", Pool.class);
    assertEquals(true, pool.getSubscriptionEnabled());

    String regions[] = ctx.getBeanNamesForType(Region.class);
    List<String> regionList = Arrays.asList(regions);
View Full Code Here

    String configLocation = "/org/springframework/data/gemfire/client/client-cache-no-close.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

  @Autowired
  private ApplicationContext context;

  @Before
  public void setUp() throws Exception {
    Cache cache = (Cache) context.getBean("gemfireCache");

    if (cache.getRegion(name) == null) {
      cache.createRegionFactory().create("test-index");
    }
  }
View Full Code Here

    tearDownCache();
  }

  private void tearDownCache() {
    try {
      Cache cache = CacheFactory.getAnyInstance();

      if (cache != null) {
        System.out.printf("Closing Cache...%n");
        cache.close();

        // Now, wait for the GemFire Hog to shutdown, OIY!
        synchronized (MUTEX_LOCK) {
          while (!cache.isClosed()) {
            try {
              System.out.printf("Waiting in tearDown...");
              MUTEX_LOCK.wait(500l);
            }
            catch (InterruptedException ignore) {
View Full Code Here

      // Cache.close();
    }
  }

  protected void doSpringContextBootstrappingInitializationTest(final String cacheXmlFile) {
    Cache gemfireCache = new CacheFactory()
      .set("name", GEMFIRE_NAME)
      .set("mcast-port", GEMFIRE_MCAST_PORT)
      .set("log-level", GEMFIRE_LOG_LEVEL)
      .set("cache-xml-file", cacheXmlFile)
      //.set("locators", GEMFIRE_LOCATORS)
      //.set("start-locator", GEMFIRE_LOCATORS)
      //.set("jmx-manager", GEMFIRE_JMX_MANAGER)
      //.set("jmx-manager-port", GEMFIRE_JMX_MANAGER_PORT)
      //.set("jmx-manager-start", GEMFIRE_JMX_MANAGER_START)
      .create();

    assertNotNull("The GemFire Cache was not properly created and initialized!", gemfireCache);
    assertFalse("The GemFire Cache is closed!", gemfireCache.isClosed());

    Set<Region<?, ?>> rootRegions = gemfireCache.rootRegions();

    assertNotNull(rootRegions);
    assertFalse(rootRegions.isEmpty());
    assertEquals(2, rootRegions.size());
    assertNotNull(gemfireCache.getRegion("/TestRegion"));
    assertNotNull(gemfireCache.getRegion("/Users"));

    ConfigurableApplicationContext applicationContext = SpringContextBootstrappingInitializer.getApplicationContext();

    assertNotNull(applicationContext);
    assertTrue(applicationContext.containsBean(GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME));
    assertTrue(applicationContext.containsBean("TestRegion"));
    assertFalse(applicationContext.containsBean("Users")); // Region 'Users' is defined in GemFire cache.xml
    assertTrue(applicationContext.containsBean("userDataSource"));
    assertTrue(applicationContext.containsBean("userDao"));
    assertTrue(applicationContext.containsBean("userService"));

    DataSource userDataSource = applicationContext.getBean("userDataSource", DataSource.class);
    TestUserDao userDao = applicationContext.getBean("userDao", TestUserDao.class);
    TestUserService userService = applicationContext.getBean("userService", TestUserService.class);

    assertSame(userDataSource, userDao.getDataSource());
    assertSame(userDao, userService.getUserDao());

    // NOTE a GemFire declared component initialized by Spring!
    UserDataStoreCacheLoader usersCacheLoader = UserDataStoreCacheLoader.getInstance();

    assertSame(userDataSource, usersCacheLoader.getDataSource());

    Region<String, User> users = gemfireCache.getRegion("/Users");

    assertNotNull(users);
    assertEquals("Users", users.getName());
    assertEquals("/Users", users.getFullPath());
    assertTrue(users.isEmpty());
View Full Code Here

*/
public class GatewayReceiverFactoryBeanTest {

  @Test
  public void testDoInit() throws Exception {
    Cache mockCache = mock(Cache.class, "testDoInit.Cache");
    GatewayReceiverFactory mockGatewayReceiverFactory = mock(GatewayReceiverFactory.class, "testDoInit.GatewayReceiverFactory");
    GatewayTransportFilter mockGatewayTransportFilter = mock(GatewayTransportFilter.class, "testDoInit.GatewayTransportFilter");

    when(mockCache.createGatewayReceiverFactory()).thenReturn(mockGatewayReceiverFactory);

    GatewayReceiverFactoryBean factoryBean = new GatewayReceiverFactoryBean(mockCache);

    factoryBean.setBindAddress("10.224.112.77");
    factoryBean.setHostnameForSenders("skullbox");
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.