use of org.apache.geode.InternalGemFireException in project geode by apache.
the class CacheXmlParser method startSubscriptionAttributes.
/**
* When a <code>subscription-attributes</code> element is first encountered, we create an
* SubscriptionAttibutes?? object from the element's attributes and stick it in the current region
* attributes.
*/
private void startSubscriptionAttributes(Attributes atts) {
String ip = atts.getValue(INTEREST_POLICY);
SubscriptionAttributes sa;
if (ip == null) {
sa = new SubscriptionAttributes();
} else if (ip.equals(ALL)) {
sa = new SubscriptionAttributes(InterestPolicy.ALL);
} else if (ip.equals(CACHE_CONTENT)) {
sa = new SubscriptionAttributes(InterestPolicy.CACHE_CONTENT);
} else {
throw new InternalGemFireException(LocalizedStrings.CacheXmlParser_UNKNOWN_INTERESTPOLICY_0.toLocalizedString(ip));
}
RegionAttributesCreation rattrs = (RegionAttributesCreation) stack.peek();
rattrs.setSubscriptionAttributes(sa);
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class GMSLocator method recoverFromFile.
/* package */
boolean recoverFromFile(File file) throws InternalGemFireException {
if (!file.exists()) {
logger.info("recovery file not found: " + file.getAbsolutePath());
return false;
}
logger.info("Peer locator recovering from " + file.getAbsolutePath());
try (ObjectInput ois = new ObjectInputStream(new FileInputStream(file))) {
if (ois.readInt() != LOCATOR_FILE_STAMP) {
return false;
}
ObjectInput ois2 = ois;
int version = ois2.readInt();
if (version != Version.CURRENT_ORDINAL) {
Version geodeVersion = Version.fromOrdinalNoThrow((short) version, false);
logger.info("Peer locator found that persistent view was written with {}", geodeVersion);
ois2 = new VersionedObjectInput(ois2, geodeVersion);
}
Object o = DataSerializer.readObject(ois2);
this.view = (NetView) o;
logger.info("Peer locator initial membership is " + view);
return true;
} catch (Exception e) {
String msg = LOCATOR_UNABLE_TO_RECOVER_VIEW.toLocalizedString(file.toString());
logger.warn(msg, e);
if (!file.delete() && file.exists()) {
logger.warn("Peer locator was unable to recover from or delete " + file);
this.viewFile = null;
}
throw new InternalGemFireException(msg, e);
}
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class EventID method initializeAndGetDSEventIdentity.
private static byte[] initializeAndGetDSEventIdentity(DistributedSystem sys) {
if (sys == null) {
// DistributedSystem is required now before handshaking -Kirk
throw new IllegalStateException(LocalizedStrings.ClientProxyMembershipID_ATTEMPTING_TO_HANDSHAKE_WITH_CACHESERVER_BEFORE_CREATING_DISTRIBUTEDSYSTEM_AND_CACHE.toLocalizedString());
}
if (EventID.system != sys) {
// DS already exists... make sure it's for current DS connection
EventID.systemMemberId = sys.getDistributedMember();
try {
HeapDataOutputStream hdos = new HeapDataOutputStream(256, Version.CURRENT);
((InternalDistributedMember) EventID.systemMemberId).writeEssentialData(hdos);
client_side_event_identity = hdos.toByteArray();
} catch (IOException ioe) {
throw new InternalGemFireException(LocalizedStrings.ClientProxyMembershipID_UNABLE_TO_SERIALIZE_IDENTITY.toLocalizedString(), ioe);
}
EventID.system = sys;
}
return EventID.client_side_event_identity;
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class CacheXmlParser method startRegionAttributes.
/**
* When a <code>region-attributes</code> element is first encountered, we create a
* {@link RegionAttributesCreation}, populate it accordingly, and push it on the stack.
*/
private void startRegionAttributes(Attributes atts) {
RegionAttributesCreation attrs = new RegionAttributesCreation(this.cache);
String scope = atts.getValue(SCOPE);
if (scope == null) {
} else if (scope.equals(LOCAL)) {
attrs.setScope(Scope.LOCAL);
} else if (scope.equals(DISTRIBUTED_NO_ACK)) {
attrs.setScope(Scope.DISTRIBUTED_NO_ACK);
} else if (scope.equals(DISTRIBUTED_ACK)) {
attrs.setScope(Scope.DISTRIBUTED_ACK);
} else if (scope.equals(GLOBAL)) {
attrs.setScope(Scope.GLOBAL);
} else {
throw new InternalGemFireException(LocalizedStrings.CacheXmlParser_UNKNOWN_SCOPE_0.toLocalizedString(scope));
}
String mirror = atts.getValue(MIRROR_TYPE);
if (mirror == null) {
} else if (mirror.equals(NONE)) {
attrs.setMirrorType(MirrorType.NONE);
} else if (mirror.equals(KEYS)) {
attrs.setMirrorType(MirrorType.KEYS);
} else if (mirror.equals(KEYS_VALUES)) {
attrs.setMirrorType(MirrorType.KEYS_VALUES);
} else {
throw new InternalGemFireException(LocalizedStrings.CacheXmlParser_UNKNOWN_MIRROR_TYPE_0.toLocalizedString(mirror));
}
{
String dp = atts.getValue(DATA_POLICY);
if (dp == null) {
} else if (dp.equals(NORMAL_DP)) {
attrs.setDataPolicy(DataPolicy.NORMAL);
} else if (dp.equals(PRELOADED_DP)) {
attrs.setDataPolicy(DataPolicy.PRELOADED);
} else if (dp.equals(EMPTY_DP)) {
attrs.setDataPolicy(DataPolicy.EMPTY);
} else if (dp.equals(REPLICATE_DP)) {
attrs.setDataPolicy(DataPolicy.REPLICATE);
} else if (dp.equals(PERSISTENT_REPLICATE_DP)) {
attrs.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
} else if (dp.equals(PARTITION_DP)) {
attrs.setDataPolicy(DataPolicy.PARTITION);
} else if (dp.equals(PERSISTENT_PARTITION_DP)) {
attrs.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
} else {
throw new InternalGemFireException(LocalizedStrings.CacheXmlParser_UNKNOWN_DATA_POLICY_0.toLocalizedString(dp));
}
}
String initialCapacity = atts.getValue(INITIAL_CAPACITY);
if (initialCapacity != null) {
attrs.setInitialCapacity(parseInt(initialCapacity));
}
String concurrencyLevel = atts.getValue(CONCURRENCY_LEVEL);
if (concurrencyLevel != null) {
attrs.setConcurrencyLevel(parseInt(concurrencyLevel));
}
String concurrencyChecksEnabled = atts.getValue(CONCURRENCY_CHECKS_ENABLED);
if (concurrencyChecksEnabled != null) {
attrs.setConcurrencyChecksEnabled(Boolean.valueOf(concurrencyChecksEnabled).booleanValue());
}
String loadFactor = atts.getValue(LOAD_FACTOR);
if (loadFactor != null) {
attrs.setLoadFactor(parseFloat(loadFactor));
}
String statisticsEnabled = atts.getValue(STATISTICS_ENABLED);
if (statisticsEnabled != null) {
attrs.setStatisticsEnabled(Boolean.valueOf(statisticsEnabled).booleanValue());
}
String ignoreJTA = atts.getValue(IGNORE_JTA);
if (ignoreJTA != null) {
attrs.setIgnoreJTA(Boolean.valueOf(ignoreJTA).booleanValue());
}
String isLockGrantor = atts.getValue(IS_LOCK_GRANTOR);
if (isLockGrantor != null) {
attrs.setLockGrantor(Boolean.valueOf(isLockGrantor).booleanValue());
}
String persistBackup = atts.getValue(PERSIST_BACKUP);
if (persistBackup != null) {
attrs.setPersistBackup(Boolean.valueOf(persistBackup).booleanValue());
}
String earlyAck = atts.getValue(EARLY_ACK);
if (earlyAck != null) {
attrs.setEarlyAck(Boolean.valueOf(earlyAck).booleanValue());
}
String mcastEnabled = atts.getValue(MULTICAST_ENABLED);
if (mcastEnabled != null) {
attrs.setMulticastEnabled(Boolean.valueOf(mcastEnabled).booleanValue());
}
String indexUpdateType = atts.getValue(INDEX_UPDATE_TYPE);
attrs.setIndexMaintenanceSynchronous(indexUpdateType == null || indexUpdateType.equals(INDEX_UPDATE_TYPE_SYNCH));
String poolName = atts.getValue(POOL_NAME);
if (poolName != null) {
attrs.setPoolName(poolName);
}
String diskStoreName = atts.getValue(DISK_STORE_NAME);
if (diskStoreName != null) {
attrs.setDiskStoreName(diskStoreName);
}
String isDiskSynchronous = atts.getValue(DISK_SYNCHRONOUS);
if (isDiskSynchronous != null) {
attrs.setDiskSynchronous(Boolean.valueOf(isDiskSynchronous).booleanValue());
}
String id = atts.getValue(ID);
if (id != null) {
attrs.setId(id);
}
String refid = atts.getValue(REFID);
if (refid != null) {
attrs.setRefid(refid);
}
String enableSubscriptionConflation = atts.getValue(ENABLE_SUBSCRIPTION_CONFLATION);
if (enableSubscriptionConflation != null) {
attrs.setEnableSubscriptionConflation(Boolean.valueOf(enableSubscriptionConflation).booleanValue());
}
String enableBridgeConflation = atts.getValue(ENABLE_BRIDGE_CONFLATION);
// so ignore it if enable-subscription-conflation is set
if (enableBridgeConflation != null && enableSubscriptionConflation == null) {
attrs.setEnableSubscriptionConflation(Boolean.valueOf(enableBridgeConflation).booleanValue());
}
if (enableBridgeConflation == null && enableSubscriptionConflation == null) {
// 4.1 compatibility
enableBridgeConflation = atts.getValue("enable-conflation");
if (enableBridgeConflation != null) {
attrs.setEnableSubscriptionConflation(Boolean.valueOf(enableBridgeConflation).booleanValue());
}
}
/*
* deprecated in prPersistSprint1 String publisherStr = atts.getValue(PUBLISHER); if
* (publisherStr != null) { attrs.setPublisher(Boolean.valueOf(publisherStr).booleanValue()); }
*/
String enableAsyncConflation = atts.getValue(ENABLE_ASYNC_CONFLATION);
if (enableAsyncConflation != null) {
attrs.setEnableAsyncConflation(Boolean.valueOf(enableAsyncConflation).booleanValue());
}
String cloningEnabledStr = atts.getValue(CLONING_ENABLED);
if (cloningEnabledStr != null) {
attrs.setCloningEnable(Boolean.valueOf(cloningEnabledStr).booleanValue());
}
String gatewaySenderIds = atts.getValue(GATEWAY_SENDER_IDS);
if (gatewaySenderIds != null && (gatewaySenderIds.length() != 0)) {
StringTokenizer st = new StringTokenizer(gatewaySenderIds, ",");
while (st.hasMoreElements()) {
attrs.addGatewaySenderId(st.nextToken());
}
}
String asyncEventQueueIds = atts.getValue(ASYNC_EVENT_QUEUE_IDS);
if (asyncEventQueueIds != null && (asyncEventQueueIds.length() != 0)) {
StringTokenizer st = new StringTokenizer(asyncEventQueueIds, ",");
while (st.hasMoreElements()) {
attrs.addAsyncEventQueueId(st.nextToken());
}
}
String offHeapStr = atts.getValue(OFF_HEAP);
if (offHeapStr != null) {
attrs.setOffHeap(Boolean.valueOf(offHeapStr).booleanValue());
}
stack.push(attrs);
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class CacheXmlParser method endIndex.
/**
* When index element is ending we need to verify all attributes because of new index tag
* definition since 6.6.1 and support previous definition also.
*
* if <code>functional</code> element was not there then we need to validate expression and
* fromClause as not null.
*/
private void endIndex() {
boolean throwExcep = false;
IndexCreationData icd = (IndexCreationData) this.stack.pop();
if (icd.getIndexType() == null) {
throwExcep = true;
} else {
if (icd.getIndexType().equals(IndexType.PRIMARY_KEY)) {
if (icd.getIndexExpression() == null) {
throwExcep = true;
}
} else {
if (icd.getIndexExpression() == null && icd.getIndexFromClause() == null) {
throwExcep = true;
}
}
}
if (!throwExcep) {
RegionCreation rc = (RegionCreation) this.stack.peek();
rc.addIndexData(icd);
} else {
throw new InternalGemFireException(LocalizedStrings.CacheXmlParser_CACHEXMLPARSERENDINDEXINDEX_CREATION_ATTRIBUTE_NOT_CORRECTLY_SPECIFIED.toLocalizedString());
}
}
Aggregations