Search in sources :

Example 16 with InternalGemFireException

use of org.apache.geode.InternalGemFireException in project geode by apache.

the class CacheXmlGenerator method generate.

/**
   * Generates XML for region attributes.
   *
   * @param id The id of the named region attributes (may be <code>null</code>)
   */
private void generate(String id, RegionAttributes attrs) throws SAXException {
    AttributesImpl atts = new AttributesImpl();
    if (id != null) {
        atts.addAttribute("", "", ID, "", id);
    }
    // point, the refid information is lost.
    if (attrs instanceof RegionAttributesCreation) {
        String refId = ((RegionAttributesCreation) attrs).getRefid();
        if (refId != null) {
            atts.addAttribute("", "", REFID, "", refId);
        }
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasScope())) {
        String scopeString;
        Scope scope = attrs.getScope();
        if (scope.equals(Scope.LOCAL)) {
            scopeString = LOCAL;
        } else if (scope.equals(Scope.DISTRIBUTED_NO_ACK)) {
            scopeString = DISTRIBUTED_NO_ACK;
        } else if (scope.equals(Scope.DISTRIBUTED_ACK)) {
            scopeString = DISTRIBUTED_ACK;
        } else if (scope.equals(Scope.GLOBAL)) {
            scopeString = GLOBAL;
        } else {
            throw new InternalGemFireException(LocalizedStrings.CacheXmlGenerator_UNKNOWN_SCOPE_0.toLocalizedString(scope));
        }
        final boolean isPartitionedRegion;
        if (attrs instanceof RegionAttributesCreation) {
            RegionAttributesCreation rac = (RegionAttributesCreation) attrs;
            isPartitionedRegion = rac.getPartitionAttributes() != null || (rac.hasDataPolicy() && rac.getDataPolicy().withPartitioning());
        } else {
            isPartitionedRegion = attrs.getPartitionAttributes() != null || attrs.getDataPolicy().withPartitioning();
        }
        if (!isPartitionedRegion) {
            // Partitioned Region don't support setting scope
            if (generateDefaults() || !scope.equals(AbstractRegion.DEFAULT_SCOPE))
                atts.addAttribute("", "", SCOPE, "", scopeString);
        }
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasEarlyAck())) {
        if (generateDefaults() || attrs.getEarlyAck())
            atts.addAttribute("", "", EARLY_ACK, "", String.valueOf(attrs.getEarlyAck()));
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasMulticastEnabled())) {
        if (generateDefaults() || attrs.getMulticastEnabled())
            atts.addAttribute("", "", MULTICAST_ENABLED, "", String.valueOf(attrs.getMulticastEnabled()));
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasPublisher())) {
        if (generateDefaults() || attrs.getPublisher())
            atts.addAttribute("", "", PUBLISHER, "", String.valueOf(attrs.getPublisher()));
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasEnableAsyncConflation())) {
        if (generateDefaults() || attrs.getEnableAsyncConflation())
            atts.addAttribute("", "", ENABLE_ASYNC_CONFLATION, "", String.valueOf(attrs.getEnableAsyncConflation()));
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_0) >= 0) {
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasEnableSubscriptionConflation())) {
            if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_7) >= 0) {
                // starting with 5.7 it is enable-subscription-conflation
                if (generateDefaults() || attrs.getEnableSubscriptionConflation())
                    atts.addAttribute("", "", ENABLE_SUBSCRIPTION_CONFLATION, "", String.valueOf(attrs.getEnableSubscriptionConflation()));
            } else {
                // before 5.7 it was enable-bridge-conflation
                if (generateDefaults() || attrs.getEnableSubscriptionConflation())
                    atts.addAttribute("", "", ENABLE_BRIDGE_CONFLATION, "", String.valueOf(attrs.getEnableSubscriptionConflation()));
            }
        }
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasDataPolicy())) {
            String dpString;
            DataPolicy dp = attrs.getDataPolicy();
            if (dp.isEmpty()) {
                dpString = EMPTY_DP;
            } else if (dp.isNormal()) {
                dpString = NORMAL_DP;
            } else if (dp.isPreloaded()) {
                dpString = PRELOADED_DP;
            } else if (dp.isReplicate()) {
                dpString = REPLICATE_DP;
            } else if (dp == DataPolicy.PERSISTENT_REPLICATE) {
                dpString = PERSISTENT_REPLICATE_DP;
            } else if (dp == DataPolicy.PERSISTENT_PARTITION) {
                dpString = PERSISTENT_PARTITION_DP;
            } else if (dp.isPartition()) {
                if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_1) >= 0) {
                    dpString = PARTITION_DP;
                } else {
                    // prior to 5.1 the data policy for partitioned regions was EMPTY
                    dpString = EMPTY_DP;
                }
            } else {
                throw new InternalGemFireException(LocalizedStrings.CacheXmlGenerator_UNKNOWN_DATA_POLICY_0.toLocalizedString(dp));
            }
            if (generateDefaults() || !dp.equals(DataPolicy.DEFAULT))
                atts.addAttribute("", "", DATA_POLICY, "", dpString);
        }
    // hasDataPolicy
    } else // GEMFIRE_5_0 >= 0
    {
        // GEMFIRE_5_0 < 0
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasEnableSubscriptionConflation())) {
            if (generateDefaults() || attrs.getEnableSubscriptionConflation())
                atts.addAttribute("", "", "enable-conflation", "", String.valueOf(attrs.getEnableSubscriptionConflation()));
        }
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasMirrorType())) {
            String mirrorString;
            MirrorType mirror = attrs.getMirrorType();
            if (mirror.equals(MirrorType.NONE))
                mirrorString = NONE;
            else if (mirror.equals(MirrorType.KEYS))
                mirrorString = KEYS;
            else if (mirror.equals(MirrorType.KEYS_VALUES))
                mirrorString = KEYS_VALUES;
            else
                throw new InternalGemFireException(LocalizedStrings.CacheXmlGenerator_UNKNOWN_MIRROR_TYPE_0.toLocalizedString(mirror));
            atts.addAttribute("", "", MIRROR_TYPE, "", mirrorString);
        }
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasPersistBackup())) {
            atts.addAttribute("", "", PERSIST_BACKUP, "", String.valueOf(attrs.getDataPolicy() == DataPolicy.PERSISTENT_REPLICATE));
        }
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasInitialCapacity())) {
        if (generateDefaults() || attrs.getInitialCapacity() != 16)
            atts.addAttribute("", "", INITIAL_CAPACITY, "", String.valueOf(attrs.getInitialCapacity()));
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasLoadFactor())) {
        if (generateDefaults() || attrs.getLoadFactor() != 0.75f)
            atts.addAttribute("", "", LOAD_FACTOR, "", String.valueOf(attrs.getLoadFactor()));
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasConcurrencyLevel())) {
        if (generateDefaults() || attrs.getConcurrencyLevel() != 16)
            atts.addAttribute("", "", CONCURRENCY_LEVEL, "", String.valueOf(attrs.getConcurrencyLevel()));
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_7_0) >= 0) {
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasConcurrencyChecksEnabled())) {
            if (generateDefaults() || attrs.getConcurrencyChecksEnabled() != true)
                /* fixes bug 46654 */
                atts.addAttribute("", "", CONCURRENCY_CHECKS_ENABLED, "", String.valueOf(attrs.getConcurrencyChecksEnabled()));
        }
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasStatisticsEnabled())) {
        if (generateDefaults() || attrs.getStatisticsEnabled())
            atts.addAttribute("", "", STATISTICS_ENABLED, "", String.valueOf(attrs.getStatisticsEnabled()));
    }
    if (!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasIgnoreJTA()) {
        if (generateDefaults() || attrs.getIgnoreJTA())
            atts.addAttribute("", "", IGNORE_JTA, "", String.valueOf(attrs.getIgnoreJTA()));
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_4_0) >= 0) {
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasIsLockGrantor())) {
            if (generateDefaults() || attrs.isLockGrantor())
                atts.addAttribute("", "", IS_LOCK_GRANTOR, "", String.valueOf(attrs.isLockGrantor()));
        }
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_7) >= 0) {
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasPoolName())) {
            String cpVal = attrs.getPoolName();
            if (cpVal == null) {
                cpVal = "";
            }
            if (generateDefaults() || !cpVal.equals(""))
                atts.addAttribute("", "", POOL_NAME, "", cpVal);
        }
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_6_5) >= 0) {
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasDiskStoreName())) {
            String dsVal = attrs.getDiskStoreName();
            if (dsVal != null) {
                atts.addAttribute("", "", DISK_STORE_NAME, "", dsVal);
            }
        }
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasDiskSynchronous())) {
            if (generateDefaults() || attrs.isDiskSynchronous() != AttributesFactory.DEFAULT_DISK_SYNCHRONOUS)
                atts.addAttribute("", "", DISK_SYNCHRONOUS, "", String.valueOf(attrs.isDiskSynchronous()));
        }
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_6_1) >= 0)
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasCloningEnabled())) {
            if (generateDefaults() || attrs.getCloningEnabled())
                atts.addAttribute("", "", CLONING_ENABLED, "", String.valueOf(attrs.getCloningEnabled()));
        }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_7_0) >= 0) {
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasGatewaySenderId())) {
            Set<String> senderIds = new HashSet<String>(attrs.getGatewaySenderIds());
            StringBuilder senderStringBuff = new StringBuilder();
            if (senderIds != null && senderIds.size() != 0) {
                for (String senderId : senderIds) {
                    if (!(senderStringBuff.length() == 0)) {
                        senderStringBuff.append(",");
                    }
                    senderStringBuff.append(senderId);
                }
            }
            if (generateDefaults() || senderStringBuff.length() > 0)
                atts.addAttribute("", "", GATEWAY_SENDER_IDS, "", senderStringBuff.toString());
        }
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_7_0) >= 0) {
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasAsyncEventListeners())) {
            Set<String> asyncEventQueueIds = new HashSet<String>(attrs.getAsyncEventQueueIds());
            StringBuilder asyncEventQueueStringBuff = new StringBuilder();
            if (asyncEventQueueIds != null && asyncEventQueueIds.size() != 0) {
                for (String asyncEventQueueId : asyncEventQueueIds) {
                    if (!(asyncEventQueueStringBuff.length() == 0)) {
                        asyncEventQueueStringBuff.append(",");
                    }
                    asyncEventQueueStringBuff.append(asyncEventQueueId);
                }
            }
            if (generateDefaults() || asyncEventQueueStringBuff.length() > 0)
                atts.addAttribute("", "", ASYNC_EVENT_QUEUE_IDS, "", asyncEventQueueStringBuff.toString());
        }
    }
    if (this.version.compareTo(CacheXmlVersion.GEODE_1_0) >= 0) {
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasOffHeap())) {
            if (generateDefaults() || attrs.getOffHeap()) {
                atts.addAttribute("", "", OFF_HEAP, "", String.valueOf(attrs.getOffHeap()));
            }
        }
    }
    handler.startElement("", REGION_ATTRIBUTES, REGION_ATTRIBUTES, atts);
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasKeyConstraint())) {
        generate(attrs.getKeyConstraint(), KEY_CONSTRAINT);
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasValueConstraint())) {
        generate(attrs.getValueConstraint(), VALUE_CONSTRAINT);
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasRegionTimeToLive())) {
        if (generateDefaults() || !attrs.getRegionTimeToLive().equals(ExpirationAttributes.DEFAULT))
            generate(REGION_TIME_TO_LIVE, attrs.getRegionTimeToLive(), null);
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasRegionIdleTimeout())) {
        if (generateDefaults() || !attrs.getRegionIdleTimeout().equals(ExpirationAttributes.DEFAULT))
            generate(REGION_IDLE_TIME, attrs.getRegionIdleTimeout(), null);
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasEntryTimeToLive() || ((RegionAttributesCreation) attrs).hasCustomEntryTimeToLive())) {
        if (generateDefaults() || !attrs.getEntryTimeToLive().equals(ExpirationAttributes.DEFAULT) || attrs.getCustomEntryTimeToLive() != null)
            generate(ENTRY_TIME_TO_LIVE, attrs.getEntryTimeToLive(), attrs.getCustomEntryTimeToLive());
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasEntryIdleTimeout() || ((RegionAttributesCreation) attrs).hasCustomEntryIdleTimeout())) {
        if (generateDefaults() || !attrs.getEntryIdleTimeout().equals(ExpirationAttributes.DEFAULT) || attrs.getCustomEntryIdleTimeout() != null)
            generate(ENTRY_IDLE_TIME, attrs.getEntryIdleTimeout(), attrs.getCustomEntryIdleTimeout());
    }
    if (attrs.getDiskStoreName() == null && (generateDefaults() || this.version.compareTo(CacheXmlVersion.GEMFIRE_6_5) < 0)) {
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasDiskWriteAttributes())) {
            generate(attrs.getDiskWriteAttributes());
        }
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasDiskDirs())) {
            File[] diskDirs = attrs.getDiskDirs();
            int[] diskSizes = attrs.getDiskDirSizes();
            if (diskDirs != null && diskDirs.length > 0) {
                handler.startElement("", DISK_DIRS, DISK_DIRS, EMPTY);
                for (int i = 0; i < diskDirs.length; i++) {
                    AttributesImpl diskAtts = new AttributesImpl();
                    if (diskSizes[i] != DiskStoreFactory.DEFAULT_DISK_DIR_SIZE) {
                        diskAtts.addAttribute("", "", DIR_SIZE, "", String.valueOf(diskSizes[i]));
                    }
                    handler.startElement("", DISK_DIR, DISK_DIR, diskAtts);
                    File dir = diskDirs[i];
                    String name = generateDefaults() ? dir.getAbsolutePath() : dir.getPath();
                    handler.characters(name.toCharArray(), 0, name.length());
                    handler.endElement("", DISK_DIR, DISK_DIR);
                }
                handler.endElement("", DISK_DIRS, DISK_DIRS);
            }
        }
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_0) >= 0) {
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasPartitionAttributes())) {
            PartitionAttributes p = attrs.getPartitionAttributes();
            if (p != null) {
                generate(p);
            }
        }
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_0) >= 0) {
        MembershipAttributes p = attrs.getMembershipAttributes();
        if (p != null && p.hasRequiredRoles()) {
            generate(p);
        }
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_0) >= 0) {
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasSubscriptionAttributes())) {
            SubscriptionAttributes sa = attrs.getSubscriptionAttributes();
            if (sa != null) {
                if (generateDefaults() || !sa.equals(new SubscriptionAttributes()))
                    generate(sa);
            }
        }
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasCacheLoader())) {
        generate(CACHE_LOADER, attrs.getCacheLoader());
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasCacheWriter())) {
        generate(CACHE_WRITER, attrs.getCacheWriter());
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasCacheListeners())) {
        CacheListener[] listeners = attrs.getCacheListeners();
        for (int i = 0; i < listeners.length; i++) {
            generate(CACHE_LISTENER, listeners[i]);
        }
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_8_0) >= 0) {
        if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasCompressor())) {
            generate(COMPRESSOR, attrs.getCompressor());
        }
    }
    if ((!(attrs instanceof RegionAttributesCreation) || ((RegionAttributesCreation) attrs).hasEvictionAttributes())) {
        generate(attrs.getEvictionAttributes());
    }
    handler.endElement("", REGION_ATTRIBUTES, REGION_ATTRIBUTES);
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes) CacheListener(org.apache.geode.cache.CacheListener) DiskWriteAttributesImpl(org.apache.geode.internal.cache.DiskWriteAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) AttributesImpl(org.xml.sax.helpers.AttributesImpl) Scope(org.apache.geode.cache.Scope) MirrorType(org.apache.geode.cache.MirrorType) DataPolicy(org.apache.geode.cache.DataPolicy) File(java.io.File) HashSet(java.util.HashSet) MembershipAttributes(org.apache.geode.cache.MembershipAttributes) SubscriptionAttributes(org.apache.geode.cache.SubscriptionAttributes)

