Friday, November 17, 2023

Lift And Shift of Monolith Group Of Architecture Patterns

Lift And Shift Of Monolith


 

History

Developer community is busy with Digital Transformation & Application Modernization activities. There are many projects where huge resources are invested to convert Java Monolith Applications into Microservices. The Goal is to realize a cloud native application, which can be scaled individually, manageable by a feasible sized team and is responsive.

We see many articles which talks about "Lift and Shift" of Applications when you move from on-premises to public clouds, but they don't help you when it comes to Monolith Application.

Since 2016, we focused on solving this challenge and find out a way to enable "Lift And Shift of Monolith". We identified the challenges and prepared a strategy around this. Finally, we came up with our first Best Practices which was foundation towards achieving our Automation Goal of Lift And Shift and was published under the heading of Application Modernization in 2019.

We involved into heavy development activities and came up with our first application which demonstrated the Automation using which we can quickly Lift And Shift Monolith class into Microservice. We also hosted an Opensource project with this code so that the developer community can get benefited with this innovation. The user guide and tutorial for the same was nicely described under the Heading Monolith to Hybrid Architecture in 1 Hour. in 2020.

The enhancement of our Tool continued and by 2023, we have deployed the tool on the cloud and is made available as SAAS to our clients, with extensive functionalities.

We identified the Architecture Patterns which can solve the complexities involved in the "Lift And Shift of Monolith", hence it gave birth to "Lift And Shift of Monolith" Group of Architecture Patterns.


Problems addressed

You can transition from Monolith to Hybrid using Strangler Pattern.
 
While Hybrid Architecture allows you to use Monolith Application and it is one of the component within Modernization, arriving to that state has its own challenges, which can be listed as follows:
  1. Manual modification of Monolith App code is time consuming.
  2. Executing modified code of Monolith App involves more than trivial efforts.
  3. Realization of benefits of Hybrid Architecture is realized only after substantial effort and time is invested over the transition of the Monolith Application. 
  4. Inter-Service communication and Monolith communication channels can add complexity to the Architecture.
  5. We need to save our Architecture from implementing Anti-patterns.
We want to break a Monolith Application into A Hybrid Architecture. This approach can be as complex as the Application itself, while very simple at Microlevel.

Monolith Application is primarily complex with respect to Architecture for:

  1. Monolith Application has huge code base.
  2. Individual Classes( DAO, VO, Service, etc) are tightly coupled
  3. The VM for their execution is generally shared.
  4. Analysis & Mapping of dependencies takes huge efforts.
  5. Vertical Slicing becomes very complex and iterative due to coupling.

 Unique Approach to Transformation

We want to break a Monolith Application into A Hybrid Architecture. This approach can be as complex as the Application itself, while very simple at Microlevel.

Monolith Application is primarily complex with respect to Architecture for:

  1. Monolith Application has huge code base.
  2. Individual Classes( DAO, VO, Service, etc) are tightly coupled
  3. The VM for their execution is generally shared.
  4. Analysis & Mapping of dependencies takes huge efforts.
  5. Vertical Slicing becomes very complex and iterative due to coupling.

 

How we solve the Problems

We identified best practices and other solutions and came up with a Strategy to minimize the risk and quickly realize Hybrid Architecture.

  1. Take Bottom-To-Top Approach
  2. No Change in Efferent Coupling of the Class
  3. Add Webclient to Dependee Class
  4. Expose Dependee Class over REST
  5. Use Stripped Monolith Application with MVC Wrapper Application
 This strategy is documented in detail at Monolith To Hybrid Strategy
 

Birth of "Lift And Shift of Monolith" Group of Architecture Patterns

 

  1. Wrapper Controller: Responsible to expose Monolith over REST API.
  2. Monolith Class Bridge: Facilitates Communication between Wrapper Controller and the Monolith Class.
  3. Monolith Controller Client: Responsible for maintaining Efferent Coupling of other classes of the Monolith and making REST Call to Wrapper Controller.

Initial Architecture

Fig 1: We have Class A, B &C within our Monolith Application. For Vertical slicing, if we process Class B, keeping its structure intact, Monolith Application can still function with modified class.

