Wednesday, March 26, 2014

Overwrite property in registry mount.

The following configuration section is a part of the mount configuration.

<mount path="/_system/config" overwrite="true|false|virtual">
        <instanceId>instanceid</instanceId>
        <targetPath>/_system/nodes</targetPath>
</mount>

The overwrite property can be a one of following three value

1. true

If the overwrite is true, the existing resources/collections  of the mount location will be removed before establishing the mount.

2. false

If the overwrite is false, the existing resources of the mount location will NOT  be removed before establishing the mount. But error will be logged if the same resources already exist.

3. virtual

If the overwrite is virtual, the existing resources of the mount location will be kept as it is, but mount will be added on top of it. If the existing resource is a mount or a symbolic link overwriting will not happen.

Tuesday, March 18, 2014

Mount (jdbc) WSO2 ESB registry to WSO2 Governance Registry Server with H2.


When you start the vanilla distribution of wso2 servers (WSO2 ESB , WSO2 Governance Registry , WSO2 Application Server ..etc) the default registry database is  "Embedded mode H2" . In this mode of connection it allows only one connection to the database.  Therefore if you need to mount ESB to external Governance Registry server, then it should have started with "Server mode H2"

Governance Registry Configurations:

1. Add the following  H2DatabaseConfiguration to the carbon.xml to start the Governance Registry with "Server mode H2.
<H2DatabaseConfiguration>        
        <property name="tcp" />
        <property name="tcpPort">9092</property>
        <property name="tcpAllowOthers" />        
</H2DatabaseConfiguration>
2. Change the <url> of the default WSO2_CARBON_DB in master-datasources.xml file.
Format:
jdbc:h2:tcp://<server>[:<port>]/[<path>]<databaseName>
Eg:
<url>jdbc:h2:tcp://localhost/~/h2-mount/wso2greg-4.6.0/repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000</url>
3. Start the Governance Registry server.

ESB Configurations

1. Add the following data source configuration for mount database in master-datasources.xml.
<datasource>
            <name>WSO2_CARBON_DB_mount</name>
            <description>The datasource used for mounting registry databse</description>
            <jndiConfig>
                <name>jdbc/WSO2CarbonDB_mount</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:h2:tcp://localhost/~/h2-mount/wso2greg-4.6.0/repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000</url>
                    <username>wso2carbon</username>
                    <password>wso2carbon</password>
                    <driverClassName>org.h2.Driver</driverClassName>
                    <maxActive>50</maxActive>
                    <maxWait>60000</maxWait>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
</datasource>
 2. Add the following mount configuration in registry.xml
    <dbConfig name="wso2registry_mount">
        <dataSource>jdbc/WSO2CarbonDB_mount</dataSource>
    </dbConfig>  

    <remoteInstance url="https://localhost:9443/registry">
        <id>instanceid</id>
        <dbConfig>wso2registry_mount</dbConfig>
        <readOnly>false</readOnly>
        <enableCache>true</enableCache>
        <registryRoot>/</registryRoot>
        <cacheId>carbon@jdbc:h2:tcp://localhost/~/h2-mount/wso2greg-4.6.0/repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000</cacheId> 
    </remoteInstance>

    <mount path="/_system/config" overwrite="true">
        <instanceId>instanceid</instanceId>
        <targetPath>/_system/nodes</targetPath>
    </mount>
    <mount path="/_system/governance" overwrite="true">
        <instanceId>instanceid</instanceId>
        <targetPath>/_system/governance</targetPath>
    </mount>
3. If you are ruining ESB in same machine, change the default port <Offset> in carbon.xml  to prevent the port conflicts with Governance Registry server.

Eg: 
<Offset>1</Offset>
4. Start the ESB sever.

5. Logged in to the ESB server and browse the registry to verify that mount has established.


Note: We don't recommend to use the H2 as the mount database for production setup. However this method is useful for the users who don't  have rights to create the databases (MySQL , Oracle ..etc) in their corporate database system but still want to demo/test the registry space sharing/mounting.