Example 17 with InternalGemFireException

use of org.apache.geode.InternalGemFireException in project geode by apache.

the class CacheXmlParser method startExpirationAttributes.

/**
   * When a <code>expiration-attributes</code> element is first encountered, we create an
   * ExpirationAttibutes?? object from the element's attributes and push it on the stack.
   */
private void startExpirationAttributes(Attributes atts) {
    int timeout = parseInt(atts.getValue(TIMEOUT));
    String action = atts.getValue(ACTION);
    ExpirationAttributes expire;
    if (action == null) {
        expire = new ExpirationAttributes(timeout);
    } else if (action.equals(INVALIDATE)) {
        expire = new ExpirationAttributes(timeout, ExpirationAction.INVALIDATE);
    } else if (action.equals(DESTROY)) {
        expire = new ExpirationAttributes(timeout, ExpirationAction.DESTROY);
    } else if (action.equals(LOCAL_INVALIDATE)) {
        expire = new ExpirationAttributes(timeout, ExpirationAction.LOCAL_INVALIDATE);
    } else if (action.equals(LOCAL_DESTROY)) {
        expire = new ExpirationAttributes(timeout, ExpirationAction.LOCAL_DESTROY);
    } else {
        throw new InternalGemFireException(LocalizedStrings.CacheXmlParser_UNKNOWN_EXPIRATION_ACTION_0.toLocalizedString(action));
    }
    stack.push(expire);
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException) ExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)