Target Architecture with applied Patterns



Fig 2: We have Class A, B &C within our Hybrid Application. Vertical slicing of Class B. Wrapper Controller, Monolith Class Bridge & Monolith Controller Client are introduced to the architecture.

 

 

Lift And Shift of Monolith" Group of Architecture Patterns in Action

This pattern is used by Digital Transformation Tools. You can refer to below videos to understand how this pattern helps in Digital Transformation.


1) CodaGeeks Digital Transform Tool:
This Tool helps you to transform your Java Monolith Class into Microservice. This tool is also available as an service ( SAAS ). Refer http://www.codageeks.com for more details.

 
 
 
 
       2)  Miracle Open Transform:
     This is an Open Source project hosted on git hub. It has code which               implements this and other "Lift and Shift Monolith" group of patterns.






What is an Architectural Pattern?

According to Wikipedia,

An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. Architectural patterns are similar to software design pattern but have a broader scope.

At Miracle Labs, we constantly innovate around real time problems and try to find solutions. While we were attempting early Digital Transformation Projects, we solved complex problems.










Monolith Controller Client

Monolith Controller Client Pattern

Monolith Controller Client Pattern solves complexity involved in exposing a Monolith Java Class into Rest API. By using this pattern, you can easily execute the Monolith Code ( Methods ) as service end points. It ensures that your other classes of Monolith Application are working seamlessly and are able to call the methods of the sliced Monolith Java Class without any modification, after you perform Lift and Shift of the Monolith Class.

This is part of "Lift & Shift of Monolith " Group of Architecture Patterns.

Problems addressed

Below are the problems that you face when you want to slice a single Java Class from a Monolith App.

  1. If you change the syntax ( Name or parameters) of methods of the Java class, it will break the consumer classes and you have to rewrite them as well. The Efferent and Ifferent Coupling will break.

  2. It will become mandatory for you change each and every dependent class, which will be a huge effort.    

 How we solve the Problems

  1. We implement "Monolith Controller Client " Pattern. This class  will have the same method syntax of each public method of the Java Monolith Class. This includes Getter and Setters as well as service methods ( Business Functions )

  2. We replace the body of the Monolith Java Class with this Monolith Controller Client class. This class is capable of calling the "Wrapper Controller" for executing the monolith class methods remotely.
     
  3. The "Monolith Controller Client" is helped by Json Convertors which converts the method data types to Json and vise-versa so that it can send and receive parameters over the REST API Calls.
     
  4.  The "Monolith Controller Client" ensures that all dependent classes are still able to call the monolith class methods without any change.

Monolith Controller Client Architecture Pattern in Action

This pattern is used by Digital Transformation Tools. You can refer to below videos to understand how this pattern helps in Digital Transformation.


1) CodaGeeks Digital Transform Tool:
This Tool helps you to transform your Java Monolith Class into Microservice. This tool is also available as an service ( SAAS ). Refer http://www.codageeks.com for more details.

 
 
 
 
       2)  Miracle Open Transform:
     This is an Open Source project hosted on git hub. It has code which               implements this and other "Lift and Shift Monolith" group of patterns.






What is an Architectural Pattern?

According to Wikipedia,

An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. Architectural patterns are similar to software design pattern but have a broader scope.

At Miracle Labs, we constantly innovate around real time problems and try to find solutions. While we were attempting early Digital Transformation Projects, we solved complex problems.










Monolith Class Bridge Pattern

Monolith Class Bridge Pattern

Monolith Class Bridge Pattern solves complexity involved in exposing a Monolith Java Class into Rest API. By using this pattern, you can easily execute the Monolith Code ( Methods ) as service end points. It ensures that "Wrapper Controller" is seamlessly able to call the methods of the sliced Monolith Java Class. This enables the request response of the remote calls. You can then realize all benefits of the cloud application for your same monolith code.

This is part of "Lift & Shift of Monolith " Group of Architecture Patterns.

Problems addressed

