This is (hopefully) close to the final thing... I made some small
changes from Gordon's last proposal:

1. Added the DataHandle (Aka MessageHandle) which allows a data source
context so that the store may optimize its storage based on multiple
writes of the same data. This would be most common for messages, but is
also possible for events. I don't see a valid case for queues and
configurations (these being the remaining calls which accept data), but
I kept the paradigm the same for consistency. However, for simplicity,
it might be better to leave these as raw DataSource pointers. Comments?

2. In keeping with Gordon's pattern for handling this pattern, the data
source is now submitted to the createXXXHandle() calls for those that
require them.

3. Also in keeping with Gordon's pattern for EnqueuedMessageHandle
(where the Queue handle is supplied to the handle, not the submitXXX()
call, I have moved all the context handles to the handle factory. This
has the effect of making the submitXX() calls more consistent, taking
only the relevant handle, the callback and broker reference parameters.

4. I removed the raw pointers to handles. I assume we will implement a
Handle-like version of these, so that it is sufficient to pass refs.

If we decide we are getting close, I will cancel the previous
ReviewBoards and create a new one with this proposal; this can then be
used to get a final vote.

Comments welcome.

On Wed, 2012-02-29 at 07:29 +0000, Gordon Sim wrote:
> I don't think you do need store contexts passed back. I think an 
> optional broker provided callback context and a status object (to
> cover 
> both success and failure with the single callback) are sufficient.
> E.g. 
> as attached.
> 

/*
 *
 * 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.
 *
 */

#ifndef qpid_broker_AsyncStore_h_
#define qpid_broker_AsyncStore_h_

#include <stdint.h>
#include <string>

namespace qpid {

// This is probably not the correct forward declaration, but it allows this to compile.
namespace types {
namespace Variant {

class Map;

}} // namespace qpid::types::Variant

namespace broker {


//defined by broker implements qpid::messaging::Handle-type template to hide ref counting:
class BrokerContext;

//subclassed by broker:
class DataSource {
public:
    virtual ~DataSource() = 0;
    virtual uint64_t getSize() = 0;
    virtual void write(char* target) = 0;
};

//defined by store, all implement qpid::messaging::Handle-type template to hide ref counting:
class ConfigHandle;
class QueueHandle;
class TxnHandle;
class EventHandle;
class EnqueueHandle;
class DataHandle;

//callback definitions:
struct AsyncResult
{
    int errNo; /** 0 implies no error */
    std::string errMsg;
};
typedef void (*ResultCallback)(const AsyncResult&, BrokerContext*);

//subclassed by store:
class StoreAsyncInterface {
public:
    StoreAsyncInterface();
    virtual ~StoreAsyncInterface() = 0;

    // Factory methods for creating handles
    virtual DataHandle createDataHandle(DataSource*) = 0;
    virtual ConfigHandle createConfigHandle(DataHandle&) = 0;
    virtual QueueHandle createQueueHandle(DataHandle&, const std::string& name, const qpid::types::Variant::Map& opts) = 0;
    virtual TxnHandle createTxnHandle(const std::string& xid=std::string()) = 0;
    virtual EventHandle createEventHandle(DataHandle&, QueueHandle&, TxnHandle&) = 0;
    virtual EnqueueHandle createEnqueueHandle(DataHandle&, QueueHandle&, TxnHandle&) = 0;

    // Store async interface

    virtual void submitCreate(ConfigHandle&, ResultCallback, BrokerContext&) = 0;
    virtual void submitDestroy(ConfigHandle&, ResultCallback, BrokerContext&) = 0;

    virtual void submitCreate(QueueHandle&, ResultCallback, BrokerContext&) = 0;
    virtual void submitDestroy(QueueHandle&, ResultCallback, BrokerContext&) = 0;

    virtual void submitFlush(QueueHandle&, ResultCallback, BrokerContext&) = 0;

    virtual void submitPrepare(TxnHandle&, ResultCallback, BrokerContext&) = 0;
    virtual void submitCommit(TxnHandle&, ResultCallback, BrokerContext&) = 0;
    virtual void submitAbort(TxnHandle&, ResultCallback, BrokerContext&) = 0;

    virtual void submitRecord(EventHandle&, ResultCallback, BrokerContext&) = 0;

    virtual void submitEnqueue(EnqueueHandle&, ResultCallback, BrokerContext&) = 0;
    virtual void submitDequeue(EnqueueHandle&, ResultCallback, BrokerContext&) = 0;

    // Legacy - Restore FTD message, is NOT async!
    virtual int loadContent(DataHandle&, QueueHandle&, char* data, uint64_t offset, const uint64_t length) = 0;
};


}} // namespace qpid::broker

#endif // qpid_broker_AsyncStore_h_

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to