Example 18 with InternalGemFireException

use of org.apache.geode.InternalGemFireException in project geode by apache.

the class CacheXmlParser method startAsyncEventQueue.

private void startAsyncEventQueue(Attributes atts) {
    AsyncEventQueueCreation asyncEventQueueCreation = new AsyncEventQueueCreation();
    // id
    String id = atts.getValue(ID);
    asyncEventQueueCreation.setId(id);
    String parallel = atts.getValue(PARALLEL);
    if (parallel == null) {
        asyncEventQueueCreation.setParallel(GatewaySender.DEFAULT_IS_PARALLEL);
    } else {
        asyncEventQueueCreation.setParallel(Boolean.parseBoolean(parallel));
    }
    // batch-size
    String batchSize = atts.getValue(BATCH_SIZE);
    if (batchSize == null) {
        asyncEventQueueCreation.setBatchSize(GatewaySender.DEFAULT_BATCH_SIZE);
    } else {
        asyncEventQueueCreation.setBatchSize(Integer.parseInt(batchSize));
    }
    // batch-time-interval
    String batchTimeInterval = atts.getValue(BATCH_TIME_INTERVAL);
    if (batchTimeInterval == null) {
        asyncEventQueueCreation.setBatchTimeInterval(GatewaySender.DEFAULT_BATCH_TIME_INTERVAL);
    } else {
        asyncEventQueueCreation.setBatchTimeInterval(Integer.parseInt(batchTimeInterval));
    }
    // batch-conflation
    String batchConflation = atts.getValue(ENABLE_BATCH_CONFLATION);
    if (batchConflation == null) {
        asyncEventQueueCreation.setBatchConflationEnabled(GatewaySender.DEFAULT_BATCH_CONFLATION);
    } else {
        asyncEventQueueCreation.setBatchConflationEnabled(Boolean.parseBoolean(batchConflation));
    }
    // maximum-queue-memory
    String maxQueueMemory = atts.getValue(MAXIMUM_QUEUE_MEMORY);
    if (maxQueueMemory == null) {
        asyncEventQueueCreation.setMaximumQueueMemory(GatewaySender.DEFAULT_MAXIMUM_QUEUE_MEMORY);
    } else {
        asyncEventQueueCreation.setMaximumQueueMemory(Integer.parseInt(maxQueueMemory));
    }
    // persistent
    String persistent = atts.getValue(PERSISTENT);
    if (persistent == null) {
        asyncEventQueueCreation.setPersistent(GatewaySender.DEFAULT_PERSISTENCE_ENABLED);
    } else {
        asyncEventQueueCreation.setPersistent(Boolean.parseBoolean(persistent));
    }
    // diskStoreName
    String diskStoreName = atts.getValue(DISK_STORE_NAME);
    if (diskStoreName == null) {
        asyncEventQueueCreation.setDiskStoreName(null);
    } else {
        asyncEventQueueCreation.setDiskStoreName(diskStoreName);
    }
    // diskSynchronous
    String diskSynchronous = atts.getValue(DISK_SYNCHRONOUS);
    if (diskSynchronous == null) {
        asyncEventQueueCreation.setDiskSynchronous(GatewaySender.DEFAULT_DISK_SYNCHRONOUS);
    } else {
        asyncEventQueueCreation.setDiskSynchronous(Boolean.parseBoolean(diskSynchronous));
    }
    String dispatcherThreads = atts.getValue(DISPATCHER_THREADS);
    if (dispatcherThreads == null) {
        asyncEventQueueCreation.setDispatcherThreads(GatewaySender.DEFAULT_DISPATCHER_THREADS);
    } else {
        asyncEventQueueCreation.setDispatcherThreads(Integer.parseInt(dispatcherThreads));
    }
    String orderPolicy = atts.getValue(ORDER_POLICY);
    if (orderPolicy != null) {
        try {
            asyncEventQueueCreation.setOrderPolicy(GatewaySender.OrderPolicy.valueOf(orderPolicy.toUpperCase()));
        } catch (IllegalArgumentException e) {
            throw new InternalGemFireException(LocalizedStrings.AsyncEventQueue_UNKNOWN_ORDER_POLICY_0_1.toLocalizedString(new Object[] { id, orderPolicy }));
        }
    }
    // forward expiration destroy events.
    String forward = atts.getValue(FORWARD_EXPIRATION_DESTROY);
    if (forward != null) {
        asyncEventQueueCreation.setForwardExpirationDestroy(Boolean.parseBoolean(forward));
    }
    stack.push(asyncEventQueueCreation);
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException)

