http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/ICacheWriter.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/ICacheWriter.hpp b/clicache/src/ICacheWriter.hpp new file mode 100644 index 0000000..ea02933 --- /dev/null +++ b/clicache/src/ICacheWriter.hpp @@ -0,0 +1,172 @@ +/* + * 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 "IRegion.hpp" +//#include "Region.hpp" + +#include "EntryEvent.hpp" +#include "RegionEvent.hpp" + +namespace Apache +{ + namespace Geode + { + namespace Client + { + + /// <summary> + /// An application plug-in that can be installed on a region. + /// Defines methods that are called <b>before</b> entry modification, + /// such as writing the value to a database. + /// </summary> + /// <remarks> + /// <para> + /// A distributed region will typically have a single cache writer. + /// If the application is designed such that all or most updates to + /// a region occur on a node, the cache writer for the region should + /// be installed at that node. + /// </para><para> + /// A cache writer is defined in the <see cref="RegionAttributes" />. + /// </para><para> + /// Cache writer invocations are initiated by the node where the entry or + /// region modification occurs. + /// </para><para> + /// Before a region is updated via a put, create, or destroy operation, + /// Geode will call an <c>ICacheWriter</c> that is installed anywhere in any + /// participating cache for that region, preferring a local <c>ICacheWriter</c> + /// if there is one. Usually there will be only one <c>ICacheWriter</c> in + /// the distributed system. If there are multiple <c>ICacheWriter</c>s + /// available in the distributed system, the Geode + /// implementation always prefers one that is stored locally, or else picks one + /// arbitrarily. In any case, only one <c>ICacheWriter</c> will be invoked. + /// </para><para> + /// The typical use for a <c>ICacheWriter</c> is to update a database. + /// Application writers should implement these methods to execute + /// application-specific behavior before the cache is modified. + /// </para> + /// <para> + /// Note that cache writer callbacks are synchronous callbacks and have the ability + /// to veto the cache update. Since cache writer invocations require communications + /// over the network, (especially if they are not co-located on the nodes where the + /// change occurs) the use of cache writers presents a performance penalty. + /// </para><para> + /// The <c>ICacheWriter</c> is capable of aborting the update to the cache by throwing + /// a <c>CacheWriterException</c>. This exception or any runtime exception + /// thrown by the <c>ICacheWriter</c> will abort the operation, and the + /// exception will be propagated to the initiator of the operation, regardless + /// of whether the initiator is in the same process as the <c>ICacheWriter</c>. + /// </para> + /// </remarks> + /// <seealso cref="AttributesFactory.SetCacheWriter" /> + /// <seealso cref="RegionAttributes.CacheWriter" /> + /// <seealso cref="ICacheLoader" /> + /// <seealso cref="ICacheListener" /> + generic <class TKey, class TValue> + public interface class ICacheWriter + { + public: + + /// <summary> + /// Called before an entry is updated. The entry update is initiated by a + /// <c>Put</c> or a <c>Get</c> that causes the loader to update an existing entry. + /// </summary> + /// <remarks> + /// The entry previously existed in the cache where the operation was + /// initiated, although the old value may have been null. The entry being + /// updated may or may not exist in the local cache where the CacheWriter is + /// installed. + /// </remarks> + /// <param name="ev"> + /// event object associated with updating the entry + /// </param> + /// <seealso cref="Region.Put" /> + /// <seealso cref="Region.Get" /> + bool BeforeUpdate(EntryEvent<TKey, TValue>^ ev); + + /// <summary> + /// Called before an entry is created. Entry creation is initiated by a + /// <c>Create</c>, a <c>Put</c>, or a <c>Get</c>. + /// </summary> + /// <remarks> + /// The <c>CacheWriter</c> can determine whether this value comes from a + /// <c>Get</c> or not from <c>Load</c>. The entry being + /// created may already exist in the local cache where this <c>CacheWriter</c> + /// is installed, but it does not yet exist in the cache where the operation was initiated. + /// </remarks> + /// <param name="ev"> + /// event object associated with creating the entry + /// </param> + /// <seealso cref="Region.Create" /> + /// <seealso cref="Region.Put" /> + /// <seealso cref="Region.Get" /> + bool BeforeCreate(EntryEvent<TKey, TValue>^ ev); + + /// <summary> + /// Called before an entry is destroyed. + /// </summary> + /// <remarks> + /// The entry being destroyed may or may + /// not exist in the local cache where the CacheWriter is installed. This method + /// is <em>not</em> called as a result of expiration or + /// <see cref="Region.LocalDestroyRegion" />. + /// </remarks> + /// <param name="ev"> + /// event object associated with destroying the entry + /// </param> + /// <seealso cref="Region.Destroy" /> + bool BeforeDestroy(EntryEvent<TKey, TValue>^ ev); + + /// <summary> + /// Called before this region is cleared. + /// </summary> + bool BeforeRegionClear(RegionEvent<TKey, TValue>^ ev); + + /// <summary> + /// Called before this region is destroyed. + /// </summary> + /// <param name="ev"> + /// event object associated with destroying the region + /// </param> + /// <seealso cref="Region.DestroyRegion" /> + bool BeforeRegionDestroy(RegionEvent<TKey, TValue>^ ev); + + /// <summary> + /// Called when the region containing this callback is destroyed, when + /// the cache is closed. + /// </summary> + /// <remarks> + /// <para> + /// Implementations should clean up any external + /// resources, such as database connections. Any runtime exceptions this method + /// throws will be logged. + /// </para><para> + /// It is possible for this method to be called multiple times on a single + /// callback instance, so implementations must be tolerant of this. + /// </para> + /// </remarks> + /// <param name="region">region to close</param> + /// <seealso cref="Cache.Close" /> + /// <seealso cref="Region.DestroyRegion" /> + void Close(IRegion<TKey, TValue>^ region); + }; + } // namespace Client + } // namespace Geode +} // namespace Apache +
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/ICacheableKey.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/ICacheableKey.hpp b/clicache/src/ICacheableKey.hpp new file mode 100644 index 0000000..3ca9514 --- /dev/null +++ b/clicache/src/ICacheableKey.hpp @@ -0,0 +1,67 @@ +/* + * 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 "IGeodeSerializable.hpp" + +using namespace System; + +namespace Apache +{ + namespace Geode + { + namespace Client + { + + /// <summary> + /// This interface class is the superclass of all user objects + /// in the cache that can be used as a key. + /// </summary> + /// <remarks> + /// If an implementation is required to act as a key in the cache, then + /// it must implement this interface and preferably override + /// <c>System.Object.ToString</c> to obtain proper string representation. + /// Note that this interface requires that the class overrides + /// <c>Object.GetHashCode</c>. Though this is not enforced, the default + /// implementation in <c>System.Object</c> is almost certainly incorrect + /// and will not work correctly. + /// </remarks> + public interface class ICacheableKey + : public IGeodeSerializable + { + public: + + /// <summary> + /// Get the hash code for this object. This is used in the internal + /// hash tables and so must have a nice distribution pattern. + /// </summary> + /// <returns> + /// The hashcode for this object. + /// </returns> + System::Int32 GetHashCode( ); + + /// <summary> + /// Returns true if this <c>ICacheableKey</c> matches the other. + /// </summary> + bool Equals( ICacheableKey^ other ); + }; + } // namespace Client + } // namespace Geode +} // namespace Apache + http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/ICqAttributes.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/ICqAttributes.hpp b/clicache/src/ICqAttributes.hpp new file mode 100644 index 0000000..b401b56 --- /dev/null +++ b/clicache/src/ICqAttributes.hpp @@ -0,0 +1,116 @@ +/* + * 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" + + +namespace Apache +{ + namespace Geode + { + namespace Client + { + + interface class CqListener; + + /// <summary> + /// An application plug-in that can be installed on a region. + /// Listener change notifications are invoked <c>after</c> + /// the change has occured. + /// </summary> + /// <remarks> + /// Listeners receive notifications when entries in a region change or changes occur to the + /// region attributes themselves. + /// <para> + /// A cache listener is defined in the <see cref="RegionAttributes" />. + /// </para> + /// The methods on a <c>ICacheListener</c> + /// are invoked asynchronously. Multiple events can cause concurrent invocation + /// of <c>ICacheListener</c> methods. If event A occurs before event B, + /// there is no guarantee that their corresponding <c>ICacheListener</c> + /// method invocations will occur in the same order. Any exceptions thrown by + /// the listener are caught by Geode and logged. + /// + /// Listeners are user callbacks that + /// are invoked by Geode. It is important to ensure that minimal work is done in the + /// listener before returning control back to Geode. For example, a listener + /// implementation may choose to hand off the event to a thread pool that then processes + /// the event on its thread rather than the listener thread + /// </remarks> + /// <seealso cref="AttributesFactory.SetCacheListener" /> + /// <seealso cref="RegionAttributes.CacheListener" /> + /// <seealso cref="ICacheLoader" /> + /// <seealso cref="ICacheWriter" /> + public interface class ICqListener + { + public: + + /// <summary> + /// Handles the event of a new key being added to a region. + /// </summary> + /// <remarks> + /// The entry did not previously exist in this region in the local cache + /// (even with a null value). + /// <para> + /// This function does not throw any exception. + /// </para> + /// </remarks> + /// <param name="ev"> + /// Denotes the event object associated with the entry creation. + /// </param> + /// <seealso cref="Region.Create" /> + /// <seealso cref="Region.Put" /> + /// <seealso cref="Region.Get" /> + void OnEvent(CqEvent^ ev); + + /// <summary> + /// Handles the event of an entry's value being modified in a region. + /// </summary> + /// <remarks> + /// This entry previously existed in this region in the local cache, + /// but its previous value may have been null. + /// </remarks> + /// <param name="ev"> + /// EntryEvent denotes the event object associated with updating the entry. + /// </param> + /// <seealso cref="Region.Put" /> + void OnError(CqEvent^ ev); + + + /// <summary> + /// Called when the region containing this callback is destroyed, when + /// the cache is closed. + /// </summary> + /// <remarks> + /// Implementations should clean up any external resources, + /// such as database connections. Any runtime exceptions this method + /// throws will be logged. + /// <para> + /// It is possible for this method to be called multiple times on a single + /// callback instance, so implementations must be tolerant of this. + /// </para> + /// </remarks> + /// <seealso cref="Cache.Close" /> + /// <seealso cref="Region.DestroyRegion" /> + void Close(); + }; + } // namespace Client + } // namespace Geode +} // namespace Apache + http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/ICqEvent.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/ICqEvent.hpp b/clicache/src/ICqEvent.hpp new file mode 100644 index 0000000..2f1bff0 --- /dev/null +++ b/clicache/src/ICqEvent.hpp @@ -0,0 +1,120 @@ +/* + * 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 "ICacheableKey.hpp" + +namespace Apache +{ + namespace Geode + { + namespace Client + { + + interface class IGeodeSerializable; + + + generic<class TKey, class TResult> + ref class CqQuery; + + interface class ICacheableKey; + /// <summary> + /// An application plug-in that can be installed on a region. + /// Listener change notifications are invoked <c>after</c> + /// the change has occured. + /// </summary> + /// <remarks> + /// Listeners receive notifications when entries in a region change or changes occur to the + /// region attributes themselves. + /// <para> + /// A cache listener is defined in the <see cref="RegionAttributes" />. + /// </para> + /// The methods on a <c>ICacheListener</c> + /// are invoked asynchronously. Multiple events can cause concurrent invocation + /// of <c>ICacheListener</c> methods. If event A occurs before event B, + /// there is no guarantee that their corresponding <c>ICacheListener</c> + /// method invocations will occur in the same order. Any exceptions thrown by + /// the listener are caught by Geode and logged. + /// + /// Listeners are user callbacks that + /// are invoked by Geode. It is important to ensure that minimal work is done in the + /// listener before returning control back to Geode. For example, a listener + /// implementation may choose to hand off the event to a thread pool that then processes + /// the event on its thread rather than the listener thread + /// </remarks> + /// <seealso cref="AttributesFactory.SetCacheListener" /> + /// <seealso cref="RegionAttributes.CacheListener" /> + /// <seealso cref="ICacheLoader" /> + /// <seealso cref="ICacheWriter" /> + generic<class TKey, class TResult> + public interface class ICqEvent + { + public: + + /// <summary> + /// Handles the event of a new key being added to a region. + /// </summary> + /// <remarks> + /// The entry did not previously exist in this region in the local cache + /// (even with a null value). + /// <para> + /// This function does not throw any exception. + /// </para> + /// </remarks> + /// <seealso cref="Region.Create" /> + /// <seealso cref="Region.Put" /> + /// <seealso cref="Region.Get" /> + CqQuery<TKey, TResult>^ getCq(); + + /// <summary> + /// Handles the event of an entry's value being modified in a region. + /// </summary> + /// <remarks> + /// This entry previously existed in this region in the local cache, + /// but its previous value may have been null. + /// </remarks> + /// <seealso cref="Region.Put" /> + CqOperationType getBaseOperation(); + + CqOperationType getQueryOperation(); + + /// <summary> + /// Called when the region containing this callback is destroyed, when + /// the cache is closed. + /// </summary> + /// <remarks> + /// Implementations should clean up any external resources, + /// such as database connections. Any runtime exceptions this method + /// throws will be logged. + /// <para> + /// It is possible for this method to be called multiple times on a single + /// callback instance, so implementations must be tolerant of this. + /// </para> + /// </remarks> + /// <seealso cref="Cache.Close" /> + /// <seealso cref="Region.DestroyRegion" /> + TKey /*Generic::ICacheableKey^*/ getKey(); + + TResult /*Object^*/ getNewValue(); + }; + } // namespace Client + } // namespace Geode +} // namespace Apache + http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/ICqListener.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/ICqListener.hpp b/clicache/src/ICqListener.hpp new file mode 100644 index 0000000..fbdaebc --- /dev/null +++ b/clicache/src/ICqListener.hpp @@ -0,0 +1,120 @@ +/* + * 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 "CqEvent.hpp" +using namespace System; +namespace Apache +{ + namespace Geode + { + namespace Client + { + + generic<class TKey, class TResult> + ref class CqEvent; + + /// <summary> + /// An application plug-in that can be installed on a region. + /// Listener change notifications are invoked <c>after</c> + /// the change has occured. + /// </summary> + /// <remarks> + /// Listeners receive notifications when entries in a region change or changes occur to the + /// region attributes themselves. + /// <para> + /// A cache listener is defined in the <see cref="RegionAttributes" />. + /// </para> + /// The methods on a <c>ICacheListener</c> + /// are invoked asynchronously. Multiple events can cause concurrent invocation + /// of <c>ICacheListener</c> methods. If event A occurs before event B, + /// there is no guarantee that their corresponding <c>ICacheListener</c> + /// method invocations will occur in the same order. Any exceptions thrown by + /// the listener are caught by Geode and logged. + /// + /// Listeners are user callbacks that + /// are invoked by Geode. It is important to ensure that minimal work is done in the + /// listener before returning control back to Geode. For example, a listener + /// implementation may choose to hand off the event to a thread pool that then processes + /// the event on its thread rather than the listener thread + /// </remarks> + /// <seealso cref="AttributesFactory.SetCacheListener" /> + /// <seealso cref="RegionAttributes.CacheListener" /> + /// <seealso cref="ICacheLoader" /> + /// <seealso cref="ICacheWriter" /> + //generic<class TKey, class TValue> + generic<class TKey, class TResult> + public interface class ICqListener + { + public: + + /// <summary> + /// Handles the event of a new key being added to a region. + /// </summary> + /// <remarks> + /// The entry did not previously exist in this region in the local cache + /// (even with a null value). + /// <para> + /// This function does not throw any exception. + /// </para> + /// </remarks> + /// <param name="ev"> + /// Denotes the event object associated with the entry creation. + /// </param> + /// <seealso cref="Region.Create" /> + /// <seealso cref="Region.Put" /> + /// <seealso cref="Region.Get" /> + void OnEvent(CqEvent<TKey, TResult>^ ev); + + /// <summary> + /// Handles the event of an entry's value being modified in a region. + /// </summary> + /// <remarks> + /// This entry previously existed in this region in the local cache, + /// but its previous value may have been null. + /// </remarks> + /// <param name="ev"> + /// EntryEvent denotes the event object associated with updating the entry. + /// </param> + /// <seealso cref="Region.Put" /> + //generic<class TKey, class TValue> + void OnError(CqEvent<TKey, TResult>^ ev); + + + /// <summary> + /// Called when the region containing this callback is destroyed, when + /// the cache is closed. + /// </summary> + /// <remarks> + /// Implementations should clean up any external resources, + /// such as database connections. Any runtime exceptions this method + /// throws will be logged. + /// <para> + /// It is possible for this method to be called multiple times on a single + /// callback instance, so implementations must be tolerant of this. + /// </para> + /// </remarks> + /// <seealso cref="Cache.Close" /> + /// <seealso cref="Region.DestroyRegion" /> + void Close(); + }; + } // namespace Client + } // namespace Geode +} // namespace Apache + http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/ICqResults.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/ICqResults.hpp b/clicache/src/ICqResults.hpp new file mode 100644 index 0000000..f8d737f --- /dev/null +++ b/clicache/src/ICqResults.hpp @@ -0,0 +1,52 @@ +/* + * 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/SelectResults.hpp> +#include "end_native.hpp" + + +#include "ISelectResults.hpp" + + +using namespace System; + +namespace Apache +{ + namespace Geode + { + namespace Client + { + + generic<class TResult> + ref class SelectResultsIterator; + + /// <summary> + /// Interface to encapsulate a select query result set. + /// </summary> + generic<class TResult> + public interface class ICqResults + : public ISelectResults<TResult> + { + }; + } // namespace Client + } // namespace Geode +} // namespace Apache + http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/ICqStatusListener.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/ICqStatusListener.hpp b/clicache/src/ICqStatusListener.hpp new file mode 100644 index 0000000..b623a68 --- /dev/null +++ b/clicache/src/ICqStatusListener.hpp @@ -0,0 +1,57 @@ +/* + * 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 "ICqListener.hpp" + +using namespace System; +namespace Apache +{ + namespace Geode + { + namespace Client + { + + /// <summary> + /// Extension of CqListener. Adds two new methods to CqListener, one that + /// is called when the cq is connected and one that is called when + /// the cq is disconnected. + /// </summary> + + generic<class TKey, class TResult> + public interface class ICqStatusListener : public ICqListener<TKey, TResult> + { + public: + + /// <summary> + /// Called when the cq loses connection with all servers. + /// </summary> + virtual void OnCqDisconnected(); + + /// <summary> + /// Called when the cq establishes a connection with a server + /// </summary> + virtual void OnCqConnected(); + + }; + } // namespace Client + } // namespace Geode +} // namespace Apache + http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/IFixedPartitionResolver.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/IFixedPartitionResolver.hpp b/clicache/src/IFixedPartitionResolver.hpp new file mode 100644 index 0000000..18962ee --- /dev/null +++ b/clicache/src/IFixedPartitionResolver.hpp @@ -0,0 +1,96 @@ +/* + * 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 "IPartitionResolver.hpp" + +//using System::Collections::Generics; + +namespace Apache +{ + namespace Geode + { + namespace Client + { + + interface class IGeodeSerializable; + /// <summary> + /// Implementers of interface <code>FixedPartitionResolver</code> helps to + /// achieve explicit mapping of a "user defined" partition to a data member node. + /// </summary> + /// <remarks> + /// <p> + /// Geode uses the partition name returned by + /// {@link FixedPartitionResolver#getPartitionName(EntryEvent, CacheableHashSet)} + /// to determine on which member the data is being managed. Say, for example, you want to + /// partition all Trades according to quarters. You can implement + /// FixedPartitionResolver to get the name of the quarter based on the date given + /// as part of {@link EntryEvent}. + /// </p> + /// + /// public class QuarterPartitionResolver implements FixedPartitionResolver{<br> + ///     public String getPartitionName(EntryOperation opDetails, CacheableHashSet + /// allAvailablePartitions) {<br> + ///     Date date = sdf.parse((String)opDetails.getKey());<br> + ///     Calendar cal = Calendar.getInstance();<br> + ///     cal.setTime(date);<br> + ///     int month = cal.get(Calendar.MONTH);<br> + ///     if (month == 0 || month == 1 || month == 2) {<br> + ///       return "Quarter1";<br> + ///     }<br> + ///     else if (month == 3 || month == 4 || month == 5) {<br> + ///       return "Quarter2";<br> + ///     }<br> + ///     else if (month == 6 || month == 7 || month == 8) {<br> + ///       return "Quarter3";<br> + ///     }<br> + ///     else if (month == 9 || month == 10 || month == 11) {<br> + ///       return "Quarter4";<br> + ///     }<br> + ///     else {<br> + ///       return "Invalid Quarter";<br> + ///     }<br> + ///   }<br> + /// + /// @see PartitionResolver + /// + /// </remarks> + /// <seealso cref="AttributesFactory.SetPartitionResolver" /> + /// <seealso cref="RegionAttributes.PartitionResolver" /> + generic<class TKey, class TValue> + public interface class IFixedPartitionResolver : public IPartitionResolver<TKey, TValue> + { + public: + + /// <summary> + /// This method is used to get the name of the partition for the given entry + /// operation. + /// </summary> + /// <param name="opDetails"> + /// the details of the entry event e.g. {@link Region#get(Object)} + /// </param> + /// <return> partition-name associated with node which allows mapping of given + /// data to user defined partition + /// </return> + String^ GetPartitionName(EntryEvent<TKey, TValue>^ opDetails); + }; + } // namespace Client + } // namespace Geode +} // namespace Apache + http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/IGeodeCache.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/IGeodeCache.hpp b/clicache/src/IGeodeCache.hpp new file mode 100644 index 0000000..69bf539 --- /dev/null +++ b/clicache/src/IGeodeCache.hpp @@ -0,0 +1,110 @@ +/* + * 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 "IRegionService.hpp" +#include "DistributedSystem.hpp" +#include "CacheTransactionManager.hpp" +using namespace System; +using namespace System::Collections::Generic; + +namespace Apache +{ + namespace Geode + { + namespace Client + { + + /// <summary> + /// GeodeCache represents the singleton cache that must be created + /// in order to connect to Geode server. + /// </summary> + /// <remarks> + /// Caches are obtained from Crest methods on the + /// <see cref="CacheFactory.Create"/> class. + /// <para> + /// When a cache is created a <see cref="DistributedSystem" /> + /// must be specified. + /// </para><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 interface class IGeodeCache : IRegionService + { + public: + + /// <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> + property String^ Name + { + String^ get(); + } + + /// <summary> + /// Initializes the cache from an XML file. + /// </summary> + /// <param name="cacheXml">pathname of a <c>cache.xml</c> file</param> + void InitializeDeclarativeCache(String^ cacheXml); + + /// <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> + property DistributedSystem^ DistributedSystem + { + Apache::Geode::Client::DistributedSystem^ get(); + } + + /// <summary> + /// Returns the cache transaction manager of + /// <see cref="CacheFactory.Create" /> this cache. + /// </summary> + property Apache::Geode::Client::CacheTransactionManager^ CacheTransactionManager + { + Apache::Geode::Client::CacheTransactionManager^ get(); + } + + ///<summary> + /// Returns whether Cache saves unread fields for Pdx types. + ///</summary> + bool GetPdxIgnoreUnreadFields(); + + ///<summary> + /// Returns whether { @link PdxInstance} is preferred for PDX types instead of .NET object. + ///</summary> + bool GetPdxReadSerialized(); + }; + } // namespace Client + } // namespace Geode +} // namespace Apache + http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/IGeodeDelta.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/IGeodeDelta.hpp b/clicache/src/IGeodeDelta.hpp new file mode 100644 index 0000000..25832a3 --- /dev/null +++ b/clicache/src/IGeodeDelta.hpp @@ -0,0 +1,78 @@ +/* + * 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" + + +namespace Apache +{ + namespace Geode + { + namespace Client + { + + ref class DataOutput; + ref class DataInput; + ref class Serializable; + + /// <summary> + /// This interface is used for delta propagation. + /// To use delta propagation, an application class must implement interfaces <c>IGeodeDelta</c> as well as <c>IGeodeSerializable</c>. + /// The <c>IGeodeDelta</c> interface methods <c>HasDelta( ), ToDelta( )</c> and <c>FromDelta( )</c> must be implemented by the class, as these methods are used by Geode + /// to detect the presence of delta in an object, to serialize the delta, and to apply a serialized delta to an existing object + /// of the class. + /// If a customized cloning method is required, the class must also implement the interface <c>System.ICloneable</c>. + /// To use cloning in delta propagation for a region, the region attribute for cloning must be enabled. + /// </summary> + public interface class IGeodeDelta + { + public: + + /// <summary> + /// Writes out delta information to out in a user-defined format. This is + /// invoked on an application object after Geode determines the presence + /// of delta in it by calling <c>HasDelta()</c> on the object. + /// </summary> + /// <exception cref="GeodeIOException"> + /// </exception> + void ToDelta(DataOutput^ out); + + /// <summary> + /// Reads in delta information to this object in a user-defined format. This is + /// invoked on an existing application object after Geode determines the + /// presence of delta in <c>DataInput</c> instance. + /// </summary> + /// <exception cref="InvalidDeltaException"> + /// if the delta in the <c>DataInput</c> instance cannot be applied + /// to this instance (possible causes may include mismatch of Delta version or logic error). + /// </exception> + /// <exception cref="GeodeIOException"> + /// </exception> + void FromDelta(DataInput^ in); + + /// <summary> + /// <c>HasDelta( )</c> is invoked by Geode during <c>Region.Put( ICacheableKey, IGeodeSerializable )</c> to determine if the object contains a delta. + /// If <c>HasDelta( )</c> returns true, the delta in the object is serialized by invoking <c>ToDelta( DataOutput )</c>. + /// If <c>HasDelta( )</c> returns false, the object is serialized by invoking <c>IGeodeSerializable.ToData( DataOutput )</c>. + /// </summary> + bool HasDelta(); + }; + } // namespace Client + } // namespace Geode +} // namespace Apache + http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/IGeodeSerializable.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/IGeodeSerializable.hpp b/clicache/src/IGeodeSerializable.hpp new file mode 100644 index 0000000..c21946f --- /dev/null +++ b/clicache/src/IGeodeSerializable.hpp @@ -0,0 +1,105 @@ +/* + * 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/geode_types.hpp> +#include "end_native.hpp" + +using namespace System; + +namespace Apache +{ + namespace Geode + { + namespace Client + { + + ref class DataOutput; + ref class DataInput; + ref class Serializable; + + /// <summary> + /// This interface class is the superclass of all user objects + /// in the cache that can be serialized. + /// </summary> + public interface class IGeodeSerializable + { + public: + + /// <summary> + /// Serializes this object. + /// </summary> + /// <param name="output"> + /// the DataOutput object to use for serializing the object + /// </param> + void ToData( DataOutput^ output ); + + //bool HasDelta(); + + /// <summary> + /// Deserialize this object, typical implementation should return + /// the 'this' pointer. + /// </summary> + /// <param name="input"> + /// the DataInput stream to use for reading the object data + /// </param> + /// <returns>the deserialized object</returns> + IGeodeSerializable^ FromData( DataInput^ input ); + + /// <summary> + /// Get the size of this object in bytes. + /// This is only needed if you use the HeapLRU feature. + /// </summary> + /// <remarks> + /// Note that you can simply return zero if you are not using the HeapLRU feature. + /// </remarks> + /// <returns>the size of this object in bytes.</returns> + property System::UInt32 ObjectSize + { + System::UInt32 get( ); + } + + /// <summary> + /// Returns the classId of the instance being serialized. + /// This is used by deserialization to determine what instance + /// type to create and deserialize into. + /// </summary> + /// <remarks> + /// The classId must be unique within an application suite + /// and in the range 0 to ((2^31)-1) both inclusive. An application can + /// thus define upto 2^31 custom <c>IGeodeSerializable</c> classes. + /// Returning a value greater than ((2^31)-1) may result in undefined + /// behaviour. + /// </remarks> + /// <returns>the classId</returns> + property System::UInt32 ClassId + { + System::UInt32 get( ); + } + + /// <summary> + /// Return a string representation of the object. + /// </summary> + String^ ToString( ); + }; + } // namespace Client + } // namespace Geode +} // namespace Apache + http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/IPartitionResolver.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/IPartitionResolver.hpp b/clicache/src/IPartitionResolver.hpp new file mode 100644 index 0000000..ae3127f --- /dev/null +++ b/clicache/src/IPartitionResolver.hpp @@ -0,0 +1,108 @@ +/* + * 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 "ICacheableKey.hpp" + +#include "EntryEvent.hpp" + +namespace Apache +{ + namespace Geode + { + namespace Client + { + + interface class IGeodeSerializable; + + + /// <summary> + /// Implementers of interface <code>PartitionResolver</code> enable custom + /// partitioning on the <code>PartitionedRegion</code>. + /// </summary> + /// <remarks> + /// 1. The Key class or callback arg can implement PartitionResolver interface to + /// enable custom partitioning OR + /// 2. Configure your own PartitionResolver class in partition attributes (For + /// instance when the Key is a primitive type or String) Implement the + /// appropriate equals - For all implementations, you need to be sure to code the + /// class equals method so it properly verifies equality for the + /// PartitionResolver implementation. This might mean verifying that class names + /// are the same or that the returned routing objects are the same etc.. When you + /// initiate the partitioned region on multiple nodes, Geode uses the equals + /// method to ensure you are using the same PartitionResolver implementation for + /// all of the nodes for the region. + /// Geode uses the routing object's hashCode to determine where the data is + /// being managed. Say, for example, you want to colocate all Trades by month and + /// year.The key is implemented by TradeKey class which also implements the + /// PartitionResolver interface. + /// public class TradeKey implements PartitionResolver {<br> + ///     private String tradeID;<br> + ///     private Month month ;<br> + ///     private Year year ;<br> + /// + ///     public TradingKey(){ } <br> + ///     public TradingKey(Month month, Year year){<br> + ///         this.month = month;<br> + ///         this.year = year;<br> + ///     } <br> + ///     public Serializable getRoutingObject(EntryOperation key){<br> + ///         return this.month + this.year;<br> + ///     }<br> }<br> + /// + /// In the example above, all trade entries with the same month and year are + /// guaranteed to be colocated. + /// </remarks> + /// <seealso cref="AttributesFactory.SetPartitionResolver" /> + /// <seealso cref="RegionAttributes.PartitionResolver" /> + generic<class TKey, class TValue> + public interface class IPartitionResolver + { + public: + + /// <summary> + /// Returns the name of the PartitionResolver. + /// </summary> + /// <remarks> + /// <para> + /// This function does not throw any exception. + /// </para> + /// <returns> + /// the name of the PartitionResolver + /// </returns> + /// </remarks> + String^ GetName(); + + /// <summary> + /// return object associated with entry event which allows the Partitioned Region to store associated data together. + /// </summary> + /// <remarks> + /// throws RuntimeException - any exception thrown will terminate the operation and the exception will be passed to the + /// calling thread. + /// </remarks> + /// <param name="key"> + /// key the detail of the entry event. + /// </param> + + Object^ GetRoutingObject(EntryEvent<TKey, TValue>^ key); + }; + } // namespace Client + } // namespace Geode +} // namespace Apache + http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/IPdxInstance.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/IPdxInstance.hpp b/clicache/src/IPdxInstance.hpp new file mode 100755 index 0000000..dee3cd0 --- /dev/null +++ b/clicache/src/IPdxInstance.hpp @@ -0,0 +1,185 @@ +/* + * 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 "IWritablePdxInstance.hpp" +using namespace System; +using namespace System::Collections::Generic; +namespace Apache +{ + namespace Geode + { + namespace Client + { + + /// <summary> + ///PdxInstance provides run time access to the fields of a PDX without + ///deserializing the PDX. Preventing deserialization saves time + ///and memory and does not require the domain class. + ///This interface is implemented by NativeClient. The PdxInstance implementation + ///is a light weight wrapper that simply refers to the raw bytes of the PDX + ///that are kept in the cache. + ///Applications can choose to access PdxInstances instead of .NET objects by + ///configuring the Cache to prefer PDX instances during deserialization. + ///This can be done in <c>cache.xml</c> by setting the attribute <c>read-serialized</c> + ///to true on the <c>pdx</c> element. Or it can be done programmatically using + ///the <see cref="CacheFactory.SetPdxReadSerialized" /> + ///method. Once this preference is configured, then any time deserialization of a + ///PDX is done it will deserialize into a PdxInstance. + ///PdxInstance are immutable. If you want to change one call + ///<see cref="IPdxInstance.CreateWriter"/>. + /// + /// </summary> + public interface class IPdxInstance : IDisposable + { + public: + /// <summary> + ///Return the full name of the class that this pdx instance represents. + /// </summary> + ///<returns> the name of the class that this pdx instance represents.</returns> + String^ GetClassName(); + /// <summary> + ///Deserializes and returns the domain object that this instance represents. + /// </summary> + ///<returns> the deserialized domain object.</returns> + Object^ GetObject(); + + /// <summary> + ///Checks if the named field exists and returns the result. + ///This can be useful when writing code that handles more than one version of + ///a PDX class. + /// </summary> + ///<param> fieldName the name of the field to check</param> + ///<returns> <code>true</code> if the named field exists; otherwise <code>false</code></returns> + + bool HasField(String^ fieldName); + + /// <summary> + ///Return an list of the field names on this PdxInstance. + /// </summary> + ///<returns> an list of the field names on this PdxInstance</returns> + IList<String^>^ GetFieldNames(); + + /// <summary> + ///Checks if the named field was <see cref="IPdxWriter.MarkIdentityField" /> marked as an identity field. + ///Note that if no fields have been marked then all the fields are used as identity fields even though + ///this method will return <code>false</code> since none of them have been marked. + /// </summary> + ///<param name="fieldName"> the name of the field to check</param> + ///<returns> <code>true</code> if the named field exists and was marked as an identify field; otherwise <code>false</code></returns> + + bool IsIdentityField(String^ fieldName); + + /// <summary> + ///Reads the named field and returns its value. If the field does + ///not exist <code>null</code> is returned. + ///A <code>null</code> result indicates that the field does not exist + ///or that it exists and its value is currently <code>null</code>. + ///The <see cref="HasField" /> method can be used to figure out + ///which if these two cases is true. + ///If an Object[] is deserialized by this call then that array's component + ///type will be <code>Object</code> instead of the original class that + ///the array had when it was serialized. This is done so that PdxInstance objects + ///can be added to the array. + /// </summary> + /// + ///<param name="fieldName"> name of the field to read</param> + /// + /// + ///<returns> If this instance has the named field then the field's value is returned, + ///otherwise <code>null</code> is returned.</returns> + + Object^ GetField(String^ fieldName); + + /// <summary> + ///Returns true if the given object is equals to this instance. + ///If <code>other</code> is not a PdxInstance then it is not equal to this instance. + ///NOTE: Even if <code>other</code> is the result of calling <see cref="GetObject" /> it will not + ///be equal to this instance. + ///Otherwise equality of two PdxInstances is determined as follows: + /// <list type="bullet"> + /// <item> + ///<description>The domain class name must be equal for both PdxInstances</description> + /// </item> + /// <item> + ///<description>Each identity field must be equal.</description> + /// </item> + /// </list> + ///If one of the instances does not have a field that the other one does then equals will assume it + ///has the field with a default value. + ///If a PdxInstance has marked identity fields using <see cref="IPdxWriter.MarkIdentityField" /> + ///then only the marked identity fields are its identity fields. + ///Otherwise all its fields are identity fields. + ///An identity field is equal if all the following are true: + /// <list type="bullet"> + /// <item> + ///<description>The field name is equal.</description> + /// </item> + /// <item> + ///<description>The field type is equal.</description> + /// </item> + /// <item> + ///<description>The field value is equal.</description> + /// </item> + /// </list> + ///If a field's type is <code>OBJECT</code> then its value must be deserialized to determine if it is equals. If the deserialized object is an array then all the array element is used to determine equality. Otherwise <see cref="Object.Equals" /> is used. + ///If a field's type is <code>OBJECT[]</code> then its value must be deserialized and all the array element is used to determine equality. + ///For all other field types then the value does not need to be deserialized. Instead the serialized raw bytes are compared and used to determine equality. + ///Note that any fields that have objects that do not override <see cref="Object.Equals" /> will cause equals to return false when you might have expected it to return true. + /// </summary> + ///<param name="other"> the other instance to compare to this.</param> + ///<returns> <code>true</code> if this instance is equal to <code>other</code>.</returns> + + bool Equals(Object^ other); + + /// <summary> + ///Generates a hashCode based on the identity fields of + ///this PdxInstance. + ///If a PdxInstance has marked identity fields using <see cref="IPdxWriter.MarkIdentityField" /> + ///then only the marked identity fields are its identity fields. + ///Otherwise all its fields are identity fields. + /// + ///If an identity field is of type <code>OBJECT</code> then it is deserialized. If the deserialized object is an array then all the array element is used. Otherwise <see cref="Object.GetHashCode" /> is used. + ///If an identity field is of type <code>OBJECT[]</code> this it is deserialized and all the array element is used. + ///Otherwise the field is not deserialized and the raw bytes of its value are used to compute the hash code. + /// </summary> + int GetHashCode(); + + /// <summary> + ///Prints out all of the identity fields of this PdxInstance. + ///If a PdxInstance has marked identity fields using <see cref="IPdxWriter.MarkIdentityField" /> + ///then only the marked identity fields are its identity fields. + ///Otherwise all its fields are identity fields. + /// </summary> + String^ ToString(); + + /// <summary> + ///Creates and returns a <see cref="IWritablePdxInstance"/> whose initial + ///values are those of this PdxInstance. + ///This call returns a copy of the current field values so modifications + ///made to the returned value will not modify this PdxInstance. + /// </summary> + /// + ///<returns> a <see cref="IWritablePdxInstance"/></returns> + + IWritablePdxInstance^ CreateWriter(); + + }; + } // namespace Client + } // namespace Geode +} // namespace Apache + http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/IPdxInstanceFactory.hpp ---------------------------------------------------------------------- diff --git a/clicache/src/IPdxInstanceFactory.hpp b/clicache/src/IPdxInstanceFactory.hpp new file mode 100644 index 0000000..64f9d18 --- /dev/null +++ b/clicache/src/IPdxInstanceFactory.hpp @@ -0,0 +1,346 @@ +/* + * 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 "IPdxInstance.hpp" +using namespace System; +using namespace System::Collections::Generic; +namespace Apache +{ + namespace Geode + { + namespace Client + { + + /// <summary> + /// PdxInstanceFactory gives you a way to create PdxInstances. + /// Call the write methods to populate the field data and then call <see cref="Create"/> + /// to produce an actual instance that contains the data. + /// To create a factory call <see cref="IRegionService.CreatePdxInstanceFactory"/>. + /// A factory can only create a single instance. To create multiple instances create + /// multiple factories or use <see cref="IPdxInstance.CreateWriter" /> to create subsequent instances. + /// + /// </summary> + public interface class IPdxInstanceFactory + { + public: + /// <summary> + /// Create a <see cref="IPdxInstance" /> . The instance + /// will contain any data written to this factory + /// using the write methods. + /// </summary> + /// <returns> the created instance</returns> + /// <exception cref="IllegalStateException"/> if called more than once </exception> + + IPdxInstance^ Create(); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>char</code>. + /// <para>Java char is mapped to .NET System.Char.</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + + IPdxInstanceFactory^ WriteChar(String^ fieldName, Char value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>boolean</code>. + /// <para>Java boolean is mapped to .NET System.Boolean.</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + + IPdxInstanceFactory^ WriteBoolean(String^ fieldName, Boolean value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>sbyte</code>. + /// <para>Java byte is mapped to .NET System.SByte.</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + + IPdxInstanceFactory^ WriteByte(String^ fieldName, SByte value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>short</code>. + /// <para>Java short is mapped to .NET System.Int16.</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + IPdxInstanceFactory^ WriteShort(String^ fieldName, Int16 value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>int</code>. + /// <para>Java int is mapped to .NET System.Int32.</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + IPdxInstanceFactory^ WriteInt(String^ fieldName, Int32 value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>long</code>. + /// <para>Java long is mapped to .NET System.Int64.</para> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + /// </summary> + IPdxInstanceFactory^ WriteLong(String^ fieldName, Int64 value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>float</code>. + /// <para>Java float is mapped to .NET System.Single(float).</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + + IPdxInstanceFactory^ WriteFloat(String^ fieldName, float value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>double</code>. + /// <para>Java double is mapped to .NET System.Double.</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + IPdxInstanceFactory^ WriteDouble(String^ fieldName, double value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>Date</code>. + /// <para>Java Date is mapped to .NET System.DateTime.</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + + IPdxInstanceFactory^ WriteDate(String^ fieldName, System::DateTime value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>String</code>. + /// <para>Java String is mapped to .NET System.String.</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + IPdxInstanceFactory^ WriteString(String^ fieldName, String^ value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>Object</code>. + /// + /// It is best to use one of the other writeXXX methods if your field type + /// will always be XXX. This method allows the field value to be anything + /// that is an instance of Object. This gives you more flexibility but more + /// space is used to store the serialized field. + /// </summary> + /// + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + + IPdxInstanceFactory^ WriteObject(String^ fieldName, Object^ value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>boolean[]</code>. + /// <para>Java boolean[] is mapped to .NET System.Boolean[].</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + + IPdxInstanceFactory^ WriteBooleanArray(String^ fieldName, array<Boolean>^ value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>char[]</code>. + /// <para>Java char[] is mapped to .NET System.Char[].</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + IPdxInstanceFactory^ WriteCharArray(String^ fieldName, array<Char>^ value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>byte[]</code>. + /// <para>Java byte[] is mapped to .NET System.Byte[].</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + IPdxInstanceFactory^ WriteByteArray(String^ fieldName, array<Byte>^ value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>short[]</code>. + /// <para>Java short[] is mapped to .NET System.Int16[].</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + IPdxInstanceFactory^ WriteShortArray(String^ fieldName, array<Int16>^ value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>int[]</code>. + /// <para>Java int[] is mapped to .NET System.Int32[].</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + IPdxInstanceFactory^ WriteIntArray(String^ fieldName, array<Int32>^ value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>long[]</code>. + /// <para>Java long[] is mapped to .NET System.Int64[].</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + IPdxInstanceFactory^ WriteLongArray(String^ fieldName, array<Int64>^ value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>float[]</code>. + /// <para>Java float[] is mapped to .NET System.Single[] or float[].</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + /// </summary> + IPdxInstanceFactory^ WriteFloatArray(String^ fieldName, array<float>^ value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>double[]</code>. + /// <para>Java double[] is mapped to .NET System.Double[].</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + IPdxInstanceFactory^ WriteDoubleArray(String^ fieldName, array<double>^ value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>String[]</code>. + /// <para>Java String[] is mapped to .NET System.String[].</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + IPdxInstanceFactory^ WriteStringArray(String^ fieldName, array<String^>^ value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>Object[]</code>. + /// Java Object[] is mapped to .NET System.Collections.Generic.List<Object>. + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + + IPdxInstanceFactory^ WriteObjectArray(String^ fieldName, System::Collections::Generic::List<Object^>^ value); + + /// <summary> + /// Writes the named field with the given value to the serialized form. + /// The fields type is <code>byte[][]</code>. + /// <para>Java byte[][] is mapped to .NET System.Byte[][].</para> + /// </summary> + /// <param name="fieldName"> the name of the field to write</param> + /// <param name="value"> the value of the field to write</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + IPdxInstanceFactory^ WriteArrayOfByteArrays(String^ fieldName, array<array<Byte>^>^ value); + + /// <summary> + /// Writes the named field with the given value and type to the serialized form. + /// This method uses the <code>fieldType</code> to determine which writeXXX method it should call. + /// If it can not find a specific match to a writeXXX method it will call <see cref="WriteObject" />. + /// This method may serialize objects that are not portable to non-java languages. + /// <para>The fieldTypes maps to a specific method.</para> + /// <param name="fieldName"> the name of the field to write</param> + /// <summary> + /// @param fieldValue the value of the field to write; this parameter's class must extend the <code>fieldType</code> + /// @param fieldType the type of the field to write + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has already been written</exception> + + IPdxInstanceFactory^ WriteField(String^ fieldName, Object^ fieldValue, Type^ fieldType); + + /// <summary> + /// Indicate that the named field should be included in hashCode and equals checks + /// of this object on a server that is accessing <see cref="IPdxInstance" /> + /// or when a client executes a query on a server. + /// + /// The fields that are marked as identity fields are used to generate the hashCode and + /// equals methods of {@link PdxInstance}. Because of this, the identity fields should themselves + /// either be primitives, or implement hashCode and equals. + /// + /// If no fields are set as identity fields, then all fields will be used in hashCode and equals + /// checks. + /// + /// The identity fields should make marked after they are written using a write/// method. + /// </summary> + /// <param name="fieldName"> the name of the field to mark as an identity field.</param> + /// <returns> this PdxInstanceFactory</returns> + /// <exception cref="IllegalStateException"/> if the named field has not already been written.</exception> + + IPdxInstanceFactory^ MarkIdentityField(String^ fieldName); + + }; + } // namespace Client + } // namespace Geode +} // namespace Apache +