Monday, November 10, 2014

Mounting remote governance registry

Let's say we have AS instance and G-reg instance, both instance have pointed their governance registry to MySql database.

Now I want to mount the AS's governance registry to G-reg's /_system/as/governance path

1. Shutdown both instances

2. Configurations to be done in G-reg side (in registry.xml file)

mount G-reg governance registry as

<mount path="/_system/governance" overwrite="true">
        <instanceId>greggov</instanceId>
        <targetPath>/_system/governance</targetPath>
    </mount>

mount AS governance registry as

<mount path="/_system/as/governance" overwrite="true">
        <instanceId>asgov</instanceId>
        <targetPath>/_system/as/governance</targetPath>
    </mount>

3. Configuration to be done in AS side (in registry.xml file)

mount AS governance registry

<mount path="/_system/governance" overwrite="true">
        <instanceId>asgov</instanceId>
        <targetPath>/_system/as/governance</targetPath>
    </mount>

4. Now we need to do a data migration as follows
Use AS database and execute following sql commands

Update REG_PATH Set REG_PATH_VALUE = REPLACE(REG_PATH_VALUE, '/_system/governance', '/_system/as/governance') where REG_PATH_VALUE like '/_system/governance%';

Update REG_LOG Set REG_PATH = REPLACE(REG_PATH, '/_system/governance', '/_system/as/governance') where REG_PATH like '/_system/governance%';

Update REG_LOG Set REG_ACTION_DATA = REPLACE(REG_ACTION_DATA, '/_system/governance', '/_system/as/governance') where REG_ACTION_DATA like '%/_system/governance%';

Update REG_ASSOCIATION Set REG_SOURCEPATH = REPLACE(REG_SOURCEPATH, '/_system/governance', '/_system/as/governance'), REG_TARGETPATH = REPLACE(REG_TARGETPATH, '/_system/governance', '/_system/as/governance') where REG_SOURCEPATH like '/_system/governance%' or REG_TARGETPATH like '/_system/governance%';

5. Restart the both instances.

Monday, November 3, 2014

Pointing governance registry to a MySQL database

Take WSO2 instance (here, I'm taking WSO2 AS) and do the following configurations

1. Modify the master-datasource.xml file

<datasource>
            <name>asgove</name>
            <description>The datasource used for governance registry</description>
            <jndiConfig>
                <name>jdbc/asgove</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:mysql://localhost:3306/asgove?autoReconnect=true</url>
                    <username>root</username>
                    <password>root</password>
                    <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                    <maxActive>50</maxActive>
                    <maxWait>60000</maxWait>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
        </datasource>

2. Modify the registry.xml file

 <dbConfig name="asgove">
        <dataSource>jdbc/asgove</dataSource>
    </dbConfig>

<mount path="/_system/governance" overwrite="true">
        <instanceId>asgove</instanceId>
        <targetPath>/_system/as/governance</targetPath>
    </mount>

    <remoteInstance url="https://localhost:9443/registry">
        <id>asgove</id>
        <dbConfig>asgove</dbConfig>
        <readOnly>false</readOnly>
        <enableCache>true</enableCache>
        <registryRoot>/</registryRoot>
        <cacheId>root@jdbc:mysql://localhost:3306/asgove</cacheId>
    </remoteInstance>

Don't forget to add the MySQL jars to the component/lib folder

Restart the instance with -Dsetup