use of org.apache.geode.InternalGemFireError in project geode by apache.
the class AbstractOp method processObjResponse.
/**
* Process a response that contains a single Object result.
*
* @param msg the message containing the response
* @param opName text describing this op
* @return the result of the response
* @throws Exception if response could not be processed or we received a response with a server
* exception.
*/
protected Object processObjResponse(Message msg, String opName) throws Exception {
Part part = msg.getPart(0);
final int msgType = msg.getMessageType();
if (msgType == MessageType.RESPONSE) {
return part.getObject();
} else {
if (msgType == MessageType.EXCEPTION) {
String s = "While performing a remote " + opName;
throw new ServerOperationException(s, (Throwable) part.getObject());
// Get the exception toString part.
// This was added for c++ thin client and not used in java
// Part exceptionToStringPart = msg.getPart(1);
} else if (isErrorResponse(msgType)) {
throw new ServerOperationException(part.getString());
} else {
throw new InternalGemFireError("Unexpected message type " + MessageType.getString(msgType));
}
}
}
use of org.apache.geode.InternalGemFireError in project geode by apache.
the class DynamicRegionFactory method doInternalInit.
/**
* The method is for internal use only. It is called implicitly during cache creation.
* <p>
* This method is called internally during cache initialization at the correct time. Initialize
* the factory with a GemFire Cache. We create the metadata Region which holds all our dynamically
* created regions.
*
* @param theCache The GemFire {@code Cache}
*/
protected void doInternalInit(InternalCache theCache) throws CacheException {
if (isClosed()) {
// DynamicRegions are not enabled in this vm. Just return.
return;
}
try {
this.cache = theCache;
this.dynamicRegionList = theCache.getRegion(dynamicRegionListName);
final boolean isClient = this.config.getPoolName() != null;
if (this.dynamicRegionList == null) {
InternalRegionArguments ira = new InternalRegionArguments().setDestroyLockFlag(true).setInternalRegion(true).setSnapshotInputStream(null).setImageTarget(null);
AttributesFactory af = new AttributesFactory();
if (this.config.getPersistBackup()) {
af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
af.setDiskWriteAttributes(new DiskWriteAttributesFactory().create());
if (this.config.getDiskDir() != null) {
af.setDiskDirs(new File[] { this.config.getDiskDir() });
}
}
if (isClient) {
af.setScope(Scope.LOCAL);
// MirrorType(MirrorType.NONE);
af.setDataPolicy(DataPolicy.NORMAL);
af.setStatisticsEnabled(true);
String cpName = this.config.getPoolName();
if (cpName != null) {
Pool cp = PoolManager.find(cpName);
if (cp == null) {
throw new IllegalStateException("Invalid pool name specified. This pool is not registered with the cache: " + cpName);
} else {
if (!cp.getSubscriptionEnabled()) {
throw new IllegalStateException("The client pool of a DynamicRegionFactory must be configured with queue-enabled set to true.");
}
af.setPoolName(cpName);
}
}
ira.setInternalMetaRegion(new LocalMetaRegion(af.create(), ira));
} else {
af.setScope(Scope.DISTRIBUTED_ACK);
if (!this.config.getPersistBackup()) {
// if persistBackup, the data policy has already
// been set
// setMirrorType(MirrorType.KEYS_VALUES);
af.setDataPolicy(DataPolicy.REPLICATE);
}
for (GatewaySender gs : this.cache.getGatewaySenders()) {
if (!gs.isParallel())
af.addGatewaySenderId(gs.getId());
}
// bug fix 35432
ira.setInternalMetaRegion(new DistributedMetaRegion(af.create()));
}
try {
this.dynamicRegionList = theCache.createVMRegion(dynamicRegionListName, af.create(), ira);
} catch (IOException e) {
// only if loading snapshot, not here
throw new InternalGemFireError(LocalizedStrings.DynamicRegionFactory_UNEXPECTED_EXCEPTION.toLocalizedString(), e);
} catch (ClassNotFoundException e) {
// only if loading snapshot, not here
throw new InternalGemFireError(LocalizedStrings.DynamicRegionFactory_UNEXPECTED_EXCEPTION.toLocalizedString(), e);
}
if (isClient) {
this.dynamicRegionList.registerInterest("ALL_KEYS");
}
if (theCache.getLoggerI18n().fineEnabled()) {
theCache.getLoggerI18n().fine("Created dynamic region: " + this.dynamicRegionList);
}
} else {
if (theCache.getLoggerI18n().fineEnabled()) {
theCache.getLoggerI18n().fine("Retrieved dynamic region: " + this.dynamicRegionList);
}
}
createDefinedDynamicRegions();
} catch (CacheException e) {
theCache.getLoggerI18n().warning(LocalizedStrings.DynamicRegionFactory_ERROR_INITIALIZING_DYNAMICREGIONFACTORY, e);
throw e;
}
}
use of org.apache.geode.InternalGemFireError in project geode by apache.
the class LocalRegion method recreate.
/** must be holding destroy lock */
private void recreate(InputStream inputStream, InternalDistributedMember imageTarget) throws TimeoutException, IOException, ClassNotFoundException {
String thePath = getFullPath();
Region newRegion = null;
try {
LocalRegion parent = this.parentRegion;
// as diskstore name any more
if (this.diskStoreImpl != null && this.diskStoreImpl.getName().equals(DiskStoreFactory.DEFAULT_DISK_STORE_NAME) && this.diskStoreName == null && !useDefaultDiskStore()) {
this.diskStoreName = this.diskStoreImpl.getName();
}
RegionAttributes attrs = this;
boolean getDestroyLock = false;
InternalRegionArguments internalRegionArguments = new InternalRegionArguments().setDestroyLockFlag(getDestroyLock).setSnapshotInputStream(inputStream).setImageTarget(imageTarget).setRecreateFlag(true);
if (this instanceof BucketRegion) {
BucketRegion me = (BucketRegion) this;
internalRegionArguments.setPartitionedRegionBucketRedundancy(me.getRedundancyLevel());
}
if (parent == null) {
newRegion = this.cache.createVMRegion(this.regionName, attrs, internalRegionArguments);
} else {
newRegion = parent.createSubregion(this.regionName, attrs, internalRegionArguments);
}
// note that createVMRegion and createSubregion now call regionReinitialized
} catch (RegionExistsException e) {
// shouldn't happen since we're holding the destroy lock
throw new InternalGemFireError(LocalizedStrings.LocalRegion_GOT_REGIONEXISTSEXCEPTION_IN_REINITIALIZE_WHEN_HOLDING_DESTROY_LOCK.toLocalizedString(), e);
} finally {
if (newRegion == null) {
// failed to create region
this.cache.unregisterReinitializingRegion(thePath);
}
}
}
use of org.apache.geode.InternalGemFireError 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.InternalGemFireError in project geode by apache.
the class RebalanceOperationImpl method getResults.
public RebalanceResults getResults() throws CancellationException, InterruptedException {
RebalanceResultsImpl results = new RebalanceResultsImpl();
List<Future<RebalanceResults>> frlist = getFutureList();
for (Future<RebalanceResults> fr : frlist) {
try {
RebalanceResults rr = fr.get();
results.addDetails((RebalanceResultsImpl) rr);
} catch (ExecutionException e) {
if (e.getCause() instanceof GemFireException) {
throw (GemFireException) e.getCause();
} else if (e.getCause() instanceof InternalGemFireError) {
throw (InternalGemFireError) e.getCause();
} else {
throw new InternalGemFireError(e.getCause());
}
}
}
return results;
}
Aggregations