本文整理汇总了Java中com.gemstone.gemfire.cache.Cache.addCacheServer方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.addCacheServer方法的具体用法?Java Cache.addCacheServer怎么用?Java Cache.addCacheServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gemstone.gemfire.cache.Cache
的用法示例。
在下文中一共展示了Cache.addCacheServer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateDummyBridge
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Generates a dummy bridge from the given cache and bridge configuration.
*/
private static void generateDummyBridge(Cache dummyCache,
String bridgeConfig, String fn) {
if (bridgeConfig != null) {
// create and configure the dummy bridge server
log("Adding dummy bridge server from config: " + bridgeConfig);
BridgeDescription bd = BridgeHelper.getBridgeDescription(bridgeConfig);
CacheServer dummyCacheServer = dummyCache.addCacheServer();
bd.configure(dummyCacheServer, BridgeHelper.getEndpoint(bd.getGroups())
.getPort());
log("Added dummy bridge server: "
+ BridgeHelper.bridgeServerToString(dummyCacheServer));
// save the bridge config for future reference
XmlBridgeConfigs.put(fn, bridgeConfig);
}
}
示例2: testMembershipPortRangeWithExactThreeValues
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void testMembershipPortRangeWithExactThreeValues() throws Exception {
Properties config = new Properties();
int mcastPort = AvailablePort.getRandomAvailablePort(AvailablePort.JGROUPS);
config.setProperty("mcast-port", String.valueOf(mcastPort));
config.setProperty("locators", "");
config.setProperty(DistributionConfig.MEMBERSHIP_PORT_RANGE_NAME, ""
+ (DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1] - 2) + "-"
+ (DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1]));
system = (InternalDistributedSystem)DistributedSystem.connect(config);
Cache cache = CacheFactory.create(system);
cache.addCacheServer();
DistributionManager dm = (DistributionManager) system.getDistributionManager();
InternalDistributedMember idm = dm.getDistributionManagerId();
system.disconnect();
assertTrue(idm.getPort() <= DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1]);
assertTrue(idm.getPort() >= DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[0]);
assertTrue(idm.getDirectChannelPort() <= DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1]);
assertTrue(idm.getDirectChannelPort() >= DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[0]);
}
示例3: getAllHDFSEventsForKey
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/** Exec a mapReduce job to find all updates for a particular entry and write
* those entries back out to a GemFire region (HDFS_RESULTS_REGION) as
* ("originalKey_EventNumber_Operation", value). Note that destroyed keys have a value
* of "DESTORYED". Creates the HDFSResultRegion if needed.
*/
public static synchronized void getAllHDFSEventsForKey(String keys) {
Cache cache = CacheHelper.getCache();
if (cache.getRegion(HDFS_RESULT_REGION) == null) {
// make this a replicated region (so it doesn't affect rebalance, waitForRecovery, etc)
Region hdfsResultRegion = cache.createRegionFactory(RegionShortcut.REPLICATE).
addCacheListener(new SummaryLogListener()).
create(HDFS_RESULT_REGION);
Log.getLogWriter().info("Created hdfsResultRegion " + hdfsResultRegion.getFullPath() + " for dumping HDFS updates for " + keys);
CacheServer cs = cache.addCacheServer();
int port = PortHelper.getRandomPort();
cs.setPort(port);
try {
cs.start();
Log.getLogWriter().info("Started server listenening on port " + port);
} catch (IOException e) {
throw new TestException("getAllHDSEventsForKey caught " + e + " while starting a CacheServer " + TestHelper.getStackTrace(e));
}
}
execMapReduceJob("hdfs.mapreduce.GetAllHDFSEventsForKey", keys);
}
示例4: startCacheServer
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* If the default server (cache server) has not been disabled and no prior cache servers were added to the cache,
* then this method will add a cache server to the Cache and start the server Thread on the specified bind address
* and port.
*
* @param cache the Cache to which the server will be added.
* @throws IOException if the Cache server fails to start due to IO error.
*/
final void startCacheServer(final Cache cache) throws IOException {
if (isDefaultServerEnabled(cache)) {
final String serverBindAddress = (getServerBindAddress() == null ? null : getServerBindAddress().getHostAddress());
final Integer serverPort = getServerPort();
CacheServerLauncher.serverBindAddress.set(serverBindAddress);
CacheServerLauncher.serverPort.set(serverPort);
final CacheServer cacheServer = cache.addCacheServer();
cacheServer.setBindAddress(serverBindAddress);
cacheServer.setPort(serverPort);
cacheServer.start();
}
}
示例5: createCacheServer
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private CacheServer createCacheServer(Cache cache) {
CacheServer server = cache.addCacheServer();
server.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
try {
server.start();
} catch (IOException e) {
fail("got exception", e);
}
return server;
}
示例6: createServerCache
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private Integer createServerCache(DataPolicy dataPolicy) throws Exception {
Cache cache = helper.createCache(false);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(dataPolicy);
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME, attrs);
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
CacheServer server1 = cache.addCacheServer();
server1.setPort(port);
server1.setNotifyBySubscription(true);
server1.start();
return new Integer(server1.getPort());
}
示例7: getCreateServerCallable
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private Callable getCreateServerCallable(final String regionName, final boolean usePR) {
return new SerializableCallable("create server and entries") {
public Object call() {
Cache cache = getCache();
List<CacheServer> servers = cache.getCacheServers();
CacheServer server;
if (servers.size() > 0) {
server = servers.get(0);
} else {
server = cache.addCacheServer();
int port = AvailablePortHelper.getRandomAvailableTCPPort();
server.setPort(port);
server.setHostnameForClients("localhost");
try {
server.start();
}
catch (IOException e) {
fail("Failed to start server ", e);
}
}
if (usePR) {
RegionFactory factory = cache.createRegionFactory(RegionShortcut.PARTITION);
PartitionAttributesFactory pf = new PartitionAttributesFactory();
pf.setTotalNumBuckets(2);
factory.setPartitionAttributes(pf.create());
factory.create(regionName);
} else {
cache.createRegionFactory(RegionShortcut.REPLICATE).create(regionName);
}
return server.getPort();
}
};
}
示例8: startBridgeServer
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Starts a bridge server on the given port, using the given
* deserializeValues and notifyBySubscription to serve up the
* given region.
*/
protected void startBridgeServer(int port, boolean notifyBySubscription)
throws IOException {
Cache cache = CacheFactory.getAnyInstance();
CacheServer bridge = cache.addCacheServer();
bridge.setPort(port);
bridge.start();
bridgeServerPort = bridge.getPort();
}
示例9: startBridgeServer
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Starts a bridge server on the given port, using the given
* deserializeValues and notifyBySubscription to serve up the
* given region.
*/
protected void startBridgeServer(int port, boolean notifyBySubscription)
throws IOException {
Cache cache = getCache();
CacheServer server = cache.addCacheServer();
server.setPort(port);
server.start();
bridgeServerPort = server.getPort();
}
示例10: createCache
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected Cache createCache(InternalDistributedSystem system,
Map<String, Object> options) throws IOException {
Cache cache = CacheFactory.create(system);
float threshold = getCriticalHeapPercent(options);
if (threshold > 0.0f) {
cache.getResourceManager().setCriticalHeapPercentage(threshold);
}
threshold = getEvictionHeapPercent(options);
if (threshold > 0.0f) {
cache.getResourceManager().setEvictionHeapPercentage(threshold);
}
threshold = getCriticalOffHeapPercent(options);
getCriticalOffHeapPercent(options);
if (threshold > 0.0f) {
cache.getResourceManager().setCriticalOffHeapPercentage(threshold);
}
threshold = getEvictionOffHeapPercent(options);
if (threshold > 0.0f) {
cache.getResourceManager().setEvictionOffHeapPercentage(threshold);
}
// Create and start a default cache server
// If (disableDefaultServer is not set or it is set but false) AND (the number of cacheservers is 0)
Boolean disable = disableDefaultServer.get();
if ((disable == null || !disable) && cache.getCacheServers().size() == 0) {
// Create and add a cache server
CacheServer server = cache.addCacheServer();
// Set its port if necessary
Integer serverPort = CacheServerLauncher.getServerPort();
if (serverPort != null) {
server.setPort(serverPort);
}
// Set its bind address if necessary
String serverBindAddress = getServerBindAddress();
if (serverBindAddress != null) {
server.setBindAddress(serverBindAddress.trim());
}
// Start it
server.start();
}
return cache;
}