Oracle Coherence for C++ API
Release 3.6.0.0

E15728-01

coherence/util/aggregator/PriorityAggregator.hpp

00001 /*
00002 * PriorityAggregator.hpp
00003 *
00004 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
00005 *
00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
00007 * affiliates.
00008 *
00009 * This software is the confidential and proprietary information of Oracle
00010 * Corporation. You shall not disclose such confidential and proprietary
00011 * information and shall use it only in accordance with the terms of the
00012 * license agreement you entered into with Oracle.
00013 *
00014 * This notice may not be removed or altered.
00015 */
00016 #ifndef COH_PRIORITY_AGGREGATOR_HPP
00017 #define COH_PRIORITY_AGGREGATOR_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/io/pof/PofReader.hpp"
00022 #include "coherence/io/pof/PofWriter.hpp"
00023 #include "coherence/net/AbstractPriorityTask.hpp"
00024 #include "coherence/util/InvocableMap.hpp"
00025 
00026 COH_OPEN_NAMESPACE3(coherence,util,aggregator)
00027 
00028 using coherence::io::pof::PofReader;
00029 using coherence::io::pof::PofWriter;
00030 using coherence::net::AbstractPriorityTask;
00031 
00032 
00033 /**
00034 * PriorityAggregator is used to explicitly control the scheduling priority
00035 * and timeouts for execution of EntryAggregator-based methods.
00036 *
00037 * For example, let's assume that there is an <i>Orders</i> cache that belongs
00038 * to a partitioned cache service configured with a <i>request-timeout</i> and
00039 * <i>task-timeout</i> of 5 seconds.
00040 * Also assume that we are willing to wait longer for a particular
00041 * aggregation request that scans the entire cache. Then we could override the
00042 * default timeout values by using the PriorityAggregator as follows:
00043 * <pre>
00044 *   Float64Average::Handle aggrStandard =
00045 *           Float64Average::create(ReflectionExtractor::create("getPrice"));
00046 *   PriorityAggregator::Handle aggrPriority =
00047 *           PriorityAggregator::create(aggrStandard);
00048 *   aggrPriority->setExecutionTimeoutMillis(PriorityTask::TIMEOUT_NONE);
00049 *   aggrPriority->setRequestTimeoutMillis(PriorityTask::TIMEOUT_NONE);
00050 *   cacheOrders->aggregate(NULL, aggrPriority);
00051 * </pre>
00052 *
00053 * This is an advanced feature which should be used judiciously.
00054 *
00055 * @author djl  2008.05.16
00056 */
00057 class COH_EXPORT PriorityAggregator
00058     : public class_spec<PriorityAggregator,
00059         extends<AbstractPriorityTask>,
00060         implements<InvocableMap::ParallelAwareAggregator> >
00061     {
00062     friend class factory<PriorityAggregator>;
00063 
00064     // ----- constructors ---------------------------------------------------
00065 
00066     protected:
00067         /**
00068         * Default constructor (necessary for the PortableObject interface).
00069         */
00070         PriorityAggregator();
00071 
00072         /**
00073         * Construct a PriorityAggregator.
00074         *
00075         * @param hAggregator  the aggregator wrapped by this
00076         *                     PriorityAggregator
00077         */
00078         PriorityAggregator(
00079                 InvocableMap::ParallelAwareAggregator::Handle hAggregator);
00080 
00081 
00082     // ----- InvocableMap::EntryAggregator interface ------------------------
00083 
00084     public:
00085         /**
00086         * {@inheritDoc}
00087         */
00088         virtual Object::Holder aggregate(Set::View vSetEntries);
00089 
00090         /**
00091         * {@inheritDoc}
00092         */
00093         virtual InvocableMap::EntryAggregator::Handle
00094                 getParallelAggregator();
00095 
00096         /**
00097         * {@inheritDoc}
00098         */
00099         virtual Object::Holder aggregateResults(
00100                 Collection::View vCollResults);
00101 
00102 
00103     // ----- PortableObject interface ---------------------------------------
00104 
00105     public:
00106         /**
00107         * {@inheritDoc}
00108         */
00109         virtual void readExternal(PofReader::Handle hIn);
00110 
00111         /**
00112         * {@inheritDoc}
00113         */
00114         virtual void writeExternal(PofWriter::Handle hOut) const;
00115 
00116 
00117     // ----- Object interface -----------------------------------------------
00118 
00119     public:
00120         /**
00121         * {@inheritDoc}
00122         */
00123         virtual void toStream(std::ostream& out) const;
00124 
00125 
00126     // ----- data member accessors ------------------------------------------
00127 
00128     public:
00129         /**
00130         * Obtain the underlying aggregator.
00131         *
00132         * @return the aggregator wrapped by this PriorityAggregator
00133         */
00134         virtual InvocableMap::ParallelAwareAggregator::Handle
00135                 getAggregator();
00136 
00137         /**
00138         * Obtain the underlying aggregator.
00139         *
00140         * @return the aggregator wrapped by this PriorityAggregator
00141         */
00142         virtual InvocableMap::ParallelAwareAggregator::View
00143                  getAggregator() const;
00144 
00145 
00146     // ----- data members ---------------------------------------------------
00147 
00148     private:
00149         /**
00150         * The wrapped aggregator.
00151         */
00152         MemberHandle<InvocableMap::ParallelAwareAggregator> m_hAggregator;
00153     };
00154 
00155 COH_CLOSE_NAMESPACE3
00156 
00157 #endif // COH_PRIORITY_AGGREGATOR_HPP
Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.