Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor/Remove all akka Remotedata #2418

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions Akka.README.md

This file was deleted.

18 changes: 0 additions & 18 deletions obp-api/src/main/resources/props/sample.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,6 @@ db.url=jdbc:h2:./lift_proto.db;NON_KEYWORDS=VALUE;DB_CLOSE_ON_EXIT=FALSE
## of remote machine
#remotedata.loglevel=INFO
#remotedata.timeout=2
#remotedata.enable=true
#remotedata.hostname=127.0.0.1
#remotedata.port=2662
## Arbitrary value used in order to assure us that
## remote and local sides are paired well
## Only needed when remotedata.enable=true
#remotedata.secret=CHANGE_ME

## Set separate database for data split
## If remotedata is disabled, bd has to be accessible from local machine
## If remotedata is enabled, db has to be accessible from remote machine
#remotedata.db.driver=org.h2.Driver
#remotedata.db.url=jdbc:h2:./lift_proto.db.remotedata;DB_CLOSE_ON_EXIT=FALSE
#remotedata.db.username=user
#remotedata.db.password=secret


## Our own remotely accessible URL
Expand Down Expand Up @@ -732,9 +717,6 @@ dauth.host=127.0.0.1
# -------------------------------------- DAuth--


# Disable akka (Remote storage not possible)
use_akka=false


# -- Display internal errors --------------------------------------
# Enable/Disable showing of nested/chained error messages to an end user
Expand Down
134 changes: 51 additions & 83 deletions obp-api/src/main/scala/bootstrap/liftweb/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ import code.productfee.ProductFee
import code.products.MappedProduct
import code.ratelimiting.RateLimiting
import code.regulatedentities.MappedRegulatedEntity
import code.remotedata.RemotedataActors
import code.scheduler.{DataBaseCleanerScheduler, DatabaseDriverScheduler, JobScheduler, MetricsArchiveScheduler}
import code.scope.{MappedScope, MappedUserScope}
import code.signingbaskets.{MappedSigningBasket, MappedSigningBasketConsent, MappedSigningBasketPayment}
Expand Down Expand Up @@ -534,16 +533,6 @@ class Boot extends MdcLoggable {
OBPKafkaConsumer.primaryConsumer.start()
}

if (APIUtil.getPropsAsBoolValue("use_akka", false) == true) {
try {
logger.info(s"RemotedataActors.startActors( ${actorSystem} ) starting")
RemotedataActors.startActors(actorSystem)
} catch {
case ex: Exception => logger.warn(s"RemotedataActors.startLocalRemotedataWorkers( ${actorSystem} ) could not start: $ex")
}
}


