本文整理了Java中org.apache.geode.cache.Region.registerInterest
方法的一些代码示例,展示了Region.registerInterest
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Region.registerInterest
方法的具体详情如下:
包路径:org.apache.geode.cache.Region
类名称:Region
方法名:registerInterest
[英]Sends a request to the CacheServer to register interest in a key for this client. Updates to this key by other clients will be pushed to this client by the CacheServer. This method is currently supported only on clients in a client server topology. This key is first locally cleared from the client and current value for this key is inserted into the local cache before this call returns.
[中]向CacheServer发送请求,以注册对此客户端密钥的兴趣。其他客户端对此密钥的更新将由CacheServer推送到该客户端。当前仅在客户端-服务器拓扑中的客户端上支持此方法。该键首先从客户端本地清除,并在调用返回之前将该键的当前值插入本地缓存。
代码示例来源:origin: apache/geode
/**
* Sends a request to the CacheServer to register interest for all key in the iterable for this
* client. Updates to any of the keys in the iterable by other clients will be pushed to this
* client by the CacheServer. This method is currently supported only on clients in a client
* server topology. The keys are first locally cleared from the client and current value for the
* keys are inserted into the local cache before this call returns. (if requested).
*
* <p>
* If you locally-destroy a key and your region has concurrency-checks-enabled turned off you will
* not receive invalidation events from your interest subscription for that key. When
* concurrency-checks-enabled is turned on GemFire will accept invalidation and deliver these
* events to your client cache.
* </p>
*
* @param iterable The <code>Iterable</code> of keys on which to register interest.
* @throws UnsupportedOperationException if the region is not configured with a pool name.
* @throws SubscriptionNotEnabledException if the region's pool does not have subcriptions
* enabled.
* @throws UnsupportedOperationException if the region is a replicate with distributed scope.
**
* @since Geode 1.5
*/
default void registerInterestForKeys(Iterable<K> iterable) {
iterable.forEach(k -> registerInterest(k));
}
代码示例来源:origin: apache/geode
keyList.add(keys[keyNum]);
region.registerInterest(keyList, policy);
region.registerInterest("ALL_KEYS", policy);
region.registerInterest(key, policy);
代码示例来源:origin: apache/geode
iterable.forEach(k -> registerInterest(k, policy));
代码示例来源:origin: org.springframework.data/spring-data-gemfire
@SuppressWarnings("unchecked")
private Region<K, V> registerInterests(Region<K, V> region) {
stream(nullSafeArray(getInterests(), Interest.class)).forEach(interest -> {
if (interest.isRegexType()) {
region.registerInterestRegex((String) interest.getKey(), interest.getPolicy(),
interest.isDurable(), interest.isReceiveValues());
}
else {
region.registerInterest(((Interest<K>) interest).getKey(), interest.getPolicy(),
interest.isDurable(), interest.isReceiveValues());
}
});
return region;
}
代码示例来源:origin: apache/geode
iterable.forEach(k -> registerInterest(k, policy, isDurable));
代码示例来源:origin: org.springframework.data/spring-data-geode
@SuppressWarnings("unchecked")
private Region<K, V> registerInterests(Region<K, V> region) {
stream(nullSafeArray(getInterests(), Interest.class)).forEach(interest -> {
if (interest.isRegexType()) {
region.registerInterestRegex((String) interest.getKey(), interest.getPolicy(),
interest.isDurable(), interest.isReceiveValues());
}
else {
region.registerInterest(((Interest<K>) interest).getKey(), interest.getPolicy(),
interest.isDurable(), interest.isReceiveValues());
}
});
return region;
}
代码示例来源:origin: apache/geode
iterable.forEach(k -> registerInterest(k, policy, isDurable, receiveValues));
代码示例来源:origin: apache/geode
public static void registerInterest() {
Cache cache = new ClientServerMiscDUnitTestBase().getCache();
Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
assertNotNull(r);
r.registerInterest("ALL_KEYS");
r.getAttributesMutator().addCacheListener(new MemberIDVerifier());
}
代码示例来源:origin: apache/geode
@Test(expected = GemFireConfigException.class)
public void clientIsPreventedFromConnectingToLocatorAsServer() {
IgnoredException.addIgnoredException("Improperly configured client detected");
ClientCacheFactory clientCacheFactory = new ClientCacheFactory();
clientCacheFactory.addPoolServer("localhost", DistributedTestUtils.getDUnitLocatorPort());
clientCacheFactory.setPoolSubscriptionEnabled(true);
getClientCache(clientCacheFactory);
Region region = ((ClientCache) cache).createClientRegionFactory(ClientRegionShortcut.PROXY)
.create(REGION_NAME1);
region.registerInterest(k1);
}
代码示例来源:origin: apache/geode
void createClientCacheAndVerifyPingIntervalIsSet(String host, int port) throws Exception {
PoolImpl pool = null;
try {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
createCache(props);
pool = (PoolImpl) PoolManager.createFactory().addServer(host, port)
.setSubscriptionEnabled(true).setThreadLocalConnections(false).setReadTimeout(1000)
.setSocketBufferSize(32768).setMinConnections(1).setSubscriptionRedundancy(-1)
.setPingInterval(2000).create("test pool");
Region<Object, Object> region = cache.createRegionFactory(RegionShortcut.LOCAL)
.setPoolName("test pool").create(REGION_NAME1);
region.registerInterest(".*");
/** get the subscription connection and verify that it has the correct timeout setting */
QueueConnectionImpl primaryConnection = (QueueConnectionImpl) pool.getPrimaryConnection();
int pingInterval = ((CacheClientUpdater) primaryConnection.getUpdater())
.getServerQueueStatus().getPingInterval();
assertNotEquals(0, pingInterval);
assertEquals(CacheClientNotifier.getClientPingInterval(), pingInterval);
} finally {
cache.close();
}
}
代码示例来源:origin: apache/geode
private void testAllOperations() {
ClientCache clientCache = (ClientCache) cache;
Region<String, String> region =
clientCache.<String, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
.create("internalRegion");
assertFailure(() -> region.create("Object1", "Value1"));
assertFailure(() -> region.put("Object1", "Value1"));
assertFailure(() -> region.putIfAbsent("Object1", "Value1"));
assertFailure(() -> region.get("Object1"));
Map<String, String> map = new HashMap<>();
map.put("Object1", "Value1");
assertFailure(() -> region.putAll(map));
List<String> list = new ArrayList<>();
list.add("Object1");
assertFailure(() -> region.getAll(list));
assertFailure(() -> region.removeAll(list));
assertFailure(() -> region.destroy("Object1"));
assertFailure(() -> region.remove("Object1"));
assertFailure(() -> region.replace("Object1", "oldValue", "newValue"));
assertFailure(() -> region.invalidate("Object1"));
assertFailure(region::keySetOnServer);
assertFailure(() -> region.registerInterest("Object1"));
}
代码示例来源:origin: apache/geode
assertNotNull(region2);
region2.registerInterest("ALL_KEYS");
代码示例来源:origin: apache/geode
assertNotNull(region2);
region2.registerInterest("ALL_KEYS");
Wait.pause(6000);
server1.invoke(() -> ClientServerMiscDUnitTestBase.verifyInterestListOnServer());
代码示例来源:origin: apache/geode
if (((Pool) proxy.getPool()).getSubscriptionEnabled()) {
try {
newRegion.registerInterest("ALL_KEYS");
} catch (GemFireSecurityException ex) {
代码示例来源:origin: apache/geode
region.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS);
代码示例来源:origin: apache/geode
protected void createOrRetrieveRegion() {
// Retrieve the local session region
this.sessionRegion = this.cache.getRegion(getSessionManager().getRegionName());
// If necessary, create the regions on the server and client
if (this.sessionRegion == null) {
// Create the PR on the servers
createSessionRegionOnServers();
// Create the region on the client
this.sessionRegion = createLocalSessionRegion();
if (getSessionManager().getLogger().isDebugEnabled()) {
getSessionManager().getLogger().debug("Created session region: " + this.sessionRegion);
}
} else {
if (getSessionManager().getLogger().isDebugEnabled()) {
getSessionManager().getLogger().debug("Retrieved session region: " + this.sessionRegion);
}
// Check that we have our expiration listener attached
if (!regionHasExpirationListenerAttached(sessionRegion)) {
sessionRegion.getAttributesMutator().addCacheListener(new SessionExpirationCacheListener());
}
// This is true for PROXY regions
if (sessionRegion.getAttributes().getDataPolicy() == DataPolicy.EMPTY) {
sessionRegion.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS);
}
}
}
代码示例来源:origin: apache/geode
this.dynamicRegionList.registerInterest("ALL_KEYS");
代码示例来源:origin: org.springframework.session/spring-session-data-geode
/**
* Registers interest on the {@link Session#getId()} ID} of a {@link Session}.
*
* And, only registers interest in the given Session ID iff we have not already registered interest
* in this Session ID before.
*
* @param sessionId {@link Session#getId() ID} of the {@link Session} of interest to this application.
* @see org.apache.geode.cache.Region#registerInterest(Object, InterestResultPolicy, boolean, boolean)
* @see #isRegisterInterestEnabled()
*/
protected void registerInterest(@Nullable Object sessionId) {
Optional.ofNullable(sessionId)
.filter(it -> this.isRegisterInterestEnabled())
.filter(SessionUtils::isValidSessionId)
.map(ObjectUtils::nullSafeHashCode)
.filter(this.interestingSessionIds::add)
.ifPresent(it ->
getSessionsRegion().registerInterest(sessionId, DEFAULT_REGISTER_INTEREST_RESULT_POLICY,
DEFAULT_REGISTER_INTEREST_DURABILITY, DEFAULT_REGISTER_INTEREST_RECEIVE_VALUES)
);
}
代码示例来源:origin: org.apache.geode/geode-modules
region.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS);
内容来源于网络,如有侵权,请联系作者删除!