Example 19 with InternalGemFireException

use of org.apache.geode.InternalGemFireException in project geode by apache.

the class DirectReplySender method putOutgoing.

public Set putOutgoing(DistributionMessage msg) {
    Assert.assertTrue(!this.sentReply, "Trying to reply twice to a message");
    // Using an ArrayList, rather than Collections.singletonList here, because the MsgStreamer
    // mutates the list when it has exceptions.
    // fix for bug #42199 - cancellation check
    this.conn.getConduit().getDM().getCancelCriterion().checkCancelInProgress(null);
    if (logger.isTraceEnabled(LogMarker.DM)) {
        logger.trace(LogMarker.DM, "Sending a direct reply {} to {}", msg, conn.getRemoteAddress());
    }
    ArrayList<Connection> conns = new ArrayList<Connection>(1);
    conns.add(conn);
    MsgStreamer ms = (MsgStreamer) MsgStreamer.create(conns, msg, false, DUMMY_STATS);
    try {
        ms.writeMessage();
        ConnectExceptions ce = ms.getConnectExceptions();
        if (ce != null && !ce.getMembers().isEmpty()) {
            Assert.assertTrue(ce.getMembers().size() == 1);
            logger.warn(LocalizedMessage.create(LocalizedStrings.DirectChannel_FAILURE_SENDING_DIRECT_REPLY, ce.getMembers().iterator().next()));
            return Collections.singleton(ce.getMembers().iterator().next());
        }
        sentReply = true;
        return Collections.emptySet();
    } catch (NotSerializableException e) {
        throw new InternalGemFireException(e);
    } catch (ToDataException e) {
        // exception from user code
        throw e;
    } catch (IOException ex) {
        throw new InternalGemFireException(LocalizedStrings.DirectChannel_UNKNOWN_ERROR_SERIALIZING_MESSAGE.toLocalizedString(), ex);
    } finally {
        try {
            ms.close();
        } catch (IOException e) {
            throw new InternalGemFireException("Unknown error serializing message", e);
        }
    }
}
Also used : NotSerializableException(java.io.NotSerializableException) InternalGemFireException(org.apache.geode.InternalGemFireException) ToDataException(org.apache.geode.ToDataException) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 20 with InternalGemFireException

