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);
}
}
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);
}
}
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;
}
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);
}
}
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());
}
Aggregations