-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from paterczm/utils-refactor
Refactored utils module into facade and bean-consistency-checker modules
- Loading branch information
Showing
28 changed files
with
221 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Lightblue-entity-consistency-checker | ||
|
||
A utility to compare POJOs field by field. Use it during migration to lightblue to ensure consistency between entities returned by legacy and lightblue DAOs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.redhat.lightblue.migrator</groupId> | ||
<artifactId>lightblue-migrator-pom</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>lightblue-bean-consistency-checker</artifactId> | ||
<packaging>jar</packaging> | ||
<name>lightblue-migrator: ${project.groupId}|${project.artifactId}</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.spec</groupId> | ||
<artifactId>jboss-javaee-6.0</artifactId> | ||
<type>pom</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.redhat.lightblue.migrator</groupId> | ||
<artifactId>lightblue-migrator-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-beanutils</groupId> | ||
<artifactId>commons-beanutils</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-all</artifactId> | ||
<version>1.10.8</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
2 changes: 1 addition & 1 deletion
2
...s/consistency/BeanConsistencyChecker.java → ...r/consistency/BeanConsistencyChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...r/utils/consistency/ConsistencyCheck.java → ...igrator/consistency/ConsistencyCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...nsistency/BeanConsistencyCheckerTest.java → ...nsistency/BeanConsistencyCheckerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
...hat/lightblue/migrator/utils/Country.java → ...ghtblue/migrator/consistency/Country.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...r/utils/consistency/CountryInCountry.java → ...igrator/consistency/CountryInCountry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...or/utils/consistency/ExtendedCountry.java → ...migrator/consistency/ExtendedCountry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tils/consistency/VeryExtendedCountry.java → ...ator/consistency/VeryExtendedCountry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Lightblue-migrator-facade | ||
|
||
The facade helps with migrating a service to lightblue by offering following features: | ||
* phased migration using feature flag support (Togglz - see LightblueMigrationFeatures), | ||
* parallel processing (when possible), | ||
* handling identifiers and | ||
* checking for data integrity across source and destination (Lightblue) entities. | ||
|
||
The facade stands in front of the source and destination DAOs, directing traffic as needed. 4 different operations are supported: | ||
|
||
### get | ||
|
||
Read from source and destination (Lightblue) DAOs in parallel. | ||
|
||
Compare returned entities. If differences are found, return source entity and log inconsistency. Otherwise, return destination entity. | ||
|
||
Will call lightblue in dual read phase and beyond. | ||
|
||
### update | ||
|
||
Update entity using source and destination (Lightblue) DAOs in parallel. An update operation requires entity ID to be present. | ||
|
||
Compare returned entities. If differences are found, return source entity and log inconsistency. Otherwise, return destination entity. | ||
|
||
Will call lightblue in dual write phase and beyond. | ||
|
||
### create | ||
|
||
Create new entity using source and destination (Lightblue) DAOs in serial. First create in source to obtain ID. Once ID is assigned by source datastore, use it to create entity in destination. The destination (Lightblue) DAO needs to use EntityIdStore to get the ID and have a setter for DAOFacadeBase to set it. | ||
|
||
Compare returned entities. If differences are found, return source entity and log inconsistency. Otherwise, return destination entity. | ||
|
||
Will call lightblue in dual write phase and beyond. | ||
|
||
### create with read | ||
|
||
Same as create, except it will call lightblue in dual read phase and beyond. | ||
|
||
## Notes | ||
|
||
The facade was designed to work with DAO objects (data access layer), but it can be also used in front of a service bean (business logic layer). In case of the latter, you may need to duplicate business logic when preparing service bean implementation for lightblue. Logic duplication is generally undesired, but re-implementing business logic for lightblue may improve performance (you will have opportunities to merge multiple data operations, reducing the number of remote calls). | ||
|
||
## Examples | ||
|
||
See unit tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ghtblue/migrator/utils/DAOFacadeBase.java → ...htblue/migrator/facade/DAOFacadeBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...lue/migrator/utils/EntityIdExtractor.java → ...ue/migrator/facade/EntityIdExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ghtblue/migrator/utils/EntityIdStore.java → ...htblue/migrator/facade/EntityIdStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...lue/migrator/utils/EntityIdStoreImpl.java → ...ue/migrator/facade/EntityIdStoreImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...edhat/lightblue/migrator/utils/Timer.java → ...dhat/lightblue/migrator/facade/Timer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
facade/src/test/java/com/redhat/lightblue/migrator/facade/Country.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.redhat.lightblue.migrator.facade; | ||
|
||
import com.redhat.lightblue.migrator.consistency.BeanConsistencyChecker; | ||
import com.redhat.lightblue.migrator.consistency.ConsistencyCheck; | ||
|
||
|
||
public class Country { | ||
|
||
@ConsistencyCheck(ignore=true) | ||
private String name; | ||
private String iso2Code, iso3Code; | ||
private Long id; | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public Country(String iso2Code) { | ||
this(null, iso2Code); | ||
} | ||
|
||
public Country(Long id, String iso2Code) { | ||
super(); | ||
this.id = id; | ||
this.iso2Code = iso2Code; | ||
} | ||
|
||
public Country() { | ||
|
||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getIso2Code() { | ||
return iso2Code; | ||
} | ||
|
||
public void setIso2Code(String iso2code) { | ||
this.iso2Code = iso2code; | ||
} | ||
|
||
public String getIso3Code() { | ||
return iso3Code; | ||
} | ||
|
||
public void setIso3Code(String iso3code) { | ||
this.iso3Code = iso3code; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
return BeanConsistencyChecker.getInstance().consistent(this, obj); | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
.../lightblue/migrator/utils/CountryDAO.java → ...lightblue/migrator/facade/CountryDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...e/migrator/utils/CountryDAOLightblue.java → .../migrator/facade/CountryDAOLightblue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
...blue/migrator/utils/DAOFacadeExample.java → ...lue/migrator/facade/DAOFacadeExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...migrator/utils/EntityIdStoreImplTest.java → ...igrator/facade/EntityIdStoreImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
log4j.rootLogger=info, A1 | ||
|
||
log4j.appender.A1=org.apache.log4j.ConsoleAppender | ||
|
||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n | ||
|
||
log4j.logger.com.redhat=DEBUG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.