[
https://issues.apache.org/jira/browse/GEODE-3571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16270051#comment-16270051
]
ASF GitHub Bot commented on GEODE-3571:
---------------------------------------
pivotal-jbarrett closed pull request #158: feature/GEODE-3571
URL: https://github.com/apache/geode-native/pull/158
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/clicache/integration-test/AttributesFactoryTestsN.cs
b/clicache/integration-test/AttributesFactoryTestsN.cs
index a570ac70..6574ddb8 100644
--- a/clicache/integration-test/AttributesFactoryTestsN.cs
+++ b/clicache/integration-test/AttributesFactoryTestsN.cs
@@ -15,94 +15,41 @@
* limitations under the License.
*/
-//using System;
-//using System.Reflection;
-
-//#pragma warning disable 618
-
-//namespace Apache.Geode.Client.UnitTests
-//{
-// using NUnit.Framework;
-// using Apache.Geode.DUnitFramework;
-// // using Apache.Geode.Client;
-// using Apache.Geode.Client;
-// //using Region = Apache.Geode.Client.IRegion<Object, Object>;
-
-// [TestFixture]
-// [Category("group1")]
-// [Category("unicast_only")]
-// [Category("generics")]
-// public class AttributesFactoryTests : UnitTests
-// {
-// protected override ClientBase[] GetClients()
-// {
-// return null;
-// }
-
-// [Test]
-// public void InvalidTCRegionAttributes()
-// {
-// Properties<string, string> config = new Properties<string, string>();
-// CacheHelper.InitConfig(config);
-// IRegion<object, object> region;
-// RegionAttributes<object, object> attrs;
-// AttributesFactory<object, object> af = new AttributesFactory<object,
object>();
-// af.SetScope(ScopeType.Local);
-// af.SetEndpoints("bass:1234");
-// attrs = af.CreateRegionAttributes();
-// region = CacheHelper.CreateRegion<object, object>("region1", attrs);
-// try
-// {
-// IRegion<Object, Object> localRegion = region.GetLocalView();
-// Assert.Fail(
-// "LOCAL scope is incompatible with a native client region");
-// }
-// catch (UnsupportedOperationException)
-// {
-// Util.Log("Got expected UnsupportedOperationException for " +
-// "LOCAL scope for native client region");
-// }
-
-// af.SetScope(ScopeType.Local);
-// af.SetClientNotificationEnabled(true);
-// attrs = af.CreateRegionAttributes();
-// try
-// {
-// region = CacheHelper.CreateRegion<object, object>("region2", attrs);
-// Assert.Fail(
-// "LOCAL scope is incompatible with clientNotificationEnabled");
-// }
-// catch (UnsupportedOperationException)
-// {
-// Util.Log("Got expected UnsupportedOperationException for " +
-// "clientNotificationEnabled for non native client region");
-// }
-
-// // Checks for HA regions
-
-// CacheHelper.CloseCache();
-// af.SetScope(ScopeType.Local);
-// af.SetEndpoints("bass:3434");
-// af.SetClientNotificationEnabled(false);
-// attrs = af.CreateRegionAttributes();
-// try
-// {
-// region = CacheHelper.CreateRegion<object, object>("region2", attrs);
-// Assert.Fail(
-// "LOCAL scope is incompatible with a native client HA region");
-// }
-// catch (UnsupportedOperationException)
-// {
-// Util.Log("Got expected UnsupportedOperationException for " +
-// "LOCAL scope for native client region");
-// }
-
-// af.SetScope(ScopeType.Local);
-// af.SetEndpoints("none");
-// af.SetClientNotificationEnabled(false);
-// attrs = af.CreateRegionAttributes();
-// region = CacheHelper.CreateRegion<object, object>("region1", attrs);
-// Util.Log("C++ local region created with HA cache specification.");
-// }
-// }
-//}
+using System;
+using System.Reflection;
+
+#pragma warning disable 618
+
+namespace Apache.Geode.Client.UnitTests
+{
+ using NUnit.Framework;
+ using Apache.Geode.DUnitFramework;
+
+
+
+ [TestFixture]
+ [Category("group1")]
+ [Category("unicast_only")]
+ [Category("generics")]
+ public class AttributesFactoryTests : UnitTests
+ {
+
+ private UnitProcess m_client1, m_client2;
+
+ protected override ClientBase[] GetClients()
+ {
+ return new ClientBase[] {};
+ }
+
+
+ [Test]
+ public void fluentModeltest()
+ {
+ AttributesFactory<string, string> af = new AttributesFactory<string,
string>();
+ Apache.Geode.Client.RegionAttributes<string, string> rattrs =
af.SetLruEntriesLimit(2).SetInitialCapacity(5).CreateRegionAttributes();
+ Assert.IsNotNull(rattrs);
+ Assert.True(rattrs.LruEntriesLimit == 2);
+ Assert.True(rattrs.InitialCapacity == 5);
+ }
+ }
+}
diff --git a/clicache/src/AttributesFactory.cpp
b/clicache/src/AttributesFactory.cpp
index 98c4efc5..d79f08cd 100644
--- a/clicache/src/AttributesFactory.cpp
+++ b/clicache/src/AttributesFactory.cpp
@@ -63,7 +63,7 @@ namespace Apache
// CALLBACKS
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetCacheLoader( ICacheLoader<TKey,
TValue>^ cacheLoader )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetCacheLoader( ICacheLoader<TKey, TValue>^ cacheLoader )
{
std::shared_ptr<native::CacheLoader> loaderptr;
if ( cacheLoader != nullptr ) {
@@ -80,10 +80,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetCacheWriter( ICacheWriter<TKey,
TValue>^ cacheWriter )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetCacheWriter( ICacheWriter<TKey, TValue>^ cacheWriter )
{
std::shared_ptr<native::CacheWriter> writerptr;
if ( cacheWriter != nullptr ) {
@@ -100,10 +101,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetCacheListener(
ICacheListener<TKey, TValue>^ cacheListener )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetCacheListener( ICacheListener<TKey, TValue>^ cacheListener )
{
std::shared_ptr<native::CacheListener> listenerptr;
if ( cacheListener != nullptr ) {
@@ -120,10 +122,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetPartitionResolver(
IPartitionResolver<TKey, TValue>^ partitionresolver )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetPartitionResolver( IPartitionResolver<TKey, TValue>^
partitionresolver )
{
std::shared_ptr<native::PartitionResolver> resolverptr;
if ( partitionresolver != nullptr ) {
@@ -150,10 +153,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetCacheLoader( String^ libPath,
String^ factoryFunctionName )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetCacheLoader( String^ libPath, String^ factoryFunctionName )
{
throw gcnew System::NotSupportedException;
ManagedString mg_libpath( libPath );
@@ -167,10 +171,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetCacheWriter( String^ libPath,
String^ factoryFunctionName )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetCacheWriter( String^ libPath, String^ factoryFunctionName )
{
throw gcnew System::NotSupportedException;
ManagedString mg_libpath( libPath );
@@ -184,10 +189,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetCacheListener( String^ libPath,
String^ factoryFunctionName )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetCacheListener( String^ libPath, String^ factoryFunctionName )
{
throw gcnew System::NotSupportedException;
ManagedString mg_libpath( libPath );
@@ -201,10 +207,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetPartitionResolver( String^
libPath, String^ factoryFunctionName )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetPartitionResolver( String^ libPath, String^ factoryFunctionName )
{
throw gcnew System::NotSupportedException;
ManagedString mg_libpath( libPath );
@@ -218,12 +225,13 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
// EXPIRATION ATTRIBUTES
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetEntryIdleTimeout(
ExpirationAction action, TimeSpan idleTimeout )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetEntryIdleTimeout( ExpirationAction action, TimeSpan idleTimeout )
{
try
{
@@ -233,10 +241,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetEntryTimeToLive(
ExpirationAction action, TimeSpan timeToLive )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetEntryTimeToLive( ExpirationAction action, TimeSpan timeToLive )
{
try
{
@@ -246,10 +255,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetRegionIdleTimeout(
ExpirationAction action, TimeSpan idleTimeout )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetRegionIdleTimeout( ExpirationAction action, TimeSpan idleTimeout )
{
try
{
@@ -259,10 +269,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetRegionTimeToLive(
ExpirationAction action, TimeSpan timeToLive )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetRegionTimeToLive( ExpirationAction action, TimeSpan timeToLive )
{
try
{
@@ -272,11 +283,12 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
// PERSISTENCE
generic<class TKey, class TValue>
- void AttributesFactory<TKey,
TValue>::SetPersistenceManager(IPersistenceManager<TKey, TValue>^
persistenceManager, Properties<String^, String^>^ config )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetPersistenceManager(IPersistenceManager<TKey, TValue>^
persistenceManager, Properties<String^, String^>^ config )
{
std::shared_ptr<native::PersistenceManager> persistenceManagerptr;
if ( persistenceManager != nullptr ) {
@@ -293,23 +305,26 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey,
TValue>::SetPersistenceManager(IPersistenceManager<TKey, TValue>^
persistenceManager )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetPersistenceManager(IPersistenceManager<TKey, TValue>^
persistenceManager )
{
SetPersistenceManager(persistenceManager, nullptr);
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetPersistenceManager( String^
libPath,
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetPersistenceManager( String^ libPath,
String^ factoryFunctionName )
{
SetPersistenceManager( libPath, factoryFunctionName, nullptr );
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetPersistenceManager( String^
libPath,
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetPersistenceManager( String^ libPath,
String^ factoryFunctionName, Properties<String^, String^>^ config )
{
ManagedString mg_libpath( libPath );
@@ -323,13 +338,14 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
// STORAGE ATTRIBUTES
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetPoolName( String^ poolName )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetPoolName( String^ poolName )
{
ManagedString mg_poolName( poolName );
@@ -341,12 +357,13 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
// MAP ATTRIBUTES
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetInitialCapacity( System::Int32
initialCapacity )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetInitialCapacity( System::Int32 initialCapacity )
{
_GF_MG_EXCEPTION_TRY2/* due to auto replace */
@@ -360,10 +377,12 @@ namespace Apache
}
_GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
+
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetLoadFactor( Single loadFactor )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetLoadFactor( Single loadFactor )
{
_GF_MG_EXCEPTION_TRY2/* due to auto replace */
@@ -377,10 +396,12 @@ namespace Apache
}
_GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
+
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetConcurrencyLevel( System::Int32
concurrencyLevel )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetConcurrencyLevel( System::Int32 concurrencyLevel )
{
_GF_MG_EXCEPTION_TRY2/* due to auto replace */
@@ -394,10 +415,12 @@ namespace Apache
}
_GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
+
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetLruEntriesLimit( System::UInt32
entriesLimit )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetLruEntriesLimit( System::UInt32 entriesLimit )
{
try
{
@@ -407,10 +430,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetDiskPolicy( DiskPolicyType
diskPolicy )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetDiskPolicy( DiskPolicyType diskPolicy )
{
try
{
@@ -420,10 +444,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetCachingEnabled( bool
cachingEnabled )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetCachingEnabled( bool cachingEnabled )
{
try
{
@@ -433,10 +458,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetCloningEnabled( bool
cloningEnabled )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetCloningEnabled( bool cloningEnabled )
{
try
{
@@ -446,10 +472,11 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
generic<class TKey, class TValue>
- void AttributesFactory<TKey, TValue>::SetConcurrencyChecksEnabled( bool
concurrencyChecksEnabled )
+ AttributesFactory<TKey, TValue>^ AttributesFactory<TKey,
TValue>::SetConcurrencyChecksEnabled( bool concurrencyChecksEnabled )
{
try
{
@@ -459,6 +486,7 @@ namespace Apache
{
GC::KeepAlive(m_nativeptr);
}
+ return this;
}
// FACTORY METHOD
diff --git a/clicache/src/AttributesFactory.hpp
b/clicache/src/AttributesFactory.hpp
index 01311b3a..095b90df 100644
--- a/clicache/src/AttributesFactory.hpp
+++ b/clicache/src/AttributesFactory.hpp
@@ -183,7 +183,7 @@ namespace Apache
/// a user-defined cache loader, or null for no cache loader
/// </param>
//generic<class TKey, class TValue>
- void SetCacheLoader( ICacheLoader<TKey, TValue>^ cacheLoader );
+ AttributesFactory<TKey, TValue>^ SetCacheLoader( ICacheLoader<TKey,
TValue>^ cacheLoader );
/// <summary>
/// Sets the cache writer for the <c>RegionAttributes</c> being
created.
@@ -192,7 +192,7 @@ namespace Apache
/// user-defined cache writer, or null for no cache writer
/// </param>
//generic<class TKey, class TValue>
- void SetCacheWriter( ICacheWriter<TKey, TValue>^ cacheWriter );
+ AttributesFactory<TKey, TValue>^ SetCacheWriter( ICacheWriter<TKey,
TValue>^ cacheWriter );
/// <summary>
/// Sets the CacheListener for the <c>RegionAttributes</c> being
created.
@@ -201,7 +201,7 @@ namespace Apache
/// user-defined cache listener, or null for no cache listener
/// </param>
//generic<class TKey, class TValue>
- void SetCacheListener( ICacheListener<TKey, TValue>^ cacheListener );
+ AttributesFactory<TKey, TValue>^ SetCacheListener(
ICacheListener<TKey, TValue>^ cacheListener );
/// <summary>
/// Sets the PartitionResolver for the <c>RegionAttributes</c> being
created.
@@ -210,7 +210,7 @@ namespace Apache
/// user-defined partition resolver, or null for no partition resolver
/// </param>
//generic<class TKey, class TValue>
- void SetPartitionResolver( IPartitionResolver<TKey, TValue>^
partitionresolver );
+ AttributesFactory<TKey, TValue>^ SetPartitionResolver(
IPartitionResolver<TKey, TValue>^ partitionresolver );
/// <summary>
/// Sets the library path for the library that will be invoked for the
loader of the region.
@@ -225,7 +225,7 @@ namespace Apache
/// <c>ICacheLoader</c> for a managed library.
/// </param>
//generic<class TKey, class TValue>
- void SetCacheLoader( String^ libPath, String^ factoryFunctionName );
+ AttributesFactory<TKey, TValue>^ SetCacheLoader( String^ libPath,
String^ factoryFunctionName );
/// <summary>
/// Sets the library path for the library that will be invoked for the
writer of the region.
@@ -240,7 +240,7 @@ namespace Apache
/// <c>ICacheWriter</c> for a managed library.
/// </param>
//generic<class TKey, class TValue>
- void SetCacheWriter( String^ libPath, String^ factoryFunctionName );
+ AttributesFactory<TKey, TValue>^ SetCacheWriter( String^ libPath,
String^ factoryFunctionName );
/// <summary>
/// Sets the library path for the library that will be invoked for the
listener of the region.
@@ -255,7 +255,7 @@ namespace Apache
/// <c>ICacheListener</c> for a managed library.
/// </param>
//generic<class TKey, class TValue>
- void SetCacheListener( String^ libPath, String^ factoryFunctionName );
+ AttributesFactory<TKey, TValue>^ SetCacheListener( String^ libPath,
String^ factoryFunctionName );
/// <summary>
@@ -271,7 +271,7 @@ namespace Apache
/// <c>IPartitionResolver</c> for a managed library.
/// </param>
//generic<class TKey, class TValue>
- void SetPartitionResolver( String^ libPath, String^
factoryFunctionName );
+ AttributesFactory<TKey, TValue>^ SetPartitionResolver( String^
libPath, String^ factoryFunctionName );
// EXPIRATION ATTRIBUTES
@@ -286,7 +286,7 @@ namespace Apache
/// <param name="idleTimeout">
/// the idleTimeout in seconds for entries in this region.
/// </param>
- void SetEntryIdleTimeout( ExpirationAction action, TimeSpan
idleTimeout );
+ AttributesFactory<TKey, TValue>^ SetEntryIdleTimeout( ExpirationAction
action, TimeSpan idleTimeout );
/// <summary>
/// Sets the timeToLive expiration attributes for region entries for
the next
@@ -298,7 +298,7 @@ namespace Apache
/// <param name="timeToLive">
/// the timeToLive in seconds for entries in this region.
/// </param>
- void SetEntryTimeToLive( ExpirationAction action, TimeSpan timeToLive
);
+ AttributesFactory<TKey, TValue>^ SetEntryTimeToLive( ExpirationAction
action, TimeSpan timeToLive );
/// <summary>
/// Sets the idleTimeout expiration attributes for the region itself
for the
@@ -310,7 +310,7 @@ namespace Apache
/// <param name="idleTimeout">
/// the idleTimeout in seconds for the region as a whole.
/// </param>
- void SetRegionIdleTimeout( ExpirationAction action, TimeSpan
idleTimeout );
+ AttributesFactory<TKey, TValue>^ SetRegionIdleTimeout(
ExpirationAction action, TimeSpan idleTimeout );
/// <summary>
/// Sets the timeToLive expiration attributes for the region itself
for the
@@ -322,7 +322,7 @@ namespace Apache
/// <param name="timeToLive">
/// the timeToLive in seconds for the region as a whole.
/// </param>
- void SetRegionTimeToLive( ExpirationAction action, TimeSpan timeToLive
);
+ AttributesFactory<TKey, TValue>^ SetRegionTimeToLive( ExpirationAction
action, TimeSpan timeToLive );
// PERSISTENCE
@@ -334,7 +334,7 @@ namespace Apache
/// Persistence Manager object
/// </param>
//generic<class TKey, class TValue>
- void SetPersistenceManager(IPersistenceManager<TKey, TValue>^
persistenceManager);
+ AttributesFactory<TKey, TValue>^
SetPersistenceManager(IPersistenceManager<TKey, TValue>^ persistenceManager);
/// <summary>
/// Sets the PersistenceManager object that will be invoked for the
persistence of the region.
@@ -346,7 +346,7 @@ namespace Apache
/// The configuration properties to use for the PersistenceManager.
/// </param>
//generic<class TKey, class TValue>
- void SetPersistenceManager(IPersistenceManager<TKey, TValue>^
persistenceManager, Properties<String^, String^>^ config);
+ AttributesFactory<TKey, TValue>^
SetPersistenceManager(IPersistenceManager<TKey, TValue>^ persistenceManager,
Properties<String^, String^>^ config);
/// <summary>
@@ -358,7 +358,7 @@ namespace Apache
/// <param name="factoryFunctionName">
/// The name of the factory function to create an instance of
PersistenceManager object.
/// </param>
- void SetPersistenceManager( String^ libPath, String^
factoryFunctionName );
+ AttributesFactory<TKey, TValue>^ SetPersistenceManager( String^
libPath, String^ factoryFunctionName );
/// <summary>
/// Sets the library path for the library that will be invoked for the
persistence of the region.
@@ -372,7 +372,7 @@ namespace Apache
/// <param name="config">
/// The configuration properties to use for the PersistenceManager.
/// </param>
- void SetPersistenceManager( String^ libPath, String^
factoryFunctionName,
+ AttributesFactory<TKey, TValue>^ SetPersistenceManager( String^
libPath, String^ factoryFunctionName,
/*Dictionary<Object^, Object^>*/Properties<String^, String^>^ config
);
@@ -387,7 +387,7 @@ namespace Apache
/// <param name="poolName">
/// The name of the pool to attach to this region.
/// </param>
- void SetPoolName( String^ poolName );
+ AttributesFactory<TKey, TValue>^ SetPoolName( String^ poolName );
// MAP ATTRIBUTES
@@ -400,7 +400,7 @@ namespace Apache
/// <exception cref="IllegalArgumentException">
/// if initialCapacity is nonpositive
/// </exception>
- void SetInitialCapacity( System::Int32 initialCapacity );
+ AttributesFactory<TKey, TValue>^ SetInitialCapacity( System::Int32
initialCapacity );
/// <summary>
/// Sets the entry load factor for the next <c>RegionAttributes</c>
@@ -411,7 +411,7 @@ namespace Apache
/// <exception cref="IllegalArgumentException">
/// if loadFactor is nonpositive
/// </exception>
- void SetLoadFactor( Single loadFactor );
+ AttributesFactory<TKey, TValue>^ SetLoadFactor( Single loadFactor );
/// <summary>
/// Sets the concurrency level of the next <c>RegionAttributes</c>
@@ -423,7 +423,7 @@ namespace Apache
/// <exception cref="IllegalArgumentException">
/// if concurrencyLevel is nonpositive
/// </exception>
- void SetConcurrencyLevel( System::Int32 concurrencyLevel );
+ AttributesFactory<TKey, TValue>^ SetConcurrencyLevel( System::Int32
concurrencyLevel );
/// <summary>
/// Sets a limit on the number of entries that will be held in the
cache.
@@ -434,7 +434,7 @@ namespace Apache
/// The limit of the number of entries before eviction starts.
/// Defaults to 0, meaning no LRU actions will used.
/// </param>
- void SetLruEntriesLimit( System::UInt32 entriesLimit );
+ AttributesFactory<TKey, TValue>^ SetLruEntriesLimit( System::UInt32
entriesLimit );
/// <summary>
/// Sets the disk policy type for the next <c>RegionAttributes</c>
created.
@@ -442,7 +442,7 @@ namespace Apache
/// <param name="diskPolicy">
/// the disk policy to use for the region
/// </param>
- void SetDiskPolicy( DiskPolicyType diskPolicy );
+ AttributesFactory<TKey, TValue>^ SetDiskPolicy( DiskPolicyType
diskPolicy );
/// <summary>
/// Set caching enabled flag for this region.
@@ -460,7 +460,7 @@ namespace Apache
/// <param name="cachingEnabled">
/// if true, cache data for this region in this process.
/// </param>
- void SetCachingEnabled( bool cachingEnabled );
+ AttributesFactory<TKey, TValue>^ SetCachingEnabled( bool
cachingEnabled );
/// <summary>
/// Set cloning enabled flag for this region.
/// </summary>
@@ -476,7 +476,7 @@ namespace Apache
/// <param name="cloningEnabled">
/// if true, clone old value before applying delta so that in-place
change would not occour..
/// </param>
- void SetCloningEnabled( bool cloningEnabled );
+ AttributesFactory<TKey, TValue>^ SetCloningEnabled( bool
cloningEnabled );
/// <summary>
/// Sets concurrency checks enabled flag for this region.
@@ -491,7 +491,7 @@ namespace Apache
/// <param name="concurrencyChecksEnabled">
/// if true, version checks for region entries will occur.
/// </param>
- void SetConcurrencyChecksEnabled( bool concurrencyChecksEnabled );
+ AttributesFactory<TKey, TValue>^ SetConcurrencyChecksEnabled( bool
concurrencyChecksEnabled );
// FACTORY METHOD
/// <summary>
diff --git a/clicache/src/geode_defs.hpp b/clicache/src/geode_defs.hpp
index 2424f771..6bab3237 100644
--- a/clicache/src/geode_defs.hpp
+++ b/clicache/src/geode_defs.hpp
@@ -33,6 +33,11 @@
// Disable native code generation warning
#pragma warning(disable: 4793)
+// Disable Native Conditional Unique warning
+#pragma warning(disable: 4383)
+
+// C4103alignment changed after including header, may be due to missing
#pragma pack(pop)
+#pragma warning(disable: 4103)
// These provide Doxygen with namespace and file descriptions.
/// @namespace Apache::Geode
diff --git a/clicache/src/impl/CacheWriter.hpp
b/clicache/src/impl/CacheWriter.hpp
index e5f238ab..12edaa1f 100644
--- a/clicache/src/impl/CacheWriter.hpp
+++ b/clicache/src/impl/CacheWriter.hpp
@@ -76,8 +76,8 @@ namespace Apache
RegionEvent<TKey, TValue> gevent(ev->GetNative());
return m_writer->BeforeRegionDestroy(%gevent);
}
-
- virtual void Close(Apache::Geode::Client::Region<Object^, Object^>^
region) override
+
+ virtual void Close(IRegion<Object^, Object^>^ region) override
{
m_writer->Close((IRegion<TKey, TValue>^) region);
}
diff --git a/clicache/src/impl/ManagedCacheWriter.cpp
b/clicache/src/impl/ManagedCacheWriter.cpp
index 8489c0f2..bd495584 100644
--- a/clicache/src/impl/ManagedCacheWriter.cpp
+++ b/clicache/src/impl/ManagedCacheWriter.cpp
@@ -297,7 +297,7 @@ namespace apache
void ManagedCacheWriterGeneric::close(const std::shared_ptr<Region>& rp)
{
try {
- auto mregion = Apache::Geode::Client::Region<Object^,
Object^>::Create(rp);
+ IRegion<Object^, Object^>^ mregion =
Apache::Geode::Client::Region<Object^, Object^>::Create(rp);
m_managedptr->Close(mregion);
}
catch (Apache::Geode::Client::GeodeException^ ex) {
diff --git a/cppcache/include/geode/AttributesFactory.hpp
b/cppcache/include/geode/AttributesFactory.hpp
index fad65c38..037990ef 100644
--- a/cppcache/include/geode/AttributesFactory.hpp
+++ b/cppcache/include/geode/AttributesFactory.hpp
@@ -42,7 +42,8 @@ namespace apache {
namespace geode {
namespace client {
-/** Creates instances of {@link RegionAttributes}. An
+/**
+ * Creates instances of {@link RegionAttributes}. An
* <code>AttributesFactory</code>
* instance maintains state for creating <code>RegionAttributes</code>
* instances.
@@ -160,12 +161,14 @@ class CPPCACHE_EXPORT AttributesFactory {
*@brief constructor
*/
- /** Creates a new instance of AttributesFactory ready to create a
+ /**
+ * Creates a new instance of AttributesFactory ready to create a
* <code>RegionAttributes</code> with default settings.
*/
AttributesFactory();
- /** Creates a new instance of AttributesFactory ready to create a
+ /**
+ * Creates a new instance of AttributesFactory ready to create a
* <code>RegionAttributes</code> with the same settings as those in the
* specified <code>RegionAttributes</code>.
* @param regionAttributes the <code>RegionAttributes</code> used to
@@ -180,98 +183,125 @@ class CPPCACHE_EXPORT AttributesFactory {
// CALLBACKS
- /** Sets the cache loader for the next <code>RegionAttributes</code> created.
+ /**
+ * Sets the cache loader for the next <code>RegionAttributes</code> created.
* @param cacheLoader the cache loader or nullptr if no loader
+ * @return a reference to <code>this</code>
*/
- void setCacheLoader(const std::shared_ptr<CacheLoader>& cacheLoader);
+ AttributesFactory& setCacheLoader(
+ const std::shared_ptr<CacheLoader>& cacheLoader);
- /** Sets the cache writer for the next <code>RegionAttributes</code> created.
+ /**
+ * Sets the cache writer for the next <code>RegionAttributes</code> created.
* @param cacheWriter the cache writer or nullptr if no cache writer
+ * @return a reference to <code>this</code>
*/
- void setCacheWriter(const std::shared_ptr<CacheWriter>& cacheWriter);
+ AttributesFactory& setCacheWriter(
+ const std::shared_ptr<CacheWriter>& cacheWriter);
- /** Sets the CacheListener for the next <code>RegionAttributes</code>
created.
+ /**
+ * Sets the CacheListener for the next <code>RegionAttributes</code> created.
* @param aListener a user defined CacheListener, nullptr if no listener
+ * @return a reference to <code>this</code>
*/
- void setCacheListener(const std::shared_ptr<CacheListener>& aListener);
+ AttributesFactory& setCacheListener(
+ const std::shared_ptr<CacheListener>& aListener);
- /** Sets the PartitionResolver for the next <code>RegionAttributes</code>
+ /**
+ * Sets the PartitionResolver for the next <code>RegionAttributes</code>
* created.
* @param aResolver a user defined PartitionResolver, nullptr if no resolver
+ * @return a reference to <code>this</code>
*/
- void setPartitionResolver(
+ AttributesFactory& setPartitionResolver(
const std::shared_ptr<PartitionResolver>& aResolver);
/**
* Sets the library path for the library that will be invoked for the loader
* of the region.
+ * @return a reference to <code>this</code>
*/
- void setCacheLoader(const char* libpath, const char* factoryFuncName);
+ AttributesFactory& setCacheLoader(const char* libpath,
+ const char* factoryFuncName);
/**
* Sets the library path for the library that will be invoked for the writer
* of the region.
+ * @return a reference to <code>this</code>
*/
- void setCacheWriter(const char* libpath, const char* factoryFuncName);
+ AttributesFactory& setCacheWriter(const char* libpath,
+ const char* factoryFuncName);
/**
* Sets the library path for the library that will be invoked for the
listener
* of the region.
+ * @return a reference to <code>this</code>
*/
- void setCacheListener(const char* libpath, const char* factoryFuncName);
+ AttributesFactory& setCacheListener(const char* libpath,
+ const char* factoryFuncName);
/**
* Sets the library path for the library that will be invoked for the
* partition resolver of the region.
+ * @return a reference to <code>this</code>
*/
- void setPartitionResolver(const char* libpath, const char* factoryFuncName);
+ AttributesFactory& setPartitionResolver(const char* libpath,
+ const char* factoryFuncName);
// EXPIRATION ATTRIBUTES
- /** Sets the idleTimeout expiration attributes for region entries for the
next
+ /**
+ * Sets the idleTimeout expiration attributes for region entries for the next
* <code>RegionAttributes</code> created. Will expire in no less than
* <code>idleTimeout</code>. Actual time may be longer depending on clock
* resolution.
*
* @param action the expiration action for entries in this region.
* @param idleTimeout the idleTimeout for entries in this region.
+ * @return a reference to <code>this</code>
*/
- void setEntryIdleTimeout(ExpirationAction::Action action,
- std::chrono::seconds idleTimeout);
+ AttributesFactory& setEntryIdleTimeout(ExpirationAction::Action action,
+ std::chrono::seconds idleTimeout);
- /** Sets the timeToLive expiration attributes for region entries for the next
+ /**
+ * Sets the timeToLive expiration attributes for region entries for the next
* <code>RegionAttributes</code> created. Will expire in no less than
* <code>timeToLive</code>, actual time may be longer depending on clock
* resolution.
*
* @param action the expiration action for entries in this region.
* @param timeToLive the timeToLive for entries in this region.
+ * @return a reference to <code>this</code>
*/
- void setEntryTimeToLive(ExpirationAction::Action action,
- std::chrono::seconds timeToLive);
+ AttributesFactory& setEntryTimeToLive(ExpirationAction::Action action,
+ std::chrono::seconds timeToLive);
- /** Sets the idleTimeout expiration attributes for the region itself for the
+ /**
+ * Sets the idleTimeout expiration attributes for the region itself for the
* next <code>RegionAttributes</code> created. Will expire in no less than
* <code>idleTimeout</code>, actual time may be longer depending on clock
* resolution.
*
* @param action the expiration action for entries in this region.
* @param idleTimeout the idleTimeout for the region as a whole.
+ * @return a reference to <code>this</code>
*/
- void setRegionIdleTimeout(ExpirationAction::Action action,
- std::chrono::seconds idleTimeout);
+ AttributesFactory& setRegionIdleTimeout(ExpirationAction::Action action,
+ std::chrono::seconds idleTimeout);
- /** Sets the timeToLive expiration attributes for the region itself for the
+ /**
+ * Sets the timeToLive expiration attributes for the region itself for the
* next <code>RegionAttributes</code> created. Will expire in no less than
* <code>timeToLive</code>, actual time may be longer depending on clock
* resolution.
*
* @param action the expiration action for entries in this region.
* @param timeToLive the timeToLive for the region as a whole.
+ * @return a reference to <code>this</code>
*/
- void setRegionTimeToLive(ExpirationAction::Action action,
- std::chrono::seconds timeToLive);
+ AttributesFactory& setRegionTimeToLive(ExpirationAction::Action action,
+ std::chrono::seconds timeToLive);
// PERSISTENCE
/**
@@ -280,8 +310,9 @@ class CPPCACHE_EXPORT AttributesFactory {
* If the region is being created from a client on a server, or on a server
* directly, then
* this must be used to set the PersistenceManager.
+ * @return a reference to <code>this</code>
*/
- void setPersistenceManager(
+ AttributesFactory& setPersistenceManager(
const char* libpath, const char* factoryFuncName,
const std::shared_ptr<Properties>& config = nullptr);
@@ -289,52 +320,59 @@ class CPPCACHE_EXPORT AttributesFactory {
* created.
* @param persistenceManager a user defined PersistenceManager, nullptr if no
* resolver
+ * @return a reference to <code>this</code>
*/
- void setPersistenceManager(
+ AttributesFactory& setPersistenceManager(
const std::shared_ptr<PersistenceManager>& persistenceManager,
const std::shared_ptr<Properties>& config = nullptr);
- public:
- // DISTRIBUTION ATTRIBUTES
-
// MAP ATTRIBUTES
- /** Sets the entry initial capacity for the next
<code>RegionAttributes</code>
+ /**
+ * Sets the entry initial capacity for the next <code>RegionAttributes</code>
* created. This value
* is used in initializing the map that holds the entries.
* @param initialCapacity the initial capacity of the entry map
+ * @return a reference to <code>this</code>
* @throws IllegalArgumentException if initialCapacity is negative.
*/
- void setInitialCapacity(int initialCapacity);
+ AttributesFactory& setInitialCapacity(int initialCapacity);
- /** Sets the entry load factor for the next <code>RegionAttributes</code>
+ /**
+ * Sets the entry load factor for the next <code>RegionAttributes</code>
* created. This value is
* used in initializing the map that holds the entries.
* @param loadFactor the load factor of the entry map
+ * @return a reference to <code>this</code>
* @throws IllegalArgumentException if loadFactor is nonpositive
*/
- void setLoadFactor(float loadFactor);
+ AttributesFactory& setLoadFactor(float loadFactor);
- /** Sets the concurrency level tof the next <code>RegionAttributes</code>
+ /**
+ * Sets the concurrency level tof the next <code>RegionAttributes</code>
* created. This value is used in initializing the map that holds the
entries.
* @param concurrencyLevel the concurrency level of the entry map
+ * @return a reference to <code>this</code>
* @throws IllegalArgumentException if concurrencyLevel is nonpositive
*/
- void setConcurrencyLevel(uint8_t concurrencyLevel);
+ AttributesFactory& setConcurrencyLevel(uint8_t concurrencyLevel);
/**
* Sets a limit on the number of entries that will be held in the cache.
* If a new entry is added while at the limit, the cache will evict the
* least recently used entry. Defaults to 0, meaning no LRU actions will
* used.
+ * @return a reference to <code>this</code>
*/
- void setLruEntriesLimit(const uint32_t entriesLimit);
+ AttributesFactory& setLruEntriesLimit(const uint32_t entriesLimit);
- /** Sets the Disk policy type for the next <code>RegionAttributes</code>
+ /**
+ * Sets the Disk policy type for the next <code>RegionAttributes</code>
* created.
* @param diskPolicy the type of disk policy to use for the region
+ * @return a reference to <code>this</code>
* @throws IllegalArgumentException if diskPolicyType is Invalid
*/
- void setDiskPolicy(const DiskPolicyType::PolicyType diskPolicy);
+ AttributesFactory& setDiskPolicy(const DiskPolicyType::PolicyType
diskPolicy);
/**
* Set caching enabled flag for this region. If set to false, then no data is
@@ -344,8 +382,9 @@ class CPPCACHE_EXPORT AttributesFactory {
* The default if not set is 'true'.
* This also requires that interestLists are turned off for the region.
* @param cachingEnabled if true, cache data for this region in this process.
+ * @return a reference to <code>this</code>
*/
- void setCachingEnabled(bool cachingEnabled);
+ AttributesFactory& setCachingEnabled(bool cachingEnabled);
/**
* Sets the pool name attribute.
@@ -360,33 +399,38 @@ class CPPCACHE_EXPORT AttributesFactory {
* attributes are used to create a region. See {@link
* PoolManager#createFactory}
* for how to create a connection pool.
+ * @return a reference to <code>this</code>
* @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.
*/
- void setPoolName(const char* name);
+ AttributesFactory& setPoolName(const char* name);
/**
* Sets cloning on region
* @param isClonable
+ * @return a reference to <code>this</code>
* @see RegionAttributes#getCloningEnabled()
*/
- void setCloningEnabled(bool isClonable);
+ AttributesFactory& setCloningEnabled(bool isClonable);
/**
* Enables or disables concurrent modification checks
* @since 7.0
* @param concurrencyChecksEnabled whether to perform concurrency checks on
* operations
+ * @return a reference to <code>this</code>
*/
- void setConcurrencyChecksEnabled(bool concurrencyChecksEnabled);
+ AttributesFactory& setConcurrencyChecksEnabled(bool
concurrencyChecksEnabled);
// FACTORY METHOD
- /** Creates a <code>RegionAttributes</code> with the current settings.
+ /**
+ * Creates a <code>RegionAttributes</code> with the current settings.
* @return the newly created <code>RegionAttributes</code>
* @throws IllegalStateException if the current settings violate the
* compatibility rules
+ * @return a reference to <code>this</code>
*/
std::unique_ptr<RegionAttributes> createRegionAttributes();
diff --git a/cppcache/include/geode/Exception.hpp
b/cppcache/include/geode/Exception.hpp
index bde81602..46ac53e6 100644
--- a/cppcache/include/geode/Exception.hpp
+++ b/cppcache/include/geode/Exception.hpp
@@ -40,6 +40,16 @@ namespace client {
class DistributedSystem;
class CacheableString;
class StackTrace;
+#pragma warning( push )
+/*
+warning C4275:
+non dll-interface class 'std::exception' used as base for dll-interface
+class 'apache::geode::client::Exception'
+
+Ok to ignore because it is ok if the class is a std class.
+*/
+#pragma warning(disable : 4275)
+
/**
* @class Exception Exception.hpp
* A description of an exception that occurred during a cache operation.
@@ -75,7 +85,7 @@ class CPPCACHE_EXPORT Exception : public std::exception {
/** Return the name of this exception type. */
virtual const char* getName() const;
- virtual const char *what() const noexcept override;
+ virtual const char* what() const noexcept override;
private:
std::shared_ptr<StackTrace> m_stack;
@@ -85,13 +95,15 @@ class CPPCACHE_EXPORT Exception : public std::exception {
friend class DistributedSystem;
};
+#pragma warning( pop )
+
+
class CacheableKey;
typedef std::unordered_map<std::shared_ptr<CacheableKey>,
std::shared_ptr<Exception>,
dereference_hash<std::shared_ptr<CacheableKey>>,
-dereference_equal_to<std::shared_ptr<CacheableKey>>>
-HashMapOfException;
-
+ dereference_equal_to<std::shared_ptr<CacheableKey>>>
+ HashMapOfException;
} // namespace client
} // namespace geode
diff --git a/cppcache/include/geode/PoolFactory.hpp
b/cppcache/include/geode/PoolFactory.hpp
index ee05ce85..2bd4bf57 100644
--- a/cppcache/include/geode/PoolFactory.hpp
+++ b/cppcache/include/geode/PoolFactory.hpp
@@ -202,10 +202,11 @@ class CPPCACHE_EXPORT PoolFactory {
*
* @param connectionTimeout is the connection timeout
*
+ * @return a reference to <code>this</code>
* @throws std::invalid_argument if <code>connectionTimeout</code>
* is less than or equal to <code>0</code>.
*/
- void setFreeConnectionTimeout(std::chrono::milliseconds connectionTimeout);
+ PoolFactory& setFreeConnectionTimeout(std::chrono::milliseconds
connectionTimeout);
/**
* Sets the load conditioning interval for this pool.
@@ -216,10 +217,11 @@ class CPPCACHE_EXPORT PoolFactory {
*
* @param loadConditioningInterval is the connection lifetime
*
+ * @return a reference to <code>this</code>
* @throws std::invalid_argument if <code>connectionLifetime</code>
* is less than <code>-1</code>.
*/
- void setLoadConditioningInterval(
+ PoolFactory& setLoadConditioningInterval(
std::chrono::milliseconds loadConditioningInterval);
/**
@@ -231,10 +233,11 @@ class CPPCACHE_EXPORT PoolFactory {
* @param bufferSize is the size of the socket buffers used for reading and
* writing on each connection in this pool.
*
+ * @return a reference to <code>this</code>
* @throws IllegalArgumentException if <code>bufferSize</code>
* is less than or equal to <code>0</code>.
*/
- void setSocketBufferSize(int bufferSize);
+ PoolFactory& setSocketBufferSize(int bufferSize);
/**
* Sets the thread local connections policy for this pool.
@@ -252,8 +255,9 @@ class CPPCACHE_EXPORT PoolFactory {
*
* @param threadLocalConnections if <code>true</code> then enable thread
local
* connections.
+ * @return a reference to <code>this</code>
*/
- void setThreadLocalConnections(bool threadLocalConnections);
+ PoolFactory& setThreadLocalConnections(bool threadLocalConnections);
/**
* Sets the duration to wait for a response from a server before timing out
@@ -261,11 +265,11 @@ class CPPCACHE_EXPORT PoolFactory {
*
* @param timeout duration to wait for a response from a
* server
- *
+ * @return a reference to <code>this</code>
* @throws std::invalid_argument if <code>timeout</code>
* is less than or equal to <code>0</code>.
*/
- void setReadTimeout(std::chrono::milliseconds timeout);
+ PoolFactory& setReadTimeout(std::chrono::milliseconds timeout);
/**
* Sets the minimum number of connections to keep available at all times.
@@ -276,11 +280,11 @@ class CPPCACHE_EXPORT PoolFactory {
*
* @param minConnections is the initial number of connections
* this pool will create.
- *
+ * @return a reference to <code>this</code>
* @throws IllegalArgumentException if <code>minConnections</code>
* is less than <code>0</code>.
*/
- void setMinConnections(int minConnections);
+ PoolFactory& setMinConnections(int minConnections);
/**
* Sets the max number of client to server connections that the pool will
@@ -294,10 +298,11 @@ class CPPCACHE_EXPORT PoolFactory {
* @param maxConnections is the maximum number of connections in the pool.
* <code>-1</code> indicates that there is no maximum number of connections
*
+ * @return a reference to <code>this</code>
* @throws IllegalArgumentException if <code>maxConnections</code>
* is less than <code>minConnections</code>.
*/
- void setMaxConnections(int maxConnections);
+ PoolFactory& setMaxConnections(int maxConnections);
/**
* Sets the amount of time a connection can be idle before expiring the
@@ -309,8 +314,9 @@ class CPPCACHE_EXPORT PoolFactory {
* should live no less than before expiring, actual time may be longer
* depending on clock resolution. A duration less than 0 indicates
* that connections should never expire.
+ * @return a reference to <code>this</code>
*/
- void setIdleTimeout(std::chrono::milliseconds);
+ PoolFactory& setIdleTimeout(std::chrono::milliseconds);
/**
* Set the number of times to retry a request after timeout/exception.
@@ -321,7 +327,7 @@ class CPPCACHE_EXPORT PoolFactory {
* @throws IllegalArgumentException if <code>idleTimout</code>
* is less than <code>0</code>.
*/
- void setRetryAttempts(int retryAttempts);
+ PoolFactory& setRetryAttempts(int retryAttempts);
/**
* The frequency with which servers must be pinged to verify that they are
@@ -335,13 +341,13 @@ class CPPCACHE_EXPORT PoolFactory {
* maximum time between pings allowed by the bridge server.
*
* @param pingInterval is the amount of time between pings.
- *
+ * @return a reference to <code>this</code>
* @throws std::invalid_argument if <code>pingInterval</code>
* is less than <code>0</code>.
*
* @see CacheServer#setMaximumTimeBetweenPings(int)
*/
- void setPingInterval(std::chrono::milliseconds pingInterval);
+ PoolFactory& setPingInterval(std::chrono::milliseconds pingInterval);
/**
* The frequency with which client updates the locator list. To disable this
@@ -349,8 +355,9 @@ class CPPCACHE_EXPORT PoolFactory {
*
* @param updateLocatorListInterval is the amount of time
* between checking locator list at locator.
+ * @return a reference to <code>this</code>
*/
- void setUpdateLocatorListInterval(
+ PoolFactory& setUpdateLocatorListInterval(
std::chrono::milliseconds updateLocatorListInterval);
/**
@@ -362,10 +369,11 @@ class CPPCACHE_EXPORT PoolFactory {
* @param statisticInterval is the amount of time between
* sends of client statistics to the server.
*
+ * @return a reference to <code>this</code>
* @throws std::invalid_argument if <code>statisticInterval</code>
* is less than <code>-1</code>.
*/
- void setStatisticInterval(std::chrono::milliseconds statisticInterval);
+ PoolFactory& setStatisticInterval(std::chrono::milliseconds
statisticInterval);
/**
* Configures the group which contains all the servers that this pool
connects
@@ -375,7 +383,7 @@ class CPPCACHE_EXPORT PoolFactory {
* to all servers.
* @return a reference to <code>this</code>
*/
- void setServerGroup(const char* group);
+ PoolFactory& setServerGroup(const char* group);
/**
* Adds a locator, given its host and port, to this factory.
@@ -394,7 +402,7 @@ class CPPCACHE_EXPORT PoolFactory {
* @throws IllegalStateException if the locator has already been {@link
* #addServer added} to this factory.
*/
- void addLocator(const char* host, int port);
+ PoolFactory& addLocator(const char* host, int port);
/**
* Adds a server, given its host and port, to this factory.
@@ -411,7 +419,7 @@ class CPPCACHE_EXPORT PoolFactory {
* @throws IllegalStateException if the server has already been {@link
* #addLocator added} to this factory.
*/
- void addServer(const char* host, int port);
+ PoolFactory& addServer(const char* host, int port);
/**
* If set to <code>true</code> then the created pool will have
@@ -421,7 +429,7 @@ class CPPCACHE_EXPORT PoolFactory {
* are ignored at the time of creation.
* @return a reference to <code>this</code>
*/
- void setSubscriptionEnabled(bool enabled);
+ PoolFactory& setSubscriptionEnabled(bool enabled);
/**
* Sets the redundancy level for this pools server-to-client subscriptions.
@@ -436,7 +444,7 @@ class CPPCACHE_EXPORT PoolFactory {
* @throws IllegalArgumentException if <code>redundancyLevel</code>
* is less than <code>-1</code>.
*/
- void setSubscriptionRedundancy(int redundancy);
+ PoolFactory& setSubscriptionRedundancy(int redundancy);
/**
* Sets the messageTrackingTimeout attribute which is the time-to-live period
@@ -445,11 +453,13 @@ class CPPCACHE_EXPORT PoolFactory {
* amount of time are expired from the list.
*
* @param messageTrackingTimeout is the duration to set the timeout to.
+ * @return a reference to <code>this</code>
*
* @throws std::invalid_argument if <code>messageTrackingTimeout</code>
* is less than or equal to <code>0</code>.
+
*/
- void setSubscriptionMessageTrackingTimeout(
+ PoolFactory& setSubscriptionMessageTrackingTimeout(
std::chrono::milliseconds messageTrackingTimeout);
/**
@@ -461,22 +471,24 @@ class CPPCACHE_EXPORT PoolFactory {
*
* @throws std::invalid_argument if <code>ackInterval</code>
* is less than or equal to <code>0</code>.
+ * @return a reference to <code>this</code>
*/
- void setSubscriptionAckInterval(std::chrono::milliseconds ackInterval);
+ PoolFactory& setSubscriptionAckInterval(std::chrono::milliseconds
ackInterval);
/**
* Sets whether Pool is in multi user secure mode.
* If its in multiuser mode then app needs to get RegionService instance of
* Cache.
* Deafult value is false.
+ * @return a reference to <code>this</code>
*/
- void setMultiuserAuthentication(bool multiuserAuthentication);
+ PoolFactory& setMultiuserAuthentication(bool multiuserAuthentication);
/**
* Resets the configuration of this factory to its defaults.
* @return a reference to <code>this</code>
*/
- void reset();
+ PoolFactory& reset();
/**
* Creates a new Pool for connecting a client to a set of Geode Cache
@@ -511,14 +523,14 @@ class CPPCACHE_EXPORT PoolFactory {
* not.
* @return a reference to <code>this</code>
*/
- void setPRSingleHopEnabled(bool enabled);
+ PoolFactory& setPRSingleHopEnabled(bool enabled);
~PoolFactory();
private:
PoolFactory(const Cache& cache);
PoolFactory(const PoolFactory&);
- void addCheck(const char* host, int port);
+ PoolFactory& addCheck(const char* host, int port);
std::shared_ptr<PoolAttributes> m_attrs;
bool m_isSubscriptionRedundancy;
bool m_addedServerOrLocator;
diff --git a/cppcache/integration-test/testPoolFactory.cpp
b/cppcache/integration-test/testPoolFactory.cpp
new file mode 100644
index 00000000..6b9d89dc
--- /dev/null
+++ b/cppcache/integration-test/testPoolFactory.cpp
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#define ROOT_NAME "testPoolFactory"
+
+#include "fw_helper.hpp"
+#include <CacheRegionHelper.hpp>
+#include <geode/PoolFactory.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/Cache.hpp>
+#include <geode/PoolManager.hpp>
+#include "CacheImpl.hpp"
+using namespace apache::geode::client;
+
+BEGIN_TEST(POOLFACTORY)
+{
+ auto cacheFactory = CacheFactory::createCacheFactory();
+ ASSERT(cacheFactory != nullptr, "CacheFactory was a nullptr");
+ auto cachePtr = cacheFactory->create();
+ ASSERT(cachePtr != nullptr, "CachePtr was a nullptr");
+ auto poolFactory = cachePtr->getPoolManager().createFactory();
+ ASSERT(poolFactory != nullptr, "poolFactory was a nullptr");
+ auto& testPoolFactory = poolFactory->setSubscriptionEnabled(true);
+ bool test = poolFactory.get() ==
std::addressof<PoolFactory>(testPoolFactory);
+ ASSERT(test, "testPoolFactory and poolFactory not equal");
+ }
+END_TEST(POOLFACTORY)
diff --git a/cppcache/integration-test/testThinClientCqDurable.cpp
b/cppcache/integration-test/testThinClientCqDurable.cpp
index 3b46e3fe..f3718adf 100644
--- a/cppcache/integration-test/testThinClientCqDurable.cpp
+++ b/cppcache/integration-test/testThinClientCqDurable.cpp
@@ -193,10 +193,10 @@ void RunDurableCqClient() {
auto cacheFactory = CacheFactory::createCacheFactory(pp);
auto cachePtr = cacheFactory->create();
auto poolFactory = cachePtr->getPoolManager().createFactory();
- poolFactory->setSubscriptionEnabled(true);
- poolFactory->setSubscriptionAckInterval(std::chrono::milliseconds(5000));
-
poolFactory->setSubscriptionMessageTrackingTimeout(std::chrono::milliseconds(50000));
- poolFactory->create("");
+ poolFactory->setSubscriptionEnabled(true)
+ .setSubscriptionAckInterval(std::chrono::milliseconds(5000))
+ .setSubscriptionMessageTrackingTimeout(std::chrono::milliseconds(50000))
+ .create("");
LOGINFO("Created the Geode Cache Programmatically");
@@ -461,9 +461,7 @@ void client1Up() {
LOG("Client1Up complete.");
QueryHelper* qh ATTR_UNUSED = &QueryHelper::getHelper();
- std::shared_ptr<QueryService> qs;
-
- qs = getHelper()
+ std::shared_ptr<QueryService> qs = getHelper()
->getCache()
->getPoolManager()
.find(regionNamesCq[0])
diff --git a/cppcache/src/AttributesFactory.cpp
b/cppcache/src/AttributesFactory.cpp
index 72a3cea1..7a80b54c 100644
--- a/cppcache/src/AttributesFactory.cpp
+++ b/cppcache/src/AttributesFactory.cpp
@@ -38,84 +38,96 @@ AttributesFactory::AttributesFactory(
AttributesFactory::~AttributesFactory() {}
-void AttributesFactory::setCacheLoader(
+AttributesFactory& AttributesFactory::setCacheLoader(
const std::shared_ptr<CacheLoader>& cacheLoader) {
m_regionAttributes.m_cacheLoader = cacheLoader;
+ return *this;
}
-void AttributesFactory::setCacheWriter(
+AttributesFactory& AttributesFactory::setCacheWriter(
const std::shared_ptr<CacheWriter>& cacheWriter) {
m_regionAttributes.m_cacheWriter = cacheWriter;
+ return *this;
}
-void AttributesFactory::setCacheListener(
+AttributesFactory& AttributesFactory::setCacheListener(
const std::shared_ptr<CacheListener>& aListener) {
m_regionAttributes.m_cacheListener = aListener;
+ return *this;
}
-void AttributesFactory::setPartitionResolver(
+AttributesFactory& AttributesFactory::setPartitionResolver(
const std::shared_ptr<PartitionResolver>& aResolver) {
m_regionAttributes.m_partitionResolver = aResolver;
+ return *this;
}
-void AttributesFactory::setCacheLoader(const char* lib, const char* func) {
+AttributesFactory& AttributesFactory::setCacheLoader(const char* lib,
+ const char* func) {
m_regionAttributes.setCacheLoader(lib, func);
+ return *this;
}
-void AttributesFactory::setCacheWriter(const char* lib, const char* func) {
+AttributesFactory& AttributesFactory::setCacheWriter(const char* lib,
+ const char* func) {
m_regionAttributes.setCacheWriter(lib, func);
+ return *this;
}
-void AttributesFactory::setCacheListener(const char* lib, const char* func) {
+AttributesFactory& AttributesFactory::setCacheListener(const char* lib,
+ const char* func) {
m_regionAttributes.setCacheListener(lib, func);
+ return *this;
}
-void AttributesFactory::setPartitionResolver(const char* lib,
- const char* func) {
+AttributesFactory& AttributesFactory::setPartitionResolver(const char* lib,
+ const char* func) {
m_regionAttributes.setPartitionResolver(lib, func);
+ return *this;
}
-void AttributesFactory::setEntryIdleTimeout(ExpirationAction::Action action,
- std::chrono::seconds idleTimeout) {
+AttributesFactory& AttributesFactory::setEntryIdleTimeout(
+ ExpirationAction::Action action, std::chrono::seconds idleTimeout) {
m_regionAttributes.m_entryIdleTimeout = idleTimeout;
m_regionAttributes.m_entryIdleTimeoutExpirationAction = action;
+ return *this;
}
-void AttributesFactory::setEntryTimeToLive(ExpirationAction::Action action,
- std::chrono::seconds timeToLive) {
+AttributesFactory& AttributesFactory::setEntryTimeToLive(
+ ExpirationAction::Action action, std::chrono::seconds timeToLive) {
m_regionAttributes.m_entryTimeToLive = timeToLive;
m_regionAttributes.m_entryTimeToLiveExpirationAction = action;
+ return *this;
}
-void AttributesFactory::setRegionIdleTimeout(ExpirationAction::Action action,
- std::chrono::seconds idleTimeout)
{
+AttributesFactory& AttributesFactory::setRegionIdleTimeout(
+ ExpirationAction::Action action, std::chrono::seconds idleTimeout) {
m_regionAttributes.m_regionIdleTimeout = idleTimeout;
m_regionAttributes.m_regionIdleTimeoutExpirationAction = action;
+ return *this;
}
-void AttributesFactory::setRegionTimeToLive(ExpirationAction::Action action,
- std::chrono::seconds timeToLive) {
+AttributesFactory& AttributesFactory::setRegionTimeToLive(
+ ExpirationAction::Action action, std::chrono::seconds timeToLive) {
m_regionAttributes.m_regionTimeToLive = timeToLive;
m_regionAttributes.m_regionTimeToLiveExpirationAction = action;
+ return *this;
}
-void AttributesFactory::setInitialCapacity(int initialCapacity) {
+AttributesFactory& AttributesFactory::setInitialCapacity(int initialCapacity) {
m_regionAttributes.m_initialCapacity = initialCapacity;
+ return *this;
}
-void AttributesFactory::setLoadFactor(float loadFactor) {
+AttributesFactory& AttributesFactory::setLoadFactor(float loadFactor) {
m_regionAttributes.m_loadFactor = loadFactor;
+ return *this;
}
-void AttributesFactory::setConcurrencyLevel(uint8_t concurrencyLevel) {
+AttributesFactory& AttributesFactory::setConcurrencyLevel(
+ uint8_t concurrencyLevel) {
m_regionAttributes.m_concurrencyLevel = concurrencyLevel;
+ return *this;
}
-/*
-void AttributesFactory::setStatisticsEnabled( bool statisticsEnabled)
-{
- m_regionAttributes.m_statisticsEnabled = statisticsEnabled;
-}
-*/
-
std::unique_ptr<RegionAttributes> AttributesFactory::createRegionAttributes() {
std::shared_ptr<RegionAttributes> res;
validateAttributes(m_regionAttributes);
@@ -164,44 +176,53 @@ void
AttributesFactory::validateAttributes(RegionAttributes& attrs) {
}
}
-void AttributesFactory::setLruEntriesLimit(const uint32_t entriesLimit) {
+AttributesFactory& AttributesFactory::setLruEntriesLimit(
+ const uint32_t entriesLimit) {
m_regionAttributes.m_lruEntriesLimit = entriesLimit;
+ return *this;
}
-void AttributesFactory::setDiskPolicy(
+AttributesFactory& AttributesFactory::setDiskPolicy(
const DiskPolicyType::PolicyType diskPolicy) {
if (diskPolicy == DiskPolicyType::PERSIST) {
throw IllegalStateException("Persistence feature is not supported");
}
m_regionAttributes.m_diskPolicy = diskPolicy;
+ return *this;
}
-void AttributesFactory::setCachingEnabled(bool cachingEnabled) {
+AttributesFactory& AttributesFactory::setCachingEnabled(bool cachingEnabled) {
m_regionAttributes.m_caching = cachingEnabled;
+ return *this;
}
-void AttributesFactory::setPersistenceManager(
+AttributesFactory& AttributesFactory::setPersistenceManager(
const std::shared_ptr<PersistenceManager>& persistenceManager,
const std::shared_ptr<Properties>& props) {
m_regionAttributes.m_persistenceManager = persistenceManager;
m_regionAttributes.m_persistenceProperties = props;
+ return *this;
}
-void AttributesFactory::setPersistenceManager(
+AttributesFactory& AttributesFactory::setPersistenceManager(
const char* lib, const char* func,
const std::shared_ptr<Properties>& config) {
m_regionAttributes.setPersistenceManager(lib, func, config);
+ return *this;
}
-void AttributesFactory::setPoolName(const char* name) {
+AttributesFactory& AttributesFactory::setPoolName(const char* name) {
m_regionAttributes.setPoolName(name);
+ return *this;
}
-void AttributesFactory::setCloningEnabled(bool isClonable) {
+AttributesFactory& AttributesFactory::setCloningEnabled(bool isClonable) {
m_regionAttributes.setCloningEnabled(isClonable);
+ return *this;
}
-void AttributesFactory::setConcurrencyChecksEnabled(bool enable) {
+AttributesFactory& AttributesFactory::setConcurrencyChecksEnabled(bool enable)
{
m_regionAttributes.setConcurrencyChecksEnabled(enable);
+ return *this;
}
} // namespace client
diff --git a/cppcache/src/PoolFactory.cpp b/cppcache/src/PoolFactory.cpp
index e21a3664..74278b6d 100644
--- a/cppcache/src/PoolFactory.cpp
+++ b/cppcache/src/PoolFactory.cpp
@@ -71,7 +71,7 @@ PoolFactory::PoolFactory(const Cache& cache)
PoolFactory::~PoolFactory() {}
-void PoolFactory::setFreeConnectionTimeout(
+PoolFactory& PoolFactory::setFreeConnectionTimeout(
std::chrono::milliseconds connectionTimeout) {
// TODO GEODE-3136 - Is this true?
if (connectionTimeout <= std::chrono::milliseconds::zero()) {
@@ -79,9 +79,10 @@ void PoolFactory::setFreeConnectionTimeout(
}
m_attrs->setFreeConnectionTimeout(connectionTimeout);
+ return *this;
}
-void PoolFactory::setLoadConditioningInterval(
+PoolFactory& PoolFactory::setLoadConditioningInterval(
std::chrono::milliseconds loadConditioningInterval) {
// TODO GEODE-3136 - Is this true?
if (loadConditioningInterval <= std::chrono::milliseconds::zero()) {
@@ -90,51 +91,60 @@ void PoolFactory::setLoadConditioningInterval(
}
m_attrs->setLoadConditioningInterval(loadConditioningInterval);
+ return *this;
}
-void PoolFactory::setSocketBufferSize(int bufferSize) {
+PoolFactory& PoolFactory::setSocketBufferSize(int bufferSize) {
m_attrs->setSocketBufferSize(bufferSize);
+ return *this;
}
-void PoolFactory::setThreadLocalConnections(bool threadLocalConnections) {
+PoolFactory& PoolFactory::setThreadLocalConnections(bool
threadLocalConnections) {
m_attrs->setThreadLocalConnectionSetting(threadLocalConnections);
+ return *this;
}
-void PoolFactory::setReadTimeout(std::chrono::milliseconds timeout) {
+PoolFactory& PoolFactory::setReadTimeout(std::chrono::milliseconds timeout) {
// TODO GEODE-3136 - Is this true?
if (timeout <= std::chrono::milliseconds::zero()) {
throw std::invalid_argument("timeout must greater than 0.");
}
m_attrs->setReadTimeout(timeout);
+ return *this;
}
-void PoolFactory::setMinConnections(int minConnections) {
+PoolFactory& PoolFactory::setMinConnections(int minConnections) {
m_attrs->setMinConnections(minConnections);
+ return *this;
}
-void PoolFactory::setMaxConnections(int maxConnections) {
+PoolFactory& PoolFactory::setMaxConnections(int maxConnections) {
m_attrs->setMaxConnections(maxConnections);
+ return *this;
}
-void PoolFactory::setIdleTimeout(std::chrono::milliseconds idleTimeout) {
+PoolFactory& PoolFactory::setIdleTimeout(std::chrono::milliseconds
idleTimeout) {
m_attrs->setIdleTimeout(idleTimeout);
+ return *this;
}
-void PoolFactory::setRetryAttempts(int retryAttempts) {
+PoolFactory& PoolFactory::setRetryAttempts(int retryAttempts) {
m_attrs->setRetryAttempts(retryAttempts);
+ return *this;
}
-void PoolFactory::setPingInterval(std::chrono::milliseconds pingInterval) {
+PoolFactory& PoolFactory::setPingInterval(std::chrono::milliseconds
pingInterval) {
// TODO GEODE-3136 - Is this true?
if (pingInterval <= std::chrono::milliseconds::zero()) {
throw std::invalid_argument("timeout must greater than 0.");
}
m_attrs->setPingInterval(pingInterval);
+ return *this;
}
-void PoolFactory::setUpdateLocatorListInterval(
+PoolFactory& PoolFactory::setUpdateLocatorListInterval(
const std::chrono::milliseconds updateLocatorListInterval) {
// TODO GEODE-3136 - Is this true?
if (updateLocatorListInterval < std::chrono::milliseconds::zero()) {
@@ -142,9 +152,10 @@ void PoolFactory::setUpdateLocatorListInterval(
}
m_attrs->setUpdateLocatorListInterval(updateLocatorListInterval);
+ return *this;
}
-void PoolFactory::setStatisticInterval(
+PoolFactory& PoolFactory::setStatisticInterval(
std::chrono::milliseconds statisticInterval) {
// TODO GEODE-3136 - Consider 0 to disable
if (statisticInterval.count() <= -1) {
@@ -152,34 +163,40 @@ void PoolFactory::setStatisticInterval(
}
m_attrs->setStatisticInterval(statisticInterval);
+ return *this;
}
-void PoolFactory::setServerGroup(const char* group) {
+PoolFactory& PoolFactory::setServerGroup(const char* group) {
m_attrs->setServerGroup(group);
+ return *this;
}
-void PoolFactory::addLocator(const char* host, int port) {
+PoolFactory& PoolFactory::addLocator(const char* host, int port) {
addCheck(host, port);
m_attrs->addLocator(host, port);
m_addedServerOrLocator = true;
+ return *this;
}
-void PoolFactory::addServer(const char* host, int port) {
+PoolFactory& PoolFactory::addServer(const char* host, int port) {
addCheck(host, port);
m_attrs->addServer(host, port);
m_addedServerOrLocator = true;
+ return *this;
}
-void PoolFactory::setSubscriptionEnabled(bool enabled) {
+PoolFactory& PoolFactory::setSubscriptionEnabled(bool enabled) {
m_attrs->setSubscriptionEnabled(enabled);
+ return *this;
}
-void PoolFactory::setSubscriptionRedundancy(int redundancy) {
+PoolFactory& PoolFactory::setSubscriptionRedundancy(int redundancy) {
m_isSubscriptionRedundancy = true;
m_attrs->setSubscriptionRedundancy(redundancy);
+ return *this;
}
-void PoolFactory::setSubscriptionMessageTrackingTimeout(
+PoolFactory& PoolFactory::setSubscriptionMessageTrackingTimeout(
std::chrono::milliseconds messageTrackingTimeout) {
// TODO GEODE-3136 - Is this true?
if (messageTrackingTimeout <= std::chrono::milliseconds::zero()) {
@@ -187,9 +204,10 @@ void PoolFactory::setSubscriptionMessageTrackingTimeout(
}
m_attrs->setSubscriptionMessageTrackingTimeout(messageTrackingTimeout);
+ return *this;
}
-void PoolFactory::setSubscriptionAckInterval(
+PoolFactory& PoolFactory::setSubscriptionAckInterval(
std::chrono::milliseconds ackInterval) {
// TODO GEODE-3136 - Is this true?
if (ackInterval <= std::chrono::milliseconds::zero()) {
@@ -197,18 +215,22 @@ void PoolFactory::setSubscriptionAckInterval(
}
m_attrs->setSubscriptionAckInterval(ackInterval);
+ return *this;
}
-void PoolFactory::setMultiuserAuthentication(bool multiuserAuthentication) {
+PoolFactory& PoolFactory::setMultiuserAuthentication(bool
multiuserAuthentication) {
m_attrs->setMultiuserSecureModeEnabled(multiuserAuthentication);
+ return *this;
}
-void PoolFactory::reset() {
+PoolFactory& PoolFactory::reset() {
m_attrs = std::shared_ptr<PoolAttributes>(new PoolAttributes);
+ return *this;
}
-void PoolFactory::setPRSingleHopEnabled(bool enabled) {
+PoolFactory& PoolFactory::setPRSingleHopEnabled(bool enabled) {
m_attrs->setPRSingleHopEnabled(enabled);
+ return *this;
}
std::shared_ptr<Pool> PoolFactory::create(const char* name) {
std::shared_ptr<ThinClientPoolDM> poolDM;
@@ -281,7 +303,7 @@ std::shared_ptr<Pool> PoolFactory::create(const char* name)
{
return std::static_pointer_cast<Pool>(poolDM);
}
-void PoolFactory::addCheck(const char* host, int port) {
+PoolFactory& PoolFactory::addCheck(const char* host, int port) {
if (port <= 0) {
char buff[100];
ACE_OS::snprintf(buff, 100, "port must be greater than 0 but was %d",
port);
@@ -293,4 +315,5 @@ void PoolFactory::addCheck(const char* host, int port) {
ACE_OS::snprintf(buff, 100, "Unknown host %s", host);
throw IllegalArgumentException(buff);
}
+ return *this;
}
diff --git a/cppcache/src/TcrMessage.hpp b/cppcache/src/TcrMessage.hpp
index 24526d00..b00dce5b 100644
--- a/cppcache/src/TcrMessage.hpp
+++ b/cppcache/src/TcrMessage.hpp
@@ -178,7 +178,7 @@ class CPPCACHE_EXPORT TcrMessage {
} MsgType;
- static bool isKeepAlive() { return *m_keepalive; }
+ static bool isKeepAlive() { return *m_keepalive > 0; }
static bool isUserInitiativeOps(const TcrMessage& msg) {
int32_t msgType = msg.getMessageType();
@@ -231,13 +231,16 @@ class CPPCACHE_EXPORT TcrMessage {
// = false, bool receiveValues = true, ThinClientBaseDM *connectionDM =
// nullptr);
- void InitializeGetallMsg(const std::shared_ptr<Serializable>&
aCallbackArgument);
+ void InitializeGetallMsg(
+ const std::shared_ptr<Serializable>& aCallbackArgument);
// for multiuser cache close
// Updates the early ack byte of the message to reflect that it is a retry op
void updateHeaderForRetry();
- inline const std::vector<std::shared_ptr<CacheableKey>> * getKeys() const {
return m_keyList; }
+ inline const std::vector<std::shared_ptr<CacheableKey>>* getKeys() const {
+ return m_keyList;
+ }
inline const std::string& getRegex() const { return m_regex; }
@@ -372,7 +375,8 @@ class CPPCACHE_EXPORT TcrMessage {
m_versionObjPartListptr = versionObjPartListptr;
}
- std::shared_ptr<VersionedCacheableObjectPartList>
getVersionedObjectPartList() {
+ std::shared_ptr<VersionedCacheableObjectPartList>
+ getVersionedObjectPartList() {
return m_versionObjPartListptr;
}
@@ -416,17 +420,22 @@ class CPPCACHE_EXPORT TcrMessage {
int32_t getNumBuckets() const { return m_bucketCount; }
- std::shared_ptr<CacheableString> getColocatedWith() const { return
m_colocatedWith; }
+ std::shared_ptr<CacheableString> getColocatedWith() const {
+ return m_colocatedWith;
+ }
std::shared_ptr<CacheableString> getPartitionResolver() const {
return m_partitionResolverName;
}
- std::vector<std::vector<std::shared_ptr<BucketServerLocation>> >*
getMetadata() {
+ std::vector<std::vector<std::shared_ptr<BucketServerLocation>>>*
+ getMetadata() {
return m_metadata;
}
- std::vector<std::shared_ptr<FixedPartitionAttributesImpl>>* getFpaSet() {
return m_fpaSet; }
+ std::vector<std::shared_ptr<FixedPartitionAttributesImpl>>* getFpaSet() {
+ return m_fpaSet;
+ }
std::shared_ptr<CacheableHashSet> getFailedNode() { return m_failedNode; }
@@ -436,16 +445,21 @@ class CPPCACHE_EXPORT TcrMessage {
m_isCallBackArguement = aCallBackArguement;
}
- void setBucketServerLocation(std::shared_ptr<BucketServerLocation>
serverLocation) {
+ void setBucketServerLocation(
+ std::shared_ptr<BucketServerLocation> serverLocation) {
m_bucketServerLocation = serverLocation;
}
- void setVersionTag(std::shared_ptr<VersionTag> versionTag) { m_versionTag =
versionTag; }
+ void setVersionTag(std::shared_ptr<VersionTag> versionTag) {
+ m_versionTag = versionTag;
+ }
std::shared_ptr<VersionTag> getVersionTag() { return m_versionTag; }
uint8_t hasResult() const { return m_hasResult; }
std::shared_ptr<CacheableHashMap> getTombstoneVersions() const {
return m_tombstoneVersions;
}
- std::shared_ptr<CacheableHashSet> getTombstoneKeys() const { return
m_tombstoneKeys; }
+ std::shared_ptr<CacheableHashSet> getTombstoneKeys() const {
+ return m_tombstoneKeys;
+ }
bool isFEAnotherHop();
diff --git a/cppcache/test/AttributesFactoryTest.cpp
b/cppcache/test/AttributesFactoryTest.cpp
index 993a9335..0d16bd8c 100644
--- a/cppcache/test/AttributesFactoryTest.cpp
+++ b/cppcache/test/AttributesFactoryTest.cpp
@@ -23,36 +23,58 @@ using namespace apache::geode::client;
TEST(AttributesFactoryTest, setEntryIdleTimeoutSeconds) {
AttributesFactory attributesFactory;
- attributesFactory.setEntryIdleTimeout(ExpirationAction::DESTROY,
- std::chrono::seconds(10));
std::shared_ptr<RegionAttributes> regionAttributes =
- attributesFactory.createRegionAttributes();
+ attributesFactory
+ .setEntryIdleTimeout(ExpirationAction::DESTROY,
+ std::chrono::seconds(10))
+ .createRegionAttributes();
EXPECT_EQ(std::chrono::seconds(10), regionAttributes->getEntryIdleTimeout());
}
TEST(AttributesFactoryTest, setEntryTimeToLiveSeconds) {
AttributesFactory attributesFactory;
- attributesFactory.setEntryTimeToLive(ExpirationAction::DESTROY,
- std::chrono::seconds(10));
std::shared_ptr<RegionAttributes> regionAttributes =
- attributesFactory.createRegionAttributes();
+ attributesFactory
+ .setEntryTimeToLive(ExpirationAction::DESTROY,
+ std::chrono::seconds(10))
+ .createRegionAttributes();
EXPECT_EQ(std::chrono::seconds(10), regionAttributes->getEntryTimeToLive());
}
TEST(AttributesFactoryTest, setRegionIdleTimeoutSeconds) {
AttributesFactory attributesFactory;
- attributesFactory.setRegionIdleTimeout(ExpirationAction::DESTROY,
- std::chrono::seconds(10));
std::shared_ptr<RegionAttributes> regionAttributes =
- attributesFactory.createRegionAttributes();
+ attributesFactory
+ .setRegionIdleTimeout(ExpirationAction::DESTROY,
+ std::chrono::seconds(10))
+ .createRegionAttributes();
EXPECT_EQ(std::chrono::seconds(10),
regionAttributes->getRegionIdleTimeout());
}
TEST(AttributesFactoryTest, setRegionTimeToLiveSeconds) {
AttributesFactory attributesFactory;
- attributesFactory.setRegionTimeToLive(ExpirationAction::DESTROY,
- std::chrono::seconds(10));
std::shared_ptr<RegionAttributes> regionAttributes =
- attributesFactory.createRegionAttributes();
+ attributesFactory
+ .setRegionTimeToLive(ExpirationAction::DESTROY,
+ std::chrono::seconds(10))
+ .createRegionAttributes();
EXPECT_EQ(std::chrono::seconds(10), regionAttributes->getRegionTimeToLive());
}
+
+TEST(AttributesFactoryTest, setInitialCapacity) {
+ AttributesFactory* af = new AttributesFactory();
+ EXPECT_NE(af, nullptr);
+ std::unique_ptr<RegionAttributes> rattrs =
+ af->setLruEntriesLimit(2).setInitialCapacity(5).createRegionAttributes();
+ EXPECT_NE(rattrs, nullptr);
+ EXPECT_EQ(rattrs->getInitialCapacity(), 5);
+}
+
+TEST(AttributesFactoryTest, setLruEntriesLimit) {
+ AttributesFactory* af = new AttributesFactory();
+ EXPECT_NE(af, nullptr);
+ std::unique_ptr<RegionAttributes> rattrs =
+ af->setLruEntriesLimit(2).setInitialCapacity(5).createRegionAttributes();
+ EXPECT_NE(rattrs, nullptr);
+ EXPECT_EQ(rattrs->getLruEntriesLimit(), 2);
+}
diff --git a/tests/cli/NewFwkLib/FwkTest.cs b/tests/cli/NewFwkLib/FwkTest.cs
index ea91a12d..f3e46fdf 100644
--- a/tests/cli/NewFwkLib/FwkTest.cs
+++ b/tests/cli/NewFwkLib/FwkTest.cs
@@ -741,11 +741,10 @@ private void ReadXmlData(RegionFactory af, PoolFactory
pf,string spec, ref strin
string regionName;
if (xmlNode.FirstChild.FirstChild.Name == "region")
{
- //Util.Log("rjk reading region xml data attri name in fwktest");
XmlAttribute nameattr =
xmlNode.FirstChild.FirstChild.Attributes["name"];
regionName = nameattr.Value;
XmlNode attrnode = xmlNode.FirstChild.FirstChild.FirstChild;
- //AttributesFactory af = new AttributesFactory();
+
if (attrnode.Name == "region-attributes")
{
XmlAttributeCollection attrcoll = attrnode.Attributes;
@@ -753,7 +752,6 @@ private void ReadXmlData(RegionFactory af, PoolFactory
pf,string spec, ref strin
{
foreach (XmlAttribute eachattr in attrcoll)
{
- //Util.Log("rjk fwktest region attri xml data attri name =
{0} , attri value = {1}", eachattr.Name, eachattr.Value);
SetThisAttribute(eachattr.Name, eachattr, af, ref
poolname);
}
}
@@ -761,7 +759,6 @@ private void ReadXmlData(RegionFactory af, PoolFactory
pf,string spec, ref strin
{
foreach (XmlNode tmpnode in attrnode.ChildNodes)
{
- //Util.Log("rjk fwktest region attri tmpnode xml data
attri name = {0} , attri value = {1}", tmpnode.Name, tmpnode.Value);
SetThisAttribute(tmpnode.Name, tmpnode, af, ref poolname);
}
}
@@ -782,7 +779,6 @@ private void ReadXmlData(RegionFactory af, PoolFactory
pf,string spec, ref strin
{
foreach (XmlAttribute eachattr in attrcoll)
{
- //Util.Log("rjk fwktest xml data attri name = {0} , attri
value = {1}", eachattr.Name, eachattr.Value);
SetThisPoolAttributes(pf, eachattr.Name, eachattr.Value);
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> API should move from factory pattern to builder pattern and fluent model
> ------------------------------------------------------------------------
>
> Key: GEODE-3571
> URL: https://issues.apache.org/jira/browse/GEODE-3571
> Project: Geode
> Issue Type: Improvement
> Components: native client
> Reporter: Mark Hanson
>
> Discussion here http://markmail.org/thread/femkjloasj4yzvoj
> The basic idea is to move away from the creation of generic objects which are
> then further specified to specifying the object in advance then creating the
> more specific object.
> This in addition to using a model where with each attribute set on an object,
> the this pointer is provided as the return value. This allows call chaining.
> Obvious target changes include
> CacheFactory
> DistributedSystem
> AttributesFactory
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)