Removed BridgeWriter, BridgeWriterException, and BridgePoolImpl
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/d102cd86 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/d102cd86 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/d102cd86 Branch: refs/heads/feature/GEODE-243 Commit: d102cd860dfea0b57ab7b16464ff5ba3d4776998 Parents: 8dd0443 Author: Darrel Schneider <dschnei...@pivotal.io> Authored: Fri Aug 28 13:57:26 2015 -0700 Committer: Darrel Schneider <dschnei...@pivotal.io> Committed: Fri Aug 28 13:57:26 2015 -0700 ---------------------------------------------------------------------- .../gemfire/cache/AttributesFactory.java | 18 - .../gemfire/cache/DynamicRegionFactory.java | 115 ++- .../cache/client/internal/BridgePoolImpl.java | 479 ----------- .../cache/client/internal/DestroyOp.java | 5 - .../gemfire/cache/client/internal/GetOp.java | 5 - .../gemfire/cache/client/internal/PutOp.java | 5 - .../client/internal/ServerRegionProxy.java | 1 - .../internal/FunctionServiceManager.java | 3 +- .../gemfire/cache/util/BridgeWriter.java | 794 ------------------- .../cache/util/BridgeWriterException.java | 48 -- .../internal/admin/ClientStatsManager.java | 7 - .../gemfire/internal/cache/AbstractRegion.java | 25 - .../internal/cache/DistributedRegion.java | 3 - .../gemfire/internal/cache/ExpiryTask.java | 18 - .../internal/cache/GemFireCacheImpl.java | 1 - .../gemfire/internal/cache/LocalRegion.java | 14 +- .../internal/cache/PartitionedRegion.java | 3 - .../gemfire/internal/cache/PoolFactoryImpl.java | 170 +--- .../gemfire/internal/cache/PoolManagerImpl.java | 19 - .../internal/cache/doc-files/properties.html | 2 + .../cache/execute/InternalFunctionService.java | 4 +- .../internal/cache/xmlcache/CacheCreation.java | 18 +- .../cache/xmlcache/CacheXmlGenerator.java | 14 +- .../internal/cache/xmlcache/CacheXmlParser.java | 18 +- .../internal/i18n/ParentLocalizedStrings.java | 2 +- .../gemstone/gemfire/cache/ClientHelper.java | 1 - .../gemfire/cache30/CacheXml41DUnitTest.java | 23 +- .../gemfire/cache30/CacheXml57DUnitTest.java | 1 - .../tier/sockets/BridgeWriterMiscDUnitTest.java | 3 - .../tier/sockets/ConnectionProxyJUnitTest.java | 209 ++--- .../tier/sockets/RedundancyLevelJUnitTest.java | 8 +- .../tier/sockets/RedundancyLevelTestBase.java | 1 - .../tier/sockets/RedundancyLevelJUnitTest.xml | 21 +- 33 files changed, 193 insertions(+), 1865 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/cache/AttributesFactory.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/AttributesFactory.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/AttributesFactory.java index 11a4dcc..7acd72a 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/AttributesFactory.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/AttributesFactory.java @@ -514,11 +514,6 @@ public class AttributesFactory<K,V> { */ public void setCacheWriter(CacheWriter<K,V> cacheWriter) { - if (cacheWriter != null) { - if (AbstractRegion.isBridgeWriter(cacheWriter) && this.regionAttributes.getPoolName() != null) { - throw new IllegalStateException("A region with a pool name can not have a BridgeWriter or BridgeClient. Please use pools OR BridgeClient."); - } - } this.regionAttributes.cacheWriter = cacheWriter; this.regionAttributes.setHasCacheWriter(true); } @@ -1280,8 +1275,6 @@ public class AttributesFactory<K,V> { * @param name the name of the connection pool to use; if <code>null</code> * or <code>""</code> then the connection pool is disabled for regions * using these attributes. - * @throws IllegalStateException if a cache loader or cache writer has already - * been set. * @since 5.7 */ public void setPoolName(String name) { @@ -1289,12 +1282,6 @@ public class AttributesFactory<K,V> { if ("".equals(nm)) { nm = null; } - if (nm != null) { - if (this.regionAttributes.getCacheWriter() != null - && AbstractRegion.isBridgeWriter(this.regionAttributes.getCacheWriter())) { - throw new IllegalStateException("A region with a bridge writer can not have a pool name."); - } - } this.regionAttributes.poolName = nm; this.regionAttributes.setHasPoolName(true); @@ -1537,11 +1524,6 @@ public class AttributesFactory<K,V> { throw new IllegalStateException(LocalizedStrings.AttributesFactory_IF_THE_MEMBERSHIP_ATTRIBUTES_HAS_REQUIRED_ROLES_THEN_SCOPE_MUST_NOT_BE_LOCAL.toLocalizedString()); } } - if (attrs.getPoolName() != null) { - if (attrs.getCacheWriter() != null && AbstractRegion.isBridgeWriter(attrs.getCacheWriter())) { - throw new IllegalStateException("A region with a pool name can not have a BridgeWriter or BridgeClient. Please use pools OR BridgeClient."); - } - } final PartitionAttributes pa = attrs.getPartitionAttributes(); // Validations for PartitionRegion Attributes http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/cache/DynamicRegionFactory.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/DynamicRegionFactory.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/DynamicRegionFactory.java index 21a6ede..d57e2b1 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/DynamicRegionFactory.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/DynamicRegionFactory.java @@ -22,7 +22,6 @@ import com.gemstone.gemfire.SystemFailure; import com.gemstone.gemfire.cache.client.Pool; import com.gemstone.gemfire.cache.client.PoolManager; import com.gemstone.gemfire.cache.client.internal.ServerRegionProxy; -import com.gemstone.gemfire.cache.util.BridgeWriter; import com.gemstone.gemfire.cache.wan.GatewaySender; import com.gemstone.gemfire.distributed.DistributedMember; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; @@ -100,7 +99,7 @@ import com.gemstone.gemfire.security.GemFireSecurityException; * <p> * Notes: * <ul> - * <li>DynamicRegionFactories in non-client VMs must not be configured with a BridgeWriter. + * <li>DynamicRegionFactories in non-client VMs must not be configured with a pool. * <li>If {@link #open()} is called before cache creation and the cache.xml has a dynamic-region-factory * element then the cache.xml will override the open call's configuration. * @@ -223,7 +222,7 @@ public abstract class DynamicRegionFactory { try { this.c = theCache; this.dynamicRegionList = theCache.getRegion(dynamicRegionListName); - final boolean isClient = this.config.getBridgeWriter() != null || this.config.getPoolName()!=null; + final boolean isClient = this.config.getPoolName()!=null; if (this.dynamicRegionList == null) { InternalRegionArguments ira = new InternalRegionArguments() .setDestroyLockFlag(true) @@ -239,7 +238,6 @@ public abstract class DynamicRegionFactory { } if (isClient) { - // BRIDGE CLIENT af.setScope(Scope.LOCAL); af.setDataPolicy(DataPolicy.NORMAL); //MirrorType(MirrorType.NONE); af.setStatisticsEnabled(true); @@ -254,12 +252,6 @@ public abstract class DynamicRegionFactory { } af.setPoolName(cpName); } - } else { - BridgeWriter bw = this.config.getBridgeWriter(); - if (!bw.hasEstablishCallbackConnection()) { - throw new IllegalStateException(LocalizedStrings.DynamicRegionFactory_THE_CLIENT_POOL_OF_A_DYNAMICREGIONFACTORY_MUST_BE_CONFIGURED_WITH_ESTABLISHCALLBACKCONNECTION_SET_TO_TRUE.toLocalizedString()); - } - af.setCacheWriter(bw); } ira.setInternalMetaRegion(new LocalMetaRegion(af.create(), ira)); } else { @@ -667,7 +659,7 @@ public abstract class DynamicRegionFactory { * The default attributes are: * <ul> * <li>diskDir: <code>null</code> - * <li>bridgeWriter: <code>null</code> + * <li>poolName: <code>null</code> * <li>persistBackup: <code>true</code> * <li>registerInterest: <code>true</code> * </ul> @@ -683,16 +675,10 @@ public abstract class DynamicRegionFactory { public final File diskDir; /** Causes regions created by the factory to register interest in all keys in a corresponding server cache region */ public final boolean registerInterest; - /** The {@link BridgeWriter} to be used by the factory to communicate with - * the factory in its server. - * Client factories must configure a BridgeWriter for their factory - * and it must be configured to establish a callback connection. - */ - public final BridgeWriter bridgeWriter; /** - * The ${link Pool} to be used by the factory to communicate with - * the server-side factory. Client factories may use this instead of a BridgeWriter + * The ${link Pool} to be used by a client factory to communicate with + * the server-side factory. */ public final String poolName; @@ -700,47 +686,15 @@ public abstract class DynamicRegionFactory { * Creates a configuration with the default attributes. */ public Config() { - this(null, null, !DISABLE_PERSIST_BACKUP); - } - /** - * Creates a configuration with the given attributes and defaults for other attributes. - * @deprecated use a pool name instead of a bridge writer - */ - @Deprecated - public Config(File diskDir, BridgeWriter bridgeWriter) { - this(diskDir, bridgeWriter, !DISABLE_PERSIST_BACKUP); + this(null, null, !DISABLE_PERSIST_BACKUP, !DISABLE_REGISTER_INTEREST); } - + /** - * Creates a configuration with the given attributes and defaults for other attributes. - * @deprecated use a pool name instead of a bridge writer + * Creates a configuration with defaults and the given diskDir and poolName. */ - @Deprecated - public Config(File diskDir, BridgeWriter bridgeWriter, boolean persistBackup) { - this(diskDir, bridgeWriter, persistBackup, !DISABLE_REGISTER_INTEREST); + public Config(File diskDir, String poolName) { + this(diskDir, poolName, !DISABLE_PERSIST_BACKUP, !DISABLE_REGISTER_INTEREST); } - - - - /** - * Creates a configuration with the given attributes - * @deprecated use a pool name instead of a bridge writer - */ - @Deprecated - public Config( - File diskDir, - BridgeWriter bridgeWriter, - boolean persistBackup, - boolean registerInterest) - { - this.registerInterest = registerInterest; - this.persistBackup = persistBackup; - this.diskDir = diskDir; - this.bridgeWriter = bridgeWriter; - this.poolName = null; - } - - /** * Creates a configuration with the given attributes */ @@ -754,7 +708,43 @@ public abstract class DynamicRegionFactory { this.persistBackup = persistBackup; this.diskDir = diskDir; this.poolName = poolName; - this.bridgeWriter = null; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((diskDir == null) ? 0 : diskDir.hashCode()); + result = prime * result + (persistBackup ? 1231 : 1237); + result = prime * result + ((poolName == null) ? 0 : poolName.hashCode()); + result = prime * result + (registerInterest ? 1231 : 1237); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Config other = (Config) obj; + if (diskDir == null) { + if (other.diskDir != null) + return false; + } else if (!diskDir.equals(other.diskDir)) + return false; + if (persistBackup != other.persistBackup) + return false; + if (poolName == null) { + if (other.poolName != null) + return false; + } else if (!poolName.equals(other.poolName)) + return false; + if (registerInterest != other.registerInterest) + return false; + return true; } /** @@ -782,14 +772,6 @@ public abstract class DynamicRegionFactory { return this.diskDir; } - /** - * Returns the {@link BridgeWriter} associated with the dynamic region factory. - * Returns null if there is no cache writer for dynamic regions. - * A cache writer will only exist if this is a client and the cache writer connects to a server. - */ - public BridgeWriter getBridgeWriter() { - return this.bridgeWriter; - } /** * Returns the name of the {@link Pool} associated with the dynamic region factory. @@ -803,7 +785,6 @@ public abstract class DynamicRegionFactory { Config(Config conf) { this.diskDir = conf.diskDir; this.persistBackup = conf.persistBackup; - this.bridgeWriter = conf.bridgeWriter; this.registerInterest = conf.registerInterest; this.poolName = conf.poolName; } @@ -814,7 +795,7 @@ public abstract class DynamicRegionFactory { return; // Ignore the callback if it originated in this process (because the region - // will already have been created) and the event is not a bridge event + // will already have been created) and the event is not a client event if ( !event.isOriginRemote() && !event.isBridgeEvent() ) return; // DynamicRegionAttributes dra = (DynamicRegionAttributes)event.getNewValue(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/BridgePoolImpl.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/BridgePoolImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/BridgePoolImpl.java deleted file mode 100644 index c138e14..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/BridgePoolImpl.java +++ /dev/null @@ -1,479 +0,0 @@ -/*========================================================================= - * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved. - * This product is protected by U.S. and international copyright - * and intellectual property laws. Pivotal products are covered by - * more patents listed at http://www.pivotal.io/patents. - *========================================================================= - */ -package com.gemstone.gemfire.cache.client.internal; - -import java.util.Properties; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.logging.log4j.Logger; - -import com.gemstone.gemfire.CancelException; -import com.gemstone.gemfire.cache.CacheLoaderException; -import com.gemstone.gemfire.cache.CacheWriterException; -import com.gemstone.gemfire.cache.NoSubscriptionServersAvailableException; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.client.Pool; -import com.gemstone.gemfire.cache.client.PoolManager; -import com.gemstone.gemfire.cache.client.ServerConnectivityException; -import com.gemstone.gemfire.cache.client.SubscriptionNotEnabledException; -import com.gemstone.gemfire.cache.client.internal.GetOp.GetOpImpl; -import com.gemstone.gemfire.cache.util.BridgeWriterException; -import com.gemstone.gemfire.cache.util.EndpointDoesNotExistException; -import com.gemstone.gemfire.cache.util.EndpointExistsException; -import com.gemstone.gemfire.cache.util.EndpointInUseException; -import com.gemstone.gemfire.distributed.internal.ServerLocation; -import com.gemstone.gemfire.internal.cache.PoolFactoryImpl; -import com.gemstone.gemfire.internal.cache.PoolManagerImpl; -import com.gemstone.gemfire.internal.cache.tier.ConnectionProxy; -import com.gemstone.gemfire.internal.cache.tier.sockets.AcceptorImpl; -import com.gemstone.gemfire.internal.logging.LogService; - -/** - * A pool for use by the old bridge code. - * This class can go away once we drop these deprecated classes - * - * @author darrel - * @since 5.7 - */ -@SuppressWarnings("deprecation") -public class BridgePoolImpl extends PoolImpl implements ConnectionProxy { - private static final Logger logger = LogService.getLogger(); - - private static final AtomicInteger ID_COUNTER = new AtomicInteger(); - public static final int DEFAULT_CONNECTIONSPERSERVER = 1; - public static final int DEFAULT_HANDSHAKE_TIMEOUT = AcceptorImpl.DEFAULT_HANDSHAKE_TIMEOUT_MS; - public static final String DEFAULT_LBPOLICY = LBPolicy.STICKY_PROPERTY_NAME; - - //this field is only set to true when the cache is closing with - //keep alive set to true. - private boolean keepAlive; - - private static int getBridgePoolId() { - return ID_COUNTER.incrementAndGet(); - } - - public static BridgePoolImpl create(Properties props, boolean usedByBridgeWriter) { - return create(props, usedByBridgeWriter, false/*usedByGateway*/); - } - - public static BridgePoolImpl create(Properties props, boolean usedByBridgeWriter, - boolean usedByGateway) { - - String name = (usedByGateway ? "GatewayPool-" : "BridgePool-") + getBridgePoolId(); - PoolFactoryImpl pf = (PoolFactoryImpl)PoolManager.createFactory(); - pf.init(props, usedByBridgeWriter, usedByGateway); - BridgePoolImpl result = (BridgePoolImpl)pf.create(name); - if (!result.isDestroyed()) { - result.attach(); - } - return result; - } - /** - * Should only be called by PoolFactoryImpl#create. - * All other creators should use the static create method - */ - public BridgePoolImpl(PoolManagerImpl pm, String name, Pool attributes) { - super(pm, name, attributes); - finishCreate(pm); // do this last since we are escaping the constructor - } - public static void loadEmergencyClasses() { - // nyi - } - - ////////////////// ConnectionProxy methods //////////////////// - /** - * Initializes this <code>ConnectionProxy</code> according to the - * given properties. - */ - public void initialize(Properties p) { - throw new IllegalStateException("nyi"); - } - - - - public void finalizeProxy() { - detach(); - if (getAttachCount() <= 0) { - destroy(keepAlive); - } - } - - - /** - * Returns the load balancing policy in effect for this connection - * proxy. - */ - public String getLBPolicy() { - if (getThreadLocalConnections()) { - return "Sticky"; - } else { - return "RoundRobin"; - } - } - - - /** - * Returns the number of milliseconds to wait before re-connecting - * to a dead server. - */ - public int getRetryInterval() { - return (int)getPingInterval(); - } - - - /** - * Closes this connection proxy and all of its connections - */ - public void close() { - if (logger.isDebugEnabled()) { - logger.debug("BridgePoolImpl - closing"); - } - finalizeProxy(); - } - - - /** - * Returned true if this ConnectionProxy has been initialized and not closed. - */ - public boolean isOpen() { - return !isDestroyed(); - } - - - /** - * Update bookkeeping on this proxy associated with the loss of a region. - * In particular, remove all region interests. - */ - public void detachRegion(Region r) { - // nyi - } - - - /** - * Returns the number of {@link Connection}s that should be created - * to every cache server. - */ - public int getConnectionsPerServer() { - return getMinConnections(); - } - - - /** - * Notes that the server with the given name is unavailable - */ - public void setServerUnavailable(String name) { - throw new IllegalStateException("nyi"); - } - - - /** - * Notes that the server with the given name is available - */ - public void setServerAvailable(String name) { - throw new IllegalStateException("nyi"); - } - - - /** - * Stops this connection proxy and - */ - public void terminate() { - finalizeProxy(); - } - - - /** - * Releases the connection associated with the current thread - */ - public void release() { - // nyi - } - - /** - * Returns value of establishCallbackConnection property. - * @since 4.2.3 - */ - public boolean getEstablishCallbackConnection() { - return getSubscriptionEnabled(); - } - - - /** - * Add an <code>Endpoint</code> to the known <code>Endpoint</code>s. - * - * @param name The name of the endpoint to add - * @param host The host name or ip address of the endpoint to add - * @param port The port of the endpoint to add - * - * @throws EndpointExistsException if the <code>Endpoint</code> to be - * added already exists. - * - * @since 5.0.2 - */ - public void addEndpoint(String name, String host, int port) - throws EndpointExistsException { - ((ExplicitConnectionSourceImpl)getConnectionSource()).addEndpoint(host,port); - } - - - /** - * Remove an <code>Endpoint</code> from the dead <code>Endpoint</code>s. - * The specified <code>Endpoint</code> must be dead. - * - * @param name The name of the endpoint to remove - * @param host The host name or ip address of the endpoint to remove - * @param port The port of the endpoint to remove - * - * @throws EndpointDoesNotExistException if the <code>Endpoint</code> to be - * removed doesn't exist. - * - * @since 5.0.2 - */ - public void removeEndpoint(String name, String host, int port) - throws EndpointDoesNotExistException,EndpointInUseException { - ((ExplicitConnectionSourceImpl)getConnectionSource()).removeEndpoint(host,port); - } - - - /** - * @return Returns the redundancy number - * @since 5.1 - */ - public int getRedundancyLevel() { - return getSubscriptionRedundancy(); - } - - /** - * The configurable expiry time of last received sequence ID - * - * @return The configurable expiry time of last received sequence ID - */ - public long getMessageTrackingTimeout() { - return getSubscriptionMessageTrackingTimeout(); - } - - public void reuse() { - attach(); - } - - - public static boolean isLoaderOp(Op op) { - return op instanceof GetOpImpl; - } - - private RuntimeException transformException(RuntimeException ex, Op op) { - if(isLoaderOp(op)) { - if (ex instanceof SubscriptionNotEnabledException) { - return new CacheLoaderException("establishCallbackConnection must be set to true", ex); - } else if (ex instanceof CacheLoaderException) { - return ex; - } else if (ex instanceof CancelException) { - return ex; - } else if (ex instanceof ServerConnectivityException && ex.getCause() != null) { - return new CacheLoaderException(ex.getCause()); - } else { - return new CacheLoaderException(ex); - } - } - else { - if (ex instanceof SubscriptionNotEnabledException) { - return new BridgeWriterException("establishCallbackConnection must be set to true", ex); - } else if (ex instanceof CacheWriterException) { - return ex; - } else if (ex instanceof CancelException) { - return ex; - } else if (ex instanceof ServerConnectivityException && ex.getCause() != null) { - return new BridgeWriterException(ex.getCause()); - } else { - return new BridgeWriterException(ex); - } - } - } - - @Override - public Object execute(Op op) { - try { - return super.execute(op); - } catch (RuntimeException ex) { - throw transformException(ex, op); - } - } - - @Override - public Object executeOn(ServerLocation server, Op op) { - try { - return super.executeOn(server, op); - } catch (RuntimeException ex) { - throw transformException(ex, op); - } - } - - @Override - public Object executeOn(Connection con, Op op) { - try { - return super.executeOn(con, op); - } catch (RuntimeException ex) { - throw transformException(ex, op); - } - } - - @Override - public Object executeOn(Connection con, Op op, boolean timeoutFatal) { - try { - return super.executeOn(con, op, timeoutFatal); - } catch (RuntimeException ex) { - throw transformException(ex, op); - } - } - - @Override - public Object executeOnQueuesAndReturnPrimaryResult(Op op) { - try { - return super.executeOnQueuesAndReturnPrimaryResult(op); - } catch (RuntimeException ex) { - throw transformException(ex, op); - } - } - - @Override - public void executeOnAllQueueServers(Op op) - throws NoSubscriptionServersAvailableException, SubscriptionNotEnabledException { - try { - super.executeOnAllQueueServers(op); - } catch (RuntimeException ex) { - throw transformException(ex, op); - } - } - - @Override - public Object executeOnPrimary(Op op) { - try { - return super.executeOnPrimary(op); - } catch (RuntimeException ex) { - throw transformException(ex, op); - } - } - public void setKeepAlive(boolean keepAlive) { - this.keepAlive = keepAlive; - } - - /** ******** INNER CLASSES ************************* */ - public static class LBPolicy - { - public static final String STICKY_PROPERTY_NAME = "Sticky"; - - public static final String RANDOMSTICKY_PROPERTY_NAME = "RandomSticky"; - - public static final String ROUNDROBIN_PROPERTY_NAME = "RoundRobin"; - - public static final String RANDOM_PROPERTY_NAME = "Random"; - - public static final String APPASSISTED_PROPERTY_NAME = "AppAssisted"; - - public static final int STICKY = 0; - - public static final int ROUNDROBIN = 1; - - public static final int APPASSISTED = 2; - - public static final int RANDOM = 3; - - public static final int RANDOMSTICKY = 4; - - public final int thePolicy; - - public LBPolicy(String name) { - if (name.equalsIgnoreCase(STICKY_PROPERTY_NAME)) { - this.thePolicy = STICKY; - } - else if (name.equalsIgnoreCase(ROUNDROBIN_PROPERTY_NAME)) { - this.thePolicy = ROUNDROBIN; - } - else if (name.equalsIgnoreCase(APPASSISTED_PROPERTY_NAME)) { - this.thePolicy = APPASSISTED; - } - else if (name.equalsIgnoreCase(RANDOM_PROPERTY_NAME)) { - this.thePolicy = RANDOM; - } - else if (name.equalsIgnoreCase(RANDOMSTICKY_PROPERTY_NAME)) { - this.thePolicy = RANDOMSTICKY; - } - else { - this.thePolicy = STICKY; // DEFAULT - } - } - - public int getPolicy() - { - return this.thePolicy; - } - - public boolean isSticky() { - return getPolicy() == STICKY || getPolicy() == RANDOMSTICKY; - } - - public boolean isRandom() { - return getPolicy() == RANDOM || getPolicy() == RANDOMSTICKY; - } - - public String getPolicyPropertyName(int pol) - { - String retStr; - switch (pol) { - case STICKY: - retStr = STICKY_PROPERTY_NAME; - break; - case ROUNDROBIN: - retStr = ROUNDROBIN_PROPERTY_NAME; - break; - case APPASSISTED: - retStr = APPASSISTED_PROPERTY_NAME; - break; - case RANDOM: - retStr = RANDOM_PROPERTY_NAME; - break; - case RANDOMSTICKY: - retStr = RANDOMSTICKY_PROPERTY_NAME; - break; - default: - return Integer.toString(pol); - } - return retStr; - } - - @Override - public boolean equals(Object obj) - { - if (obj == this) { - return true; - } - - if (obj instanceof LBPolicy) { - LBPolicy other = (LBPolicy)obj; - return this.thePolicy == other.thePolicy; - } - else { - return false; - } - } - - @Override - public int hashCode() - { - return this.thePolicy; - } - - @Override - public String toString() - { - return getPolicyPropertyName(this.thePolicy); - } - } - - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/DestroyOp.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/DestroyOp.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/DestroyOp.java index 7dc0eaa..dbcc7ed 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/DestroyOp.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/DestroyOp.java @@ -15,7 +15,6 @@ import com.gemstone.gemfire.cache.Operation; import com.gemstone.gemfire.cache.client.AllConnectionsInUseException; import com.gemstone.gemfire.cache.client.ServerConnectivityException; import com.gemstone.gemfire.cache.client.ServerOperationException; -import com.gemstone.gemfire.cache.util.BridgeWriterException; import com.gemstone.gemfire.distributed.internal.ServerLocation; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.internal.cache.EntryEventImpl; @@ -80,10 +79,6 @@ public class DestroyOp { } cms.removeBucketServerLocation(server); } - catch (BridgeWriterException e) { - if (e.getCause() instanceof ServerConnectivityException) - cms.removeBucketServerLocation(server); - } } } return pool.execute(op); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/GetOp.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/GetOp.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/GetOp.java index 019da2e..a187bcb 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/GetOp.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/GetOp.java @@ -15,7 +15,6 @@ import com.gemstone.gemfire.cache.Operation; import com.gemstone.gemfire.cache.client.AllConnectionsInUseException; import com.gemstone.gemfire.cache.client.ServerConnectivityException; import com.gemstone.gemfire.cache.client.ServerOperationException; -import com.gemstone.gemfire.cache.util.BridgeWriterException; import com.gemstone.gemfire.distributed.internal.ServerLocation; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.internal.cache.EntryEventImpl; @@ -81,10 +80,6 @@ public class GetOp { } cms.removeBucketServerLocation(server); } - catch (BridgeWriterException e) { - if (e.getCause() instanceof ServerConnectivityException) - cms.removeBucketServerLocation(server); - } catch (CacheLoaderException e) { if (e.getCause() instanceof ServerConnectivityException) cms.removeBucketServerLocation(server); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PutOp.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PutOp.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PutOp.java index 35822ed..05caa9c 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PutOp.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PutOp.java @@ -14,7 +14,6 @@ import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.client.AllConnectionsInUseException; import com.gemstone.gemfire.cache.client.ServerConnectivityException; import com.gemstone.gemfire.cache.client.ServerOperationException; -import com.gemstone.gemfire.cache.util.BridgeWriterException; import com.gemstone.gemfire.distributed.internal.ServerLocation; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.internal.cache.CachedDeserializable; @@ -91,10 +90,6 @@ public class PutOp { } cms.removeBucketServerLocation(server); } - catch (BridgeWriterException e) { - if (e.getCause() instanceof ServerConnectivityException) - cms.removeBucketServerLocation(server); - } } } return pool.execute(op); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ServerRegionProxy.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ServerRegionProxy.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ServerRegionProxy.java index ec85356..077461c 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ServerRegionProxy.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ServerRegionProxy.java @@ -27,7 +27,6 @@ import com.gemstone.gemfire.cache.client.PoolManager; import com.gemstone.gemfire.cache.client.internal.ContainsKeyOp.MODE; import com.gemstone.gemfire.cache.execute.Function; import com.gemstone.gemfire.cache.execute.ResultCollector; -import com.gemstone.gemfire.cache.util.BridgeWriter; import com.gemstone.gemfire.distributed.internal.ServerLocation; import com.gemstone.gemfire.internal.cache.AbstractRegion; import com.gemstone.gemfire.internal.cache.BridgeObserver; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/cache/execute/internal/FunctionServiceManager.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/execute/internal/FunctionServiceManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/execute/internal/FunctionServiceManager.java index 8ec4d83..af73acc 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/execute/internal/FunctionServiceManager.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/execute/internal/FunctionServiceManager.java @@ -422,8 +422,7 @@ public final class FunctionServiceManager { */ private final boolean isClientRegion(Region region) { LocalRegion localRegion = (LocalRegion) region; - return (localRegion.hasServerProxy() || AbstractRegion - .isBridgeWriter(localRegion.getCacheWriter())); + return localRegion.hasServerProxy(); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/cache/util/BridgeWriter.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/util/BridgeWriter.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/util/BridgeWriter.java deleted file mode 100755 index 6ef35cc..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/util/BridgeWriter.java +++ /dev/null @@ -1,794 +0,0 @@ -/*========================================================================= - * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved. - * This product is protected by U.S. and international copyright - * and intellectual property laws. Pivotal products are covered by - * one or more patents listed at http://www.pivotal.io/patents. - *========================================================================= - */ -package com.gemstone.gemfire.cache.util; - -import java.util.Properties; -import java.util.concurrent.atomic.AtomicInteger; - -import com.gemstone.gemfire.LicenseException; -import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.cache.AttributesFactory; -import com.gemstone.gemfire.cache.AttributesMutator; -import com.gemstone.gemfire.cache.CacheWriter; -import com.gemstone.gemfire.cache.CacheWriterException; -import com.gemstone.gemfire.cache.Declarable; -import com.gemstone.gemfire.cache.EntryEvent; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionEvent; -import com.gemstone.gemfire.cache.client.internal.BridgePoolImpl; -import com.gemstone.gemfire.internal.cache.tier.ConnectionProxy; -import com.gemstone.gemfire.internal.i18n.LocalizedStrings; - -/** - * A <code>CacheWriter</code> that writes data to one or more remote - * <code>CacheServer</code> processes. This allows for a hierarchical caching - * scheme in which one cache ('client' cache) delegates a request to another - * cache ('server' cache). - * - * - * When using the <code>BridgeWriter</code>, at least two GemFire Caches must - * exist in a client/server mode (they should not be part of the same - * distributed system). - * - * The 'server' cache must be running a gemfire <code>CacheServer</code> - * process, while the 'client' cache must have a <code>BridgeWriter</code> - * installed in one or more of its <code>Regions</code>. If a - * <code>BridgeWriter</code> is defined in a client <code>Region</code>, - * there must also be a <code>Region</code> defined in the 'server' cache with - * the same exact name. - * - * <p> - * - * The <code>BridgeWriter</code> performs <code>put()</code> operations on - * the remote server cache, and does not provide the distribution behavior that - * can be enabled by using a <code>DISTRIBUTED</code> or - * <code>DISTRIBUTED_NO_ACK</code> <code>Region</code>. This mechanism is - * designed as a more targeted alternative to netSearch, in which the 'client' - * cache completely delegates the loading of the data to the 'server' cache if - * it is not yet cached in the client. This directed behavior enables a remote - * network <code>put()</code> operation to be performed much more efficiently - * in a scenario where there is a hierarchical cache topology. Updates and - * invalidation remain local, in fact the <code>Regions</code> that are used - * for this loosely coupled cache may even be <code>LOCAL</code> in scope. - * - * The <code>BridgeWriter</code> may be used to configure caches with - * multi-layer hierarchies. - * - * - * <p> - * <b>Load Balancing: </b> - * <p> - * The <code>BridgeWriter</code> supports these load balancing mechanisms - * (specified by the <code>LBPolicy</code> config attribute): - * <p> - * <ul> - * <li><b>Sticky </b> <br> - * In this mode, the client writer picks the first server from the list of - * servers and establishes a connection to it. Once this connection has been - * established, every request from that particular 'client' cache is sent on - * that connection. If requests time out or produce exceptions, the - * <code>BridgeWriter</code> picks another server and then sends further - * requests to that server. This achieves a level of load balancing by - * redirecting requests away from servers that produce timeouts.</li> - * - * <li><b>RandomSticky </b> <br> - * The behavior is the same as Sticky, however the initial assignment of the - * connection is randomly selected from the list of servers.</li> - * - * <li><b>RoundRobin </b> <br> - * In this mode, the client establishes connections to all the servers in the - * server list and then randomly picks a server for each given request. For the - * next request, it picks the next server in the list.</li> - * - * <li><b>Random </b>: <br> - * In this mode, the edge establishes connections to all the servers in the - * server list and then randomly picks a server for every request.</li> - * </ul> - * - * <p> - * <b>Failover: </b> - * <p> - * - * If a remote server cache throws an exception or times out, the client will - * retry based on the configured <code>retryCount</code> parameter. If the - * <code>retryCount</code> is exceeded, the server in question will be added - * to a failed server list, and the client will select another server to connect - * to. The servers in the failed server list will be periodically pinged with an - * intelligent ping that ensures cache health. If a server is determined to be - * healthy again, it will be promoted back to the healthy server list. The time - * period between failed server pings is configurable via the - * <code>retryInterval</code> parameter. - * - * <p> - * <b>Configuration: </b> - * <p> - * The <code>BridgeWriter</code> is configurable declaratively or - * programmatically. Declarative configuration is achieved through defining the - * configuration parameters in a <code>cache.xml</code> file. Programmatic - * configuration may be achieved by first instantiating a - * <code>BridgeWriter</code> object and subsequently calling - * {@link #init(Properties)}with a <code>Properties</code> object containing - * each desired parameter and value. - * <p> - * <b>The supported parameters are: </b> - * <p> - * <ul> - * <li><b>endpoints </b> (required) <br> - * A comma delimited list of logical names, hostnames, and ports of 'server' - * caches to connect to <br> - * The endpoints parameter follows this syntax: - * logicalName=host:port,logicalName2=host2:port2,.... <br> - * Example: - * - * <pre> - *<code> - * <parameter name="endpoints"> - * <string>MyPrimaryServer=hostsrv:40404,MySecondary=hostsrv2:40404</string> - * </parameter> - * </code> - *</pre> - * - * </li> - * <li><b>readTimeout </b> (optional: default 10000) <br> - * A millisecond value representing the amount of time to wait for a response - * from a cache server. <br> - * Example: - * - * <pre> - *<code> - * <parameter name="readTimeout"> - * <string>5000</string> - * </parameter> - * </code> - *</pre> - * - * </li> - * - * <li><b>retryAttempts </b> (optional: default 5)<br> - * The number of times to retry a request after timeout/exception. <br> - * Example: - * - * <pre> - *<code> - * <parameter name="retryAttempts"> - * <string>5</string> - * </parameter> - * </code> - *</pre> - * - * </li> - * <li><b>retryInterval </b> (optional: default 10000) <br> - * A millisecond value representing the amount of time to wait between attempts - * by the <code>ServerMonitor</code> to ping living servers to verify that - * they are still alive and dead servers to verify that they are still dead. - * <br> - * Example:</li> - * - * <pre> - *<code> - * <parameter name="retryInterval"> - * <string>10000</string> - * </parameter> - * </code> - *</pre> - * - * </li> - * <li><b>LBPolicy </b> (optional: default "Sticky") <br> - * A String value representing the load balancing policy to use. See above for - * more details. <br> - * Options are: - * <ul> - * <li>"Sticky"</li> - * <li>"RandomSticky"</li> - * <li>"RoundRobin"</li> - * <li>"Random"</li> - * </ul> - * Example: - * - * <pre> - *<code> - * <parameter name="LBPolicy"> - * <string>Sticky</string> - * </parameter> - * </code> - *</pre> - * - * </li> - * <li><b>connectionsPerServer </b> (optional: default 1)<br> - * The number of initial connections created to each time it is determined to be - * alive. The minimum of <code>0</code> causes no initial connections to be - * created (they are only created on demand). <br> - * Example: - * - * <pre> - *<code> - * <parameter name="connectionsPerServer"> - * <string>10</string> - * </parameter> - * </code> - *</pre> - * - * </li> - * <li><b>establishCallbackConnection </b> (optional: default false) <br> - * Instruct the server to make a connection back to this edge client through - * which the client receives cache updates. <br> - * Example: - * - * <pre> - *<code> - * <parameter name="establishCallbackConnection"> - * <string>true</string> - * </parameter> - * </code> - *</pre> - * - * </li> - * - * <li><b>redundancyLevel </b> (optional: default 0) <br> - * The number of secondary servers set for backup to the primary server for the - * high availability of client queue. <br> - * Example: - * - * <pre> - *<code> - * <parameter name="redundancyLevel"> - * <string>1</string> - * </parameter> - * </code> - *</pre> - * - * </li> - * - * <li><b>socketBufferSize </b> (optional: default 32768) <br> - * The size of the socket buffers in bytes. <br> - * Example: - * - * <pre> - *<code> - * <parameter name="socketBufferSize"> - * <string>32768</string> - * </parameter> - * </code> - *</pre> - * - * </li> - * - * <li><b>messageTrackingTimeout </b> (optional: default 300000 milliseconds) - * <br> - * messageTrackingTimeout property specifies the time-to-live period, in - * milliseconds, for entries in the client's message tracking list, to minimize - * duplicate events. Entries that have not been modified for this amount of time - * are expired from the list <br> - * Example: - * - * <pre> - *<code> - * <parameter name="messageTrackingTimeout"> - * <string>300000</string> - * </parameter> - * </code> - *</pre> - * - * </li> - * <li><b>clientAckInterval</b> (optional: default 500 milliseconds) <br> - * Bridge client sends an acknowledgement to its primary server for the events - * it has got after every ClientAckInterval time.Client will send an ack to the - * primary server only when redundancy level is greater than 0 or -1.<br> - * Example: - * - * <pre> - *<code> - * <parameter name="clientAckInterval"> - * <string>5000</string> - * </parameter> - * </code> - *</pre> - * - * </li> - * </ul> - * - * <p> - * - * If you are using a <code>cache.xml</code> file to create a - * <code>Region</code> declaratively, you can include the following to - * associate a <code>BridgeWriter</code> with a <code>Region</code> (default - * values shown for optional parameters): - * - * <pre> - * - * <cache-writer> - * <classname>com.gemstone.gemfire.cache.util.BridgeWriter</classname> - * <parameter name="endpoints"> - * <string>MyHost=ninja.gemstone.com:40404</string> - * </parameter> - * <parameter name="readTimeout"> - * <string>10000</string> - * </parameter> - * <parameter name="retryAttempts"> - * <string>5</string> - * </parameter> - * <parameter name="retryInterval"> - * <string>10000</string> - * </parameter> - * <parameter name="LBPolicy"> - * <string>Sticky</string> - * </parameter> - * <parameter name="establishCallbackConnection"> - * <string>false</string> - * </parameter> - * <parameter name="socketBufferSize"> - * <string>32768</string> - * </parameter> - * </parameter> - * <parameter name="messageTrackingTimeout"> - * <string>300000</string> - * </parameter> - * </parameter> - * </parameter> - * <parameter name="clientAckInterval"> - * <string>5000</string> - * </parameter> - * </cache-writer> - * </pre> - * - * @since 3.5 - * @author Barry Oglesby - * @deprecated as of 5.7 use {@link com.gemstone.gemfire.cache.client pools} instead. - */ - -@Deprecated -public class BridgeWriter implements CacheWriter, Declarable -{ - protected ConnectionProxy proxy = null; // package access for - // tests/com/gemstone/gemfire/cache/util/BridgeHelper - - private Properties properties; - - private volatile boolean isClosed = false; - - private final AtomicInteger refCount = new AtomicInteger(); - - // all writers logic was moved to ConnectionProxyImpl - - /** - * Initializes the writer with supplied config parameters. If instantiating - * the writer programmatically, this method must be called with a - * <code>Properties</code> object that at a minimum contains the 'endpoints' - * parameter before the writer can be used. If init fails with a - * LicenseException, the resulting BridgeWriter will throw - * IllegalStateException until it is properly initialized. - * - * @param p configuration data such as 'endpoint' definitions - * @throws IllegalStateException if the writer is already initialized - */ - public void init(Properties p) - { - if (this.proxy != null) throw new IllegalStateException(LocalizedStrings.BridgeWriter_ALREADY_INITIALIZED.toLocalizedString()); - this.properties = p; - if (Boolean.getBoolean("skipConnection")) { - // used by hydra when generating XML via RegionAttributesCreation - return; - } - this.proxy = BridgePoolImpl.create(properties, true/*useByBridgeWriter*/); - } - - /** - * Initializes this writer from an existing <code>BridgeWriter</code>. This - * method reuses the existing <code>BridgeWriter</code>'s proxy. - * - * @param bridgeWriter - * The existing <code>BridgeWriter</code> - * @throws IllegalStateException if the writer is already initialized - * - * @since 4.2 - */ - public void init(BridgeWriter bridgeWriter) - { - if (this.proxy != null) throw new IllegalStateException(LocalizedStrings.BridgeWriter_ALREADY_INITIALIZED.toLocalizedString()); - ConnectionProxy p = bridgeWriter.proxy; - p.reuse(); - this.proxy = p; - } - - /** - * Ensure that the BridgeClient and BridgePoolImpl classes - * get loaded. - * - * @see SystemFailure#loadEmergencyClasses() - */ - public static void loadEmergencyClasses() { - BridgePoolImpl.loadEmergencyClasses(); - } - - // emergency logic was moved to ConnectionProxyImpl - - /** - * Called when a region using this <code>BridgeWriter</code> is destroyed, - * when the cache is closed, or when a callback is removed from a region using - * an {@link AttributesMutator}. - * - * Closes connections to {@link BridgeServer BridgeServers}when all - * {@link Region Regions}are finished using this BridgeWriter, - * - * - * @see #attach(Region) - * @see #detach(Region) - */ - public void close() - { - if (this.refCount.get() <= 0) { - this.isClosed = true; - this.proxy.close(); - } - } - - // handleMarker moved to ConnectionProxyImpl - - /** - * Returns true if this <code>BridgeWriter</code> has been closed. - */ - public boolean isClosed() { - return this.isClosed; - } - - private void checkClosed() { - String reason = this.proxy.getCancelCriterion().cancelInProgress(); - if(reason != null) { - throw new BridgeWriterException("The BridgeWriter has been closed: " + reason); - } - - if (this.isClosed) { - throw new BridgeWriterException(LocalizedStrings.BridgeWriter_THE_BRIDGEWRITER_HAS_BEEN_CLOSED.toLocalizedString()); - } - if (this.proxy != null && !this.proxy.isOpen()) { - throw new BridgeWriterException(LocalizedStrings.BridgeWriter_THE_BRIDGEWRITER_HAS_BEEN_CLOSED.toLocalizedString()); - } - } - - /** - * Notify the BridgeWriter that the given region is no longer relevant. This - * method is used internally during Region - * {@link Region#destroyRegion() destruction}and - * {@link Region#close() closure}. This method effects the behavor of - * {@link #close()}. - * - * @see #attach(Region) - * @see #close() - * @param r - * the Region which will no longer use this BridgeWriter - * @since 4.3 - */ - public void detach(Region r) - { - this.refCount.decrementAndGet(); - if (r != null) { - this.proxy.detachRegion(r); - } -// close(); // only closes if refCount is zero - } - - /** - * Returns the number of attaches that have not yet called detach. - * @since 5.7 - */ - public int getAttachCount() { - return this.refCount.get(); - } - - /** - * For speed optimizations, a connection to a server may be assigned to the - * calling thread when the BridgeWriter is used to do an operation. - * When the application thread is done doing its work it can invoke - * the BridgeWriter release method to make the connection available - * to other application threads. - */ - public void release() - { - proxy.release(); - } - - /** - * This method should be invoked when the BridgeWriter mechanism is to be shut - * down explicitly , outside of closing the cache. - */ - public void terminate() - { - this.isClosed = true; - proxy.terminate(); - } - - // removed checkForTransaction - - /** - * Called before an entry is updated. The entry update is initiated by a - * <code>put</code> or a <code>get</code> that causes the writer to update - * an existing entry. The entry previously existed in the cache where the - * operation was initiated, although the old value may have been null. The - * entry being updated may or may not exist in the local cache where the - * CacheWriter is installed. - * - * @param event - * an EntryEvent that provides information about the operation in - * progress - * @throws CacheWriterException - * if thrown will abort the operation in progress, and the exception - * will be propagated back to caller that initiated the operation - * @see Region#put(Object, Object) - * @see Region#get(Object) - */ - public void beforeUpdate(EntryEvent event) throws CacheWriterException - { - throw new IllegalStateException("this method should not be called"); - } - - /** - * Called before an entry is created. Entry creation is initiated by a - * <code>create</code>, a <code>put</code>, or a <code>get</code>. - * The <code>CacheWriter</code> can determine whether this value comes from - * a <code>get</code> or not from {@link EntryEvent#isLoad}. The entry - * being created may already exist in the local cache where this - * <code>CacheWriter</code> is installed, but it does not yet exist in the - * cache where the operation was initiated. - * - * @param event - * an EntryEvent that provides information about the operation in - * progress - * @throws CacheWriterException - * if thrown will abort the operation in progress, and the exception - * will be propagated back to caller that initiated the operation - * @see Region#create(Object, Object) - * @see Region#put(Object, Object) - * @see Region#get(Object) - */ - public void beforeCreate(EntryEvent event) throws CacheWriterException - { - throw new IllegalStateException("this method should not be called"); - } - - /** - * Called before an entry is destroyed. The entry being destroyed may or may - * not exist in the local cache where the CacheWriter is installed. This - * method is <em>not</em> called as a result of expiration or - * {@link Region#localDestroy(Object)}. - * - * @param event - * an EntryEvent that provides information about the operation in - * progress - * @throws CacheWriterException - * if thrown will abort the operation in progress, and the exception - * will be propagated back to caller that initiated the operation - * - * @see Region#destroy(Object) - */ - public void beforeDestroy(EntryEvent event) throws CacheWriterException - { - throw new IllegalStateException("this method should not be called"); - } - - /** - * Called before a region is destroyed. The <code>CacheWriter</code> will - * not additionally be called for each entry that is destroyed in the region - * as a result of a region destroy. If the region's subregions have - * <code>CacheWriter</code> s installed, then they will be called for the - * cascading subregion destroys. This method is <em>not</em> called as a - * result of expiration or {@link Region#localDestroyRegion()}. However, the - * {@link #close}method is invoked regardless of whether a region is - * destroyed locally. A non-local region destroy results in an invocation of - * {@link #beforeRegionDestroy}followed by an invocation of {@link #close}. - * <p> - * WARNING: This method should not destroy or create any regions itself or a - * deadlock will occur. - * - * @param event - * a RegionEvent that provides information about the - * - * @throws CacheWriterException - * if thrown, will abort the operation in progress, and the - * exception will be propagated back to the caller that initiated - * the operation - * - * @see Region#destroyRegion() - */ - public void beforeRegionDestroy(RegionEvent event) - throws CacheWriterException - { - throw new IllegalStateException("this method should not be called"); - } - - - /** - * Called before a region is cleared. The <code>CacheWriter</code> will - * not additionally be called for each entry that is cleared in the region - * as a result of a region clear. If the region's subregions have - * <code>CacheWriter</code> s installed, then they will be called for the - * cascading subregion clears. This method is <em>not</em> called as a - * result of expiration or {@link Region#localDestroyRegion()}. However, the - * {@link #close}method is invoked regardless of whether a region is - * cleared locally. A non-local region clear results in an invocation of - * {@link #beforeRegionClear}followed by an invocation of {@link #close}. - * <p> - * WARNING: This method should not destroy or create or clear any regions itself or a - * deadlock will occur. - * - * @param event - * a RegionEvent that provides information about the - * - * @throws CacheWriterException - * if thrown, will abort the operation in progress, and the - * exception will be propagated back to the caller that initiated - * the operation - * - */ - - public void beforeRegionClear(RegionEvent event) throws CacheWriterException - { - throw new IllegalStateException("this method should not be called"); - } - - /** - * Return true if this writer has not been closed and it was configured to - * establish a callback connection. - * - * @since 4.3 - */ - public boolean hasEstablishCallbackConnection() - { - if (this.isClosed) { - return false; - } - else { - return this.proxy.getEstablishCallbackConnection(); - } - } - - // removed unregisterInterest - - // removed getInterestList - - // removed getObjectFromPrimaryServer - - // removed keySet - - // removed containsKey - - /** Returns the retry interval in use. Retry interval refers to the interval - * at which dead servers are attempted to be reconnected. - * Internal use only. - */ - public int getRetryInterval() - { - return proxy.getRetryInterval(); - } - - /** - * Returns the read timeout being used to time out requests to the server - * Internal use only. - */ - public int getReadTimeout() - { - return proxy.getReadTimeout(); - } - - /** - * Returns the number of times the bridge writer tries to write data on - * encountering certain types of exceptions. Internal use only - */ - public int getRetryAttempts() - { - return this.proxy.getRetryAttempts(); - } - - /** - * Returns the load balancing policy being used by the bridge writer Internal - * use only - */ - public String getLBPolicy() - { - return proxy.getLBPolicy(); - } - - /** - * Returns the properties that defined this <code>BridgeWriter</code>. - * - * @return the properties that defined this <code>BridgeWriter</code> - * - * @since 4.2 - */ - public Properties getProperties() - { - return this.properties; - } - - - /** - * Add an <code>Endpoint</code> to the known <code>Endpoint</code>s. - * - * @param name The name of the endpoint to add - * @param host The host name or ip address of the endpoint to add - * @param port The port of the endpoint to add - * - * @throws EndpointExistsException if the <code>Endpoint</code> to be - * added already exists. - * - * @since 5.0.2 - */ - public void addEndpoint(String name, String host, int port) - throws EndpointExistsException { - this.proxy.addEndpoint(name, host, port); - } - - /** - * Remove an <code>Endpoint</code> from the dead <code>Endpoint</code>s. - * The specified <code>Endpoint</code> must be dead. - * - * @param name The name of the endpoint to remove - * @param host The host name or ip address of the endpoint to remove - * @param port The port of the endpoint to remove - * - * @throws EndpointDoesNotExistException if the <code>Endpoint</code> to be - * removed doesn't exist. - * - * @throws EndpointInUseException if the <code>Endpoint</code> to be removed - * contains <code>Connection</code>s - * - * @since 5.0.2 - */ - public void removeEndpoint(String name, String host, int port) - throws EndpointDoesNotExistException, EndpointInUseException { - this.proxy.removeEndpoint(name, host, port); - } - - // removed handleException - - // removed getExceptionMessage - - /** - * Returns a brief description of this <code>BridgeWriter</code> - * - * @since 4.0 - */ - @Override - public String toString() - { - return LocalizedStrings.BridgeWriter_BRIDGEWRITER_CONNECTED_TO_0.toLocalizedString(this.proxy); - } - - /** - * Notify the BridgeWriter that the given Region will begin delivering events - * to this BridgeWriter. This method effects the behavior of {@link #close()} - * - * This is called internally when the BridgeWriter is added to a Region via - * {@link AttributesFactory#setCacheWriter(CacheWriter)}} - * - * @param r - * the Region which will begin use this BridgeWriter. - * @since 4.3 - * - * @see #detach(Region) - * @see #close() - */ - public void attach(Region r) - { - checkClosed(); - this.refCount.incrementAndGet(); - } - - /** - * Returns the <code>ConnectionProxy</code> associated with this - * <code>BridgeWriter</code>. - * - * For internal use only. - * - * @return the <code>ConnectionProxy</code> associated with this - * <code>BridgeWriter</code> - */ - public Object/*ConnectionProxy*/ getConnectionProxy() { - return proxy; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/cache/util/BridgeWriterException.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/util/BridgeWriterException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/util/BridgeWriterException.java deleted file mode 100755 index e481c65..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/util/BridgeWriterException.java +++ /dev/null @@ -1,48 +0,0 @@ -/*========================================================================= - * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved. - * This product is protected by U.S. and international copyright - * and intellectual property laws. Pivotal products are covered by - * one or more patents listed at http://www.pivotal.io/patents. - *========================================================================= - */ -package com.gemstone.gemfire.cache.util; - -import com.gemstone.gemfire.cache.CacheWriterException; - -/** - * An exception that is thrown by a {@link BridgeWriter} when a - * problem occurs when communicating with a bridge server. - * - * @author David Whitlock - * @since 3.5.2 - * @deprecated as of 5.7 use {@link com.gemstone.gemfire.cache.client pools} instead. - */ -@Deprecated -public class BridgeWriterException extends CacheWriterException { -private static final long serialVersionUID = -295001316745954159L; - - /** - * Creates a new <code>BridgeWriterException</code> with the given - * message. - */ - public BridgeWriterException(String message) { - super(message); - } - - /** - * Creates a new <code>BridgeWriterException</code> with the given - * message and cause. - */ - public BridgeWriterException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Creates a new <code>BridgeWriterException</code> with the given - * cause. - */ - public BridgeWriterException(Throwable cause) { - super(cause); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/internal/admin/ClientStatsManager.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/admin/ClientStatsManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/admin/ClientStatsManager.java index 7166024..b8ceb0b 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/admin/ClientStatsManager.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/admin/ClientStatsManager.java @@ -19,7 +19,6 @@ import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.client.internal.PoolImpl; import com.gemstone.gemfire.cache.client.internal.ServerRegionProxy; import com.gemstone.gemfire.cache.query.CqQuery; -import com.gemstone.gemfire.cache.util.BridgeWriterException; import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.i18n.LogWriterI18n; @@ -88,12 +87,6 @@ public class ClientStatsManager { catch (DistributedSystemDisconnectedException e) { throw e; } - catch (BridgeWriterException bgx) { - pool.getCancelCriterion().checkCancelInProgress(bgx); - currentCache.getCancelCriterion().checkCancelInProgress(bgx); - //TODO: Need to analyze these exception scenarios. - logger.warning(LocalizedStrings.ClientStatsManager_FAILED_TO_SEND_CLIENT_HEALTH_STATS_TO_CACHESERVER, bgx); - } catch (CacheWriterException cwx) { pool.getCancelCriterion().checkCancelInProgress(cwx); currentCache.getCancelCriterion().checkCancelInProgress(cwx); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java index 8a05a5d..344155b 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegion.java @@ -74,7 +74,6 @@ import com.gemstone.gemfire.cache.query.SelectResults; import com.gemstone.gemfire.cache.query.TypeMismatchException; import com.gemstone.gemfire.cache.query.internal.index.IndexManager; import com.gemstone.gemfire.cache.snapshot.RegionSnapshotService; -import com.gemstone.gemfire.cache.util.BridgeWriter; import com.gemstone.gemfire.cache.wan.GatewaySender; import com.gemstone.gemfire.compression.Compressor; import com.gemstone.gemfire.distributed.DistributedMember; @@ -493,9 +492,6 @@ public abstract class AbstractRegion implements Region, RegionAttributes, */ public CacheWriter basicGetWriter() { CacheWriter result = this.cacheWriter; - if (isBridgeWriter(result)) { - result = null; - } return result; } @@ -1209,11 +1205,6 @@ public abstract class AbstractRegion implements Region, RegionAttributes, public synchronized CacheWriter setCacheWriter(CacheWriter cacheWriter) { checkReadiness(); - if (cacheWriter != null && isBridgeWriter(cacheWriter)) { - if (getPoolName() != null) { - throw new IllegalStateException("A region with a connection pool can not have a BridgeWriter."); - } - } CacheWriter oldWriter = this.cacheWriter; assignCacheWriter(cacheWriter); cacheWriterChanged(oldWriter); @@ -1223,10 +1214,6 @@ public abstract class AbstractRegion implements Region, RegionAttributes, private synchronized void assignCacheWriter(CacheWriter cacheWriter) { this.cacheWriter = cacheWriter; - if (cacheWriter instanceof BridgeWriter) { - BridgeWriter bw = (BridgeWriter)cacheWriter; - bw.attach(this); - } } void checkEntryTimeoutAction(String mode, ExpirationAction ea) { @@ -1555,11 +1542,6 @@ public abstract class AbstractRegion implements Region, RegionAttributes, protected void closeCacheCallback(CacheCallback cb) { if (cb != null) { - if (cb instanceof BridgeWriter) { - BridgeWriter bw = (BridgeWriter)cb; - bw.detach(this); - } - try { cb.close(); } @@ -1589,13 +1571,6 @@ public abstract class AbstractRegion implements Region, RegionAttributes, // nothing needed by default } - /** - * @since 5.7 - */ - public static boolean isBridgeWriter(CacheWriter cw) { - return cw instanceof BridgeWriter; - } - protected void cacheWriterChanged(CacheWriter oldWriter) { if (this.cacheWriter != oldWriter) { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java index 80f7828..77fbc88 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/DistributedRegion.java @@ -2893,9 +2893,6 @@ public class DistributedRegion extends LocalRegion implements protected void cacheWriterChanged(CacheWriter oldWriter) { super.cacheWriterChanged(oldWriter); - if (isBridgeWriter(oldWriter)) { - oldWriter = null; - } if (oldWriter == null ^ basicGetWriter() == null) { new UpdateAttributesProcessor(this).distribute(); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ExpiryTask.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ExpiryTask.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ExpiryTask.java index d5dc5ee..e5ec552 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ExpiryTask.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/ExpiryTask.java @@ -28,7 +28,6 @@ import com.gemstone.gemfire.cache.EntryNotFoundException; import com.gemstone.gemfire.cache.ExpirationAction; import com.gemstone.gemfire.cache.ExpirationAttributes; import com.gemstone.gemfire.cache.RegionDestroyedException; -import com.gemstone.gemfire.cache.util.BridgeWriterException; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.distributed.internal.PooledExecutorWithDMStats; import com.gemstone.gemfire.internal.SystemTimer; @@ -364,23 +363,6 @@ public abstract class ExpiryTask extends SystemTimer.SystemTimerTask { } catch (CancelException ex) { // ignore - - // @todo grid: do we need to deal with pool exceptions here? - } catch (BridgeWriterException ex) { - // Some exceptions from the bridge writer should not be logged. - Throwable cause = ex.getCause(); - // BridgeWriterExceptions from the server are wrapped in CacheWriterExceptions - if (cause != null && cause instanceof CacheWriterException) - cause = cause.getCause(); - if (cause instanceof RegionDestroyedException || - cause instanceof EntryNotFoundException || - cause instanceof CancelException) { - if (logger.isDebugEnabled()) { - logger.debug("Exception in expiration task", ex); - } - } else { - logger.fatal(LocalizedMessage.create(LocalizedStrings.ExpiryTask_EXCEPTION_IN_EXPIRATION_TASK), ex); - } } catch (VirtualMachineError err) { SystemFailure.initiateFailure(err); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java index 79bcbc2..69d3a2f 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java @@ -1986,7 +1986,6 @@ public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePer TXStateProxy tx = null; try { this.keepAlive = keepalive; - PoolManagerImpl.setKeepAlive(keepalive); if (this.txMgr != null) { tx = this.txMgr.internalSuspend(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java index 1b6ba4b..7654f6f 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java @@ -100,7 +100,6 @@ import com.gemstone.gemfire.cache.TransactionId; import com.gemstone.gemfire.cache.client.PoolManager; import com.gemstone.gemfire.cache.client.ServerOperationException; import com.gemstone.gemfire.cache.client.SubscriptionNotEnabledException; -import com.gemstone.gemfire.cache.client.internal.BridgePoolImpl; import com.gemstone.gemfire.cache.client.internal.Connection; import com.gemstone.gemfire.cache.client.internal.Endpoint; import com.gemstone.gemfire.cache.client.internal.PoolImpl; @@ -134,7 +133,6 @@ import com.gemstone.gemfire.cache.query.internal.index.IndexCreationData; import com.gemstone.gemfire.cache.query.internal.index.IndexManager; import com.gemstone.gemfire.cache.query.internal.index.IndexProtocol; import com.gemstone.gemfire.cache.query.internal.index.IndexUtils; -import com.gemstone.gemfire.cache.util.BridgeWriterException; import com.gemstone.gemfire.cache.util.ObjectSizer; import com.gemstone.gemfire.cache.wan.GatewaySender; import com.gemstone.gemfire.distributed.DistributedMember; @@ -674,8 +672,7 @@ public class LocalRegion extends AbstractRegion } // initialize client to server proxy - this.srp = ((this.getPoolName() != null) - || isBridgeWriter(this.getCacheWriter())) + this.srp = (this.getPoolName() != null) ? new ServerRegionProxy(this) : null; this.imageState = @@ -4067,13 +4064,8 @@ public class LocalRegion extends AbstractRegion throw new IllegalStateException(LocalizedStrings.LocalRegion_DURABLE_FLAG_ONLY_APPLICABLE_FOR_DURABLE_CLIENTS.toLocalizedString()); } if (!proxy.getPool().getSubscriptionEnabled()) { - if (proxy.getPool() instanceof BridgePoolImpl) { - String msg = "Interest registration requires establishCallbackConnection to be set to true."; - throw new BridgeWriterException(msg); - } else { - String msg = "Interest registration requires a pool whose queue is enabled."; - throw new SubscriptionNotEnabledException(msg); - } + String msg = "Interest registration requires a pool whose queue is enabled."; + throw new SubscriptionNotEnabledException(msg); } if (getAttributes().getDataPolicy().withReplication() // fix for bug 36185 http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java index a874e64..5da6fbd 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PartitionedRegion.java @@ -5457,9 +5457,6 @@ public class PartitionedRegion extends LocalRegion implements protected void cacheWriterChanged(CacheWriter p_oldWriter) { CacheWriter oldWriter = p_oldWriter; super.cacheWriterChanged(oldWriter); - if (isBridgeWriter(oldWriter)) { - oldWriter = null; - } if (oldWriter == null ^ basicGetWriter() == null) { new UpdateAttributesProcessor(this).distribute(); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d102cd86/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PoolFactoryImpl.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PoolFactoryImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PoolFactoryImpl.java index c290f16..0838d29 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PoolFactoryImpl.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/PoolFactoryImpl.java @@ -27,8 +27,6 @@ import com.gemstone.gemfire.cache.CacheException; import com.gemstone.gemfire.cache.RegionService; import com.gemstone.gemfire.cache.client.Pool; import com.gemstone.gemfire.cache.client.PoolFactory; -import com.gemstone.gemfire.cache.client.internal.BridgePoolImpl; -import com.gemstone.gemfire.cache.client.internal.BridgePoolImpl.LBPolicy; import com.gemstone.gemfire.cache.client.internal.LocatorDiscoveryCallback; import com.gemstone.gemfire.cache.client.internal.PoolImpl; import com.gemstone.gemfire.cache.query.QueryService; @@ -286,141 +284,14 @@ public class PoolFactoryImpl implements PoolFactory { this.attributes.servers.addAll(cp.getServers()); } - public void init(Properties properties, boolean usedByBridgeWriter, - boolean usedByGateway, GatewaySender sender) { + public void init(GatewaySender sender) { + this.attributes.setGateway(true); this.attributes.setGatewaySender(sender); - init(properties, usedByBridgeWriter, usedByGateway); - } - /** - * Used to create a pool given the old Bridge properties - * @param properties from a BridgeWriter or bl - * @param usedByBridgeWriter true if props from BridgeWriter; - * false if props from bl. - * *param usedByGateway true if props from GatewayImpl. - * @since 5.7 - */ - public void init(Properties properties, boolean usedByBridgeWriter, - boolean usedByGateway) { - this.attributes.setBridge(usedByBridgeWriter || !usedByGateway); - this.attributes.setBridgeWriter(usedByBridgeWriter); - this.attributes.setGateway(usedByGateway); setIdleTimeout(-1); // never time out setLoadConditioningInterval(-1); // never time out setMaxConnections(-1); - int endpointCount = 0; - boolean useLocators = false; - boolean useEndPoints = false; - IllegalArgumentException exception = null; - if (properties.containsKey(DistributionConfig.LOCATORS_NAME)) { - String locatorObject = properties - .getProperty(DistributionConfig.LOCATORS_NAME); - if (locatorObject != null && !locatorObject.equals("")) { - StringTokenizer locatorsOnThisVM = new StringTokenizer(locatorObject, ","); - while (locatorsOnThisVM.hasMoreTokens()) { - String localLocator = locatorsOnThisVM.nextToken(); - DistributionLocatorId locatorId = new DistributionLocatorId( - localLocator); - addLocator(locatorId.getHost().getHostName(), locatorId.getPort()); - } - useLocators = true; - } - } - if (!useLocators && properties.containsKey("endpoints")) { - useEndPoints = true; - String pv = properties.getProperty("endpoints"); - StringTokenizer tokenizer = new StringTokenizer(pv, ","); - while (tokenizer.hasMoreTokens()) { - String serverdetail = tokenizer.nextToken(); - int cIndex = serverdetail.indexOf("="); - // note we throw the name away -// String name = serverdetail.substring(0, cIndex); -// if (name != null) { -// name = name.trim(); -// } - String remainder = serverdetail.substring(cIndex + 1); - cIndex = remainder.lastIndexOf(":"); - String host = remainder.substring(0, cIndex); - if (host != null) { - host = host.trim(); - } - String port = remainder.substring(cIndex + 1); - if (port != null) { - port = port.trim(); - } - try { - addServer(host, Integer.parseInt(port)); - endpointCount++; - } catch (IllegalArgumentException e) { - if (!(e.getCause() instanceof UnknownHostException)) { - throw e; - } else { - exception = e; - } - } - } - if ((endpointCount == 0) && (exception != null)) { - IllegalArgumentException ex = new IllegalArgumentException("Couldn't find any Endpoint. " + exception.getMessage()); - ex.initCause(exception.getCause()); - throw ex; - } - } - if(!useLocators && !useEndPoints) { - throw new IllegalArgumentException( - "Property 'locators ' or 'endpoints' must be specified"); - } - // @todo grid: handshakeTimeout ignored - { - // @todo grid: roundRobin and appAssisted ignored - LBPolicy policy = new LBPolicy(properties.getProperty("LBPolicy", - LBPolicy.STICKY_PROPERTY_NAME)); - setThreadLocalConnections(policy.isSticky()); - } - - if (properties.containsKey("retryAttempts")) { - String strRetryAttempts = properties.getProperty("retryAttempts"); - setRetryAttempts(Integer.parseInt(strRetryAttempts)); - } - if (properties.containsKey("retryInterval")) { - String strRetryAttempts = properties.getProperty("retryInterval"); - setPingInterval(Integer.parseInt(strRetryAttempts)); - } - if (properties.containsKey("establishCallbackConnection")) { - String str = properties.getProperty("establishCallbackConnection"); - setSubscriptionEnabled(Boolean.valueOf(str).booleanValue()); - } - if (properties.containsKey("enablePRSingleHop")) { - String str = properties.getProperty("enablePRSingleHop"); - setPRSingleHopEnabled(Boolean.valueOf(str).booleanValue()); - } - if (properties.containsKey("connectionsPerServer")) { - String str = properties.getProperty("connectionsPerServer"); - setMinConnections(Integer.parseInt(str)*endpointCount); - } else { - setMinConnections(1*endpointCount); - } - if (properties.containsKey("redundancyLevel")) { - String str = properties.getProperty("redundancyLevel"); - setSubscriptionRedundancy(Integer.parseInt(str)); - } - if (properties.containsKey("readTimeout")) { - String strReadTimeout = properties.getProperty("readTimeout"); - setReadTimeout(Integer.parseInt(strReadTimeout)); - } - if (properties.containsKey("socketBufferSize")) { - String strSocketBufferSize = properties.getProperty("socketBufferSize"); - setSocketBufferSize(Integer.parseInt(strSocketBufferSize)); - } - if (properties.containsKey("messageTrackingTimeout")) { - String pv = properties.getProperty("messageTrackingTimeout"); - setSubscriptionMessageTrackingTimeout(Integer.parseInt(pv)); - } - if(properties.containsKey("clientAckInterval") ) { - String pv = properties.getProperty("clientAckInterval"); - setSubscriptionAckInterval(Integer.parseInt(pv)); - } - if(usedByGateway && exception!= null) { - throw exception; - } + setMinConnections(0); + setThreadLocalConnections(true); } /** @@ -441,11 +312,7 @@ public class PoolFactoryImpl implements PoolFactory { registry.creatingPool(); } } - if (this.attributes.isBridge()) { - return new BridgePoolImpl(this.pm, name, this.attributes); - } else { - return PoolImpl.create(this.pm, name, this.attributes); - } + return PoolImpl.create(this.pm, name, this.attributes); } /** @@ -487,18 +354,7 @@ public class PoolFactoryImpl implements PoolFactory { public transient LocatorDiscoveryCallback locatorCallback = null; //only used by tests public GatewaySender gatewaySender = null; /** - * True if this factory needs to produce a pool for use by old bridge - */ - public boolean bridge = false; - /** - * True if bridge is true and the pool is used by a bw. - * False if bridge is true and the pool is used by a bl. - * Ignore this attribute if bridge is false. - */ - public boolean bridgeWriter = false; - /** - * True if bridge is true and the pool is used by a Gateway. - * Ignore this attribute if bridge is false. + * True if the pool is used by a Gateway. */ public boolean gateway = false; @@ -553,18 +409,6 @@ public class PoolFactoryImpl implements PoolFactory { public String getServerGroup() { return this.serverGroup; } - public boolean isBridge() { - return this.bridge; - } - public void setBridge(boolean v) { - this.bridge = v; - } - public boolean isBridgeWriter() { - return this.bridgeWriter; - } - public void setBridgeWriter(boolean v) { - this.bridgeWriter = v; - } public boolean isGateway() { return this.gateway; } @@ -647,7 +491,6 @@ public class PoolFactoryImpl implements PoolFactory { DataSerializer.writeString(this.serverGroup, out); DataSerializer.writeArrayList(this.locators, out); DataSerializer.writeArrayList(this.servers, out); - DataSerializer.writePrimitiveBoolean(this.bridge, out); DataSerializer.writePrimitiveInt(this.statisticInterval, out); DataSerializer.writePrimitiveBoolean(this.multiuserSecureModeEnabled,out); } @@ -670,7 +513,6 @@ public class PoolFactoryImpl implements PoolFactory { this.serverGroup = DataSerializer.readString(in); this.locators = DataSerializer.readArrayList(in); this.servers = DataSerializer.readArrayList(in); - this.bridge = DataSerializer.readPrimitiveBoolean(in); this.statisticInterval= DataSerializer.readPrimitiveInt(in); this.multiuserSecureModeEnabled = DataSerializer.readPrimitiveBoolean(in); }