Search in sources :

Example 21 with InternalGemFireException

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

the class LocalRegion method extractDeltaIntoEvent.

private void extractDeltaIntoEvent(Object value, EntryEventImpl event) {
    // 11. Wrap any checked exception in InternalGemFireException before throwing it.
    try {
        // How costly is this if check?
        if (getSystem().getConfig().getDeltaPropagation() && value instanceof Delta) {
            boolean extractDelta = false;
            if (!this.hasServerProxy()) {
                if (this instanceof PartitionedRegion) {
                    if (((PartitionedRegion) this).getRedundantCopies() > 0) {
                        extractDelta = true;
                    } else {
                        InternalDistributedMember ids = (InternalDistributedMember) PartitionRegionHelper.getPrimaryMemberForKey(this, event.getKey());
                        if (ids != null) {
                            extractDelta = !this.getSystem().getMemberId().equals(ids.getId()) || hasAdjunctRecipientsNeedingDelta(event);
                        } else {
                            extractDelta = true;
                        }
                    }
                } else if (this instanceof DistributedRegion && !((DistributedRegion) this).scope.isDistributedNoAck() && !((CacheDistributionAdvisee) this).getCacheDistributionAdvisor().adviseCacheOp().isEmpty()) {
                    extractDelta = true;
                }
                if (!extractDelta && ClientHealthMonitor.getInstance() != null) {
                    extractDelta = ClientHealthMonitor.getInstance().hasDeltaClients();
                }
            } else if (HandShake.isDeltaEnabledOnServer()) {
                // This is a client region
                extractDelta = true;
            }
            if (extractDelta && ((org.apache.geode.Delta) value).hasDelta()) {
                HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT);
                long start = DistributionStats.getStatTime();
                try {
                    ((org.apache.geode.Delta) value).toDelta(hdos);
                } catch (RuntimeException re) {
                    throw re;
                } catch (Exception e) {
                    throw new DeltaSerializationException(LocalizedStrings.DistributionManager_CAUGHT_EXCEPTION_WHILE_SENDING_DELTA.toLocalizedString(), e);
                }
                event.setDeltaBytes(hdos.toByteArray());
                this.getCachePerfStats().endDeltaPrepared(start);
            }
        }
    } catch (RuntimeException re) {
        throw re;
    } catch (Exception e) {
        throw new InternalGemFireException(e);
    }
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException) TimeoutException(org.apache.geode.cache.TimeoutException) NameResolutionException(org.apache.geode.cache.query.NameResolutionException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) InternalGemFireException(org.apache.geode.InternalGemFireException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) CacheRuntimeException(org.apache.geode.cache.CacheRuntimeException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) EntryDestroyedException(org.apache.geode.cache.EntryDestroyedException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) ExecutionException(java.util.concurrent.ExecutionException) TypeMismatchException(org.apache.geode.cache.query.TypeMismatchException) FunctionDomainException(org.apache.geode.cache.query.FunctionDomainException) EntryExistsException(org.apache.geode.cache.EntryExistsException) PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) StatisticsDisabledException(org.apache.geode.cache.StatisticsDisabledException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) FailedSynchronizationException(org.apache.geode.cache.FailedSynchronizationException) NoSuchElementException(java.util.NoSuchElementException) QueryException(org.apache.geode.cache.query.QueryException) RedundancyAlreadyMetException(org.apache.geode.internal.cache.partitioned.RedundancyAlreadyMetException) QueryInvalidException(org.apache.geode.cache.query.QueryInvalidException) LowMemoryException(org.apache.geode.cache.LowMemoryException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) SystemException(javax.transaction.SystemException) SubscriptionNotEnabledException(org.apache.geode.cache.client.SubscriptionNotEnabledException) RegionExistsException(org.apache.geode.cache.RegionExistsException) RegionReinitializedException(org.apache.geode.cache.RegionReinitializedException) CancelException(org.apache.geode.CancelException) DiskAccessException(org.apache.geode.cache.DiskAccessException) CacheWriterException(org.apache.geode.cache.CacheWriterException) IndexMaintenanceException(org.apache.geode.cache.query.IndexMaintenanceException) TransactionException(org.apache.geode.cache.TransactionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) CacheClosedException(org.apache.geode.cache.CacheClosedException) RollbackException(javax.transaction.RollbackException) ConcurrentCacheModificationException(org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException) MultiIndexCreationException(org.apache.geode.cache.query.MultiIndexCreationException) DeltaSerializationException(org.apache.geode.DeltaSerializationException) CacheRuntimeException(org.apache.geode.cache.CacheRuntimeException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) Delta(org.apache.geode.Delta) DeltaSerializationException(org.apache.geode.DeltaSerializationException) HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream)

Example 22 with InternalGemFireException

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

the class HandShake method readServerMember.