Below are the problems that you face when you want to expose a single Java Class from a Monolith App as Rest API.

  1. If you change the syntax ( Name or parameters) of methods of the Java class, it will break the consumer classes and you have to rewrite them as well.

  2. The formal data types of the parameters of the methods are not directly supported for Request / Response, as required by REST API best practicies.
       

 How we solve the Problems

  1. We implement "Wrapper Controller " Pattern. The REST Controller will have an unique end point, corresponding to each public method of the Java Monolith Class. This includes Getter and Setters as well as service methods ( Business Functions )

  2. We add "Monolith Class Bridge" Java class to the application. This class acts as a bridge for the conversion of datatype of request payload and response body to the datatypes matching to the method parameters and there return types.
     
  3. Monolith Class Bridge is linked to the "Wrapper Controller", hence all the upstream requests received by the "Wrapper Controller" are forwarded to Monolith Class Bridge, which delagtes the call to the actual Monolith Class and captures the result of the method being called.
     
  4. Monolith Class Bridge is then responsible of converting the result of the method call into the required Json string such that controller can send it back as the Response.

Monolith Class Bridge Architecture Pattern in Action

This pattern is used by Digital Transformation Tools. You can refer to below videos to understand how this pattern helps in Digital Transformation.


1) CodaGeeks Digital Transform Tool:
This Tool helps you to transform your Java Monolith Class into Microservice. This tool is also available as an service ( SAAS ). Refer http://www.codageeks.com for more details.

 
 
 
 
       2)  Miracle Open Transform:
     This is an Open Source project hosted on git hub. It has code which               implements this and other "Lift and Shift Monolith" group of patterns.






What is an Architectural Pattern?

According to Wikipedia,

An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. Architectural patterns are similar to software design pattern but have a broader scope.

At Miracle Labs, we constantly innovate around real time problems and try to find solutions. While we were attempting early Digital Transformation Projects, we solved complex problems.










Wrapper Controller Architecture Pattern

Wrapper Controller Architecture Pattern

Wrapper Controller Architecture Pattern solves complexity involved in exposing a Monolith Java Class into Rest API. By using this pattern, you can easily execute the Monolith Code ( Methods ) as service end points. Thus you can add this Rest API as Microservice within your cloud applications. You can then realize all benefits of the cloud application for your same monolith code.

This is part of "Lift & Shift of Monolith " Group of Architecture Patterns.

Problems addressed

Below are the problems that you face when you want to expose a single Java Class from a Monolith App as Rest API.

  1. You cannot scale out a single Java class from Monolith Application

  2. If you change the syntax ( Name or parameters) of methods of the Java class, it will break the consumer classes and you have to rewrite them as well.

  3. The formal data types of the parameters of the methods are not directly supported for Request / Response over Rest API
       
  4. We cannot slice a Java class from Monolith as it is A Single JVM Application

 How we solve the Problems

  1. We create a serverless application ( Spring Boot / Thorntail ) and add a REST Controller to the application and the Monolith Jar.

  2. The REST Controller will have an unique end point, corresponding to each public method of the Java Monolith Class. This includes Getter and Setters as well as service methods ( Business Functions )

  3. Call to REST Endpoints will further propagate to the Java Monolith Class. We wire the Java Monolith Class ( as service ) to this Controller Class

Wrapper Controller Architecture Pattern in Action

This pattern is used by Digital Transformation Tools. You can refer to below videos to understand how this pattern helps in Digital Transformation.


1) CodaGeeks Digital Transform Tool:
This Tool helps you to transform your Java Monolith Class into Microservice. This tool is also available as an service ( SAAS ). Refer http://www.codageeks.com for more details.

 
 
 
 
       2)  Miracle Open Transform:
     This is an Open Source project hosted on git hub. It has code which               implements this and other "Lift and Shift Monolith" group of patterns.






What is an Architectural Pattern?

According to Wikipedia,

An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. Architectural patterns are similar to software design pattern but have a broader scope.

At Miracle Labs, we constantly innovate around real time problems and try to find solutions. While we were attempting early Digital Transformation Projects, we solved complex problems.










Tuesday, September 5, 2023

Convert An(y) Monolith Opensource git Project Into Hybrid Application using Digital Transform tool in less than 20 mins.