use of org.apache.geode.InternalGemFireException in project geode by apache.

the class StatArchiveWriter method allocatedResourceInstance.

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "This is only for debugging and there is never more than one instance being traced because there is only one stat sampler.")
public void allocatedResourceInstance(ResourceInstance statResource) {
    if (logger.isTraceEnabled(LogMarker.STATISTICS)) {
        logger.trace(LogMarker.STATISTICS, "StatArchiveWriter#allocatedResourceInstance statResource={}", statResource);
    }
    if (statResource.getResourceType().getStatisticDescriptors().length >= ILLEGAL_STAT_OFFSET) {
        throw new InternalGemFireException(LocalizedStrings.StatArchiveWriter_COULD_NOT_ARCHIVE_TYPE_0_BECAUSE_IT_HAD_MORE_THAN_1_STATISTICS.toLocalizedString(new Object[] { statResource.getResourceType().getStatisticsType().getName(), Integer.valueOf(ILLEGAL_STAT_OFFSET - 1) }));
    }
    if (statResource.getStatistics().isClosed()) {
        return;
    }
    this.addedResources.add(statResource);
    try {
        this.dataOut.writeByte(RESOURCE_INSTANCE_CREATE_TOKEN);
        this.dataOut.writeInt(statResource.getId());
        this.dataOut.writeUTF(statResource.getStatistics().getTextId());
        this.dataOut.writeLong(statResource.getStatistics().getNumericId());
        this.dataOut.writeInt(statResource.getResourceType().getId());
        if (this.trace && (traceStatisticsName == null || traceStatisticsName.equals(statResource.getStatistics().getTextId())) && (traceStatisticsTypeName == null || traceStatisticsTypeName.equals(statResource.getResourceType().getStatisticsType().getName()))) {
            traceResourceInstId = statResource.getId();
            this.traceDataOut.println("writeHeader traceResourceInstId: " + traceResourceInstId);
            this.traceDataOut.println("allocatedResourceInstance#writeByte RESOURCE_INSTANCE_CREATE_TOKEN: " + RESOURCE_INSTANCE_CREATE_TOKEN);
            this.traceDataOut.println("allocatedResourceInstance#writeInt statResource.getId(): " + statResource.getId());
            this.traceDataOut.println("allocatedResourceInstance#writeUTF statResource.getStatistics().getTextId(): " + statResource.getStatistics().getTextId());
            this.traceDataOut.println("allocatedResourceInstance#writeLong statResource.getStatistics().getNumericId(): " + statResource.getStatistics().getNumericId());
            this.traceDataOut.println("allocatedResourceInstance#writeInt statResource.getResourceType().getId(): " + statResource.getResourceType().getId());
        }
    } catch (IOException ex) {
        throw new GemFireIOException(LocalizedStrings.StatArchiveWriter_FAILED_WRITING_NEW_RESOURCE_INSTANCE_TO_STATISTIC_ARCHIVE.toLocalizedString(), ex);
    }
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException) GemFireIOException(org.apache.geode.GemFireIOException) GemFireIOException(org.apache.geode.GemFireIOException) IOException(java.io.IOException)

Aggregations

InternalGemFireException (org.apache.geode.InternalGemFireException)46 IOException (java.io.IOException)12 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)8 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)8 ExecutionException (java.util.concurrent.ExecutionException)7 UnknownHostException (java.net.UnknownHostException)6 Future (java.util.concurrent.Future)6 Method (java.lang.reflect.Method)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 List (java.util.List)4 CancelException (org.apache.geode.CancelException)4 CacheException (org.apache.geode.cache.CacheException)4 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)4 ServerOperationException (org.apache.geode.cache.client.ServerOperationException)4 NoSuchElementException (java.util.NoSuchElementException)3 Set (java.util.Set)3 ExecutorService (java.util.concurrent.ExecutorService)3