// API Metrics (logs of API calls)
// If set to true we will write each URL with params to a datastore / log file
if (APIUtil.getPropsAsBoolValue("write_metrics", false)) {
Expand Down Expand Up @@ -772,17 +761,7 @@ class Boot extends MdcLoggable {
LiftSession.onBeginServicing = UsernameLockedChecker.onBeginServicing _ :: LiftSession.onBeginServicing
LiftSession.onSessionActivate = UsernameLockedChecker.onSessionActivate _ :: LiftSession.onSessionActivate
LiftSession.onSessionPassivate = UsernameLockedChecker.onSessionPassivate _ :: LiftSession.onSessionPassivate

APIUtil.akkaSanityCheck() match {
case Full(c) if c == true => logger.info(s"remotedata.secret matched = $c")
case Full(c) if c == false => throw new Exception(ErrorMessages.RemoteDataSecretMatchError)
case Empty => APIUtil.getPropsAsBoolValue("use_akka", false) match {
case true => throw new Exception(ErrorMessages.RemoteDataSecretObtainError)
case false => logger.info("Akka middleware layer is disabled.")
}
case _ => throw new Exception(s"Unexpected error occurs during Akka sanity check!")
}


// Sanity check for incompatible Props values for Scopes.
sanityCheckOPropertiesRegardingScopes()
// export one Connector's methods as endpoints, it is just for develop
Expand Down Expand Up @@ -859,10 +838,6 @@ class Boot extends MdcLoggable {

def schemifyAll() = {
Schemifier.schemify(true, Schemifier.infoF _, ToSchemify.models: _*)
if (APIUtil.getPropsAsBoolValue("remotedata.enable", false) == false) {
logger.debug("Run Schemifier.schemify during Boot:")
Schemifier.schemify(true, Schemifier.infoF _, ToSchemify.modelsRemotedata: _*)
}
}

private def showExceptionAtJson(error: Throwable): String = {
Expand Down Expand Up @@ -967,62 +942,6 @@ class Boot extends MdcLoggable {
}

object ToSchemify {
// The following tables will be accessed via Akka to the OBP Storage instance which in turn uses Mapper / JDBC
// TODO EPIC The aim is to have all models prefixed with "Mapped" but table names should not be prefixed with "Mapped
// TODO EPIC The aim is to remove all field name prefixes("m")
val modelsRemotedata: List[MetaMapper[_]] = List(
AccountAccess,
ViewDefinition,
ResourceUser,
UserInvitation,
UserAgreement,
UserAttribute,
MappedComment,
MappedTag,
MappedWhereTag,
MappedTransactionImage,
MappedNarrative,
MappedCustomer,
MappedUserCustomerLink,
Consumer,
Token,
OpenIDConnectToken,
Nonce,
MappedCounterparty,
MappedCounterpartyBespoke,
MappedCounterpartyMetadata,
MappedCounterpartyWhereTag,
MappedTransactionRequest,
TransactionRequestAttribute,
MappedMetric,
MetricArchive,
MapperAccountHolders,
MappedEntitlement,
MappedConnectorMetric,
MappedExpectedChallengeAnswer,
MappedEntitlementRequest,
MappedScope,
MappedUserScope,
MappedTaxResidence,
MappedCustomerAddress,
MappedUserAuthContext,
MappedUserAuthContextUpdate,
MappedConsentAuthContext,
MappedAccountApplication,
MappedProductCollection,
MappedProductCollectionItem,
MappedAccountAttribute,
MappedCustomerAttribute,
MappedTransactionAttribute,
MappedCardAttribute,
BankAttribute,
RateLimiting,
MappedCustomerDependant,
AttributeDefinition,
CustomerAccountLink
)

// The following tables are accessed directly via Mapper / JDBC
val models: List[MetaMapper[_]] = List(
AuthUser,
JobScheduler,
Expand Down Expand Up @@ -1089,7 +1008,56 @@ object ToSchemify {
ProductFee,
ViewPermission,
UserInitAction,
CounterpartyLimit
CounterpartyLimit,
AccountAccess,
ViewDefinition,
ResourceUser,
UserInvitation,
UserAgreement,
UserAttribute,
MappedComment,
MappedTag,
MappedWhereTag,
MappedTransactionImage,
MappedNarrative,
MappedCustomer,
MappedUserCustomerLink,
Consumer,
Token,
OpenIDConnectToken,
Nonce,
MappedCounterparty,
MappedCounterpartyBespoke,
MappedCounterpartyMetadata,
MappedCounterpartyWhereTag,
MappedTransactionRequest,
TransactionRequestAttribute,
MappedMetric,
MetricArchive,
MapperAccountHolders,
MappedEntitlement,
MappedConnectorMetric,
MappedExpectedChallengeAnswer,
MappedEntitlementRequest,
MappedScope,
MappedUserScope,
MappedTaxResidence,
MappedCustomerAddress,
MappedUserAuthContext,
MappedUserAuthContextUpdate,
MappedConsentAuthContext,
MappedAccountApplication,
MappedProductCollection,
MappedProductCollectionItem,
MappedAccountAttribute,
MappedCustomerAttribute,
MappedTransactionAttribute,
MappedCardAttribute,
BankAttribute,
RateLimiting,
MappedCustomerDependant,
AttributeDefinition,
CustomerAccountLink
)

// start grpc server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package code.accountapplication


import code.api.util.APIUtil
import code.remotedata.RemotedataAccountApplication
import com.openbankproject.commons.model.{AccountApplication, ProductCode}
import net.liftweb.common.Box
import net.liftweb.util.SimpleInjector
Expand All @@ -13,11 +12,8 @@ object AccountApplicationX extends SimpleInjector {

val accountApplication = new Inject(buildOne _) {}

def buildOne: AccountApplicationProvider =
APIUtil.getPropsAsBoolValue("use_akka", false) match {
case false => MappedAccountApplicationProvider
case true => RemotedataAccountApplication
}
def buildOne: AccountApplicationProvider = MappedAccountApplicationProvider

}

trait AccountApplicationProvider {
Expand All @@ -26,16 +22,3 @@ trait AccountApplicationProvider {
def createAccountApplication(productCode: ProductCode, userId: Option[String], customerId: Option[String]): Future[Box[AccountApplication]]
def updateStatus(accountApplicationId:String, status: String): Future[Box[AccountApplication]]
}


class RemotedataAccountApplicationCaseClasses {
case class getAll()
case class getById(accountApplicationId: String)
case class createAccountApplication(productCode: ProductCode, userId: Option[String], customerId: Option[String])
case class updateStatus(accountApplicationId:String, status: String)
}

object RemotedataAccountApplicationCaseClasses extends RemotedataAccountApplicationCaseClasses



Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package code.accountattribute
/* For AccountAttribute */

import code.api.util.APIUtil
import code.remotedata.RemotedataAccountAttribute
import com.openbankproject.commons.model.enums.AccountAttributeType
import com.openbankproject.commons.model.{AccountAttribute, AccountId, BankId, BankIdAccountId, ProductAttribute, ProductCode, ViewId}
import net.liftweb.common.{Box, Logger}
Expand All @@ -16,12 +15,8 @@ object AccountAttributeX extends SimpleInjector {

val accountAttributeProvider = new Inject(buildOne _) {}

def buildOne: AccountAttributeProvider =
APIUtil.getPropsAsBoolValue("use_akka", false) match {
case false => MappedAccountAttributeProvider
case true => RemotedataAccountAttribute // We will use Akka as a middleware
}

def buildOne: AccountAttributeProvider = MappedAccountAttributeProvider

// Helper to get the count out of an option
def countOfAccountAttribute(listOpt: Option[List[AccountAttribute]]): Int = {
val count = listOpt match {
Expand Down Expand Up @@ -69,38 +64,4 @@ trait AccountAttributeProvider {
def getAccountIdsByParams(bankId: BankId, params: Map[String, List[String]]): Future[Box[List[String]]]

// End of Trait
}

class RemotedataAccountAttributeCaseClasses {
case class getAccountAttributesFromProvider(accountId: AccountId, productCode: ProductCode)
case class getAccountAttributesByAccount(bankId: BankId,
accountId: AccountId)
case class getAccountAttributesByAccountCanBeSeenOnView(bankId: BankId,
accountId: AccountId,
viewId: ViewId)
case class getAccountAttributesByAccountsCanBeSeenOnView(accounts: List[BankIdAccountId],
viewId: ViewId)

case class getAccountAttributeById(accountAttributeId: String)

case class createOrUpdateAccountAttribute(bankId: BankId,
accountId: AccountId,
productCode: ProductCode,
accountAttributeId: Option[String],
name: String,
attributeType: AccountAttributeType.Value,
value: String,
productInstanceCode: Option[String])

case class createAccountAttributes(bankId: BankId,
accountId: AccountId,
productCode: ProductCode,
accountAttributes: List[ProductAttribute],
productInstanceCode: Option[String])

case class deleteAccountAttribute(accountAttributeId: String)

case class getAccountIdsByParams(bankId: BankId, params: Map[String, List[String]])
}

object RemotedataAccountAttributeCaseClasses extends RemotedataAccountAttributeCaseClasses
}
Loading
Loading