Automate Monolith to Hybrid Application

Quicker Digital Transformation

We are in the world of cloud, and applications have to be smart enough to support cloud computations. We often see Monolith applications around us.  Architects are tempted to rewrite the Monolith App into Microservices but we can now reuse the existing functionality of Monolith, which is tested, supports Testing. We can now scale that code without giving huge Time - Material - Efforts on conversion.

Using Digital Transform Tool

Miracle has formed A new Team specialized for Digital Transformation with identity "CodAGeeks". They have recently launched cloud based Tool for Digital Transformation. It is quick and works as Charm!

I will demonstrate the use of the tool and briefly explain its features here.
 
The Tool can be accessed at  http://codageeks.com/demo.html

You can request A token to execute the transformation by sending an email on support@codageeks.com
 

Selecting the Project to Transform

I visited http://www.github.com to select a widely used Monolith Application in Java, since the tool only supports Java code base as of now. I selected the project with below details.

  • url: https://github.com/hta218/StoreManager/
  • Monolith Functional Class to Transform:  src/Functions/pdf_Export.java
  • Libs folder: /lib
  • Libs used:  itextpdf-5.3.4.jar:jcalendar-1.4.jar:sqljdbc4-3.0.jar:jtds-1.3.1.jar
  • Binary Folder: /build/classes

Purpose: This class has most Efferent coupling with other classes in the project. It is been called to  converting the invoice to pdf. For an enterprise, this can be a use case to scale this class to support multiple requests across various departments.

End Result of the Transformation

  1. Rest Controller: You will see that pdf_Export.java is exposed through a controller class and the entire code is wrapped into a Thorntail Microservice Application. Hence You can now Horizontally  scale this code.

  2. Modified Monolith Code: Existing Monolith code is modified in such a way that You don't have to do any further customization. The new Monolith code will consume the new Rest end point without any manual intervention.

Executing the Digital Transformation Tool:

 I opened the tool url http://codageeks.com/demo.html in chrome browser. 







    I have received 3 tokens after mailing to support@codageeks.com

I gave below details in the input boxes:


 


    

 

    I am sharing the inputs below in Plain Text:

Git Project URL:"https://github.com/hta218/StoreManager/",
Git Project Branch:"master",
Project Folder Name:"StoreManager",
Project Source Path From Git Root: "src",
Project Binary Path From Git Root: "build/classes",
Filename of the class to Transform:"Functions",
Path of the class to Transform From Source Folder:"pdf_Export.java",   
Library Folder Path From Git Root:"/lib",
Libs in ':' separated list :"itextpdf-5.3.4.jar:jcalendar-1.4.jar:sqljdbc4-3.0.jar:jtds-1.3.1.jar:"


You can use your Digital Transformation Token and git credentials.

On successful Transformation, you will see a response with link to the new code for you to download:

 

 

Incase the tool is not able to Automate the transformation you can subscribe to the support plans.

Checking the modified Code

The downloaded zip file is having below folders:

1) Microservice : This is the Thorntail Application project folder. The REST Controller for the pdf_Export class is located at inside it, as shown below:



 

 

 2) Monolith/StoreManager : The existing pdf_Export.java class is modified to consume the Microservices. All the test cases are still valid as the class efferent coupling remains intact.






Executing the transformed code

You have to execute Microservice and the newMonolith application. There is no change in the way you execute the newMonolith as compared to StoreManager( Monolith)

Copy the Microservice and newMonolith Folders into same file system from where you executed Monolith application, earlier to the Digital Transformation.

  • Executing Microservice: Navigate to the Microservice/ThorntailDemo folder in conole applilcation, and issue the commnd mvn thorntail:run.

You have to manually copy your dependencies of Monolith Application to the Thorntail Demo. You will observe that Microservice Application is listening on port 8080 on your local machine.

  • Executing newMonolilth: Just execute it in the same way you did execute Monolith application. You will notice that your newMonolith Application is trying to connect to your local port 8080.

 

Additional Notes:

CodAGeeks provides support services to transform complex Monolith application in just 15 days !!!