@Override public void resume() { this.firstProxy.getPool().setupServerAffinity(true); this.firstProxy.getPool().setServerAffinityLocation(this.serverAffinityLocation); if (logger.isDebugEnabled()) { logger.debug("TX: resuming transaction: {} server delegate: {}", getTransactionId(), this.serverAffinityLocation); } }
@Override public void suspend() { this.serverAffinityLocation = this.firstProxy.getPool().getServerAffinityLocation(); this.firstProxy.getPool().releaseServerAffinity(); if (logger.isDebugEnabled()) { logger.debug("TX: suspending transaction: {} server delegate: {}", getTransactionId(), this.serverAffinityLocation); } }
public ClientTXStateStub(InternalCache cache, DistributionManager dm, TXStateProxy stateProxy, DistributedMember target, InternalRegion firstRegion) { super(stateProxy, target); this.cache = cache; this.dm = dm; this.firstProxy = firstRegion.getServerProxy(); this.firstProxy.getPool().setupServerAffinity(true); if (recordedTransactionalOperations != null) { recordedTransactionalOperations.set(this.recordedOperations); } }
@Override public void rollback() { if (this.internalAfterSendRollback != null) { this.internalAfterSendRollback.run(); } try { txRolledback = true; this.firstProxy.rollback(proxy.getTxId().getUniqId()); } finally { this.firstProxy.getPool().releaseServerAffinity(); } }
@Override protected void validateRegionCanJoinTransaction(InternalRegion region) throws TransactionException { if (!region.hasServerProxy()) { throw new TransactionException("Region " + region.getName() + " is local to this client and cannot be used in a transaction."); } else if (this.firstProxy != null && this.firstProxy.getPool() != region.getServerProxy().getPool()) { throw new TransactionException("Region " + region.getName() + " is using a different server pool than other regions in this transaction."); } }
UnregisterInterestOp.execute(srp.getPool(), regName, key, interestType, true/* isClosing */, keepAlive); } catch (Exception e) { if (!srp.getPool().getCancelCriterion().isCancelInProgress()) { logger.warn("Problem removing all interest on region={} interestType={} :{}", new Object[] {regName, InterestType.getString(interestType),
@Before public void setUp() { cache = mock(InternalCache.class); dm = mock(DistributionManager.class); stateProxy = mock(TXStateProxy.class); target = mock(DistributedMember.class); region = mock(LocalRegion.class); serverRegionProxy = mock(ServerRegionProxy.class); internalPool = mock(InternalPool.class); cancelCriterion = mock(CancelCriterion.class); when(region.getServerProxy()).thenReturn(serverRegionProxy); when(serverRegionProxy.getPool()).thenReturn(internalPool); when(stateProxy.getTxId()).thenReturn(mock(TXId.class)); when(cache.getCancelCriterion()).thenReturn(cancelCriterion); doThrow(new CacheClosedException()).when(cancelCriterion).checkCancelInProgress(any()); }
@Override public void afterCompletion(int status) { try { if (txRolledback) { return; } TXCommitMessage txcm = this.firstProxy.afterCompletion(status, proxy.getTxId().getUniqId()); if (status == Status.STATUS_COMMITTED) { if (txcm == null) { throw new TransactionInDoubtException( "Commit failed on cache server"); } else { afterServerCommit(txcm); } } else if (status == Status.STATUS_ROLLEDBACK) { if (this.internalAfterSendRollback != null) { this.internalAfterSendRollback.run(); } this.firstProxy.getPool().releaseServerAffinity(); } } finally { if (status == Status.STATUS_COMMITTED) { // rollback does not grab locks this.lockReq.releaseLocal(); } this.firstProxy.getPool().releaseServerAffinity(); } }
@Override public void beforeCompletion() { obtainLocalLocks(); try { this.firstProxy.beforeCompletion(proxy.getTxId().getUniqId()); } catch (GemFireException e) { this.lockReq.releaseLocal(); this.firstProxy.getPool().releaseServerAffinity(); throw e; } }
/** * Initializes the connection using the pool from the client region. Also sets the cqBaseRegion * value of this CQ. */ private void initConnectionProxy() throws CqException, RegionNotFoundException { cqBaseRegion = (LocalRegion) cqService.getCache().getRegion(regionName); // Check if the region exists on the local cache. // In the current implementation of 5.1 the Server Connection is (ConnectionProxyImpl) // is obtained by the Bridge Client/writer/loader on the local region. if (cqBaseRegion == null) { throw new RegionNotFoundException( String.format("Region on which query is specified not found locally, regionName: %s", regionName)); } ServerRegionProxy srp = cqBaseRegion.getServerProxy(); if (srp != null) { if (logger.isTraceEnabled()) { logger.trace("Found server region proxy on region. RegionName: {}", regionName); } this.cqProxy = new ServerCQProxyImpl(srp); if (!srp.getPool().getSubscriptionEnabled()) { throw new CqException("The 'queueEnabled' flag on Pool installed on Region " + regionName + " is set to false."); } } else { throw new CqException( "Unable to get the connection pool. The Region does not have a pool configured."); } }
@Override public void commit() throws CommitConflictException { obtainLocalLocks(); try { TXCommitMessage txcm = null; try { txcm = firstProxy.commit(proxy.getTxId().getUniqId()); } finally { this.firstProxy.getPool().releaseServerAffinity(); } afterServerCommit(txcm); } catch (TransactionDataNodeHasDepartedException e) { throw new TransactionInDoubtException(e); } finally { lockReq.releaseLocal(); } }
"Interest registration requires a Pool"); if (isDurable && !proxy.getPool().isDurableClient()) { throw new IllegalStateException( "Durable flag only applicable for durable clients."); if (!proxy.getPool().getSubscriptionEnabled()) { String msg = "Interest registration requires a pool whose queue is enabled."; throw new SubscriptionNotEnabledException(msg);
/** * GEODE-478 - large payloads are rejected by client->server */ @Test public void testLargeMessageIsRejected() throws Exception { PORT1 = initServerCache(false); createClientCache(NetworkUtils.getServerHostName(), PORT1); Region region = static_cache.getRegion(REGION_NAME1); Op operation = new Op() { @Override public Object attempt(Connection cnx) throws Exception { throw new MessageTooLargeException("message is too big"); } @Override public boolean useThreadLocalConnection() { return false; } }; try { ((LocalRegion) region).getServerProxy().getPool().execute(operation); } catch (GemFireIOException e) { assertTrue(e.getCause() instanceof MessageTooLargeException); return; } fail("expected an exception to be thrown"); }
public void getClientPRMetadata(InternalRegion region) { final String regionFullPath = region.getFullPath(); ClientPartitionAdvisor advisor = null; InternalPool pool = region.getServerProxy().getPool();
long clientReadTimeOut = PoolFactory.DEFAULT_READ_TIMEOUT; if (r.hasServerProxy()) { clientReadTimeOut = r.getServerProxy().getPool().getReadTimeout(); if (logger.isDebugEnabled()) { logger.debug("RemoveAllPRMessage: doLocalRemoveAll: clientReadTimeOut is {}",
long clientReadTimeOut = PoolFactory.DEFAULT_READ_TIMEOUT; if (r.hasServerProxy()) { clientReadTimeOut = r.getServerProxy().getPool().getReadTimeout(); if (logger.isDebugEnabled()) { logger.debug("PutAllPRMessage: doLocalPutAll: clientReadTimeOut is {}", clientReadTimeOut);
ServerRegionProxy proxy = ((InternalRegion) newRegion).getServerProxy(); if (proxy != null) { if (((Pool) proxy.getPool()).getSubscriptionEnabled()) { try { newRegion.registerInterest("ALL_KEYS");
/** * Unregisters everything registered on the given region name */ public void unregisterRegion(ServerRegionProxy srp, boolean keepalive) { removeAllInterests(srp, InterestType.KEY, false, keepalive, false); removeAllInterests(srp, InterestType.FILTER_CLASS, false, keepalive, false); removeAllInterests(srp, InterestType.OQL_QUERY, false, keepalive, false); removeAllInterests(srp, InterestType.REGULAR_EXPRESSION, false, keepalive, false); removeAllInterests(srp, InterestType.KEY, false, keepalive, true); removeAllInterests(srp, InterestType.FILTER_CLASS, false, keepalive, true); removeAllInterests(srp, InterestType.OQL_QUERY, false, keepalive, true); removeAllInterests(srp, InterestType.REGULAR_EXPRESSION, false, keepalive, true); // durable if (srp.getPool().isDurableClient()) { removeAllInterests(srp, InterestType.KEY, true, keepalive, true); removeAllInterests(srp, InterestType.FILTER_CLASS, true, keepalive, true); removeAllInterests(srp, InterestType.OQL_QUERY, true, keepalive, true); removeAllInterests(srp, InterestType.REGULAR_EXPRESSION, true, keepalive, true); removeAllInterests(srp, InterestType.KEY, true, keepalive, false); removeAllInterests(srp, InterestType.FILTER_CLASS, true, keepalive, false); removeAllInterests(srp, InterestType.OQL_QUERY, true, keepalive, false); removeAllInterests(srp, InterestType.REGULAR_EXPRESSION, true, keepalive, false); } }