/// @param statement_tag prepared statement being executed; defaults to an
/// invalid index
virtual void
- createBindForSelect(AnyArray &data,
- StatementTag statement_tag = NULL) override = 0;
+ createBindForSelect(AnyArray &data, StatementTag statement_tag = NULL) override = 0;
/// @brief Copy received data into the derived class' object.
///
public:
/// @brief Constructor
///
- /// The initialization of the variables here is only to satisfy cppcheck -
- /// all variables are initialized/set in the methods before they are used.
+ /// The initialization of the variables here is only to satisfy
+ /// cppcheck - all variables are initialized/set in the methods before
+ /// they are used.
///
/// @param connection connection used for this query
explicit CqlLease4Exchange(const CqlConnection &connection);
/// @param lease Updated lease information.
/// @param data lease info in CQL format will be stored here
/// @param statement_tag tag identifying the query (optional)
- void createBindForUpdate(const Lease4Ptr &lease,
- AnyArray &data,
+ void createBindForUpdate(const Lease4Ptr &lease, AnyArray &data,
StatementTag statement_tag = NULL);
/// @brief Create CQL_BIND objects for Lease4 Pointer
// Gets an IPv4 lease with specified hardware addr and subnet-id
{GET_LEASE4_HWADDR_SUBID,
- {GET_LEASE4_HWADDR_SUBID,
+ {GET_LEASE4_HWADDR_SUBID,
"SELECT "
"address, hwaddr, client_id, valid_lifetime, expire, subnet_id, "
"fqdn_fwd, fqdn_rev, hostname, state "
data.add(&state_);
} catch (const Exception &ex) {
- isc_throw(DbOperationError,
- "CqlLease4Exchange::createBindForInsert(): "
- "could not create bind array from Lease4: "
- << lease_->addr_.toText() << ", reason: " << ex.what());
+ isc_throw(DbOperationError, "CqlLease4Exchange::createBindForInsert(): "
+ "could not create bind array from Lease4: " << lease_->addr_.toText()
+ << ", reason: " << ex.what());
}
}
try {
// address: int
- // The address in the Lease structure is an IOAddress object.
- // Convert this to an integer for storage.
address_ = static_cast<cass_int32_t>(address.toUint32());
// Start with a fresh array.
} catch (const Exception &ex) {
isc_throw(DbOperationError,
"CqlLease4Exchange::createBindForDelete(): "
- "could not create bind array from Lease4: "
- << lease_->addr_.toText() << ", reason: " << ex.what());
+ "could not create bind array with address: "
+ << address_ << ", reason: " << ex.what());
}
}
return (result);
} catch (const Exception &ex) {
isc_throw(DbOperationError,
- "CqlLease4Exchange::retrieveLease(): "
+ "CqlLease4Exchange::retrieve(): "
"could not convert data to Lease4, reason: "
<< ex.what());
}
public:
/// @brief Constructor
///
- /// The initialization of the variables here is nonly to satisfy
+ /// The initialization of the variables here is only to satisfy
/// cppcheck - all variables are initialized/set in the methods before
/// they are used.
///
/// @brief Create CQL_BIND objects for Lease6 Pointer
///
- /// Fills in the CQL_BIND array for sending data in the Lease4 object to
+ /// Fills in the CQL_BIND array for sending data in the Lease6 object to
/// the database. Used for INSERT statements.
///
/// @param lease The lease information to be inserted
/// @brief Create CQL_BIND objects for Lease6 Pointer
///
- /// Fills in the CQL_BIND array for sending data in the Lease4 object to
+ /// Fills in the CQL_BIND array for sending data in the Lease6 object to
/// the database. Used for UPDATE statements.
///
/// @param lease Updated lease information.
/// @brief Create CQL_BIND objects for Lease4 Pointer
///
- /// Fills in the CQL_BIND array for sending data in the Lease4 object to
+ /// Fills in the CQL_BIND array for sending data in the Lease6 object to
/// the database. Used for DELETE statements.
///
/// @param address address of the lease to be deleted
/// @param data lease info in CQL format will be stored here
/// @param statement_tag tag identifying the query (optional)
- void createBindForDelete(const IOAddress &address, AnyArray &data,
+ void createBindForDelete(const IOAddress &address,
+ AnyArray &data,
StatementTag statement_tag = NULL);
/// @brief Create BIND array to receive data
///
/// @param data info returned by CQL will be stored here
/// @param statement_tag tag identifying the query (optional)
- void createBindForSelect(AnyArray &data,
- StatementTag statement_tag = NULL) override;
+ virtual void
+ createBindForSelect(AnyArray &data, StatementTag statement_tag = NULL) override;
/// @brief Retrieves the Lease6 object in Kea format
///
/// @return C++ representation of the object being returned
- boost::any retrieve() override;
+ virtual boost::any retrieve() override;
/// @brief Retrieves zero or more IPv6 leases
///
void
CqlLease6Exchange::createBindForInsert(const Lease6Ptr &lease, AnyArray &data) {
if (!lease) {
- isc_throw(BadValue, "Lease6 object is NULL");
+ isc_throw(BadValue, "CqlLease6Exchange::createBindForInsert(): "
+ "Lease6 object is NULL");
}
// Store lease object to ensure it remains valid.
lease_ = lease;
// For convenience for external tools, this is converted to lease
// expiry time (expire). The relationship is given by:
// expire = cltt_ + valid_lft_
- CqlExchange::convertToDatabaseTime(lease_->cltt_, lease_->valid_lft_, expire_);
+ CqlExchange::convertToDatabaseTime(lease_->cltt_, lease_->valid_lft_,
+ expire_);
// subnet_id: int
subnet_id_ = static_cast<cass_int32_t>(lease_->subnet_id_);
CqlLease6Exchange::createBindForUpdate(const Lease6Ptr &lease, AnyArray &data,
StatementTag /* unused */) {
if (!lease) {
- isc_throw(BadValue, "Lease6 object is NULL");
+ isc_throw(BadValue, "CqlLease6Exchange::createBindForUpdate(): "
+ "Lease6 object is NULL");
}
// Store lease object to ensure it remains valid.
lease_ = lease;
// structure.
try {
// address: varchar
- // The address in the Lease structure is an IOAddress object.
- // Convert this to an integer for storage.
address_ = address.toText();
// Start with a fresh array.
result->cltt_ = cltt;
result->state_ = state_;
- return result;
+
+ return (result);
} catch (const Exception &ex) {
isc_throw(DbOperationError,
"CqlLease6Exchange::retrieve(): "
- "could not convert data to Lease4, reason: "
+ "could not convert data to Lease6, reason: "
<< ex.what());
}
return Lease6Ptr();
// Return single record if present, else clear the lease.
const size_t collection_size = collection.size();
if (collection_size >= 2u) {
- isc_throw(
- MultipleRecords,
- "CqlLease6Exchange::getLease(): multiple records were found in "
- "the database where only one was expected for statement "
- << statement_tag);
+ isc_throw(MultipleRecords,
+ "CqlLease6Exchange::getLease(): multiple records were found in "
+ "the database where only one was expected for statement "
+ << statement_tag);
} else if (collection_size == 0u) {
result.reset();
} else {
AnyArray data;
- std::unique_ptr<CqlLease4Exchange> exchange4(
- new CqlLease4Exchange(dbconn_));
+ std::unique_ptr<CqlLease4Exchange> exchange4(new CqlLease4Exchange(dbconn_));
exchange4->createBindForInsert(lease, data);
try {
exchange4->executeMutation(dbconn_, data, CqlLease4Exchange::INSERT_LEASE4);
std::unique_ptr<CqlLease4Exchange> exchange4(new CqlLease4Exchange(dbconn_));
exchange4->getLeaseCollection(CqlLease4Exchange::GET_LEASE4_CLIENTID, data, result);
- return result;
+ return (result);
}
Lease4Ptr
std::unique_ptr<CqlLease6Exchange> exchange6(new CqlLease6Exchange(dbconn_));
exchange6->getLeaseCollection(CqlLease6Exchange::GET_LEASE6_DUID_IAID, data, result);
- return result;
+ return (result);
}
Lease6Collection
Lease6Collection result;
std::unique_ptr<CqlLease6Exchange> exchange6(new CqlLease6Exchange(dbconn_));
exchange6->getLeaseCollection(CqlLease6Exchange::GET_LEASE6_DUID_IAID_SUBID, data, result);
+
return (result);
}
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_GET_EXPIRED6)
.arg(max_leases);
- std::unique_ptr<CqlLease6Exchange> exchange6(
- new CqlLease6Exchange(dbconn_));
+ std::unique_ptr<CqlLease6Exchange> exchange6(new CqlLease6Exchange(dbconn_));
exchange6->getExpiredLeases(max_leases, expired_leases);
}