-
Notifications
You must be signed in to change notification settings - Fork 55
Using the Migration Data Adapter
stanzikratel edited this page Sep 5, 2014
·
9 revisions
###Configuring Atom Hopper to use the Migration Data Adapter###
The Migration data adapter ships with Atom hopper version 1.2.0 and above.
Note: Please note that the Migration Data Adapter is currently in the stage of ongoing development.
You can turn on the Migration data adapter easily following these steps:
- Edit the application-context.xml file so it looks similar to the following (edit as needed to suit your particular needs). This example shows someone migrating from a database schema used in the original Hibernate Data Adapter to a database schema used in the new Postgres Data Adapter.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean name="feed-repository-bean" class="org.atomhopper.hibernate.HibernateFeedRepository">
<constructor-arg>
<map>
<entry key="hibernate.connection.driver_class" value="org.postgresql.Driver" />
<entry key="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<entry key="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/atomhopperold" />
<entry key="hibernate.connection.username" value="username" />
<entry key="hibernate.connection.password" value="password" />
</map>
</constructor-arg>
</bean>
<bean name="hibernate-feed-publisher"
class="org.atomhopper.hibernate.adapter.HibernateFeedPublisher">
<property name="feedRepository" ref="feed-repository-bean" />
<property name="allowOverrideId">
<value>true</value>
</property>
<property name="allowOverrideDate">
<value>true</value>
</property>
</bean>
<bean name="hibernate-feed-source" class="org.atomhopper.hibernate.adapter.HibernateFeedSource">
<property name="feedRepository" ref="feed-repository-bean" />
</bean>
<bean id="atomHopperDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://localhost:5432/atomhoppernew" />
<property name="username" value="username" />
<property name="password" value="password" />
<property name="minIdle" value="10" />
<property name="maxIdle" value="25" />
<property name="initialSize" value="10" />
<property name="maxActive" value="50" />
</bean>
<bean name="atomHopperJdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg name="dataSource" ref="atomHopperDataSource"/>
</bean>
<bean name="postgres-feed-publisher" class="org.atomhopper.postgres.adapter.PostgresFeedPublisher">
<property name="jdbcTemplate" ref="atomHopperJdbcTemplate" />
<property name="allowOverrideId">
<value>true</value>
</property>
<property name="allowOverrideDate">
<value>true</value>
</property>
</bean>
<bean name="postgres-feed-source" class="org.atomhopper.postgres.adapter.PostgresFeedSource">
<property name="jdbcTemplate" ref="atomHopperJdbcTemplate" />
</bean>
<bean name="migration-feed-publisher" class="org.atomhopper.migration.adapter.MigrationFeedPublisher">
<property name="oldFeedPublisher" ref="hibernate-feed-publisher" />
<property name="newFeedPublisher" ref="postgres-feed-publisher" />
<property name="writeTo">
<value>BOTH</value>
</property>
<property name="readFrom">
<value>OLD</value>
</property>
</bean>
<bean name="migration-feed-source" class="org.atomhopper.migration.adapter.MigrationFeedSource">
<property name="oldFeedSource" ref="hibernate-feed-source" />
<property name="newFeedSource" ref="postgres-feed-source" />
<property name="readFrom">
<value>OLD</value>
</property>
</bean>
</beans>
- NOTE: In order for the entries to have the same Id and LastUpdatedDate, the override properties on the feed publisher for both Data Adapters MUST to be set to true.
<bean name="hibernate-feed-publisher" class="org.atomhopper.hibernate.adapter.HibernateFeedPublisher">
<property name="feedRepository" ref="feed-repository-bean" />
<property name="allowOverrideId">
<value>true</value>
</property>
<property name="allowOverrideDate">
<value>true</value>
</property>
</bean>
<bean name="postgres-feed-publisher" class="org.atomhopper.postgres.adapter.PostgresFeedPublisher">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="allowOverrideId">
<value>true</value>
</property>
<property name="allowOverrideDate">
<value>true</value>
</property>
</bean>
- Edit the atom-server.cfg.xml file (by default the file is located in: /etc/atomhopper) so it looks similar to the following (edit as needed to suit your particular needs):
<?xml version="1.0" encoding="UTF-8"?>
<atom-hopper-config xmlns="http://atomhopper.org/atom/hopper-config/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://atomhopper.org/atom/hopper-config/v1.0 ./../../config/atom-hopper-config.xsd">
<defaults>
<author name="Atom Hopper" />
</defaults>
<host domain="localhost:8080" />
<workspace title="Testing Namespace" resource="/namespace/">
<categories-descriptor reference="workspace-categories-descriptor" />
<feed title="Testing Feed" resource="/feed">
<publisher reference="migration-feed-publisher" />
<feed-source reference="migration-feed-source" />
</feed>
</workspace>
</atom-hopper-config>
The important thing here is to ensure the following:
<publisher reference="migration-feed-publisher" />
<feed-source reference="migration-feed-source" />
Matches what is specified in the application-context.xml file.
<bean name="migration-feed-publisher" class="org.atomhopper.migration.adapter.MigrationFeedPublisher">
<property name="oldFeedPublisher" ref="hibernate-feed-publisher" />
<property name="newFeedPublisher" ref="postgres-feed-publisher" />
<property name="writeTo">
<value>BOTH</value>
</property>
<property name="readFrom">
<value>OLD</value>
</property>
</bean>
<bean name="migration-feed-source" class="org.atomhopper.migration.adapter.MigrationFeedSource">
<property name="oldFeedSource" ref="hibernate-feed-source" />
<property name="newFeedSource" ref="postgres-feed-source" />
<property name="readFrom">
<value>OLD</value>
</property>
</bean>
If Atom Hopper is currently running you will need to restart it for the changes to take effect.