Commit 829cac98 authored by Andrei Pavel's avatar Andrei Pavel Committed by Tomek Mrugalski

fixed issues and refactored cassandra backend

parent c629300a
......@@ -97,6 +97,9 @@ We have received the following contributions:
- Angelo Failla, Facebook
2016-04: Fixes for transaction id generation in perfdhcp
- Razvan Becheriu, Qualitance
2016-05: Added support for Cassandra
Kea uses log4cplus (http://sourceforge.net/projects/log4cplus/) for logging,
Boost (http://www.boost.org/) library for almost everything, and can use Botan
(http://botan.randombit.net/) or OpenSSL (https://www.openssl.org/) for
......
......@@ -9,3 +9,5 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
The ext/coroutine code is externally maintained and distributed under
the Boost Software License, Version 1.0. (See its accompanying file
LICENSE_1_0.txt.)
The Cassandra backend code is distributed under the Apache License, Version 2.0.
......@@ -78,16 +78,12 @@ public:
/// @brief Commit Transactions
///
/// Commits all pending database operations.
///
/// @throw DbOperationError If the commit failed.
/// This is a no-op for Cassandra.
virtual void commit();
/// @brief Rollback Transactions
///
/// Rolls back all pending database operations.
///
/// @throw DbOperationError If the rollback failed.
/// This is a no-op for Cassandra.
virtual void rollback();
/// @brief Check Error
......
This diff is collapsed.
......@@ -33,17 +33,17 @@ namespace dhcp {
/// This vector is passed directly into the
/// CQL execute call.
///
/// Note that the data values are stored as pointers. These pointers need to
/// valid for the duration of the CQL statement execution. In other
/// words populating them with pointers to values that go out of scope before
/// statement is executed is a bad idea.
/// Note that the data values are stored as pointers. These pointers need
/// to be valid for the duration of the CQL statement execution. In other
/// words populating them with pointers to values that go out of scope
/// before statement is executed is a bad idea.
struct CqlDataArray {
/// @brief Vector of pointers to the data values.
/// Add void pointer to a vector of pointers to the data values.
std::vector<void*> values_;
void add(void* value) {
values_.push_back(value);
}
/// Remove void pointer from a vector of pointers to the data values.
void remove(int index) {
if (values_.size() <= index) {
isc_throw(BadValue, "Index " << index << " out of bounds: [0, " <<
......@@ -307,7 +307,6 @@ public:
virtual void getExpiredLeases6(Lease6Collection& ,
const size_t ) const;
/// @brief Returns a collection of expired DHCPv4 leases.
///
/// This method returns at most @c max_leases expired leases. The leases
......@@ -321,7 +320,6 @@ public:
virtual void getExpiredLeases4(Lease4Collection& ,
const size_t ) const;
/// @brief Updates IPv4 lease.
///
/// Updates the record of the lease in the database (as identified by the
......@@ -415,7 +413,6 @@ public:
/// This is a no-op for Cassandra.
virtual void rollback();
/// @brief Statement Tags
///
/// The contents of the enum are indexes into the list of compiled SQL
......@@ -462,8 +459,8 @@ public:
/// @param param TODO
/// @param exchange Exchange object to use
/// @param type TODO
static void getDataType(const StatementIndex stindex, int param,
const SqlExchange& exchange, ExchangeDataType& type);
static ExchangeDataType getDataType(const StatementIndex stindex, int param,
const SqlExchange& exchange);
/// @brief TODO
///
......
......@@ -82,18 +82,69 @@ enum ExchangeDataTypeIO {
/// @brief Used to map the column name with internal backend storage data types.
struct ExchangeColumnInfo {
ExchangeColumnInfo () : column_(NULL), type_io_(EXCHANGE_DATA_TYPE_IO_IN), type_(EXCHANGE_DATA_TYPE_NONE) {};
ExchangeColumnInfo (const char *column, ExchangeDataTypeIO type_io, ExchangeDataType type) : column_(column), type_io_(type_io), type_(type) {};
const char* column_;
ExchangeColumnInfo () : name_(""), index_(0), type_io_(EXCHANGE_DATA_TYPE_IO_IN),
type_(EXCHANGE_DATA_TYPE_NONE) {};
ExchangeColumnInfo (const char* name, const uint32_t index,
const ExchangeDataTypeIO type_io, const ExchangeDataType type) :
name_(name), index_(index), type_io_(type_io), type_(type) {};
std::string name_;
uint32_t index_;
ExchangeDataTypeIO type_io_;
ExchangeDataType type_;
};
typedef boost::shared_ptr<ExchangeColumnInfo> ExchangeColumnInfoPtr;
typedef boost::multi_index_container<
// Container comprises elements of ExchangeColumnInfoPtr type.
ExchangeColumnInfoPtr,
// Here we start enumerating various indexes.
boost::multi_index::indexed_by<
// Sequenced index allows accessing elements in the same way as elements
// in std::list.
// Sequenced is an index #0.
boost::multi_index::sequenced<>,
// Start definition of index #1.
boost::multi_index::hashed_non_unique<
boost::multi_index::member<
ExchangeColumnInfo,
std::string,
&ExchangeColumnInfo::name_
>
>,
// Start definition of index #2.
boost::multi_index::hashed_non_unique<
boost::multi_index::member<
ExchangeColumnInfo,
uint32_t,
&ExchangeColumnInfo::index_
>
>
>
> ExchangeColumnInfoContainer;
/// Pointer to the ExchangeColumnInfoContainer object.
typedef boost::shared_ptr<ExchangeColumnInfoContainer> ExchangeColumnInfoContainerPtr;
/// Type of the index #1 - name.
typedef ExchangeColumnInfoContainer::nth_index<1>::type ExchangeColumnInfoContainerName;
/// Pair of iterators to represent the range of ExchangeColumnInfo having the
/// same name value. The first element in this pair represents
/// the beginning of the range, the second element represents the end.
typedef std::pair<ExchangeColumnInfoContainerName::const_iterator,
ExchangeColumnInfoContainerName::const_iterator> ExchangeColumnInfoContainerNameRange;
/// Type of the index #2 - index.
typedef ExchangeColumnInfoContainer::nth_index<2>::type ExchangeColumnInfoContainerIndex;
/// Pair of iterators to represent the range of ExchangeColumnInfo having the
/// same index value. The first element in this pair represents
/// the beginning of the range, the second element represents the end.
typedef std::pair<ExchangeColumnInfoContainerIndex::const_iterator,
ExchangeColumnInfoContainerIndex::const_iterator> ExchangeColumnInfoContainerIndexRange;
class SqlExchange {
public:
SqlExchange () {};
virtual ~SqlExchange() {};
std::vector<ExchangeColumnInfo> parameters_; ///< Column names and types
ExchangeColumnInfoContainer parameters_; ///< Column names and types
};
/// @brief Abstract Lease Manager
///
......
// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2015 - 2016 Deutsche Telekom AG.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Author: Razvan Becheriu <razvan.becheriu@qualitance.com>
// Author: Andrei Pavel <andrei.pavel@qualitance.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <config.h>
......@@ -279,7 +290,7 @@ TEST_F(CqlLeaseMgrTest, getLease4ClientIdSubnetId) {
/// @brief Basic Lease4 Checks
///
/// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),
/// Checks that the addLease, getLease4(by address), getLease4(hwaddr, subnet_id),
/// updateLease4() and deleteLease (IPv4 address) can handle NULL client-id.
/// (client-id is optional and may not be present)
TEST_F(CqlLeaseMgrTest, lease4NullClientId) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment