Better login missing cash selection implementation. (#3026)

* When a cash selection implementation cannot be found for a driver name, print the driver name  and also driver names with implementation (available).
* Remove MySQL stub class as it would be misleading in error logs (MySQL would appear as implemented).
This commit is contained in:
szymonsztuka 2018-04-27 16:06:56 +01:00 committed by GitHub
parent efd203e5f3
commit 6e7787bd64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 33 deletions

View File

@ -39,8 +39,9 @@ abstract class AbstractCashSelection {
cashSelectionAlgo?.let {
instance.set(cashSelectionAlgo)
cashSelectionAlgo
} ?: throw ClassNotFoundException("\nUnable to load compatible cash selection algorithm implementation for JDBC driver ($_metadata)." +
"\nPlease specify an implementation in META-INF/services/${AbstractCashSelection::class.java}")
} ?: throw ClassNotFoundException("\nUnable to load compatible cash selection algorithm implementation for JDBC driver name '${_metadata.driverName}'." +
"\nPlease specify an implementation in META-INF/services/${AbstractCashSelection::class.qualifiedName}." +
"\nAvailable implementations: $cashSelectionAlgos")
}.invoke()
}

View File

@ -22,7 +22,7 @@ class CashSelectionH2Impl : AbstractCashSelection() {
return metadata.driverName == JDBC_DRIVER_NAME
}
override fun toString() = "${this::class.java} for $JDBC_DRIVER_NAME"
override fun toString() = "${this::class.qualifiedName} for '$JDBC_DRIVER_NAME'"
// We are using an H2 specific means of selecting a minimum set of rows that match a request amount of coins:
// 1) There is no standard SQL mechanism of calculating a cumulative total on a field and restricting row selection on the

View File

@ -1,27 +0,0 @@
package net.corda.finance.contracts.asset.cash.selection
import net.corda.core.contracts.Amount
import net.corda.core.identity.AbstractParty
import net.corda.core.identity.Party
import net.corda.core.utilities.OpaqueBytes
import java.sql.Connection
import java.sql.DatabaseMetaData
import java.sql.ResultSet
import java.util.*
class CashSelectionMySQLImpl : AbstractCashSelection() {
companion object {
const val JDBC_DRIVER_NAME = "MySQL JDBC Driver"
}
override fun isCompatible(metadata: DatabaseMetaData): Boolean {
return metadata.driverName == JDBC_DRIVER_NAME
}
override fun executeQuery(statement: Connection, amount: Amount<Currency>, lockId: UUID, notary: Party?, issuerKeysStr: Set<AbstractParty>, issuerRefsStr: Set<OpaqueBytes>, withResultSet: (ResultSet) -> Boolean): Boolean {
TODO("MySQL cash selection not implemented")
}
override fun toString() = "${this::class.java} for ${CashSelectionH2Impl.JDBC_DRIVER_NAME}"
}

View File

@ -13,7 +13,7 @@ import java.util.*
class CashSelectionPostgreSQLImpl : AbstractCashSelection() {
companion object {
val JDBC_DRIVER_NAME = "PostgreSQL JDBC Driver"
const val JDBC_DRIVER_NAME = "PostgreSQL JDBC Driver"
private val log = contextLogger()
}
@ -21,7 +21,7 @@ class CashSelectionPostgreSQLImpl : AbstractCashSelection() {
return metadata.driverName == JDBC_DRIVER_NAME
}
override fun toString() = "${this::class.java} for $JDBC_DRIVER_NAME"
override fun toString() = "${this::class.qualifiedName} for '$JDBC_DRIVER_NAME'"
// This is using PostgreSQL window functions for selecting a minimum set of rows that match a request amount of coins:
// 1) This may also be possible with user-defined functions (e.g. using PL/pgSQL)

View File

@ -1,3 +1,2 @@
net.corda.finance.contracts.asset.cash.selection.CashSelectionH2Impl
net.corda.finance.contracts.asset.cash.selection.CashSelectionMySQLImpl
net.corda.finance.contracts.asset.cash.selection.CashSelectionPostgreSQLImpl