protected DistributedMember readServerMember(DataInputStream p_dis) throws IOException {
    byte[] memberBytes = DataSerializer.readByteArray(p_dis);
    ByteArrayInputStream bais = new ByteArrayInputStream(memberBytes);
    DataInputStream dis = new DataInputStream(bais);
    Version v = InternalDataSerializer.getVersionForDataStreamOrNull(p_dis);
    if (v != null) {
        dis = new VersionedDataInputStream(dis, v);
    }
    try {
        return DataSerializer.readObject(dis);
    } catch (EOFException e) {
        throw e;
    } catch (Exception e) {
        throw new InternalGemFireException(LocalizedStrings.HandShake_UNABLE_TO_DESERIALIZE_MEMBER.toLocalizedString(), e);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Version(org.apache.geode.internal.Version) InternalGemFireException(org.apache.geode.InternalGemFireException) EOFException(java.io.EOFException) VersionedDataInputStream(org.apache.geode.internal.VersionedDataInputStream) DataInputStream(java.io.DataInputStream) VersionedDataInputStream(org.apache.geode.internal.VersionedDataInputStream) ServerRefusedConnectionException(org.apache.geode.cache.client.ServerRefusedConnectionException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) InternalGemFireException(org.apache.geode.InternalGemFireException) GatewayConfigurationException(org.apache.geode.cache.GatewayConfigurationException) EOFException(java.io.EOFException) AuthenticationFailedException(org.apache.geode.security.AuthenticationFailedException) GemFireConfigException(org.apache.geode.GemFireConfigException) IOException(java.io.IOException) AuthenticationRequiredException(org.apache.geode.security.AuthenticationRequiredException)

Example 23 with InternalGemFireException

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

the class ClientProxyMembershipID method updateID.

/**
   * call this when the distributed system ID has been modified
   */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "Only applicable in client DS and in that case too multiple instances do not modify it at the same time.")
public void updateID(DistributedMember idm) {
    // this.transientPort = ((InternalDistributedMember)this.memberId).getPort();
    // if (this.transientPort == 0) {
    // InternalDistributedSystem.getLoggerI18n().warning(
    // LocalizedStrings.DEBUG,
    // "updating client ID when member port is zero: " + this.memberId,
    // new Exception("stack trace")
    // );
    // }
    HeapDataOutputStream hdos = new HeapDataOutputStream(256, Version.CURRENT);
    try {
        DataSerializer.writeObject(idm, hdos);
    } catch (IOException e) {
        throw new InternalGemFireException("Unable to serialize member: " + this.memberId, e);
    }
    this.identity = hdos.toByteArray();
    if (this.memberId != null && this.memberId == systemMemberId) {
        systemMemberId = idm;
    // client_side_identity = this.identity;
    }
    this.memberId = idm;
    // make sure we don't retain the old ID representation in toString
    this._toString = null;
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException)

Example 24 with InternalGemFireException

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

the class ConcurrentParallelGatewaySenderEventProcessor method stopProcessing.

@Override
public void stopProcessing() {
    if (!this.isAlive()) {
        return;
    }
    setIsStopped(true);
    final LoggingThreadGroup loggingThreadGroup = LoggingThreadGroup.createThreadGroup("ConcurrentParallelGatewaySenderEventProcessor Logger Group", logger);
    ThreadFactory threadFactory = new ThreadFactory() {

        public Thread newThread(final Runnable task) {
            final Thread thread = new Thread(loggingThreadGroup, task, "ConcurrentParallelGatewaySenderEventProcessor Stopper Thread");
            thread.setDaemon(true);
            return thread;
        }
    };
    List<SenderStopperCallable> stopperCallables = new ArrayList<SenderStopperCallable>();
    for (ParallelGatewaySenderEventProcessor parallelProcessor : this.processors) {
        stopperCallables.add(new SenderStopperCallable(parallelProcessor));
    }
    ExecutorService stopperService = Executors.newFixedThreadPool(processors.length, threadFactory);
    try {
        List<Future<Boolean>> futures = stopperService.invokeAll(stopperCallables);
        for (Future<Boolean> f : futures) {
            try {
                Boolean b = f.get();
                if (logger.isDebugEnabled()) {
                    logger.debug("ConcurrentParallelGatewaySenderEventProcessor: {} stopped dispatching: {}", (b ? "Successfully" : "Unsuccesfully"), this);
                }
            } catch (ExecutionException e) {
                // we don't expect any exception but if caught then eat it and log warning
                logger.warn(LocalizedMessage.create(LocalizedStrings.GatewaySender_0_CAUGHT_EXCEPTION_WHILE_STOPPING_1, sender), e.getCause());
            }
        }
    } catch (InterruptedException e) {
        throw new InternalGemFireException(e);
    } catch (RejectedExecutionException rejectedExecutionEx) {
        throw rejectedExecutionEx;
    }
    stopperService.shutdown();
    closeProcessor();
    if (logger.isDebugEnabled()) {
        logger.debug("ConcurrentParallelGatewaySenderEventProcessor: Stopped dispatching: {}", this);
    }
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) InternalGemFireException(org.apache.geode.InternalGemFireException) ArrayList(java.util.ArrayList) LoggingThreadGroup(org.apache.geode.internal.logging.LoggingThreadGroup) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException)

Example 25 with InternalGemFireException

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

the class DistributedCacheTestCase method preTearDown.

/**
   * Closes the cache in this VM and each remote VM
   */
@Override
public final void preTearDown() throws Exception {
    StringBuffer problems = new StringBuffer();
    if (cache != null) {
        try {
            if (remoteCloseCache()) {
                problems.append("An exception occurred trying to close the cache.");
            }
            assertTrue(cache == null);
        } catch (Exception ex) {
            String s = "While closing the cache in this VM";
            throw new InternalGemFireException(s, ex);
        }
    }
    for (int h = 0; h < Host.getHostCount(); h++) {
        Host host = Host.getHost(h);
        for (int v = 0; v < host.getVMCount(); v++) {
            VM vm = host.getVM(v);
            boolean exceptionInThreads = vm.invoke(() -> this.remoteCloseCache());
            if (exceptionInThreads) {
                String s = "An exception occurred in GemFire system";
                problems.append(s);
            }
        }
    }
    assertEquals("Problems while tearing down", "", problems.toString().trim());
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException) VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host) CacheException(org.apache.geode.cache.CacheException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) InternalGemFireException(org.apache.geode.InternalGemFireException)

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