use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.
the class HAInterestTestCase method stopPrimaryAndUnregisterRegisterK1.
public static void stopPrimaryAndUnregisterRegisterK1() {
LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(r);
ServerRegionProxy srp = new ServerRegionProxy(r);
WaitCriterion wc = new WaitCriterion() {
@Override
public boolean done() {
return pool.getConnectedServerCount() == 3;
}
@Override
public String description() {
return "connected server count never became 3";
}
};
Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
// close primaryEP
getPrimaryVM().invoke(() -> HAInterestTestCase.stopServer());
List list = new ArrayList();
list.add(k1);
srp.unregisterInterest(list, InterestType.KEY, false, false);
}
use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.
the class HAInterestTestCase method stopSecondaryAndUNregisterK1.
/**
* returns the secondary that was stopped
*/
public static VM stopSecondaryAndUNregisterK1() {
LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(r);
ServerRegionProxy srp = new ServerRegionProxy(r);
WaitCriterion wc = new WaitCriterion() {
@Override
public boolean done() {
return pool.getConnectedServerCount() == 3;
}
@Override
public String description() {
return "connected server count never became 3";
}
};
Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
// close secondary EP
VM result = getBackupVM();
result.invoke(() -> HAInterestTestCase.stopServer());
List list = new ArrayList();
list.add(k1);
srp.unregisterInterest(list, InterestType.KEY, false, false);
return result;
}
use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.
the class ClientStatsManager method publishClientStats.
/**
* This method publishes the client stats using the admin region.
*
* @param pool Connection pool which may be used for admin region.
*/
public static synchronized void publishClientStats(PoolImpl pool) {
InternalCache currentCache = GemFireCacheImpl.getInstance();
if (!initializeStatistics(currentCache)) {
// handles null case too
return;
}
LogWriterI18n logger = currentCache.getLoggerI18n();
if (logger.fineEnabled())
logger.fine("Entering ClientStatsManager#publishClientStats...");
ClientHealthStats stats = getClientHealthStats(currentCache, pool);
try {
InternalDistributedSystem ds = (InternalDistributedSystem) currentCache.getDistributedSystem();
ServerRegionProxy regionProxy = new ServerRegionProxy(ClientHealthMonitoringRegion.ADMIN_REGION_NAME, pool);
EventID eventId = new EventID(ds);
@Released EntryEventImpl event = new EntryEventImpl((Object) null);
try {
event.setEventId(eventId);
regionProxy.putForMetaRegion(ds.getMemberId(), stats, null, event, null, true);
} finally {
event.release();
}
} catch (DistributedSystemDisconnectedException e) {
throw e;
} catch (CacheWriterException cwx) {
pool.getCancelCriterion().checkCancelInProgress(cwx);
currentCache.getCancelCriterion().checkCancelInProgress(cwx);
// TODO: Need to analyze these exception scenarios.
logger.warning(LocalizedStrings.ClientStatsManager_FAILED_TO_SEND_CLIENT_HEALTH_STATS_TO_CACHESERVER, cwx);
} catch (Exception e) {
pool.getCancelCriterion().checkCancelInProgress(e);
currentCache.getCancelCriterion().checkCancelInProgress(e);
logger.info(LocalizedStrings.ClientStatsManager_FAILED_TO_PUBLISH_CLIENT_STATISTICS, e);
}
if (logger.fineEnabled()) {
logger.fine("Exiting ClientStatsManager#publishClientStats.");
}
}
use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.
the class LocalRegion method processSingleInterest.
// TODO: this is distressingly similar to code in the client.internal package
private void processSingleInterest(Object key, int interestType, InterestResultPolicy interestResultPolicy, boolean isDurable, boolean receiveUpdatesAsInvalidates) {
final ServerRegionProxy proxy = getServerProxy();
if (proxy == null) {
throw new UnsupportedOperationException(LocalizedStrings.LocalRegion_INTEREST_REGISTRATION_REQUIRES_A_POOL.toLocalizedString());
}
if (isDurable && !proxy.getPool().isDurableClient()) {
throw new IllegalStateException(LocalizedStrings.LocalRegion_DURABLE_FLAG_ONLY_APPLICABLE_FOR_DURABLE_CLIENTS.toLocalizedString());
}
if (!proxy.getPool().getSubscriptionEnabled()) {
String msg = "Interest registration requires a pool whose queue is enabled.";
throw new SubscriptionNotEnabledException(msg);
}
if (// fix for bug 36185
getAttributes().getDataPolicy().withReplication() && !getAttributes().getScope().isLocal()) {
// fix for bug 37692
throw new UnsupportedOperationException(LocalizedStrings.LocalRegion_INTEREST_REGISTRATION_NOT_SUPPORTED_ON_REPLICATED_REGIONS.toLocalizedString());
}
if (key == null) {
throw new IllegalArgumentException(LocalizedStrings.LocalRegion_INTEREST_KEY_MUST_NOT_BE_NULL.toLocalizedString());
}
// Sequence of events, on a single entry:
// 1. Client puts value (a).
// 2. Server updates with value (b). Client never gets the update,
// because it isn't interested in that key.
// 3. Client registers interest.
// At this point, there is an entry in the local cache, but it is
// inconsistent with the server.
//
// Because of this, we must _always_ destroy and refetch affected values
// during registerInterest.
startRegisterInterest();
try {
this.clearKeysOfInterest(key, interestType, interestResultPolicy);
// Checking for the Dunit test(testRegisterInterst_Destroy_Concurrent) flag
if (PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG) {
ClientServerObserver bo = ClientServerObserverHolder.getInstance();
bo.beforeInterestRegistration();
}
// Test Code Ends
final byte regionDataPolicy = getAttributes().getDataPolicy().ordinal;
List serverKeys;
switch(interestType) {
case InterestType.FILTER_CLASS:
serverKeys = proxy.registerInterest(key, interestType, interestResultPolicy, isDurable, receiveUpdatesAsInvalidates, regionDataPolicy);
break;
case InterestType.KEY:
if (key instanceof String && key.equals("ALL_KEYS")) {
serverKeys = proxy.registerInterest(".*", InterestType.REGULAR_EXPRESSION, interestResultPolicy, isDurable, receiveUpdatesAsInvalidates, regionDataPolicy);
} else {
if (key instanceof List) {
serverKeys = proxy.registerInterestList((List) key, interestResultPolicy, isDurable, receiveUpdatesAsInvalidates, regionDataPolicy);
} else {
serverKeys = proxy.registerInterest(key, InterestType.KEY, interestResultPolicy, isDurable, receiveUpdatesAsInvalidates, regionDataPolicy);
}
}
break;
case InterestType.OQL_QUERY:
serverKeys = proxy.registerInterest(key, InterestType.OQL_QUERY, interestResultPolicy, isDurable, receiveUpdatesAsInvalidates, regionDataPolicy);
break;
case InterestType.REGULAR_EXPRESSION:
{
String regex = (String) key;
// compile regex throws java.util.regex.PatternSyntaxException if invalid
// we do this before sending to the server because it's more efficient
// and the client is not receiving exception messages properly
// TODO: result of Pattern.compile is ignored
Pattern.compile(regex);
serverKeys = proxy.registerInterest(regex, InterestType.REGULAR_EXPRESSION, interestResultPolicy, isDurable, receiveUpdatesAsInvalidates, regionDataPolicy);
break;
}
default:
throw new InternalGemFireError(LocalizedStrings.LocalRegion_UNKNOWN_INTEREST_TYPE.toLocalizedString());
}
boolean finishedRefresh = false;
try {
refreshEntriesFromServerKeys(null, serverKeys, interestResultPolicy);
finishedRefresh = true;
} finally {
if (!finishedRefresh) {
// unregister before throwing the exception caused by the refresh
switch(interestType) {
case InterestType.FILTER_CLASS:
proxy.unregisterInterest(key, interestType, false, false);
break;
case InterestType.KEY:
if (key instanceof String && key.equals("ALL_KEYS")) {
proxy.unregisterInterest(".*", InterestType.REGULAR_EXPRESSION, false, false);
} else if (key instanceof List) {
proxy.unregisterInterestList((List) key, false, false);
} else {
proxy.unregisterInterest(key, InterestType.KEY, false, false);
}
break;
case InterestType.OQL_QUERY:
proxy.unregisterInterest(key, InterestType.OQL_QUERY, false, false);
break;
case InterestType.REGULAR_EXPRESSION:
{
proxy.unregisterInterest(key, InterestType.REGULAR_EXPRESSION, false, false);
break;
}
default:
throw new InternalGemFireError(LocalizedStrings.LocalRegion_UNKNOWN_INTEREST_TYPE.toLocalizedString());
}
}
}
} finally {
finishRegisterInterest();
}
}
use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.
the class LocalRegion method containsKeyOnServer.
@Override
public boolean containsKeyOnServer(Object key) {
checkReadiness();
checkForNoAccess();
ServerRegionProxy proxy = getServerProxy();
if (proxy != null) {
return proxy.containsKey(key);
} else {
throw new UnsupportedOperationException(LocalizedStrings.LocalRegion_SERVER_KEYSET_REQUIRES_A_POOL.toLocalizedString());
}
}
Aggregations