当前位置: 首页>>代码示例>>Java>>正文


Java ClientCacheFactory类代码示例

本文整理汇总了Java中com.gemstone.gemfire.cache.client.ClientCacheFactory的典型用法代码示例。如果您正苦于以下问题:Java ClientCacheFactory类的具体用法?Java ClientCacheFactory怎么用?Java ClientCacheFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClientCacheFactory类属于com.gemstone.gemfire.cache.client包,在下文中一共展示了ClientCacheFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  writeToStdout("Connecting to the distributed system and creating the cache.");
  
  // Create the cache which causes the cache-xml-file to be parsed
  ClientCache cache = new ClientCacheFactory()
      .set("name", "DeltaPropagationClientReceiver")
      .set("cache-xml-file", "xml/DeltaClient2.xml")
      .create();
  
  Region<Object, Object> reg = cache.getRegion("exampleRegion");
  reg.registerInterest("ALL_KEYS");
  
  writeToStdout("Please press Enter to stop the receiver.");
  BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
  bufferedReader.readLine();
  cache.close();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:18,代码来源:DeltaPropagationClientReceiver.java

示例2: main

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
public static void main(String [] args) throws Exception {
  System.out.println("Connecting to the distributed system and creating the cache.");
  // Create the cache which causes the cache-xml-file to be parsed
  ClientCache cache = new ClientCacheFactory()
      .set("name", "I18nClient")
      .set("cache-xml-file", "xml/I18nClient.xml")
      .create();
  
  // Get the exampleRegion
  Region<String, String> region = cache.getRegion("家具店");
  System.out.println("Example region, " + region.getFullPath() + ", created in cache.");

  System.out.println();
  System.out.println("Getting values from the server...");
  String query = "SELECT DISTINCT * FROM " + region.getFullPath() + ".keys";
  SelectResults<String> results = region.query(query);
  List<String> keys = results.asList();
  for (String key : keys) {
    String value = region.get(key);
    System.out.println("item: " + key + " price: " + value);
  }
  System.out.println();
  System.out.println("Closing the cache and disconnecting.");

  cache.close();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:27,代码来源:I18nClient.java

示例3: initialize

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
/**
 * Initializes the <code>Cache</code> for this example program. Uses the
 * {@link LoggingCacheWriter}.
 */
void initialize() throws Exception {
  Properties props = new Properties();
  if (this.xmlFile != null) {
    props.setProperty("cache-xml-file", this.xmlFile.toString());
  }

  this.cache = new ClientCacheFactory(props).create();
  Iterator rIter = this.cache.rootRegions().iterator();
  if (rIter.hasNext()) {
    this.currRegion = (Region)rIter.next();
  }
  else {
    /* If no root region exists, create one with default attributes */
    System.out.println("No root region in cache. Creating a root, +"
        + "'root'\nfor cache access.\n");
    currRegion = cache.createClientRegionFactory(CACHING_PROXY).create("root");
  }

  System.out.println("Region name is " + this.currRegion.getFullPath());
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:25,代码来源:HAFeederClient.java

示例4: createClientRegion

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
private void createClientRegion(final VM vm, final int port1, final int port2, 
    final boolean threadLocalConnections) {
  SerializableCallable createRegion = new SerializableCallable("create client region in " + vm) {
    public Object call() throws Exception {
      ClientCacheFactory cf = new ClientCacheFactory();
      cf.addPoolServer(getServerHostName(vm.getHost()), port1);
      cf.addPoolServer(getServerHostName(vm.getHost()), port2);
      cf.setPoolPRSingleHopEnabled(false);
      cf.setPoolThreadLocalConnections(threadLocalConnections);
      cf.setPoolReadTimeout(10 * 60 * 1000);
      ClientCache cache = getClientCache(cf);
      cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
      .create("region");
      return null;
    }
  };
  vm.invoke(createRegion);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:19,代码来源:ClientsWithVersioningRetryDUnitTest.java

示例5: createClientRegion

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
private void createClientRegion(final VM vm, final String regionName, final int port) {
  SerializableCallable createRegion = new SerializableCallable() {
    public Object call() throws Exception {
      ClientCacheFactory cf = new ClientCacheFactory();
      cf.addPoolServer(getServerHostName(vm.getHost()), port);
      cf.setPoolSubscriptionEnabled(true);
      cf.set("log-level", getDUnitLogLevel());
      ClientCache cache = getClientCache(cf);
      ClientRegionFactory crf = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
      crf.setConcurrencyChecksEnabled(true);
      TestRegion = (LocalRegion)crf.create(regionName);
      TestRegion.registerInterestRegex(".*", InterestResultPolicy.KEYS_VALUES, false, true);
      return null;
    }
  };
  vm.invoke(createRegion);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:18,代码来源:ClientServerCCEDUnitTest.java

示例6: createDurableClientRegion

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
private void createDurableClientRegion(final VM vm, final String regionName,
    final int port1, final int port2, final boolean ccEnabled) {
  SerializableCallable createRegion = new SerializableCallable() {
    public Object call() throws Exception {
      ClientCacheFactory cf = new ClientCacheFactory();
      cf.addPoolServer(getServerHostName(vm.getHost()), port1);
      cf.addPoolServer(getServerHostName(vm.getHost()), port2);
      cf.setPoolSubscriptionEnabled(true);
      cf.setPoolSubscriptionRedundancy(1);
      // bug #50683 - secondary durable queue retains all GC messages
      cf.set("durable-client-id", ""+vm.getPid());
      cf.set("durable-client-timeout", "" + 200);
      cf.set("log-level", "fine");
      ClientCache cache = getClientCache(cf);
      ClientRegionFactory crf = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
      crf.setConcurrencyChecksEnabled(ccEnabled);
      TestRegion = (LocalRegion)crf.create(regionName);
      TestRegion.registerInterestRegex(".*", InterestResultPolicy.KEYS_VALUES, true, true);
      cache.readyForEvents();
      return null;
    }
  };
  vm.invoke(createRegion);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:25,代码来源:ClientServerCCEDUnitTest.java

示例7: createCacheClientFromXmlN

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
public static void createCacheClientFromXmlN(URL url, String poolName, String durableClientId, int timeout, Boolean addControlListener) {
  ClientCacheFactory ccf = new ClientCacheFactory();
  try {
    File cacheXmlFile = new File(url.toURI().getPath());
    ccf.set("cache-xml-file", cacheXmlFile.toURI().getPath());
    
  }
  catch (URISyntaxException e) {
    throw new ExceptionInInitializerError(e);
  }
  ccf.set("mcast-port", "0");
  ccf.set(DistributionConfig.DURABLE_CLIENT_ID_NAME, durableClientId);
  ccf.set(DistributionConfig.DURABLE_CLIENT_TIMEOUT_NAME, String.valueOf(timeout));
  ccf.set("log-file", "abs_client_system.log");
  ccf.set("log-level", getDUnitLogLevel());
  cache = (Cache)ccf.create();
  pool = (PoolImpl)PoolManager.find(poolName);
  
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:CacheServerTestUtil.java

示例8: createCacheClientFromXml

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
public static void createCacheClientFromXml(URL url, String poolName, String durableClientId, int timeout, Boolean addControlListener) {
  ClientCacheFactory ccf = new ClientCacheFactory();
  try {
    File cacheXmlFile = new File(url.toURI().getPath());
    ccf.set("cache-xml-file", cacheXmlFile.toURI().getPath());
    
  }
  catch (URISyntaxException e) {
    throw new ExceptionInInitializerError(e);
  }
  ccf.set("mcast-port", "0");
  ccf.set(DistributionConfig.DURABLE_CLIENT_ID_NAME, durableClientId);
  ccf.set(DistributionConfig.DURABLE_CLIENT_TIMEOUT_NAME, String.valueOf(timeout));
  cache = (Cache)ccf.create();
  pool = (PoolImpl)PoolManager.find(poolName);
  
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:18,代码来源:CacheServerTestUtil.java

示例9: createClientRegion

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
private void createClientRegion(VM vm, final int port1, final boolean isEmpty, final boolean ri, final int port2) {
  vm.invoke(new SerializableCallable() {
    public Object call() throws Exception {
      ClientCacheFactory ccf = new ClientCacheFactory();
      ccf.addPoolServer("localhost"/*getServerHostName(Host.getHost(0))*/, port1);
      if (port2 > 0) {
        ccf.addPoolServer("localhost", port2);
      }
      ccf.setPoolSubscriptionEnabled(true);
      ccf.set("log-level", getDUnitLogLevel());
      ClientCache cCache = getClientCache(ccf);
      ClientRegionFactory<Integer, String> crf = cCache
          .createClientRegionFactory(isEmpty ? ClientRegionShortcut.PROXY
              : ClientRegionShortcut.CACHING_PROXY);
      Region<Integer, String> r = crf.create(REP_REG_NAME);
      Region<Integer, String> pr = crf.create(PR_REG_NAME);
      if (ri) {
        r.registerInterestRegex(".*");
        pr.registerInterestRegex(".*");
      }
      return null;
    }
  });
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:25,代码来源:ConcurrentMapOpsDUnitTest.java

示例10: createClientRegion

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
private void createClientRegion(VM vm, final int port, final boolean isEmpty, final boolean ri) {
  vm.invoke(new SerializableCallable() {
    public Object call() throws Exception {
      ClientCacheFactory ccf = new ClientCacheFactory();
      ccf.addPoolServer("localhost"/*getServerHostName(Host.getHost(0))*/, port);
      ccf.setPoolSubscriptionEnabled(false);
      ccf.set("log-level", getDUnitLogLevel());
      ClientCache cCache = getClientCache(ccf);
      ClientRegionFactory<Integer, String> crf = cCache
          .createClientRegionFactory(isEmpty ? ClientRegionShortcut.PROXY
              : ClientRegionShortcut.CACHING_PROXY);
      Region<Integer, String> r = crf.create(D_REFERENCE);
      Region<Integer, String> customer = crf.create(CUSTOMER);
      Region<Integer, String> order = crf.create(ORDER);
      if (ri) {
        r.registerInterestRegex(".*");
        customer.registerInterestRegex(".*");
        order.registerInterestRegex(".*");
      }
      return null;
    }
  });
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:TransactionsWithDeltaDUnitTest.java

示例11: createClient

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
public static void createClient(Integer port1, Integer port2, Integer port3) {
  ClientCacheFactory cf = new ClientCacheFactory();
  cache = (Cache)cf.create();
  PoolFactoryImpl pf = (PoolFactoryImpl)PoolManager.createFactory();
  pf.setReadTimeout(0);
  pf.setIdleTimeout(-1);
  pf.setMinConnections(4);
  pf.setServerGroup(GatewayReceiverImpl.RECEIVER_GROUP);
  Properties props = new Properties();
  String locators = "localhost[" + port1 + "],localhost[" + port2
      + "],localhost[" + port3 + "]";
  props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
  pf.init(props, false, true);
  proxy = ((PoolImpl)pf.create("KISHOR_POOL"));
  Connection con1 = proxy.acquireConnection();
  try {
    con1.close(true);
  }
  catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:WANLocatorServerDUnitTest.java

示例12: runLDSQueryOnClientUsingFunc

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
/**
 * Runs a {@link LocalDataSet} query on a single server. 
 * @param func
 * @param filter
 * @param query
 * @return results in a List
 */
private ArrayList runLDSQueryOnClientUsingFunc(Function func, Set filter, String query) {
  ResultCollector rcollector = null;

  // Filter can not be set as null if withFilter() is called.
  rcollector = FunctionService
      .onServer(ClientCacheFactory.getAnyInstance())
      .withArgs(new Object[]{query, filter}).execute(func);
  Object result = rcollector.getResult();
  assertTrue(result instanceof ArrayList);

  //Results from multiple nodes.
  ArrayList resultList = (ArrayList)result;
  resultList.trimToSize();
  List queryResults = new ArrayList();
  
  if (resultList.size()!=0 && resultList.get(0) instanceof ArrayList) {
    for (Object obj: resultList) {
      if (obj != null) {
        queryResults.addAll((ArrayList)obj);
      }
    }
  }

  return (ArrayList) queryResults;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:33,代码来源:QueryUsingFunctionContextDUnitTest.java

示例13: setupGemFire

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
public static ClientCache setupGemFire(String[] locatorInfo, String userName, String password) throws Exception {
    Properties properties = new Properties();
    properties.load(ToolBox.class.getResourceAsStream("/gemfire.properties"));
    ClientCacheFactory factory = new ClientCacheFactory(properties);
    factory.setPoolSubscriptionEnabled(true);
    factory.addPoolLocator(locatorInfo[0], Integer.parseInt(locatorInfo[1]));
    factory.setPoolPRSingleHopEnabled(true);
    factory.setPoolMaxConnections(-1);

    System.out.println("userName = " + userName);
    System.out.println("password = " + password);
    if (userName != null && password != null) {
        factory.set("security-client-auth-init", "io.pivotal.gemfire.demo.ClientAuthentication.create");
        factory.set("security-username", userName);
        factory.set("security-password", password);
    }
    factory.set("name", "source");
    factory.set("statistic-archive-file", "source.gfs");
    ClientCache clientCache = factory.create();
    ToolBox.addTimerForPdxTypeMetrics(clientCache);
    return clientCache;
}
 
开发者ID:charliemblack,项目名称:gemfire-copy,代码行数:23,代码来源:ToolBox.java

示例14: insertAWholeBunch

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
@Test
public void insertAWholeBunch() throws JsonProcessingException {
    ClientCacheFactory factory = new ClientCacheFactory();
    factory.set("security-client-auth-init", "io.pivotal.gemfire.demo.ClientAuthentication.create");
    factory.set("security-username", "super-user");
    factory.set("security-password", "1234567");
    factory.addPoolLocator("localhost", 10334);
    factory.setPdxSerializer(new ReflectionBasedAutoSerializer("demo.geode.greenplum.*"));
    ClientCache clientCache = factory.create();
    Region testRegion = clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY).create("Region1");
    int counter = 1;
    ObjectMapper objectMapper = new ObjectMapper();
    while (true) {
        SampleData sampleData = new SampleData(counter++, new Date(), "some text" + counter++, counter % 2 == 0);
        String json = objectMapper.writeValueAsString(sampleData);
        testRegion.put(counter, JSONFormatter.fromJSON(json));
    }
}
 
开发者ID:charliemblack,项目名称:gemfire-copy,代码行数:19,代码来源:DataJammer.java

示例15: main

import com.gemstone.gemfire.cache.client.ClientCacheFactory; //导入依赖的package包/类
public static void main(String[] args) {
  CloudFactory cloudFactory = new CloudFactory();
  Cloud cloud = cloudFactory.getCloud();
  GemfireServiceInfo myService = (GemfireServiceInfo) cloud.getServiceInfo("service0");
  Properties props = new Properties();
  props.setProperty("security-client-auth-init", "io.pivotal.ClientAuthInitialize.create");
  ClientCacheFactory ccf = new ClientCacheFactory(props);
  URI[] locators = myService.getLocators();
  for (URI locator : locators) {
    ccf.addPoolLocator(locator.getHost(), locator.getPort());
  }
  ClientCache client = ccf.create();
  Region r = client.createClientRegionFactory(ClientRegionShortcut.PROXY).create("test");
  r.put("1", "one");
  if (!r.get("1").equals("one")) {
    throw new RuntimeException("Expected value to be \"one\", but was:"+r.get("1"));
  }
  try {
    Thread.sleep(Long.MAX_VALUE);
  } catch (InterruptedException e) {
    e.printStackTrace();
  }
}
 
开发者ID:gemfire,项目名称:cf-gemfire-connector-examples,代码行数:24,代码来源:JavaAppSpringCloud.java


注:本文中的com.gemstone.gemfire.cache.client.ClientCacheFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。