You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2017/08/11 23:52:41 UTC
[25/52] [partial] geode-native git commit: GEODE-3165: Reogranized
sources relative to the root for better CMake IDE integration.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/AttributesFactory.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/AttributesFactory.hpp b/clicache/src/AttributesFactory.hpp
new file mode 100644
index 0000000..608c372
--- /dev/null
+++ b/clicache/src/AttributesFactory.hpp
@@ -0,0 +1,513 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include "geode_defs.hpp"
+#include "begin_native.hpp"
+#include <geode/AttributesFactory.hpp>
+#include "end_native.hpp"
+
+#include "ExpirationAction.hpp"
+#include "DiskPolicyType.hpp"
+
+#include "ICacheLoader.hpp"
+#include "ICacheWriter.hpp"
+#include "ICacheListener.hpp"
+#include "IPartitionResolver.hpp"
+#include "IFixedPartitionResolver.hpp"
+#include "IPersistenceManager.hpp"
+#include "RegionAttributes.hpp"
+#include "RegionAttributes.hpp"
+#include "native_unique_ptr.hpp"
+
+
+using namespace System;
+using namespace System::Collections::Generic;
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+ namespace native = apache::geode::client;
+
+ /// <summary>
+ /// Factory class to create instances of <see cref="RegionAttributes" />.
+ /// </summary>
+ /// <remarks>
+ /// An <see cref="AttributesFactory" />
+ /// instance maintains state for creating <see cref="RegionAttributes" /> instances.
+ /// The setter methods are used to change the settings that will be used for
+ /// creating the next attributes instance with the <see cref="CreateRegionAttributes" />
+ /// method. If you create a factory with the default constructor, then the
+ /// factory is set up to create attributes with all default settings. You can
+ /// also create a factory by providing a preset <see cref="RegionAttributes" />.
+ /// <para>
+ /// Once a <see cref="RegionAttributes" /> is created, it can only be modified
+ /// after it has been used to create a <see cref="Region" />, and then only by
+ /// using an <see cref="AttributesMutator" /> obtained from the region.
+ /// </para><para>
+ /// <h3>Attributes</h3>
+ /// <h4>Callbacks</h4>
+ /// <dl>
+ /// <dt><see cref="ICacheLoader" /> [<em>default:</em> null]</dt>
+ /// <dd>User-implemented plug-in for loading data on cache misses.<br />
+ /// see <see cref="SetCacheLoader" />,
+ /// <see cref="RegionAttributes.CacheLoader" /></dd>
+ ///
+ /// <dt><see cref="ICacheWriter" /> [<em>default:</em> null]</dt>
+ /// <dd>User-implemented plug-in for intercepting cache modifications, e.g.
+ /// for writing to an external data source.<br />
+ /// see <see cref="SetCacheWriter" />,
+ /// <see cref="RegionAttributes.CacheWriter" /></dd>
+ ///
+ /// <dt><see cref="ICacheListener" /> [<em>default:</em> null]</dt>
+ /// <dd>User-implemented plug-in for receiving and handling cache-related events.<br />
+ /// see <see cref="SetCacheListener" />,
+ /// <see cref="RegionAttributes.CacheListener" /></dd>
+ ///
+ /// <dt><see cref="IPartitionResolver" /> [<em>default:</em> null]</dt>
+ /// <dd>User-implemented plug-in for custom partitioning.<br />
+ /// see <see cref="SetPartitionResolver" />,
+ /// <see cref="RegionAttributes.PartitionResolver" /></dd>
+ /// </dl>
+ /// <h4>Expiration</h4>
+ /// <dl>
+ /// <dt>RegionTimeToLive [<em>default:</em> no expiration]</dt>
+ /// <dd>Expiration configuration for the entire region based on the
+ /// lastModifiedTime ( <see cref="CacheStatistics.LastModifiedTime" /> ).<br />
+ /// see <see cref="SetRegionTimeToLive" />,
+ /// <see cref="RegionAttributes.RegionTimeToLive" />,
+ /// <see cref="AttributesMutator.SetRegionTimeToLive" /></dd>
+ ///
+ /// <dt>RegionIdleTimeout [<em>default:</em> no expiration]</dt>
+ /// <dd>Expiration configuration for the entire region based on the
+ /// lastAccessedTime ( <see cref="CacheStatistics.LastAccessedTime" /> ).<br />
+ /// see <see cref="SetRegionIdleTimeout" />,
+ /// <see cref="RegionAttributes.RegionIdleTimeout" />,
+ /// <see cref="AttributesMutator.SetRegionIdleTimeout" /></dd>
+ ///
+ /// <dt>EntryTimeToLive [<em>default:</em> no expiration]</dt>
+ /// <dd>Expiration configuration for individual entries based on the
+ /// lastModifiedTime ( <see cref="CacheStatistics.LastModifiedTime" /> ).<br />
+ /// see <see cref="SetEntryTimeToLive" />,
+ /// <see cref="RegionAttributes.EntryTimeToLive" />,
+ /// <see cref="AttributesMutator.SetEntryTimeToLive" /></dd>
+ ///
+ /// <dt>EntryIdleTimeout [<em>default:</em> no expiration]</dt>
+ /// <dd>Expiration configuration for individual entries based on the
+ /// lastAccessedTime ( <see cref="CacheStatistics.LastAccessedTime" /> ).<br />
+ /// see <see cref="SetEntryIdleTimeout" />,
+ /// <see cref="RegionAttributes.EntryIdleTimeout" />,
+ /// <see cref="AttributesMutator.SetEntryIdleTimeout" /></dd>
+ /// </dl>
+ /// <h4>Storage</h4>
+ /// <dl>
+ /// <dt>InitialCapacity [<em>default:</em> <tt>16</tt>]</dt>
+ /// <dd>The initial capacity of the map used for storing the entries.<br />
+ /// see <see cref="SetInitialCapacity" />,
+ /// <see cref="RegionAttributes.InitialCapacity" /></dd>
+ ///
+ /// <dt>LoadFactor [<em>default:</em> <tt>0.75</tt>]</dt>
+ /// <dd>The load factor of the map used for storing the entries.<br />
+ /// see <see cref="SetLoadFactor" />,
+ /// <see cref="RegionAttributes.LoadFactor" /></dd>
+ ///
+ /// <dt>ConcurrencyLevel [<em>default:</em> <tt>16</tt>]</dt>
+ /// <dd>The allowed concurrency among updates to values in the region
+ /// is guided by the <tt>concurrencyLevel</tt>, which is used as a hint
+ /// for internal sizing. The actual concurrency will vary.
+ /// Ideally, you should choose a value to accommodate as many
+ /// threads as will ever concurrently modify values in the region. Using a
+ /// significantly higher value than you need can waste space and time,
+ /// and a significantly lower value can lead to thread contention. But
+ /// overestimates and underestimates within an order of magnitude do
+ /// not usually have much noticeable impact. A value of one is
+ /// appropriate when it is known that only one thread will modify
+ /// and all others will only read.<br />
+ /// see <see cref="SetConcurrencyLevel" />,
+ /// <see cref="RegionAttributes.ConcurrencyLevel" /></dd>
+ ///
+ /// </dl>
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="RegionAttributes" />
+ /// <seealso cref="AttributesMutator" />
+ /// <seealso cref="Region.CreateSubRegion" />
+ generic<class TKey, class TValue>
+ public ref class AttributesFactory sealed
+ {
+ public:
+
+ /// <summary>
+ /// Creates a new <c>AttributesFactory</c> ready to create
+ /// a <c>RegionAttributes</c> with default settings.
+ /// </summary>
+ inline AttributesFactory<TKey, TValue>( )
+ {
+ m_nativeptr = gcnew native_unique_ptr<native::AttributesFactory>(std::make_unique<native::AttributesFactory>());
+ }
+
+ /// <summary>
+ /// Creates a new instance of <c>AttributesFactory</c> ready to create
+ /// a <c>RegionAttributes</c> with the same settings as those in the
+ /// specified <c>RegionAttributes</c>.
+ /// </summary>
+ /// <param name="regionAttributes">
+ /// attributes used to initialize this AttributesFactory
+ /// </param>
+ AttributesFactory<TKey, TValue>(RegionAttributes<TKey, TValue>^ regionAttributes);
+
+ // CALLBACKS
+
+ /// <summary>
+ /// Sets the cache loader for the <c>RegionAttributes</c> being created.
+ /// </summary>
+ /// <param name="cacheLoader">
+ /// a user-defined cache loader, or null for no cache loader
+ /// </param>
+ //generic<class TKey, class TValue>
+ void SetCacheLoader( ICacheLoader<TKey, TValue>^ cacheLoader );
+
+ /// <summary>
+ /// Sets the cache writer for the <c>RegionAttributes</c> being created.
+ /// </summary>
+ /// <param name="cacheWriter">
+ /// user-defined cache writer, or null for no cache writer
+ /// </param>
+ //generic<class TKey, class TValue>
+ void SetCacheWriter( ICacheWriter<TKey, TValue>^ cacheWriter );
+
+ /// <summary>
+ /// Sets the CacheListener for the <c>RegionAttributes</c> being created.
+ /// </summary>
+ /// <param name="cacheListener">
+ /// user-defined cache listener, or null for no cache listener
+ /// </param>
+ //generic<class TKey, class TValue>
+ void SetCacheListener( ICacheListener<TKey, TValue>^ cacheListener );
+
+ /// <summary>
+ /// Sets the PartitionResolver for the <c>RegionAttributes</c> being created.
+ /// </summary>
+ /// <param name="partitionresolver">
+ /// user-defined partition resolver, or null for no partition resolver
+ /// </param>
+ //generic<class TKey, class TValue>
+ void SetPartitionResolver( IPartitionResolver<TKey, TValue>^ partitionresolver );
+
+ /// <summary>
+ /// Sets the library path for the library that will be invoked for the loader of the region.
+ /// </summary>
+ /// <param name="libPath">
+ /// library pathname containing the factory function.
+ /// </param>
+ /// <param name="factoryFunctionName">
+ /// Name of factory function that creates a <c>CacheLoader</c>
+ /// for a native library, or the name of the method in the form
+ /// {Namespace}.{Class Name}.{Method Name} that creates an
+ /// <c>ICacheLoader</c> for a managed library.
+ /// </param>
+ //generic<class TKey, class TValue>
+ void SetCacheLoader( String^ libPath, String^ factoryFunctionName );
+
+ /// <summary>
+ /// Sets the library path for the library that will be invoked for the writer of the region.
+ /// </summary>
+ /// <param name="libPath">
+ /// library pathname containing the factory function.
+ /// </param>
+ /// <param name="factoryFunctionName">
+ /// Name of factory function that creates a <c>CacheWriter</c>
+ /// for a native library, or the name of the method in the form
+ /// {Namespace}.{Class Name}.{Method Name} that creates an
+ /// <c>ICacheWriter</c> for a managed library.
+ /// </param>
+ //generic<class TKey, class TValue>
+ void SetCacheWriter( String^ libPath, String^ factoryFunctionName );
+
+ /// <summary>
+ /// Sets the library path for the library that will be invoked for the listener of the region.
+ /// </summary>
+ /// <param name="libPath">
+ /// library pathname containing the factory function.
+ /// </param>
+ /// <param name="factoryFunctionName">
+ /// Name of factory function that creates a <c>CacheListener</c>
+ /// for a native library, or the name of the method in the form
+ /// {Namespace}.{Class Name}.{Method Name} that creates an
+ /// <c>ICacheListener</c> for a managed library.
+ /// </param>
+ //generic<class TKey, class TValue>
+ void SetCacheListener( String^ libPath, String^ factoryFunctionName );
+
+
+ /// <summary>
+ /// Sets the library path for the library that will be invoked for the partition resolver of the region.
+ /// </summary>
+ /// <param name="libPath">
+ /// library pathname containing the factory function.
+ /// </param>
+ /// <param name="factoryFunctionName">
+ /// Name of factory function that creates a <c>PartitionResolver</c>
+ /// for a native library, or the name of the method in the form
+ /// {Namespace}.{Class Name}.{Method Name} that creates an
+ /// <c>IPartitionResolver</c> for a managed library.
+ /// </param>
+ //generic<class TKey, class TValue>
+ void SetPartitionResolver( String^ libPath, String^ factoryFunctionName );
+
+
+ // EXPIRATION ATTRIBUTES
+
+ /// <summary>
+ /// Sets the idleTimeout expiration attributes for region entries for the next
+ /// <c>RegionAttributes</c> created.
+ /// </summary>
+ /// <param name="action">
+ /// The expiration action for which to set the timeout.
+ /// </param>
+ /// <param name="idleTimeout">
+ /// the idleTimeout in seconds for entries in this region.
+ /// </param>
+ void SetEntryIdleTimeout( ExpirationAction action, System::UInt32 idleTimeout );
+
+ /// <summary>
+ /// Sets the timeToLive expiration attributes for region entries for the next
+ /// <c>RegionAttributes</c> created.
+ /// </summary>
+ /// <param name="action">
+ /// The expiration action for which to set the timeout.
+ /// </param>
+ /// <param name="timeToLive">
+ /// the timeToLive in seconds for entries in this region.
+ /// </param>
+ void SetEntryTimeToLive( ExpirationAction action, System::UInt32 timeToLive );
+
+ /// <summary>
+ /// Sets the idleTimeout expiration attributes for the region itself for the
+ /// next <c>RegionAttributes</c> created.
+ /// </summary>
+ /// <param name="action">
+ /// The expiration action for which to set the timeout.
+ /// </param>
+ /// <param name="idleTimeout">
+ /// the idleTimeout in seconds for the region as a whole.
+ /// </param>
+ void SetRegionIdleTimeout( ExpirationAction action, System::UInt32 idleTimeout );
+
+ /// <summary>
+ /// Sets the timeToLive expiration attributes for the region itself for the
+ /// next <c>RegionAttributes</c> created.
+ /// </summary>
+ /// <param name="action">
+ /// The expiration action for which to set the timeout.
+ /// </param>
+ /// <param name="timeToLive">
+ /// the timeToLive in seconds for the region as a whole.
+ /// </param>
+ void SetRegionTimeToLive( ExpirationAction action, System::UInt32 timeToLive );
+
+
+ // PERSISTENCE
+
+ /// <summary>
+ /// Sets the PersistenceManager object that will be invoked for the persistence of the region.
+ /// </summary>
+ /// <param name="persistenceManager">
+ /// Persistence Manager object
+ /// </param>
+ //generic<class TKey, class TValue>
+ void SetPersistenceManager(IPersistenceManager<TKey, TValue>^ persistenceManager);
+
+ /// <summary>
+ /// Sets the PersistenceManager object that will be invoked for the persistence of the region.
+ /// </summary>
+ /// <param name="persistenceManager">
+ /// Persistence Manager object
+ /// </param>
+ /// <param name="config">
+ /// The configuration properties to use for the PersistenceManager.
+ /// </param>
+ //generic<class TKey, class TValue>
+ void SetPersistenceManager(IPersistenceManager<TKey, TValue>^ persistenceManager, Properties<String^, String^>^ config);
+
+
+ /// <summary>
+ /// Sets the library path for the library that will be invoked for the persistence of the region.
+ /// 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.
+ /// </summary>
+ /// <param name="libPath">The path of the PersistenceManager shared library.</param>
+ /// <param name="factoryFunctionName">
+ /// The name of the factory function to create an instance of PersistenceManager object.
+ /// </param>
+ void SetPersistenceManager( String^ libPath, String^ factoryFunctionName );
+
+ /// <summary>
+ /// Sets the library path for the library that will be invoked for the persistence of the region.
+ /// 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.
+ /// </summary>
+ /// <param name="libPath">The path of the PersistenceManager shared library.</param>
+ /// <param name="factoryFunctionName">
+ /// The name of the factory function to create an instance of PersistenceManager object.
+ /// </param>
+ /// <param name="config">
+ /// The configuration properties to use for the PersistenceManager.
+ /// </param>
+ void SetPersistenceManager( String^ libPath, String^ factoryFunctionName,
+ /*Dictionary<Object^, Object^>*/Properties<String^, String^>^ config );
+
+
+ // STORAGE ATTRIBUTES
+
+ /// <summary>
+ /// Set the pool name for a Thin Client region.
+ /// </summary>
+ /// <remarks>
+ /// The pool with the name specified must be already created.
+ /// </remarks>
+ /// <param name="poolName">
+ /// The name of the pool to attach to this region.
+ /// </param>
+ void SetPoolName( String^ poolName );
+
+ // MAP ATTRIBUTES
+
+ /// <summary>
+ /// Sets the entry initial capacity for the <c>RegionAttributes</c>
+ /// being created. This value is used in initializing the map that
+ /// holds the entries.
+ /// </summary>
+ /// <param name="initialCapacity">the initial capacity of the entry map</param>
+ /// <exception cref="IllegalArgumentException">
+ /// if initialCapacity is nonpositive
+ /// </exception>
+ void SetInitialCapacity( System::Int32 initialCapacity );
+
+ /// <summary>
+ /// Sets the entry load factor for the next <c>RegionAttributes</c>
+ /// created. This value is
+ /// used in initializing the map that holds the entries.
+ /// </summary>
+ /// <param name="loadFactor">the load factor of the entry map</param>
+ /// <exception cref="IllegalArgumentException">
+ /// if loadFactor is nonpositive
+ /// </exception>
+ void SetLoadFactor( Single loadFactor );
+
+ /// <summary>
+ /// Sets the concurrency level of the next <c>RegionAttributes</c>
+ /// created. This value is used in initializing the map that holds the entries.
+ /// </summary>
+ /// <param name="concurrencyLevel">
+ /// the concurrency level of the entry map
+ /// </param>
+ /// <exception cref="IllegalArgumentException">
+ /// if concurrencyLevel is nonpositive
+ /// </exception>
+ void SetConcurrencyLevel( System::Int32 concurrencyLevel );
+
+ /// <summary>
+ /// 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.
+ /// </summary>
+ /// <param name="entriesLimit">
+ /// 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 );
+
+ /// <summary>
+ /// Sets the disk policy type for the next <c>RegionAttributes</c> created.
+ /// </summary>
+ /// <param name="diskPolicy">
+ /// the disk policy to use for the region
+ /// </param>
+ void SetDiskPolicy( DiskPolicyType diskPolicy );
+
+ /// <summary>
+ /// Set caching enabled flag for this region.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If set to false, then no data is stored in the local process,
+ /// but events and distributions will still occur, and the region
+ /// can still be used to put and remove, etc...
+ /// </para><para>
+ /// The default if not set is 'true', 'false' is illegal for regions
+ /// of <c>ScopeType.Local</c> scope.
+ /// </para>
+ /// </remarks>
+ /// <param name="cachingEnabled">
+ /// if true, cache data for this region in this process.
+ /// </param>
+ void SetCachingEnabled( bool cachingEnabled );
+ /// <summary>
+ /// Set cloning enabled flag for this region.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If set to false, then there is no cloning will take place in case of delta.
+ /// Delta will be applied on the old value which will change old value in-place.
+ /// </para><para>
+ /// The default if not set is 'false'
+ /// of <c>ScopeType.Local</c> scope.
+ /// </para>
+ /// </remarks>
+ /// <param name="cloningEnabled">
+ /// if true, clone old value before applying delta so that in-place change would not occour..
+ /// </param>
+ void SetCloningEnabled( bool cloningEnabled );
+
+ /// <summary>
+ /// Sets concurrency checks enabled flag for this region.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If set to false, then the version checks will not occur.
+ /// </para><para>
+ /// The default if not set is 'true'
+ /// </para>
+ /// </remarks>
+ /// <param name="concurrencyChecksEnabled">
+ /// if true, version checks for region entries will occur.
+ /// </param>
+ void SetConcurrencyChecksEnabled( bool concurrencyChecksEnabled );
+ // FACTORY METHOD
+
+ /// <summary>
+ /// Creates a <c>RegionAttributes</c> with the current settings.
+ /// </summary>
+ /// <returns>the newly created <c>RegionAttributes</c></returns>
+ /// <exception cref="IllegalStateException">
+ /// if the current settings violate the
+ /// compatibility rules.
+ /// </exception>
+ RegionAttributes<TKey, TValue>^ CreateRegionAttributes( );
+
+ private:
+ native_unique_ptr<native::AttributesFactory>^ m_nativeptr;
+ };
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache
+
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/AttributesMutator.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/AttributesMutator.cpp b/clicache/src/AttributesMutator.cpp
new file mode 100644
index 0000000..9702ae3
--- /dev/null
+++ b/clicache/src/AttributesMutator.cpp
@@ -0,0 +1,251 @@
+/*
+ * 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.
+ */
+
+#include "AttributesMutator.hpp"
+
+#include "impl/ManagedCacheListener.hpp"
+#include "impl/ManagedCacheLoader.hpp"
+#include "impl/ManagedCacheWriter.hpp"
+#include "impl/CacheLoader.hpp"
+#include "impl/CacheWriter.hpp"
+#include "impl/CacheListener.hpp"
+
+using namespace System;
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+ namespace native = apache::geode::client;
+
+ generic<class TKey, class TValue>
+ System::Int32 AttributesMutator<TKey, TValue>::SetEntryIdleTimeout( System::Int32 idleTimeout )
+ {
+ try
+ {
+ return m_nativeptr->get()->setEntryIdleTimeout( idleTimeout );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ generic<class TKey, class TValue>
+ ExpirationAction AttributesMutator<TKey, TValue>::SetEntryIdleTimeoutAction(
+ ExpirationAction action )
+ {
+ try
+ {
+ return static_cast<ExpirationAction>(
+ m_nativeptr->get()->setEntryIdleTimeoutAction(
+ static_cast<native::ExpirationAction::Action>(action)));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ generic<class TKey, class TValue>
+ System::Int32 AttributesMutator<TKey, TValue>::SetEntryTimeToLive( System::Int32 timeToLive )
+ {
+ try
+ {
+ return m_nativeptr->get()->setEntryTimeToLive( timeToLive );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ generic<class TKey, class TValue>
+ ExpirationAction AttributesMutator<TKey, TValue>::SetEntryTimeToLiveAction(
+ ExpirationAction action )
+ {
+ try
+ {
+ return static_cast<ExpirationAction>(
+ m_nativeptr->get()->setEntryTimeToLiveAction(
+ static_cast<native::ExpirationAction::Action>(action)));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ generic<class TKey, class TValue>
+ System::Int32 AttributesMutator<TKey, TValue>::SetRegionIdleTimeout( System::Int32 idleTimeout )
+ {
+ try
+ {
+ return m_nativeptr->get()->setRegionIdleTimeout( idleTimeout );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ generic<class TKey, class TValue>
+ ExpirationAction AttributesMutator<TKey, TValue>::SetRegionIdleTimeoutAction(
+ ExpirationAction action )
+ {
+ try
+ {
+ return static_cast<ExpirationAction>(
+ m_nativeptr->get()->setRegionIdleTimeoutAction(
+ static_cast<native::ExpirationAction::Action>(action)));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ generic<class TKey, class TValue>
+ System::Int32 AttributesMutator<TKey, TValue>::SetRegionTimeToLive( System::Int32 timeToLive )
+ {
+ try
+ {
+ return m_nativeptr->get()->setRegionTimeToLive( timeToLive );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ generic<class TKey, class TValue>
+ ExpirationAction AttributesMutator<TKey, TValue>::SetRegionTimeToLiveAction(
+ ExpirationAction action )
+ {
+ try
+ {
+ return static_cast<ExpirationAction>(
+ m_nativeptr->get()->setRegionTimeToLiveAction(
+ static_cast<native::ExpirationAction::Action>(action)));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ generic<class TKey, class TValue>
+ System::UInt32 AttributesMutator<TKey, TValue>::SetLruEntriesLimit( System::UInt32 entriesLimit )
+ {
+ try
+ {
+ return m_nativeptr->get()->setLruEntriesLimit( entriesLimit );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ generic<class TKey, class TValue>
+ void AttributesMutator<TKey, TValue>::SetCacheListener( ICacheListener<TKey, TValue>^ cacheListener )
+ {
+ native::CacheListenerPtr listenerptr;
+ if (cacheListener != nullptr)
+ {
+ auto clg = gcnew CacheListenerGeneric<TKey, TValue>();
+ clg->SetCacheListener(cacheListener);
+ listenerptr = std::shared_ptr<native::ManagedCacheListenerGeneric>( new native::ManagedCacheListenerGeneric(cacheListener) );
+ ((native::ManagedCacheListenerGeneric*)listenerptr.get())->setptr(clg);
+ }
+ try
+ {
+ m_nativeptr->get()->setCacheListener( listenerptr );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ generic<class TKey, class TValue>
+ void AttributesMutator<TKey, TValue>::SetCacheListener( String^ libPath,
+ String^ factoryFunctionName )
+ {
+ throw gcnew System::NotSupportedException;
+ }
+
+ generic<class TKey, class TValue>
+ void AttributesMutator<TKey, TValue>::SetCacheLoader( ICacheLoader<TKey, TValue>^ cacheLoader )
+ {
+ native::CacheLoaderPtr loaderptr;
+ if (cacheLoader != nullptr)
+ {
+ auto clg = gcnew CacheLoaderGeneric<TKey, TValue>();
+ clg->SetCacheLoader(cacheLoader);
+ loaderptr = std::shared_ptr<native::ManagedCacheLoaderGeneric>( new native::ManagedCacheLoaderGeneric(cacheLoader) );
+ ((native::ManagedCacheLoaderGeneric*)loaderptr.get())->setptr(clg);
+ }
+ try
+ {
+ m_nativeptr->get()->setCacheLoader( loaderptr );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ generic<class TKey, class TValue>
+ void AttributesMutator<TKey, TValue>::SetCacheLoader( String^ libPath,
+ String^ factoryFunctionName )
+ {
+ throw gcnew System::NotSupportedException;
+ }
+
+ generic<class TKey, class TValue>
+ void AttributesMutator<TKey, TValue>::SetCacheWriter( ICacheWriter<TKey, TValue>^ cacheWriter )
+ {
+ native::CacheWriterPtr writerptr;
+ if (cacheWriter != nullptr)
+ {
+ auto cwg = gcnew CacheWriterGeneric<TKey, TValue>();
+ cwg->SetCacheWriter(cacheWriter);
+ writerptr = std::shared_ptr<native::ManagedCacheWriterGeneric>( new native::ManagedCacheWriterGeneric(cacheWriter) );
+ ((native::ManagedCacheWriterGeneric*)writerptr.get())->setptr(cwg);
+ }
+ try
+ {
+ m_nativeptr->get()->setCacheWriter( writerptr );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ generic<class TKey, class TValue>
+ void AttributesMutator<TKey, TValue>::SetCacheWriter( String^ libPath,
+ String^ factoryFunctionName )
+ {
+ throw gcnew System::NotSupportedException;
+ }
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/AttributesMutator.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/AttributesMutator.hpp b/clicache/src/AttributesMutator.hpp
new file mode 100644
index 0000000..db0bd62
--- /dev/null
+++ b/clicache/src/AttributesMutator.hpp
@@ -0,0 +1,271 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include "geode_defs.hpp"
+#include "begin_native.hpp"
+#include <geode/AttributesMutator.hpp>
+#include "end_native.hpp"
+
+#include "native_shared_ptr.hpp"
+#include "ExpirationAction.hpp"
+#include "ICacheListener.hpp"
+#include "ICacheLoader.hpp"
+#include "ICacheWriter.hpp"
+
+
+using namespace System;
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+ namespace native = apache::geode::client;
+
+ /// <summary>
+ /// Supports modification of certain region attributes after the region
+ /// has been created.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// It is required that the attributes be completely initialized using an
+ /// <see cref="AttributesFactory" /> before creating the region.
+ /// AttributesMutator can be applied to adjusting and tuning a subset of
+ /// attributes that are modifiable at runtime.
+ /// </para><para>
+ /// The setter methods all return the previous value of the attribute.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="Region.AttributesMutator" />
+ /// <seealso cref="RegionAttributes" />
+ /// <seealso cref="AttributesFactory" />
+ generic<class TKey, class TValue>
+ public ref class AttributesMutator sealed
+ {
+ public:
+
+ /// <summary>
+ /// Sets the idleTimeout duration for region entries.
+ /// </summary>
+ /// <param name="idleTimeout">
+ /// the idleTimeout in seconds for entries in this region, or 0 for no idle timeout
+ /// </param>
+ /// <returns>the previous value</returns>
+ /// <exception cref="IllegalStateException">
+ /// if the new idleTimeout changes entry expiration from
+ /// disabled to enabled or enabled to disabled.
+ /// </exception>
+ System::Int32 SetEntryIdleTimeout( System::Int32 idleTimeout );
+
+ /// <summary>
+ /// Sets the idleTimeout action for region entries.
+ /// </summary>
+ /// <param name="action">
+ /// the idleTimeout action for entries in this region
+ /// </param>
+ /// <returns>the previous action</returns>
+ ExpirationAction SetEntryIdleTimeoutAction( ExpirationAction action );
+
+ /// <summary>
+ /// Sets the timeToLive duration for region entries.
+ /// </summary>
+ /// <param name="timeToLive">
+ /// the timeToLive in seconds for entries in this region, or 0 to disable time-to-live
+ /// </param>
+ /// <returns>the previous value</returns>
+ /// <exception cref="IllegalStateException">
+ /// if the new timeToLive changes entry expiration from
+ /// disabled to enabled or enabled to disabled
+ /// </exception>
+ System::Int32 SetEntryTimeToLive( System::Int32 timeToLive );
+
+ /// <summary>
+ /// Set the timeToLive action for region entries.
+ /// </summary>
+ /// <param name="action">
+ /// the timeToLive action for entries in this region
+ /// </param>
+ /// <returns>the previous action</returns>
+ ExpirationAction SetEntryTimeToLiveAction( ExpirationAction action );
+
+ /// <summary>
+ /// Sets the idleTimeout duration for the region itself.
+ /// </summary>
+ /// <param name="idleTimeout">
+ /// the idleTimeout for this region, in seconds, or 0 to disable idle timeout
+ /// </param>
+ /// <returns>the previous value</returns>
+ /// <exception cref="IllegalStateException">
+ /// if the new idleTimeout changes region expiration from
+ /// disabled to enabled or enabled to disabled.
+ /// </exception>
+ System::Int32 SetRegionIdleTimeout( System::Int32 idleTimeout );
+
+ /// <summary>
+ /// Sets the idleTimeout action for the region itself.
+ /// </summary>
+ /// <param name="action">
+ /// the idleTimeout action for this region
+ /// </param>
+ /// <returns>the previous action</returns>
+ ExpirationAction SetRegionIdleTimeoutAction( ExpirationAction action );
+
+ /// <summary>
+ /// Sets the timeToLive duration for the region itself.
+ /// </summary>
+ /// <param name="timeToLive">
+ /// the timeToLive for this region, in seconds, or 0 to disable time-to-live
+ /// </param>
+ /// <returns>the previous value</returns>
+ /// <exception cref="IllegalStateException">
+ /// if the new timeToLive changes region expiration from
+ /// disabled to enabled or enabled to disabled.
+ /// </exception>
+ System::Int32 SetRegionTimeToLive( System::Int32 timeToLive );
+
+ /// <summary>
+ /// Sets the timeToLive action for the region itself.
+ /// </summary>
+ /// <param name="action">
+ /// the timeToLiv eaction for this region
+ /// </param>
+ /// <returns>the previous action</returns>
+ ExpirationAction SetRegionTimeToLiveAction( ExpirationAction action );
+
+ /// <summary>
+ /// Sets the maximum entry count in the region before LRU eviction.
+ /// </summary>
+ /// <param name="entriesLimit">the number of entries to allow, or 0 to disable LRU</param>
+ /// <returns>the previous value</returns>
+ /// <exception cref="IllegalStateException">
+ /// if the new entriesLimit changes LRU from
+ /// disabled to enabled or enabled to disabled.
+ /// </exception>
+ System::UInt32 SetLruEntriesLimit( System::UInt32 entriesLimit );
+
+ /// <summary>
+ /// Sets the CacheListener for the region.
+ /// The previous cache listener (if any) will be replaced with the given <c>cacheListener</c>.
+ /// </summary>
+ /// <param name="cacheListener">
+ /// user-defined cache listener, or null for no cache listener
+ /// </param>
+ void SetCacheListener( ICacheListener<TKey, TValue>^ cacheListener );
+
+ /// <summary>
+ /// Sets the library path for the library that will be invoked for the listener of the region.
+ /// The previous cache listener will be replaced with a listener created
+ /// using the factory function provided in the given library.
+ /// </summary>
+ /// <param name="libPath">
+ /// library pathname containing the factory function.
+ /// </param>
+ /// <param name="factoryFunctionName">
+ /// Name of factory function that creates a <c>CacheListener</c>
+ /// for a native library, or the name of the method in the form
+ /// {Namespace}.{Class Name}.{Method Name} that creates an
+ /// <c>ICacheListener</c> for a managed library.
+ /// </param>
+ void SetCacheListener( String^ libPath, String^ factoryFunctionName );
+
+ /// <summary>
+ /// Sets the CacheLoader for the region.
+ /// The previous cache loader (if any) will be replaced with the given <c>cacheLoader</c>.
+ /// </summary>
+ /// <param name="cacheLoader">
+ /// user-defined cache loader, or null for no cache loader
+ /// </param>
+ void SetCacheLoader( ICacheLoader<TKey, TValue>^ cacheLoader );
+
+ /// <summary>
+ /// Sets the library path for the library that will be invoked for the loader of the region.
+ /// The previous cache loader will be replaced with a loader created
+ /// using the factory function provided in the given library.
+ /// </summary>
+ /// <param name="libPath">
+ /// library pathname containing the factory function.
+ /// </param>
+ /// <param name="factoryFunctionName">
+ /// Name of factory function that creates a <c>CacheLoader</c>
+ /// for a native library, or the name of the method in the form
+ /// {Namespace}.{Class Name}.{Method Name} that creates an
+ /// <c>ICacheLoader</c> for a managed library.
+ /// </param>
+ void SetCacheLoader( String^ libPath, String^ factoryFunctionName );
+
+ /// <summary>
+ /// Sets the CacheListener for the region.
+ /// The previous cache writer (if any) will be replaced with the given <c>cacheWriter</c>.
+ /// </summary>
+ /// <param name="cacheWriter">
+ /// user-defined cache writer, or null for no cache writer
+ /// </param>
+ void SetCacheWriter( ICacheWriter<TKey, TValue>^ cacheWriter );
+
+ /// <summary>
+ /// Sets the library path for the library that will be invoked for the writer of the region.
+ /// The previous cache writer will be replaced with a writer created
+ /// using the factory function provided in the given library.
+ /// </summary>
+ /// <param name="libPath">
+ /// library pathname containing the factory function.
+ /// </param>
+ /// <param name="factoryFunctionName">
+ /// Name of factory function that creates a <c>CacheWriter</c>
+ /// for a native library, or the name of the method in the form
+ /// {Namespace}.{Class Name}.{Method Name} that creates an
+ /// <c>ICacheWriter</c> for a managed library.
+ /// </param>
+ void SetCacheWriter( String^ libPath, String^ factoryFunctionName );
+
+
+ internal:
+ /// <summary>
+ /// Internal factory function to wrap a native object pointer inside
+ /// this managed class with null pointer check.
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ /// <returns>
+ /// The managed wrapper object; null if the native pointer is null.
+ /// </returns>
+ inline static AttributesMutator<TKey, TValue>^ Create( native::AttributesMutatorPtr nativeptr )
+ {
+ return __nullptr == nativeptr ? nullptr :
+ gcnew AttributesMutator<TKey, TValue>( nativeptr );
+ }
+
+
+ private:
+
+ /// <summary>
+ /// Private constructor to wrap a native object pointer
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ inline AttributesMutator<TKey, TValue>( native::AttributesMutatorPtr nativeptr )
+ {
+ m_nativeptr = gcnew native_shared_ptr<native::AttributesMutator>(nativeptr);
+ }
+
+ native_shared_ptr<native::AttributesMutator>^ m_nativeptr;
+ };
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache
+
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/clicache/src/CMakeLists.txt b/clicache/src/CMakeLists.txt
new file mode 100644
index 0000000..80b0c1c
--- /dev/null
+++ b/clicache/src/CMakeLists.txt
@@ -0,0 +1,73 @@
+# 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.
+cmake_minimum_required(VERSION 3.4)
+project(clicache)
+
+file(GLOB_RECURSE SOURCES "*.cpp")
+
+file(GLOB_RECURSE PRIVATE_HEADERS "*.hpp")
+set_source_files_properties(${PRIVATE_HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE)
+
+set(RESOURCES Apache.Geode.rc)
+
+if(NOT "${STRONG_NAME_PUBLIC_KEY}" STREQUAL "")
+ set(STRONG_NAME_PUBLIC_KEY_ATTRIBUTE ", PublicKey=${STRONG_NAME_PUBLIC_KEY}")
+endif()
+list(APPEND CONFIGURE_IN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/impl/AssemblyInfo.cpp.in)
+list(APPEND CONFIGURE_OUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/impl/AssemblyInfo.cpp)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/impl/AssemblyInfo.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/impl/AssemblyInfo.cpp)
+
+#set_source_files_properties(${CONFIGURE_IN_FILES} PROPERTIES LANGUAGE NONE)
+set_source_files_properties(${CONFIGURE_OUT_FILES} PROPERTIES GENERATED TRUE)
+
+add_library(Apache.Geode SHARED
+ ${SOURCES}
+ ${PRIVATE_HEADERS} ${CONFIGURE_IN_FILES} ${CONFIGURE_OUT_FILES} ${RESOURCES})
+add_dependencies(client-libraries Apache.Geode)
+
+#TODO get external project library names
+target_link_libraries(Apache.Geode
+ PRIVATE
+ apache-geode-static
+ psapi
+ PUBLIC
+ c++11
+)
+
+string(REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /clr /wd4947 /doc")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SHARED_LINKER_FLAGS_STRONG_KEY}")
+
+include_directories(${CMAKE_SOURCE_DIR}/clicache/include)
+include_directories(${CMAKE_SOURCE_DIR}/clicache/src)
+include_directories(${CMAKE_SOURCE_DIR}/cppcache/src)
+
+set_target_properties(Apache.Geode PROPERTIES
+ OUTPUT_NAME ${PRODUCT_DLL_NAME}
+ VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.5.2"
+ VS_DOTNET_REFERENCES "System;System.Xml")
+
+add_subdirectory(templates)
+
+install(TARGETS Apache.Geode
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+)
+
+# For Visual Studio organization
+source_group("Header Files" REGULAR_EXPRESSION "\.(hpp|inl)$")
+source_group("Configure In Files" FILES ${CONFIGURE_IN_FILES})
+source_group("Configure Out Files" FILES ${CONFIGURE_OUT_FILES})
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/Cache.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/Cache.cpp b/clicache/src/Cache.cpp
new file mode 100644
index 0000000..7438e84
--- /dev/null
+++ b/clicache/src/Cache.cpp
@@ -0,0 +1,382 @@
+/*
+ * 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.
+ */
+
+#include "begin_native.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+#include "end_native.hpp"
+
+#include "Cache.hpp"
+#include "ExceptionTypes.hpp"
+#include "DistributedSystem.hpp"
+#include "PoolFactory.hpp"
+#include "Region.hpp"
+#include "RegionAttributes.hpp"
+#include "QueryService.hpp"
+#include "CacheFactory.hpp"
+#include "impl/AuthenticatedCache.hpp"
+#include "impl/ManagedString.hpp"
+#include "impl/SafeConvert.hpp"
+#include "impl/PdxTypeRegistry.hpp"
+#include "impl/PdxInstanceFactoryImpl.hpp"
+
+#pragma warning(disable:4091)
+
+using namespace System;
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+ namespace native = apache::geode::client;
+
+ String^ Cache::Name::get( )
+ {
+ try
+ {
+ return ManagedString::Get( m_nativeptr->get()->getName( ).c_str() );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ bool Cache::IsClosed::get( )
+ {
+ try
+ {
+ return m_nativeptr->get()->isClosed( );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ DistributedSystem^ Cache::DistributedSystem::get( )
+ {
+ try
+ {
+ return Client::DistributedSystem::Create(&(m_nativeptr->get()->getDistributedSystem()));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ CacheTransactionManager^ Cache::CacheTransactionManager::get( )
+ {
+ // TODO shared_ptr this should be checking the return type for which tx mgr
+ try
+ {
+ auto nativeptr = std::dynamic_pointer_cast<InternalCacheTransactionManager2PC>(
+ m_nativeptr->get()->getCacheTransactionManager());
+ return Apache::Geode::Client::CacheTransactionManager::Create(nativeptr);
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ void Cache::Close( )
+ {
+ Close( false );
+ }
+
+ void Cache::Close( bool keepalive )
+ {
+ _GF_MG_EXCEPTION_TRY2
+
+ Apache::Geode::Client::DistributedSystem::acquireDisconnectLock();
+
+ Apache::Geode::Client::DistributedSystem::disconnectInstance();
+ CacheFactory::m_connected = false;
+
+ try
+ {
+ m_nativeptr->get()->close( keepalive );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
+ // If DS automatically disconnected due to the new bootstrap API, then cleanup the C++/CLI side
+ //if (!apache::geode::client::DistributedSystem::isConnected())
+ {
+ Apache::Geode::Client::DistributedSystem::UnregisterBuiltinManagedTypes(this);
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ finally
+ {
+ CacheRegionHelper::getCacheImpl(m_nativeptr->get())->getPdxTypeRegistry()->clear();
+ Serializable::Clear();
+ Apache::Geode::Client::DistributedSystem::releaseDisconnectLock();
+ Apache::Geode::Client::DistributedSystem::unregisterCliCallback();
+ }
+ }
+
+ void Cache::ReadyForEvents( )
+ {
+ _GF_MG_EXCEPTION_TRY2
+
+ try
+ {
+ m_nativeptr->get()->readyForEvents( );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ }
+
+ generic<class TKey, class TValue>
+ Client::IRegion<TKey,TValue>^ Cache::GetRegion( String^ path )
+ {
+ _GF_MG_EXCEPTION_TRY2/* due to auto replace */
+
+ ManagedString mg_path( path );
+ try
+ {
+ return Client::Region<TKey, TValue>::Create(m_nativeptr->get()->getRegion(mg_path.CharPtr));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
+ }
+
+ generic<class TKey, class TValue>
+ array<Client::IRegion<TKey, TValue>^>^ Cache::RootRegions( )
+ {
+ apache::geode::client::VectorOfRegion vrr;
+ try
+ {
+ m_nativeptr->get()->rootRegions( vrr );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ array<Client::IRegion<TKey, TValue>^>^ rootRegions =
+ gcnew array<Client::IRegion<TKey, TValue>^>( vrr.size( ) );
+
+ for( System::Int32 index = 0; index < vrr.size( ); index++ )
+ {
+ apache::geode::client::RegionPtr& nativeptr( vrr[ index ] );
+ rootRegions[ index ] = Client::Region<TKey, TValue>::Create( nativeptr );
+ }
+ return rootRegions;
+ }
+
+ generic<class TKey, class TResult>
+ Client::QueryService<TKey, TResult>^ Cache::GetQueryService( )
+ {
+ _GF_MG_EXCEPTION_TRY2
+
+ try
+ {
+ return Client::QueryService<TKey, TResult>::Create(m_nativeptr->get()->getQueryService());
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ }
+
+ generic<class TKey, class TResult>
+ Client::QueryService<TKey, TResult>^ Cache::GetQueryService(String^ poolName )
+ {
+ _GF_MG_EXCEPTION_TRY2
+
+ ManagedString mg_poolName( poolName );
+ try
+ {
+ return QueryService<TKey, TResult>::Create(m_nativeptr->get()->getQueryService(mg_poolName.CharPtr));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ }
+
+ RegionFactory^ Cache::CreateRegionFactory(RegionShortcut preDefinedRegionAttributes)
+ {
+ _GF_MG_EXCEPTION_TRY2
+
+ apache::geode::client::RegionShortcut preDefineRegionAttr = apache::geode::client::CACHING_PROXY;
+
+ switch(preDefinedRegionAttributes)
+ {
+ case RegionShortcut::PROXY:
+ preDefineRegionAttr = apache::geode::client::PROXY;
+ break;
+ case RegionShortcut::CACHING_PROXY:
+ preDefineRegionAttr = apache::geode::client::CACHING_PROXY;
+ break;
+ case RegionShortcut::CACHING_PROXY_ENTRY_LRU:
+ preDefineRegionAttr = apache::geode::client::CACHING_PROXY_ENTRY_LRU;
+ break;
+ case RegionShortcut::LOCAL:
+ preDefineRegionAttr = apache::geode::client::LOCAL;
+ break;
+ case RegionShortcut::LOCAL_ENTRY_LRU:
+ preDefineRegionAttr = apache::geode::client::LOCAL_ENTRY_LRU;
+ break;
+ }
+
+ try
+ {
+ return RegionFactory::Create(m_nativeptr->get()->createRegionFactory(preDefineRegionAttr));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ }
+
+ IRegionService^ Cache::CreateAuthenticatedView(Properties<String^, Object^>^ credentials)
+ {
+ _GF_MG_EXCEPTION_TRY2
+
+ try
+ {
+ return AuthenticatedCache::Create((m_nativeptr->get()->createAuthenticatedView(credentials->GetNative())));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ }
+
+ bool Cache::GetPdxIgnoreUnreadFields()
+ {
+ _GF_MG_EXCEPTION_TRY2
+
+ try
+ {
+ return m_nativeptr->get()->getPdxIgnoreUnreadFields();
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ }
+
+ bool Cache::GetPdxReadSerialized()
+ {
+ _GF_MG_EXCEPTION_TRY2
+
+ try
+ {
+ return m_nativeptr->get()->getPdxReadSerialized();
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ }
+
+ IRegionService^ Cache::CreateAuthenticatedView(Properties<String^, Object^>^ credentials, String^ poolName)
+ {
+ ManagedString mg_poolName( poolName );
+
+ _GF_MG_EXCEPTION_TRY2
+
+ try
+ {
+ return AuthenticatedCache::Create( (m_nativeptr->get()->createAuthenticatedView(credentials->GetNative(), mg_poolName.CharPtr)));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ }
+
+ void Cache::InitializeDeclarativeCache( String^ cacheXml )
+ {
+ ManagedString mg_cacheXml( cacheXml );
+ try
+ {
+ m_nativeptr->get()->initializeDeclarativeCache( mg_cacheXml.CharPtr );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ IPdxInstanceFactory^ Cache::CreatePdxInstanceFactory(String^ className)
+ {
+
+ return gcnew Internal::PdxInstanceFactoryImpl(className, (m_nativeptr->get()));
+
+ }
+
+ DataInput^ Cache::CreateDataInput(array<Byte>^ buffer, System::Int32 len)
+ {
+ return gcnew DataInput(buffer, len, m_nativeptr->get());
+ }
+
+
+ DataInput^ Cache::CreateDataInput(array<Byte>^ buffer)
+ {
+ return gcnew DataInput(buffer, m_nativeptr->get());
+ }
+
+ DataOutput^ Cache::CreateDataOutput()
+ {
+ return gcnew DataOutput( m_nativeptr->get());
+ }
+
+ PoolFactory^ Cache::GetPoolFactory()
+ {
+ return PoolFactory::Create(m_nativeptr->get_shared_ptr()->getPoolManager().createFactory());
+ }
+
+ PoolManager^ Cache::GetPoolManager()
+ {
+ return gcnew PoolManager(m_nativeptr->get_shared_ptr()->getPoolManager());
+ }
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache
+
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/Cache.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/Cache.hpp b/clicache/src/Cache.hpp
new file mode 100644
index 0000000..666e562
--- /dev/null
+++ b/clicache/src/Cache.hpp
@@ -0,0 +1,302 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include "geode_defs.hpp"
+#include "RegionShortcut.hpp"
+#include "IGeodeCache.hpp"
+#include "IRegion.hpp"
+#include "RegionAttributes.hpp"
+#include "PoolManager.hpp"
+
+using namespace System;
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+ namespace native = apache::geode::client;
+
+ generic<class TKey, class TResult>
+ ref class QueryService;
+
+ ref class RegionFactory;
+ enum class ExpirationAction;
+ ref class DistributedSystem;
+ ref class CacheTransactionManager2PC;
+ //ref class FunctionService;
+
+ /// <summary>
+ /// Provides a distributed cache.
+ /// </summary>
+ /// <remarks>
+ /// Caches are obtained from Create methods on the
+ /// <see cref="CacheFactory.Create"/> class.
+ /// <para>
+ /// When a cache will no longer be used, call <see cref="Cache.Close" />.
+ /// Once it <see cref="Cache.IsClosed" /> any attempt to use it
+ /// will cause a <c>CacheClosedException</c> to be thrown.
+ /// </para><para>
+ /// A cache can have multiple root regions, each with a different name.
+ /// </para>
+ /// </remarks>
+ public ref class Cache sealed
+ : public IGeodeCache
+ {
+ public:
+
+ /// <summary>
+ /// Initializes the cache from an XML file.
+ /// </summary>
+ /// <param name="cacheXml">pathname of a <c>cache.xml</c> file</param>
+ virtual void InitializeDeclarativeCache(String^ cacheXml);
+
+ /// <summary>
+ /// Returns the name of this cache.
+ /// </summary>
+ /// <remarks>
+ /// This method does not throw
+ /// <c>CacheClosedException</c> if the cache is closed.
+ /// </remarks>
+ /// <returns>the string name of this cache</returns>
+ virtual property String^ Name
+ {
+ String^ get();
+ }
+
+ /// <summary>
+ /// True if this cache has been closed.
+ /// </summary>
+ /// <remarks>
+ /// After a new cache object is created, this method returns false.
+ /// After <see cref="Close" /> is called on this cache object, this method
+ /// returns true.
+ /// </remarks>
+ /// <returns>true if this cache is closed, otherwise false</returns>
+ virtual property bool IsClosed
+ {
+ bool get();
+ }
+
+ /// <summary>
+ /// Returns the distributed system used to
+ /// <see cref="CacheFactory.Create" /> this cache.
+ /// </summary>
+ /// <remarks>
+ /// This method does not throw
+ /// <c>CacheClosedException</c> if the cache is closed.
+ /// </remarks>
+ virtual property Apache::Geode::Client::DistributedSystem^ DistributedSystem
+ {
+ Apache::Geode::Client::DistributedSystem^ get();
+ }
+
+ /// <summary>
+ /// Returns the cache transaction manager of
+ /// <see cref="CacheFactory.Create" /> this cache.
+ /// </summary>
+ virtual property Apache::Geode::Client::CacheTransactionManager^ CacheTransactionManager
+ {
+ Apache::Geode::Client::CacheTransactionManager^ get();
+ }
+
+ /// <summary>
+ /// Terminates this object cache and releases all the local resources.
+ /// </summary>
+ /// <remarks>
+ /// After this cache is closed, any further
+ /// method call on this cache or any region object will throw
+ /// <c>CacheClosedException</c>, unless otherwise noted.
+ /// </remarks>
+ /// <exception cref="CacheClosedException">
+ /// if the cache is already closed.
+ /// </exception>
+ virtual void Close();
+
+ /// <summary>
+ /// Terminates this object cache and releases all the local resources.
+ /// </summary>
+ /// <remarks>
+ /// After this cache is closed, any further
+ /// method call on this cache or any region object will throw
+ /// <c>CacheClosedException</c>, unless otherwise noted.
+ /// </remarks>
+ /// <param name="keepalive">whether to keep a durable client's queue alive</param>
+ /// <exception cref="CacheClosedException">
+ /// if the cache is already closed.
+ /// </exception>
+ virtual void Close(bool keepalive);
+
+ /// <summary>
+ /// Send the client-ready message to the server for a durable client.
+ /// </summary>
+ /// <remarks>
+ /// This method should only be called for durable clients and
+ /// with a cache server version 5.5 onwards.
+ /// </remarks>
+ /// <exception cref="IllegalStateException">
+ /// if there was a problem sending the message to the server.
+ /// </exception>
+ virtual void ReadyForEvents();
+
+ /// <summary>
+ /// Returns an existing region given the full path from root, or null
+ /// if no such region exists.
+ /// </summary>
+ /// <remarks>
+ /// If Pool attached with Region is in multiusersecure mode then don't use return instance of region as no credential are attached with this instance.
+ /// Get region from RegionService instance of Cache.<see cref="Cache.CreateAuthenticatedView(PropertiesPtr)" />.
+ /// </remarks>
+ /// <param name="path">the pathname of the region</param>
+ /// <returns>the region</returns>
+ generic<class TKey, class TValue>
+ virtual IRegion<TKey, TValue>^ GetRegion(String^ path);
+
+ /// <summary>
+ /// Returns an array of root regions in the cache. This set is a
+ /// snapshot and is not backed by the cache.
+ /// </summary>
+ /// <remarks>
+ /// It is not supported when Cache is created from Pool.
+ /// </remarks>
+ /// <returns>array of regions</returns>
+ generic<class TKey, class TValue>
+ virtual array<IRegion<TKey, TValue>^>^ RootRegions();
+
+ /// <summary>
+ /// Get a query service object to be able to query the cache.
+ /// Supported only when cache is created from Pool(pool is in multiuserSecure mode)
+ /// </summary>
+ /// <remarks>
+ /// Currently only works against the java server in native mode, and
+ /// at least some endpoints must have been defined in some regions
+ /// before actually firing a query.
+ /// </remarks>
+ generic<class TKey, class TResult>
+ virtual Client::QueryService<TKey, TResult>^ GetQueryService();
+
+ /// <summary>
+ /// Get a query service object to be able to query the cache.
+ /// Use only when Cache has more than one Pool.
+ /// </summary>
+ /// <remarks>
+ /// Currently only works against the java server in native mode, and
+ /// at least some endpoints must have been defined in some regions
+ /// before actually firing a query.
+ /// </remarks>
+ generic<class TKey, class TResult>
+ virtual Client::QueryService<TKey, TResult>^ GetQueryService(String^ poolName);
+
+ /// <summary>
+ /// Returns the instance of <see cref="RegionFactory" /> to create the region
+ /// </summary>
+ /// <remarks>
+ /// Pass the <see cref="RegionShortcut" /> to set the deafult region attributes
+ /// </remarks>
+ /// <param name="regionShortcut">the regionShortcut to set the default region attributes</param>
+ /// <returns>Instance of RegionFactory</returns>
+ RegionFactory^ CreateRegionFactory(RegionShortcut regionShortcut);
+
+ /// <summary>
+ /// Returns the instance of <see cref="IRegionService" /> to do the operation on Cache with different Credential.
+ /// </summary>
+ /// <remarks>
+ /// Deafault pool should be in multiuser mode <see cref="CacheFactory.SetMultiuserAuthentication" />
+ /// </remarks>
+ /// <param name="credentials">the user Credentials.</param>
+ /// <returns>Instance of IRegionService</returns>
+ IRegionService^ CreateAuthenticatedView(Properties<String^, Object^>^ credentials);
+
+ /// <summary>
+ /// Returns the instance of <see cref="IRegionService" /> to do the operation on Cache with different Credential.
+ /// </summary>
+ /// <remarks>
+ /// Deafault pool should be in multiuser mode <see cref="CacheFactory.SetMultiuserAuthentication" />
+ /// </remarks>
+ /// <param name="credentials">the user Credentials.</param>
+ /// <param name="poolName">Pool, which is in multiuser mode.</param>
+ /// <returns>Instance of IRegionService</returns>
+ IRegionService^ CreateAuthenticatedView(Properties<String^, Object^>^ credentials, String^ poolName);
+
+ ///<summary>
+ /// Returns whether Cache saves unread fields for Pdx types.
+ ///</summary>
+ virtual bool GetPdxIgnoreUnreadFields();
+
+ ///<summary>
+ /// Returns whether { @link PdxInstance} is preferred for PDX types instead of .NET object.
+ ///</summary>
+ virtual bool GetPdxReadSerialized();
+
+ /// <summary>
+ /// Returns a factory that can create a {@link PdxInstance}.
+ /// @param className the fully qualified class name that the PdxInstance will become
+ /// when it is fully deserialized.
+ /// @return the factory
+ /// </summary>
+ virtual IPdxInstanceFactory^ CreatePdxInstanceFactory(String^ className);
+
+ virtual DataInput^ CreateDataInput(array<Byte>^ buffer, System::Int32 len);
+ virtual DataInput^ CreateDataInput(array<Byte>^ buffer);
+
+ virtual DataOutput^ Cache::CreateDataOutput();
+
+ virtual PoolFactory^ GetPoolFactory();
+
+ virtual PoolManager^ GetPoolManager();
+
+ internal:
+
+ /// <summary>
+ /// Internal factory function to wrap a native object pointer inside
+ /// this managed class with null pointer check.
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ /// <returns>
+ /// The managed wrapper object; null if the native pointer is null.
+ /// </returns>
+ inline static Cache^ Create(native::CachePtr nativeptr)
+ {
+ return __nullptr == nativeptr ? nullptr :
+ gcnew Cache( nativeptr );
+ }
+
+ std::shared_ptr<native::Cache> GetNative()
+ {
+ return m_nativeptr->get_shared_ptr();
+ }
+
+ private:
+
+ /// <summary>
+ /// Private constructor to wrap a native object pointer
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ inline Cache(native::CachePtr nativeptr)
+ {
+ m_nativeptr = gcnew native_shared_ptr<native::Cache>(nativeptr);
+ }
+
+ native_shared_ptr<native::Cache>^ m_nativeptr;
+ };
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache
+
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/CacheFactory.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/CacheFactory.cpp b/clicache/src/CacheFactory.cpp
new file mode 100644
index 0000000..2071b20
--- /dev/null
+++ b/clicache/src/CacheFactory.cpp
@@ -0,0 +1,193 @@
+/*
+ * 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.
+ */
+
+//#include "geode_includes.hpp"
+
+#include "ExceptionTypes.hpp"
+
+#include "CacheFactory.hpp"
+#include "Cache.hpp"
+#include "DistributedSystem.hpp"
+#include "SystemProperties.hpp"
+#include "impl/SafeConvert.hpp"
+#include "impl/PdxTypeRegistry.hpp"
+//#pragma warning(disable:4091)
+//#include <msclr/lock.h>
+//#pragma warning(disable:4091)
+#include "impl/AppDomainContext.hpp"
+
+using namespace System;
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+
+ namespace native = apache::geode::client;
+
+ CacheFactory^ CacheFactory::CreateCacheFactory()
+ {
+ return CacheFactory::CreateCacheFactory(Properties<String^, String^>::Create<String^, String^>());
+ }
+
+ CacheFactory^ CacheFactory::CreateCacheFactory(Properties<String^, String^>^ dsProps)
+ {
+ _GF_MG_EXCEPTION_TRY2
+
+ auto nativeCacheFactory = native::CacheFactory::createCacheFactory(dsProps->GetNative());
+ if (nativeCacheFactory)
+ return gcnew CacheFactory( nativeCacheFactory, dsProps );
+
+ return nullptr;
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ }
+
+ Cache^ CacheFactory::Create()
+ {
+ bool pdxIgnoreUnreadFields = false;
+ bool pdxReadSerialized = false;
+ bool appDomainEnable = false;
+ native::CachePtr nativeCache = nullptr;
+ _GF_MG_EXCEPTION_TRY2
+ //msclr::lock lockInstance(m_singletonSync);
+ DistributedSystem::acquireDisconnectLock();
+
+ nativeCache = m_nativeptr->get()->create( );
+
+ auto cache = Cache::Create( nativeCache );
+ // TODO global create SerializerRegistry
+ if(!m_connected)
+ {
+ DistributedSystem::AppDomainInstanceInitialization(cache);
+ }
+
+
+ pdxIgnoreUnreadFields = nativeCache->getPdxIgnoreUnreadFields();
+ pdxReadSerialized = nativeCache->getPdxReadSerialized();
+
+ appDomainEnable = cache->DistributedSystem->SystemProperties->AppDomainEnabled;
+ Log::SetLogLevel(static_cast<LogLevel>(native::Log::logLevel( )));
+ //TODO::split
+ SafeConvertClassGeneric::SetAppDomainEnabled(appDomainEnable);
+
+ if (appDomainEnable)
+ {
+ // Register managed AppDomain context with unmanaged.
+ native::createAppDomainContext = &Apache::Geode::Client::createAppDomainContext;
+ }
+
+ Serializable::RegisterTypeGeneric(
+ native::GeodeTypeIds::PdxType,
+ gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::Internal::PdxType::CreateDeserializable),
+ nullptr, cache);
+
+ if(!m_connected)
+ {
+ //it registers types in unmanage layer, so should be once only
+ DistributedSystem::ManagedPostConnect(cache);
+ DistributedSystem::AppDomainInstancePostInitialization();
+ DistributedSystem::connectInstance();
+ }
+
+ m_connected = true;
+
+
+
+ DistributedSystem::registerCliCallback();
+ Serializable::RegisterPDXManagedCacheableKey(appDomainEnable, cache);
+
+ return cache;
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ finally {
+ GC::KeepAlive(m_nativeptr);
+ Apache::Geode::Client::Internal::PdxTypeRegistry::PdxIgnoreUnreadFields = pdxIgnoreUnreadFields;
+ Apache::Geode::Client::Internal::PdxTypeRegistry::PdxReadSerialized = pdxReadSerialized;
+ DistributedSystem::releaseDisconnectLock();
+ }
+ }
+
+
+ String^ CacheFactory::Version::get( )
+ {
+ return ManagedString::Get( native::CacheFactory::getVersion( ) );
+ }
+
+ String^ CacheFactory::ProductDescription::get( )
+ {
+ return ManagedString::Get(
+ native::CacheFactory::getProductDescription( ) );
+ }
+
+
+ CacheFactory^ CacheFactory::SetPdxIgnoreUnreadFields(bool ignore)
+ {
+ _GF_MG_EXCEPTION_TRY2
+
+ try
+ {
+ m_nativeptr->get()->setPdxIgnoreUnreadFields( ignore );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ return this;
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ }
+
+ CacheFactory^ CacheFactory::SetPdxReadSerialized(bool pdxReadSerialized)
+ {
+ _GF_MG_EXCEPTION_TRY2
+
+ try
+ {
+ m_nativeptr->get()->setPdxReadSerialized( pdxReadSerialized );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ return this;
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ }
+
+ CacheFactory^ CacheFactory::Set(String^ name, String^ value)
+ {
+ _GF_MG_EXCEPTION_TRY2
+ ManagedString mg_name( name );
+ ManagedString mg_value( value );
+ try
+ {
+ m_nativeptr->get()->set( mg_name.CharPtr, mg_value.CharPtr );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ return this;
+
+ _GF_MG_EXCEPTION_CATCH_ALL2
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache
+
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/CacheFactory.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/CacheFactory.hpp b/clicache/src/CacheFactory.hpp
new file mode 100644
index 0000000..fb9f8ba
--- /dev/null
+++ b/clicache/src/CacheFactory.hpp
@@ -0,0 +1,177 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include "geode_defs.hpp"
+#include "begin_native.hpp"
+#include <geode/CacheFactory.hpp>
+#include "end_native.hpp"
+
+#include "native_shared_ptr.hpp"
+#include "Properties.hpp"
+
+using namespace System::Collections::Generic;
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+ namespace native = apache::geode::client;
+
+ ref class Cache;
+ ref class CacheAttributes;
+ ref class DistributedSystem;
+
+ /// <summary>
+ /// A factory class that must be used to obtain instance of <see cref="Cache" />.
+ /// </summary>
+ /// <remarks>
+ /// To create a new cache instance, use <see cref="CacheFactory.CreateCacheFactory" />.
+ /// <para>
+ /// To get an existing unclosed cache instance, use <see cref="CacheFactory.GetInstance" />.
+ /// </para>
+ /// </remarks>
+ public ref class CacheFactory
+ {
+ public:
+
+ /// <summary>
+ /// A factory class that must be used to obtain instance of <see cref="Cache" />.
+ /// This should be called once. Using this one can set default values of <see cref="Pool" />.
+ /// </summary>
+ /// <param name="dsProps">Properties which are applicable at client level.</param>
+ // static CacheFactory^ CreateCacheFactory(Dictionary<Object^, Object^>^ dsProps);
+ static CacheFactory^ CreateCacheFactory(Properties<String^, String^>^ dsProps);
+
+ /// <summary>
+ /// A factory class that must be used to obtain instance of <see cref="Cache" />.
+ /// This should be called once. Using this one can set default values of <see cref="Pool" />.
+ /// </summary>
+ static CacheFactory^ CreateCacheFactory();
+
+ /// <summary>
+ /// To create the instance of <see cref="Cache" />.
+ /// </summary>
+ Cache^ Create();
+
+ /// <summary>
+ /// Set allocators for non default Microsoft CRT versions.
+ /// </summary>
+ /* static void SetNewAndDelete()
+ {
+ native::setNewAndDelete(&operator new, &operator delete);
+ }
+*/
+ /// <summary>
+ /// Returns the version of the cache implementation.
+ /// For the 1.0 release of Geode, the string returned is <c>1.0</c>.
+ /// </summary>
+ /// <returns>the version of the cache implementation as a <c>String</c></returns>
+ static property String^ Version
+ {
+ static String^ get();
+ }
+
+ /// <summary>
+ /// Returns the product description string including product name and version.
+ /// </summary>
+ static property String^ ProductDescription
+ {
+ static String^ get();
+ }
+
+ ///<summary>
+ /// Control whether pdx ignores fields that were unread during deserialization.
+ /// The default is to preserve unread fields be including their data during serialization.
+ /// But if you configure the cache to ignore unread fields then their data will be lost
+ /// during serialization.
+ /// <P>You should only set this attribute to <code>true</code> if you know this member
+ /// will only be reading cache data. In this use case you do not need to pay the cost
+ /// of preserving the unread fields since you will never be reserializing pdx data.
+ ///<summary>
+ /// <param> ignore <code>true</code> if fields not read during pdx deserialization should be ignored;
+ /// <code>false</code>, the default, if they should be preserved.
+ /// </param>
+ /// <returns>
+ /// a instance of <c>CacheFactory</c>
+ /// </returns>
+ CacheFactory^ SetPdxIgnoreUnreadFields(bool ignore);
+
+ ///<summary>
+ /// Sets the object preference to PdxInstance type.
+ /// When a cached object that was serialized as a PDX is read
+ /// from the cache a {@link PdxInstance} will be returned instead of the actual domain class.
+ /// The PdxInstance is an interface that provides run time access to
+ /// the fields of a PDX without deserializing the entire PDX.
+ /// The PdxInstance implementation is a light weight wrapper
+ /// that simply refers to the raw bytes of the PDX that are kept
+ /// in the cache. Using this method applications can choose to
+ /// access PdxInstance instead of Java object.
+ /// Note that a PdxInstance is only returned if a serialized PDX is found in the cache.
+ /// If the cache contains a deserialized PDX, then a domain class instance is returned instead of a PdxInstance.
+ ///</summary>
+ /// <param> pdxReadSerialized <code>true</code> to prefer PdxInstance
+ /// <code>false</code>, the default, if they should be preserved.
+ /// </param>
+ /// <returns>
+ /// a instance of <c>CacheFactory</c>
+ /// </returns>
+ CacheFactory^ SetPdxReadSerialized(bool pdxReadSerialized);
+
+
+ /// <summary>
+ /// Sets a geode property that will be used when creating the ClientCache.
+ /// </summary>
+ /// <param>
+ /// name the name of the geode property
+ /// </param>
+ /// <param>
+ /// value the value of the geode property
+ /// </param>
+ /// <returns>
+ /// a instance of <c>CacheFactory</c>
+ /// </returns>
+ CacheFactory^ Set(String^ name, String^ value);
+
+ private:
+
+ /// <summary>
+ /// Private constructor to wrap a native object pointer
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ inline CacheFactory(native::CacheFactoryPtr nativeptr, Properties<String^, String^>^ dsProps)
+ {
+ m_nativeptr = gcnew native_shared_ptr<native::CacheFactory>(nativeptr);
+ m_dsProps = dsProps;
+ }
+
+ Properties<String^, String^>^ m_dsProps;
+
+ static System::Object^ m_singletonSync = gcnew System::Object();
+
+ native_shared_ptr<native::CacheFactory>^ m_nativeptr;
+
+ internal:
+ static bool m_connected = false;
+ };
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache
+
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/CacheListenerAdapter.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/CacheListenerAdapter.hpp b/clicache/src/CacheListenerAdapter.hpp
new file mode 100644
index 0000000..aaf3212
--- /dev/null
+++ b/clicache/src/CacheListenerAdapter.hpp
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include "geode_defs.hpp"
+#include "ICacheListener.hpp"
+
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+
+ /// <summary>
+ /// Utility class that implements all methods in <c>ICacheListener</c>
+ /// with empty implementations. Applications can subclass this class
+ /// and only override the methods for the events of interest.
+ /// </summary>
+ generic<class TKey, class TValue>
+ public ref class CacheListenerAdapter
+ : public ICacheListener<TKey, TValue>
+ {
+ public:
+ virtual void AfterCreate(EntryEvent<TKey, TValue>^ ev)
+ {
+ }
+
+ virtual void AfterUpdate(EntryEvent<TKey, TValue>^ ev)
+ {
+ }
+
+ virtual void AfterInvalidate(EntryEvent<TKey, TValue>^ ev)
+ {
+ }
+
+ virtual void AfterDestroy(EntryEvent<TKey, TValue>^ ev)
+ {
+ }
+
+ virtual void AfterRegionInvalidate(RegionEvent<TKey, TValue>^ ev)
+ {
+ }
+
+ virtual void AfterRegionDestroy(RegionEvent<TKey, TValue>^ ev)
+ {
+ }
+
+ virtual void AfterRegionLive(RegionEvent<TKey, TValue>^ ev)
+ {
+ }
+
+ virtual void AfterRegionClear(RegionEvent<TKey, TValue>^ ev)
+ {
+ }
+
+ virtual void Close(Apache::Geode::Client::IRegion<TKey, TValue>^ region)
+ {
+ }
+ virtual void AfterRegionDisconnected(Apache::Geode::Client::IRegion<TKey, TValue>^ region)
+ {
+ }
+ };
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache
+
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/CacheStatistics.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/CacheStatistics.cpp b/clicache/src/CacheStatistics.cpp
new file mode 100644
index 0000000..4259246
--- /dev/null
+++ b/clicache/src/CacheStatistics.cpp
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+#include "CacheStatistics.hpp"
+
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+
+ using namespace System;
+
+ System::UInt32 CacheStatistics::LastModifiedTime::get( )
+ {
+ try
+ {
+ return m_nativeptr->get()->getLastModifiedTime( );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+
+ System::UInt32 CacheStatistics::LastAccessedTime::get()
+ {
+ try
+ {
+ return m_nativeptr->get()->getLastAccessedTime();
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache