Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 41FB1200BF8 for ; Fri, 13 Jan 2017 23:45:53 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 40826160B4D; Fri, 13 Jan 2017 22:45:53 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0368C160B5D for ; Fri, 13 Jan 2017 23:45:47 +0100 (CET) Received: (qmail 66487 invoked by uid 500); 13 Jan 2017 22:45:47 -0000 Mailing-List: contact commits-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list commits@geode.apache.org Received: (qmail 65222 invoked by uid 99); 13 Jan 2017 22:45:45 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jan 2017 22:45:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 92676E007F; Fri, 13 Jan 2017 22:45:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rvs@apache.org To: commits@geode.apache.org Date: Fri, 13 Jan 2017 22:45:56 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [12/51] [partial] geode git commit: Software Grant Agreement (SGA) from Pivotal for Apache Geode archived-at: Fri, 13 Jan 2017 22:45:53 -0000 http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheFactory.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/CacheFactory.cpp b/src/clicache/src/CacheFactory.cpp new file mode 100644 index 0000000..7ca4b67 --- /dev/null +++ b/src/clicache/src/CacheFactory.cpp @@ -0,0 +1,404 @@ +/*========================================================================= + * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved. + * This product is protected by U.S. and international copyright + * and intellectual property laws. Pivotal products are covered by + * more patents listed at http://www.pivotal.io/patents. + *========================================================================= + */ + +//#include "gf_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 +//#pragma warning(disable:4091) + +using namespace System; + +namespace GemStone +{ + namespace GemFire + { + namespace Cache + { + namespace Generic + { + CacheFactory^ CacheFactory::CreateCacheFactory() + { + return CacheFactory::CreateCacheFactory(Properties::Create()); + } + + CacheFactory^ CacheFactory::CreateCacheFactory(Properties^ dsProps) + { + _GF_MG_EXCEPTION_TRY2 + + gemfire::PropertiesPtr nativepropsptr( + GetNativePtr(dsProps)); + + gemfire::CacheFactoryPtr& nativeptr( gemfire::CacheFactory::createCacheFactory( nativepropsptr) ); + if (nativeptr.ptr() != nullptr) + return gcnew CacheFactory( nativeptr.ptr(), dsProps ); + + return nullptr; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + Cache^ CacheFactory::Create() + { + bool pdxIgnoreUnreadFields = false; + bool pdxReadSerialized = false; + bool appDomainEnable = false; + _GF_MG_EXCEPTION_TRY2 + //msclr::lock lockInstance(m_singletonSync); + DistributedSystem::acquireDisconnectLock(); + + if(!m_connected) + { + gemfire::PropertiesPtr nativepropsptr( + GetNativePtr(m_dsProps)); + DistributedSystem::AppDomainInstanceInitialization(nativepropsptr); + } + + gemfire::CachePtr& nativeptr( NativePtr->create( ) ); + pdxIgnoreUnreadFields = nativeptr->getPdxIgnoreUnreadFields(); + pdxReadSerialized = nativeptr->getPdxReadSerialized(); + + appDomainEnable = DistributedSystem::SystemProperties->AppDomainEnabled; + Log::SetLogLevel(static_cast(gemfire::Log::logLevel( ))); + //TODO::split + SafeConvertClassGeneric::SetAppDomainEnabled(appDomainEnable); + + Serializable::RegisterTypeGeneric( + gemfire::GemfireTypeIds::PdxType, + gcnew TypeFactoryMethodGeneric(GemStone::GemFire::Cache::Generic::Internal::PdxType::CreateDeserializable), + nullptr); + + if(!m_connected) + { + //it registers types in unmanage layer, so should be once only + DistributedSystem::ManagedPostConnect(); + DistributedSystem::AppDomainInstancePostInitialization(); + DistributedSystem::connectInstance(); + } + + m_connected = true; + + return Cache::Create( nativeptr.ptr( ) ); + _GF_MG_EXCEPTION_CATCH_ALL2 + finally { + DistributedSystem::registerCliCallback(); + Serializable::RegisterPDXManagedCacheableKey(appDomainEnable); + GemStone::GemFire::Cache::Generic::Internal::PdxTypeRegistry::PdxIgnoreUnreadFields = pdxIgnoreUnreadFields; + GemStone::GemFire::Cache::Generic::Internal::PdxTypeRegistry::PdxReadSerialized = pdxReadSerialized; + DistributedSystem::releaseDisconnectLock(); + } + } + + Cache^ CacheFactory::GetInstance( DistributedSystem^ system ) + { + _GF_MG_EXCEPTION_TRY2 + + gemfire::DistributedSystemPtr p_system( + GetNativePtr( system ) ); + gemfire::CachePtr& nativeptr( + gemfire::CacheFactory::getInstance( p_system ) ); + + return Cache::Create( nativeptr.ptr( ) ); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + Cache^ CacheFactory::GetInstanceCloseOk( DistributedSystem^ system ) + { + _GF_MG_EXCEPTION_TRY2 + + gemfire::DistributedSystemPtr p_system( + GetNativePtr( system ) ); + gemfire::CachePtr& nativeptr( + gemfire::CacheFactory::getInstanceCloseOk( p_system ) ); + + return Cache::Create( nativeptr.ptr( ) ); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + Cache^ CacheFactory::GetAnyInstance( ) + { + _GF_MG_EXCEPTION_TRY2 + + gemfire::CachePtr& nativeptr( + gemfire::CacheFactory::getAnyInstance( ) ); + return Cache::Create( nativeptr.ptr( ) ); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + String^ CacheFactory::Version::get( ) + { + return ManagedString::Get( gemfire::CacheFactory::getVersion( ) ); + } + + String^ CacheFactory::ProductDescription::get( ) + { + return ManagedString::Get( + gemfire::CacheFactory::getProductDescription( ) ); + } + + + CacheFactory^ CacheFactory::SetFreeConnectionTimeout( Int32 connectionTimeout ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setFreeConnectionTimeout( connectionTimeout ); + + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetLoadConditioningInterval( Int32 loadConditioningInterval ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setLoadConditioningInterval( loadConditioningInterval ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetSocketBufferSize( Int32 bufferSize ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setSocketBufferSize( bufferSize ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetReadTimeout( Int32 timeout ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setReadTimeout( timeout ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetMinConnections( Int32 minConnections ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setMinConnections( minConnections ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetMaxConnections( Int32 maxConnections ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setMaxConnections( maxConnections ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetIdleTimeout( Int32 idleTimeout ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setIdleTimeout( idleTimeout ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetRetryAttempts( Int32 retryAttempts ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setRetryAttempts( retryAttempts ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetPingInterval( Int32 pingInterval ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setPingInterval( pingInterval ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetUpdateLocatorListInterval( Int32 updateLocatorListInterval ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setUpdateLocatorListInterval( updateLocatorListInterval ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetStatisticInterval( Int32 statisticInterval ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setStatisticInterval( statisticInterval ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetServerGroup( String^ group ) + { + _GF_MG_EXCEPTION_TRY2 + + ManagedString mg_servergroup( group ); + NativePtr->setServerGroup( mg_servergroup.CharPtr ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::AddLocator( String^ host, Int32 port ) + { + _GF_MG_EXCEPTION_TRY2 + + ManagedString mg_host( host ); + NativePtr->addLocator( mg_host.CharPtr, port ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::AddServer( String^ host, Int32 port ) + { + _GF_MG_EXCEPTION_TRY2 + + ManagedString mg_host( host ); + NativePtr->addServer( mg_host.CharPtr, port ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetSubscriptionEnabled( Boolean enabled ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setSubscriptionEnabled( enabled ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetPRSingleHopEnabled( Boolean enabled ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setPRSingleHopEnabled(enabled); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetSubscriptionRedundancy( Int32 redundancy ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setSubscriptionRedundancy( redundancy ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetSubscriptionMessageTrackingTimeout( Int32 messageTrackingTimeout ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setSubscriptionMessageTrackingTimeout( messageTrackingTimeout ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetSubscriptionAckInterval( Int32 ackInterval ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setSubscriptionAckInterval( ackInterval ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetThreadLocalConnections( bool enabled ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setThreadLocalConnections( enabled ); + + _GF_MG_EXCEPTION_CATCH_ALL2 + + return this; + } + + CacheFactory^ CacheFactory::SetMultiuserAuthentication( bool multiuserAuthentication ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setMultiuserAuthentication( multiuserAuthentication ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetPdxIgnoreUnreadFields(bool ignore) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setPdxIgnoreUnreadFields( ignore ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + CacheFactory^ CacheFactory::SetPdxReadSerialized(bool pdxReadSerialized) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->setPdxReadSerialized( pdxReadSerialized ); + 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 ); + NativePtr->set( mg_name.CharPtr, mg_value.CharPtr ); + return this; + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + } // end namespace Generic + } + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheFactory.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/CacheFactory.hpp b/src/clicache/src/CacheFactory.hpp new file mode 100644 index 0000000..080fe78 --- /dev/null +++ b/src/clicache/src/CacheFactory.hpp @@ -0,0 +1,603 @@ +/*========================================================================= + * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved. + * This product is protected by U.S. and international copyright + * and intellectual property laws. Pivotal products are covered by + * more patents listed at http://www.pivotal.io/patents. + *========================================================================= + */ + +#pragma once + +#include "gf_defs.hpp" +#include "impl/NativeWrapper.hpp" +#include +#include "Properties.hpp" + +//using namespace System; +using namespace System::Collections::Generic; + +namespace GemStone +{ + namespace GemFire + { + namespace Cache + { + namespace Generic + { + ref class Cache; + ref class CacheAttributes; + ref class DistributedSystem; + + /// + /// A factory class that must be used to obtain instance of . + /// + /// + /// To create a new cache instance, use . + /// + /// To get an existing unclosed cache instance, use . + /// + /// + public ref class CacheFactory :public Internal::SBWrap + { + public: + + /// + /// A factory class that must be used to obtain instance of . + /// This should be called once. Using this one can set default values of . + /// + /// Properties which are applicable at client level. + // static CacheFactory^ CreateCacheFactory(Dictionary^ dsProps); + static CacheFactory^ CreateCacheFactory(Properties^ dsProps); + + /// + /// A factory class that must be used to obtain instance of . + /// This should be called once. Using this one can set default values of . + /// + static CacheFactory^ CreateCacheFactory(); + + /// + /// To create the instance of . + /// + Cache^ Create(); + + /// + /// Gets the instance of produced by an + /// earlier call to . + /// + /// + /// the the cache was created with. + /// + /// the associated with the specified system. + /// + /// if the distributed system argument is null + /// + /// + /// if a cache has not been created or the created one is closed + /// ( ) + /// + /// + /// if a cache with specified system not found + /// + static Cache^ GetInstance( DistributedSystem^ system ); + + /// + /// Gets the instance of produced by an + /// earlier call to , even if it has been closed. + /// + /// + /// the the cache was created with. + /// + /// + /// the Cache associated with the specified system. + /// + /// + /// if the distributed system argument is null + /// + /// + /// if a cache has not been created. + /// + /// + /// if a cache with specified system not found + /// + static Cache^ GetInstanceCloseOk( DistributedSystem^ system ); + + /// + /// Gets an arbitrary open instance of produced by an + /// earlier call to . + /// + /// + /// if a cache has not been created or the only created one is + /// closed ( ) + /// + /// + /// if a cache with specified system not found + /// + static Cache^ GetAnyInstance( ); + + /// + /// Set allocators for non default Microsoft CRT versions. + /// + static void SetNewAndDelete() + { + gemfire::setNewAndDelete( & operator new, & operator delete ); + } + + /// + /// Returns the version of the cache implementation. + /// For the 1.0 release of GemFire, the string returned is 1.0. + /// + /// the version of the cache implementation as a String + static property String^ Version + { + static String^ get( ); + } + + /// + /// Returns the product description string including product name and version. + /// + static property String^ ProductDescription + { + static String^ get( ); + } + + /// + /// Sets the free connection timeout for this pool. + /// + /// + /// If the pool has a max connections setting, operations will block + /// if all of the connections are in use. The free connection timeout + /// specifies how long those operations will block waiting for + /// a free connection before receiving an AllConnectionsInUseException. + /// If max connections is not set this setting has no effect. + /// + /// + /// connectionTimeout the connection timeout in milliseconds + /// + /// + /// IllegalArgumentException if connectionTimeout + /// is less than or equal to 0. + /// + CacheFactory^ SetFreeConnectionTimeout( Int32 connectionTimeout ); + + /// + /// Sets the load conditioning interval for this pool. + /// + /// + /// This interval controls how frequently the pool will check to see if + /// a connection to a given server should be moved to a different + /// server to improve the load balance. + /// + /// + /// loadConditioningInterval the connection lifetime in milliseconds + /// A value of -1 disables load conditioning. + /// + /// + /// throws IllegalArgumentException if connectionLifetime + /// is less than -1. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetLoadConditioningInterval( Int32 loadConditioningInterval ); + + /// + /// Sets the socket buffer size for each connection made in this pool. + /// + /// + /// Large messages can be received and sent faster when this buffer is larger. + /// Larger buffers also optimize the rate at which servers can send events + /// for client subscriptions. + /// + /// + /// bufferSize the size of the socket buffers used for reading and + /// writing on each connection in this pool. + /// + /// + /// throws IllegalArgumentException if bufferSize + /// is less than or equal to 0. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetSocketBufferSize( Int32 bufferSize ); + + /// + /// Sets the number of milliseconds to wait for a response from a server before + /// timing out the operation and trying another server (if any are available). + /// + /// + /// timeout number of milliseconds to wait for a response from a server + /// + /// + /// throws IllegalArgumentException if timeout + /// is less than or equal to 0. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetReadTimeout( Int32 timeout ); + + /// + /// Set the minimum number of connections to keep available at all times. + /// + /// + /// When the pool is created, it will create this many connections. + /// If 0 then connections will not be made until an actual operation + /// is done that requires client-to-server communication. + /// + /// + /// minConnections the initial number of connections this pool will create. + /// + /// + /// throws IllegalArgumentException if minConnections is less than 0. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetMinConnections( Int32 minConnections ); + + /// + /// Set the max number of client to server connections that the pool will create. + /// + /// + /// If all of the connections are in use, an operation requiring a client to + /// server connection will block until a connection is available. + /// see setFreeConnectionTimeout(int) + /// + /// + /// maxConnections the maximum number of connections in the pool. + /// -1 indicates that there is no maximum number of connections. + /// + /// + /// throws IllegalArgumentException if maxConnections is less than minConnections. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetMaxConnections( Int32 maxConnections ); + + /// + /// Set the amount of time a connection can be idle before expiring the connection. + /// + /// + /// If the pool size is greater than the minimum specified, connections which have + /// been idle for longer than the idleTimeout will be closed. + /// + /// + /// idleTimeout The amount of time in milliseconds that an idle connection + /// should live before expiring. -1 indicates that connections should never expire. + /// + /// + /// throws IllegalArgumentException if idleTimout is less than 0. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetIdleTimeout( Int32 idleTimeout ); + + /// + /// Set the number of times to retry a request after timeout/exception. + /// + /// + /// retryAttempts The number of times to retry a request + /// after timeout/exception. -1 indicates that a request should be + /// tried against every available server before failing. + /// + /// + /// throws IllegalArgumentException if idleTimout is less than 0. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetRetryAttempts( Int32 retryAttempts ); + + /// + /// Set how often to ping servers to verify that they are still alive. + /// + /// + /// Each server will be sent a ping every pingInterval if there has not + /// been any other communication with the server. + /// These pings are used by the server to monitor the health of + /// the client. Make sure that the pingInterval is less than the + /// maximum time between pings allowed by the bridge server. + /// see in CacheServer: setMaximumTimeBetweenPings(int) + /// + /// + /// pingInterval The amount of time in milliseconds between pings. + /// + /// + /// throws IllegalArgumentException if pingInterval is less than 0. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetPingInterval( Int32 pingInterval ); + + /// + /// Set how often to update locator list from locator + /// + /// + /// updateLocatorListInterval The amount of time in milliseconds between + /// updating locator list. If its set to 0 then client will not update + /// the locator list. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetUpdateLocatorListInterval( Int32 updateLocatorListInterval ); + + + /// + /// Set how often to send client statistics to the server. + /// + /// + /// Doing this allows gfmon to monitor clients. + /// A value of -1 disables the sending of client statistics + /// to the server. + /// + /// + /// statisticInterval The amount of time in milliseconds between + /// sends of client statistics to the server. + /// + /// + /// throws IllegalArgumentException if statisticInterval + /// is less than -1. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetStatisticInterval( Int32 statisticInterval); + + /// + /// Configures the group that all servers this pool connects to must belong to. + /// + /// + /// group the server group that this pool will connect to. + /// If null or "" then all servers will be connected to. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetServerGroup( String^ group ); + + /// + /// Add a locator, given its host and port, to this factory. + /// + /// + /// The locator must be a server locator and will be used to discover other running + /// bridge servers and locators. + /// + /// + /// host the host name or ip address that the locator is listening on. + /// + /// + /// port the port that the locator is listening on + /// + /// + /// throws IllegalArgumentException if host is an unknown host + /// or if port is outside the valid range of [1..65535] inclusive. + /// + /// + /// throws IllegalStateException if a locator has already been added to this factory. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ AddLocator( String^ host, Int32 port ); + + /// + /// Add a server, given its host and port, to this factory. + /// + /// + /// The server must be a bridge server and this client will + /// directly connect to without consulting a server locator. + /// + /// + /// host the host name or ip address that the server is listening on. + /// + /// + /// port the port that the server is listening on + /// + /// + /// throws IllegalArgumentException if host is an unknown host + /// or if port is outside the valid range of [1..65535] inclusive. + /// + /// + /// throws IllegalStateException if a server has already been added to this factory. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ AddServer( String^ host, Int32 port ); + + /// + /// Enable subscriptions. + /// + /// + /// If set to true then the created pool will have server-to-client + /// subscriptions enabled. If set to false then all Subscription* + /// attributes are ignored at create time. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetSubscriptionEnabled( Boolean enabled ); + + /// + /// By default SetPRSingleHopEnabled is true. + /// + /// + /// The client is aware of location of partitions on servers hosting + /// Using this information, the client routes the client cache operations + /// directly to the server which is hosting the required partition for the + /// cache operation. + /// If SetPRSingleHopEnabled is false the client can do an extra hop on servers + /// to go to the required partition for that cache operation. + /// The SetPRSingleHopEnabled avoids extra hops only for following cache operations : + /// put, get & destroy operations. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetPRSingleHopEnabled( Boolean enabled ); + + /// + /// Sets the redundancy level for this pools server-to-client subscriptions. + /// + /// + /// If 0 then no redundant copies will be kept on the servers. + /// Otherwise an effort will be made to maintain the requested number of + /// copies of the server-to-client subscriptions. At most one copy per server will + /// be made up to the requested level. + /// + /// + /// redundancy the number of redundant servers for this client's subscriptions. + /// + /// + /// throws IllegalArgumentException if redundancyLevel is less than -1. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetSubscriptionRedundancy( Int32 redundancy ); + + /// + /// Sets the messageTrackingTimeout attribute which is the time-to-live period, + /// in milliseconds, for subscription events the client has received from the server. + /// + /// + /// It's used to minimize duplicate events. Entries that have not been modified + /// for this amount of time are expired from the list. + /// + /// + /// messageTrackingTimeout number of milliseconds to set the timeout to. + /// + /// + /// throws IllegalArgumentException if messageTrackingTimeout is less than or equal to 0. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetSubscriptionMessageTrackingTimeout( Int32 messageTrackingTimeout ); + + /// + /// Sets the is the interval in milliseconds to wait before sending + /// acknowledgements to the bridge server for events received from the server subscriptions. + /// + /// + /// ackInterval number of milliseconds to wait before sending event acknowledgements. + /// + /// + /// throws IllegalArgumentException if ackInterval is less than or equal to 0. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetSubscriptionAckInterval( Int32 ackInterval ); + + /// + /// Enable thread local connections. + /// + /// + /// Sets the thread local connections policy for the default connection pool. + /// If true then any time a thread goes to use a connection + /// from this pool it will check a thread local cache and see if it already + /// has a connection in it. If so it will use it. If not it will get one from + /// this pool and cache it in the thread local. This gets rid of thread contention + /// for the connections but increases the number of connections the servers see. + /// If false then connections are returned to the pool as soon + /// as the operation being done with the connection completes. This allows + /// connections to be shared amonst multiple threads keeping the number of + /// connections down. + /// + CacheFactory^ SetThreadLocalConnections( bool enabled ); + + /// + /// Sets whether pool is in multiuser mode + /// + /// + /// multiuserAuthentication should be true/false. Default value is false; + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetMultiuserAuthentication( bool multiuserAuthentication ); + + + /// + /// 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. + ///

You should only set this attribute to true 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. + ///

+ /// ignore true if fields not read during pdx deserialization should be ignored; + /// false, the default, if they should be preserved. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetPdxIgnoreUnreadFields(bool ignore); + + /// + /// 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. + /// + /// pdxReadSerialized true to prefer PdxInstance + /// false, the default, if they should be preserved. + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ SetPdxReadSerialized(bool pdxReadSerialized); + + + /// + /// Sets a gemfire property that will be used when creating the ClientCache. + /// + /// + /// name the name of the gemfire property + /// + /// + /// value the value of the gemfire property + /// + /// + /// a instance of CacheFactory + /// + CacheFactory^ Set(String^ name, String^ value); + + private: + + /// + /// Private constructor to wrap a native object pointer + /// + /// The native object pointer + inline CacheFactory( gemfire::CacheFactory* nativeptr, Properties^ dsProps ) + : SBWrap( nativeptr ) + { + m_dsProps = dsProps; + } + + Properties^ m_dsProps; + + static System::Object^ m_singletonSync = gcnew System::Object(); + + internal: + static bool m_connected = false; + }; + + } + } +} +} http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheListenerAdapter.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/CacheListenerAdapter.hpp b/src/clicache/src/CacheListenerAdapter.hpp new file mode 100644 index 0000000..6436960 --- /dev/null +++ b/src/clicache/src/CacheListenerAdapter.hpp @@ -0,0 +1,75 @@ +/*========================================================================= + * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved. + * This product is protected by U.S. and international copyright + * and intellectual property laws. Pivotal products are covered by + * more patents listed at http://www.pivotal.io/patents. + *========================================================================= + */ + +#pragma once + +#include "gf_defs.hpp" +#include "ICacheListener.hpp" + + +namespace GemStone +{ + namespace GemFire + { + namespace Cache { namespace Generic + { + + /// + /// Utility class that implements all methods in ICacheListener + /// with empty implementations. Applications can subclass this class + /// and only override the methods for the events of interest. + /// + generic + public ref class CacheListenerAdapter + : public ICacheListener + { + public: + virtual void AfterCreate(EntryEvent^ ev) + { + } + + virtual void AfterUpdate(EntryEvent^ ev) + { + } + + virtual void AfterInvalidate(EntryEvent^ ev) + { + } + + virtual void AfterDestroy(EntryEvent^ ev) + { + } + + virtual void AfterRegionInvalidate(RegionEvent^ ev) + { + } + + virtual void AfterRegionDestroy(RegionEvent^ ev) + { + } + + virtual void AfterRegionLive(RegionEvent^ ev) + { + } + + virtual void AfterRegionClear(RegionEvent^ ev) + { + } + + virtual void Close(GemStone::GemFire::Cache::Generic::IRegion^ region) + { + } + virtual void AfterRegionDisconnected(GemStone::GemFire::Cache::Generic::IRegion^ region) + { + } + }; + + } + } +} + } //namespace http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheStatistics.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/CacheStatistics.cpp b/src/clicache/src/CacheStatistics.cpp new file mode 100644 index 0000000..e975f63 --- /dev/null +++ b/src/clicache/src/CacheStatistics.cpp @@ -0,0 +1,33 @@ +/*========================================================================= + * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved. + * This product is protected by U.S. and international copyright + * and intellectual property laws. Pivotal products are covered by + * more patents listed at http://www.pivotal.io/patents. + *========================================================================= + */ + +//#include "gf_includes.hpp" +#include "CacheStatistics.hpp" + + +namespace GemStone +{ + namespace GemFire + { + namespace Cache { namespace Generic + { + + uint32_t CacheStatistics::LastModifiedTime::get( ) + { + return NativePtr->getLastModifiedTime( ); + } + + uint32_t CacheStatistics::LastAccessedTime::get( ) + { + return NativePtr->getLastAccessedTime( ); + } + + } + } +} + } //namespace http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheStatistics.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/CacheStatistics.hpp b/src/clicache/src/CacheStatistics.hpp new file mode 100644 index 0000000..ab3b69a --- /dev/null +++ b/src/clicache/src/CacheStatistics.hpp @@ -0,0 +1,145 @@ +/*========================================================================= + * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved. + * This product is protected by U.S. and international copyright + * and intellectual property laws. Pivotal products are covered by + * more patents listed at http://www.pivotal.io/patents. + *========================================================================= + */ + +#pragma once + +#include "gf_defs.hpp" +#include +#include "impl/NativeWrapper.hpp" + + +namespace GemStone +{ + namespace GemFire + { + namespace Cache { namespace Generic + { + + /// + /// Defines common statistical information for both the region and its entries. + /// + /// + /// All of these methods may throw a CacheClosedException, + /// RegionDestroyedException, or EntryDestroyedException. + /// + /// + /// + public ref class CacheStatistics sealed + : public Internal::SBWrap + { + public: + + /// + /// For an entry, returns the time that the entry's value was last modified. + /// For a region, returns the last time any of the region's entries' values or + /// the values in subregions' entries were modified. + /// + /// + /// + /// The modification may have been initiated locally, or it may have been + /// an update distributed from another cache. It may also have been a new + /// value provided by a loader. The modification time on a region is + /// propagated upward to parent regions, transitively, to the root region. + /// + /// The number is expressed as the number of milliseconds since January 1, 1970. + /// The granularity may be as coarse as 100ms, so the accuracy may be off by + /// up to 50ms. + /// + /// Entry and subregion creation will update the modification time on a + /// region, but Region.Destroy, Region.DestroyRegion, + /// Region.Invalidate, and Region.InvalidateRegion + /// do not update the modification time. + /// + /// + /// + /// the last modification time of the region or the entry; + /// returns 0 if the entry is invalid or the modification time is uninitialized. + /// + /// + /// + /// + /// + property uint32_t LastModifiedTime + { + /// + /// Get the last modified time of an entry or a region. + /// + /// + /// the last accessed time expressed as the number of milliseconds since + /// January 1, 1970. + /// + uint32_t get( ); + } + + /// + /// For an entry, returns the last time it was accessed via Region.Get. + /// For a region, returns the last time any of its entries or the entries of + /// its subregions were accessed with Region.Get. + /// + /// + /// + /// Any modifications will also update the LastAccessedTime, + /// so LastAccessedTime is always greater than or equal to + /// LastModifiedTime. The LastAccessedTime on a region is + /// propagated upward to parent regions, transitively, to the the root region. + /// + /// The number is expressed as the number of milliseconds since + /// January 1, 1970. The granularity may be as coarse as 100ms, so + /// the accuracy may be off by up to 50ms. + /// + /// + /// + /// the last access time of the region or the entry's value; + /// returns 0 if entry is invalid or access time is uninitialized. + /// + /// + /// + property uint32_t LastAccessedTime + { + /// + /// Get the last accessed time of an entry or a region. + /// + /// + /// the last accessed time expressed as the number of milliseconds since + /// January 1, 1970. + /// + uint32_t get( ); + } + + + internal: + + /// + /// Internal factory function to wrap a native object pointer inside + /// this managed class with null pointer check. + /// + /// The native object pointer + /// + /// The managed wrapper object; null if the native pointer is null. + /// + inline static CacheStatistics^ Create( gemfire::CacheStatistics* nativeptr ) + { + return ( nativeptr != nullptr ? + gcnew CacheStatistics( nativeptr ) : nullptr ); + } + + + private: + + /// + /// Private constructor to wrap a native object pointer + /// + /// The native object pointer + inline CacheStatistics( gemfire::CacheStatistics* nativeptr ) + : SBWrap( nativeptr ) { } + }; + + } + } +} + } //namespace http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheTransactionManager.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/CacheTransactionManager.cpp b/src/clicache/src/CacheTransactionManager.cpp new file mode 100644 index 0000000..927878b --- /dev/null +++ b/src/clicache/src/CacheTransactionManager.cpp @@ -0,0 +1,204 @@ +/*========================================================================= + * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved. + * This product is protected by U.S. and international copyright + * and intellectual property laws. Pivotal products are covered by + * more patents listed at http://www.pivotal.io/patents. + *========================================================================= + */ + +//#include "gf_includes.hpp" +#include "impl/SafeConvert.hpp" +#include "impl/ManagedTransactionListener.hpp" +#include "impl/ManagedTransactionWriter.hpp" +#include "CacheTransactionManager.hpp" + +using namespace System; + +namespace GemStone +{ + namespace GemFire + { + namespace Cache { + namespace Generic + { + + void CacheTransactionManager::Begin( ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->begin( ); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + void CacheTransactionManager::Prepare( ) + { + _GF_MG_EXCEPTION_TRY2 + + NativePtr->prepare( ); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + void CacheTransactionManager::Commit( ) + { + _GF_MG_EXCEPTION_TRY2 + NativePtr->commit( ); + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + void CacheTransactionManager::Rollback( ) + { + _GF_MG_EXCEPTION_TRY2 + NativePtr->rollback( ); + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + bool CacheTransactionManager::Exists( ) + { + _GF_MG_EXCEPTION_TRY2 + + return NativePtr->exists( ); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + GemStone::GemFire::Cache::Generic::TransactionId^ CacheTransactionManager::Suspend( ) + { + _GF_MG_EXCEPTION_TRY2 + + return GemStone::GemFire::Cache::Generic::TransactionId::Create( NativePtr->suspend().ptr() ); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + GemStone::GemFire::Cache::Generic::TransactionId^ CacheTransactionManager::TransactionId::get( ) + { + _GF_MG_EXCEPTION_TRY2 + + return GemStone::GemFire::Cache::Generic::TransactionId::Create( NativePtr->getTransactionId().ptr() ); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + void CacheTransactionManager::Resume(GemStone::GemFire::Cache::Generic::TransactionId^ transactionId) + { + _GF_MG_EXCEPTION_TRY2 + + return NativePtr->resume( gemfire::TransactionIdPtr(transactionId->NativePtr())); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + bool CacheTransactionManager::IsSuspended(GemStone::GemFire::Cache::Generic::TransactionId^ transactionId) + { + _GF_MG_EXCEPTION_TRY2 + + return NativePtr->isSuspended( gemfire::TransactionIdPtr(transactionId->NativePtr())); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + bool CacheTransactionManager::TryResume(GemStone::GemFire::Cache::Generic::TransactionId^ transactionId) + { + _GF_MG_EXCEPTION_TRY2 + + return NativePtr->tryResume( gemfire::TransactionIdPtr(transactionId->NativePtr())); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + bool CacheTransactionManager::TryResume(GemStone::GemFire::Cache::Generic::TransactionId^ transactionId, int32_t waitTimeInMilliSec) + { + _GF_MG_EXCEPTION_TRY2 + + return NativePtr->tryResume( gemfire::TransactionIdPtr(transactionId->NativePtr()), waitTimeInMilliSec); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + bool CacheTransactionManager::Exists(GemStone::GemFire::Cache::Generic::TransactionId^ transactionId) + { + _GF_MG_EXCEPTION_TRY2 + + return NativePtr->exists( gemfire::TransactionIdPtr(transactionId->NativePtr())); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + +#ifdef CSTX_COMMENTED + generic + ITransactionWriter^ CacheTransactionManager::GetWriter( ) + { + _GF_MG_EXCEPTION_TRY2 + + // Conver the unmanaged object to managed generic object + gemfire::TransactionWriterPtr& writerPtr( NativePtr->getWriter( ) ); + gemfire::ManagedTransactionWriterGeneric* twg = + dynamic_cast( writerPtr.ptr( ) ); + + if (twg != nullptr) + { + return (ITransactionWriter^)twg->userptr( ); + } + + _GF_MG_EXCEPTION_CATCH_ALL2 + + return nullptr; + } + + generic + void CacheTransactionManager::SetWriter(ITransactionWriter^ transactionWriter) + { + _GF_MG_EXCEPTION_TRY2 + // Create a unmanaged object using the ManagedTransactionWriterGeneric. + // Set the generic object inside the TransactionWriterGeneric that is a non generic object + gemfire::TransactionWriterPtr writerPtr; + if ( transactionWriter != nullptr ) + { + TransactionWriterGeneric^ twg = gcnew TransactionWriterGeneric (); + twg->SetTransactionWriter(transactionWriter); + writerPtr = new gemfire::ManagedTransactionWriterGeneric( transactionWriter ); + ((gemfire::ManagedTransactionWriterGeneric*)writerPtr.ptr())->setptr(twg); + } + NativePtr->setWriter( writerPtr ); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + generic + void CacheTransactionManager::AddListener(ITransactionListener^ transactionListener) + { + _GF_MG_EXCEPTION_TRY2 + // Create a unmanaged object using the ManagedTransactionListenerGeneric. + // Set the generic object inside the TransactionListenerGeneric that is a non generic object + gemfire::TransactionListenerPtr listenerPtr; + if ( transactionListener != nullptr ) + { + TransactionListenerGeneric^ twg = gcnew TransactionListenerGeneric (); + twg->SetTransactionListener(transactionListener); + listenerPtr = new gemfire::ManagedTransactionListenerGeneric( transactionListener ); + ((gemfire::ManagedTransactionListenerGeneric*)listenerPtr.ptr())->setptr(twg); + } + NativePtr->addListener( listenerPtr ); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } + + generic + void CacheTransactionManager::RemoveListener(ITransactionListener^ transactionListener) + { + _GF_MG_EXCEPTION_TRY2 + // Create an unmanaged non generic object using the managed generic object + // use this to call the remove listener + gemfire::TransactionListenerPtr listenerPtr; + if ( transactionListener != nullptr ) + { + TransactionListenerGeneric^ twg = gcnew TransactionListenerGeneric (); + twg->SetTransactionListener(transactionListener); + listenerPtr = new gemfire::ManagedTransactionListenerGeneric( transactionListener ); + ((gemfire::ManagedTransactionListenerGeneric*)listenerPtr.ptr())->setptr(twg); + } + NativePtr->removeListener( listenerPtr ); + + _GF_MG_EXCEPTION_CATCH_ALL2 + } +#endif + } + } +} + } //namespace http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheTransactionManager.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/CacheTransactionManager.hpp b/src/clicache/src/CacheTransactionManager.hpp new file mode 100644 index 0000000..811624d --- /dev/null +++ b/src/clicache/src/CacheTransactionManager.hpp @@ -0,0 +1,262 @@ +/*========================================================================= + * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved. + * This product is protected by U.S. and international copyright + * and intellectual property laws. Pivotal products are covered by + * more patents listed at http://www.pivotal.io/patents. + *========================================================================= + */ + +#pragma once + +#include "gf_defs.hpp" +#include +#include +#include "TransactionId.hpp" +//#include "impl/NativeWrapper.hpp" +//#include "impl/TransactionWriter.hpp" +//#include "impl/TransactionListener.hpp" + +using namespace System; +namespace GemStone +{ + namespace GemFire + { + namespace Cache { + namespace Generic + { + + /// + /// CacheTransactionManager encapsulates the transactions for a cache + /// + public ref class CacheTransactionManager sealed + : Internal::SBWrap + { + public: + /// + /// Creates a new transaction and associates it with the current thread. + /// + /// + /// Throws exception if the thread is already associated with a transaction + /// + void Begin(); + + /// + /// Prepare the first message of two-phase-commit transaction associated + /// with the current thread. + /// + /// + /// if the thread is not associated with a transaction + /// + /// + /// if the commit operation fails due to a write conflict. + /// + void Prepare(); + + /// + /// Commit the transaction associated with the current thread. If + /// the commit operation fails due to a conflict it will destroy + /// the transaction state and throw a CommitConflictException. + /// If the commit operation succeeds,it returns after the transaction + /// state has been merged with committed state. When this method + /// completes, the thread is no longer associated with a transaction. + /// + /// + /// if the thread is not associated with a transaction + /// + /// + /// if the commit operation fails due to a write conflict. + /// + void Commit(); + + /// + /// Roll back the transaction associated with the current thread. When + /// this method completes, the thread is no longer associated with a + /// transaction and the transaction context is destroyed. + /// + /// + /// if the thread is not associated with a transaction + /// + void Rollback(); + + /// + /// Reports the existence of a Transaction for this thread + /// + /// true if a transaction exists, false otherwise + bool Exists(); + + /// + /// Suspends the transaction on the current thread. All subsequent operations + /// performed by this thread will be non-transactional. The suspended + /// transaction can be resumed by calling + /// + /// Since 3.6.2 + /// + /// + /// the transaction identifier of the suspended transaction or null if + /// the thread was not associated with a transaction + GemStone::GemFire::Cache::Generic::TransactionId^ Suspend(); + + /// + /// On the current thread, resumes a transaction that was previously suspended + /// using + /// + /// Since 3.6.2 + /// + /// + /// the transaction to resume + /// if the thread is associated with a transaction or if + /// would return false for the given transactionId + /// + void Resume(GemStone::GemFire::Cache::Generic::TransactionId^ transactionId); + + /// + /// This method can be used to determine if a transaction with the given + /// transaction identifier is currently suspended locally. This method does not + /// check other members for transaction status. + /// + /// Since 3.6.2 + /// + /// + /// + /// true if the transaction is in suspended state, false otherwise + /// + bool IsSuspended(GemStone::GemFire::Cache::Generic::TransactionId^ transactionId); + + + /// + /// On the current thread, resumes a transaction that was previously suspended + /// using . + /// This method is equivalent to + /// + /// if (isSuspended(txId)) { + /// resume(txId); + /// } + /// + /// except that this action is performed atomically + /// + /// Since 3.6.2 + /// + /// + /// the transaction to resume + /// true if the transaction was resumed, false otherwise + bool TryResume(GemStone::GemFire::Cache::Generic::TransactionId^ transactionId); + + + /// + /// On the current thread, resumes a transaction that was previously suspended + /// using , or waits for the specified timeout interval if + /// the transaction has not been suspended. This method will return if: + /// + /// Another thread suspends the transaction + /// + /// + /// Another thread calls commit/rollback on the transaction + /// + /// + /// This thread has waited for the specified timeout + /// + /// This method returns immediately if returns false. + /// + /// Since 3.6.2 + /// + /// + /// the transaction to resume + /// the maximum milliseconds to wait + /// true if the transaction was resumed, false otherwise + bool TryResume(GemStone::GemFire::Cache::Generic::TransactionId^ transactionId, int32_t waitTimeInMilliSec); + + + + /// + /// Reports the existence of a transaction for the given transactionId. This + /// method can be used to determine if a transaction with the given transaction + /// identifier is currently in progress locally. + /// + /// Since 3.6.2 + /// + /// + /// the given transaction identifier + /// true if the transaction is in progress, false otherwise. + /// + bool Exists(GemStone::GemFire::Cache::Generic::TransactionId^ transactionId); + + + /// + /// Returns the transaction identifier for the current thread + /// + /// Since 3.6.2 + /// + /// + /// the transaction identifier or null if no transaction exists + property GemStone::GemFire::Cache::Generic::TransactionId^ TransactionId + { + //TODO::split + GemStone::GemFire::Cache::Generic::TransactionId^ get( ); + } + +#ifdef CSTX_COMMENTED + + /// + /// Returns the current transaction writer + /// + /// current transaction writer(ITransactionWriter) + generic + ITransactionWriter^ GetWriter (); + + /// + /// Set the ITransactionWriter for the cache + /// transaction writer + generic + void SetWriter (ITransactionWriter^ transactionWriter); + + /// + /// Adds a transaction listener to the end of the list of transaction listeners + /// on this cache. + /// + /// + /// the user defined transaction listener to add to the cache + /// + /// + /// If the parameter is null. + /// + generic + void AddListener(ITransactionListener^ aListener); + + /// + /// Removes a transaction listener from the list of transaction listeners on this cache. + /// Does nothing if the specified listener has not been added. + /// If the specified listener has been added then the close method of the listener will + /// be called. + /// + /// the transaction listener to remove from the cache. + /// + /// if the parameteris null + /// + generic + void RemoveListener(ITransactionListener^ aListener); + +#endif + + internal: + + inline static CacheTransactionManager^ Create( gemfire::InternalCacheTransactionManager2PC* nativeptr ) + { + return ( nativeptr != nullptr ? + gcnew CacheTransactionManager( nativeptr ) : nullptr ); + } + + + private: + + /// + /// Private constructor to wrap a native object pointer + /// + /// The native object pointer + inline CacheTransactionManager( gemfire::InternalCacheTransactionManager2PC* nativeptr ) + : SBWrap( nativeptr ) { } + }; + + } + } +} + } //namespace \ No newline at end of file http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheWriterAdapter.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/CacheWriterAdapter.hpp b/src/clicache/src/CacheWriterAdapter.hpp new file mode 100644 index 0000000..e9fd045 --- /dev/null +++ b/src/clicache/src/CacheWriterAdapter.hpp @@ -0,0 +1,65 @@ +/*========================================================================= + * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved. + * This product is protected by U.S. and international copyright + * and intellectual property laws. Pivotal products are covered by + * more patents listed at http://www.pivotal.io/patents. + *========================================================================= + */ + +#pragma once + +#include "gf_defs.hpp" +#include "ICacheWriter.hpp" + + +namespace GemStone +{ + namespace GemFire + { + namespace Cache { namespace Generic + { + + /// + /// Utility class that implements all methods in ICacheWriter + /// with empty implementations. Applications can subclass this class + /// and only override the methods for the events of interest. + /// + generic + public ref class CacheWriterAdapter + : public ICacheWriter + { + public: + virtual bool BeforeUpdate(EntryEvent^ ev) + { + return true; + } + + virtual bool BeforeCreate(EntryEvent^ ev) + { + return true; + } + + virtual bool BeforeDestroy(EntryEvent^ ev) + { + return true; + } + + virtual bool BeforeRegionDestroy(RegionEvent^ ev) + { + return true; + } + + virtual bool BeforeRegionClear(RegionEvent^ ev) + { + return true; + } + + virtual void Close(IRegion^ region) + { + } + }; + + } + } +} + } //namespace http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableArrayList.hpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/CacheableArrayList.hpp b/src/clicache/src/CacheableArrayList.hpp new file mode 100644 index 0000000..9770ace --- /dev/null +++ b/src/clicache/src/CacheableArrayList.hpp @@ -0,0 +1,87 @@ +/*========================================================================= + * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved. + * This product is protected by U.S. and international copyright + * and intellectual property laws. Pivotal products are covered by + * more patents listed at http://www.pivotal.io/patents. + *========================================================================= + */ + +#pragma once + +#include "gf_defs.hpp" +#include "CacheableVector.hpp" + + +using namespace System; +using namespace System::Collections::Generic; + +namespace GemStone +{ + namespace GemFire + { + namespace Cache { namespace Generic + { + /// + /// A mutable IGFSerializable vector wrapper that can serve as + /// a distributable object for caching. This class extends .NET generic + /// List class. + /// + ref class CacheableArrayList + : public CacheableVector + { + public: + /// + /// Allocates a new empty instance. + /// + inline CacheableArrayList(System::Collections::IList^ list) + : CacheableVector(list) + { } + + + /// + /// Static function to create a new empty instance. + /// + inline static CacheableArrayList^ Create() + { + return gcnew CacheableArrayList(gcnew System::Collections::Generic::List()); + } + + /// + /// Static function to create a new empty instance. + /// + inline static CacheableArrayList^ Create(System::Collections::IList^ list) + { + return gcnew CacheableArrayList(list); + } + + + // Region: IGFSerializable Members + + /// + /// Returns the classId of the instance being serialized. + /// This is used by deserialization to determine what instance + /// type to create and deserialize into. + /// + /// the classId + virtual property uint32_t ClassId + { + virtual uint32_t get() override + { + return GemFireClassIds::CacheableArrayList; + } + } + + // End Region: IGFSerializable Members + + /// + /// Factory function to register this class. + /// + static IGFSerializable^ CreateDeserializable() + { + return gcnew CacheableArrayList(gcnew System::Collections::Generic::List()); + } + }; + } + } +} + } //namespace