Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here's a quick step guide to getting XMLPS up and running on your project.

Table of Contents
indent20px
styledisc

Get and Build Apache OODT Web-Grid

To get started with Apache OODT XMLPS, you'll need to install Apache OODT Web Grid.

  1. svn export httpgit clone https://svngit-wip-us.apache.org/repos/asf/oodt/tags/0.5/grid.git
  2. cd grid
  3. mvn install (builds target/web-grid-0.511-SNAPSHOT.war)

You're done here for now, let's go grab Apache Tomcat.

...

Layering Apache OODT Web Grid on top of Tomcat

  1. copy web-grid-0.5.war from the target directory from your built Web-Grid to /usr/local/tomcat5/webapps/grid.war (yes rename it, you'll thank me later)

    Warning
    titleWarning

    Make sure Tomcat isn't running until the guide says for you to turn it on. Tomcat doesn't like you messing with its webapp and work directories.

Building and Installing XMLPS

  1. svn export httpgit clone https://svngit-wip-us.apache.org/repos/asf/oodt/tags/0.5/xmlps.git
  2. cd xmlps
  3. mvn install assembly:assembly (builds target/oodt-xmlps-0.5-with-dependencies.jar)
  4. create deploy area, e.g., /usr/local/xmlps and copy oodt-xmlps-0.5-with-dependencies.jar to it
  5. copy example conf files out of xmlps/src/main/conf (example.db.properties and example-ps.xml) into /usr/local/xmlps

...

Let's assume you have installed MySQL. There are plenty of guides out there to do so (including the one I just linked to) for specific operating systems, etc. So assuming that you have MySQL already installed, let's create a quick database and sample schema and user.

  1. Create a MySQL database with user xmlps and password xmlps and add some sample data.

    Code Block
    sql
    sql
    
    CREATE DATABASE xmlps;
    GRANT ALL PRIVILEGES ON xmlps.* TO 'xmlps'@'localhost' IDENTIFIED BY 'xmlps';
    GRANT ALL PRIVILEGES ON xmlps.* TO 'xmlps'@'%' IDENTIFIED BY 'xmlps';
    
  2. Log on to MySQL with user xmlps

    No Format
    
    mysql -u xmlps xmlps -p
    

    (enter password "xmlps")

  3. Create a simple data product schema

    Code Block
    sql
    sql
    
    CREATE TABLE products (product_id int auto_increment NOT NULL PRIMARY KEY, product_name varchar(255));
    
  4. INSERT 2 rows of data into the table

    Code Block
    sql
    sql
    
    INSERT INTO products (product_name) VALUES ('Test1');
    INSERT INTO products (product_name) VALUES ('Test2');
    

...

Now that everything is installed, and that you have a DB, you'll need to configure XMLPS to talk to your backend MySQL db. The first step is to configure the DB connection.

  1. Edit /usr/local/xmlps/example.db.properties.

    Code Block
    
    # Licensed to the Apache Software Foundation (ASF) under one or more
    # contributor license agreements.  See the NOTICE file distributed with
    # this work for additional information regarding copyright ownership.
    # The ASF licenses this file to You under the Apache License, Version 2.0
    # (the "License"); you may not use this file except in compliance with
    # the License.  You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    # Example data source configuration file
    
    xmlps.datasource.jdbc.url=jdbc:mysql://localhost:3306/xmlps?autoReconnect=true
    xmlps.datasource.jdbc.user=xmlps
    xmlps.datasource.jdbc.pass=xmlps
    xmlps.datasource.jdbc.driver=com.mysql.jdbc.Driver
    
  2. Expose the underlying data from the DB by editing the /usr/local/xmlps/example-ps.xml. We're going to rename the product_id field to "id" and the product_name field to "name" and add a constant field representing the data quality (called "quality_flag"), giving it the value "sample" to indicate this is just a test.

    Code Block
    xml
    xml
    
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
    
        http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
    -->
    <oodt:xmlps xmlns:oodt="http://incubator.apache.org/oodt/0.1-incubating"
    	name="My Query Handler" id="myqueryhandler">
    	<tables default="products">
    	</tables>
    	<field type="dynamic" name="id" dbname="product_id" />
    	<field type="dynamic" name="name" dbname="product_name"/>
    	<field type="constant" name="quality_flag" value="sample" />
    </oodt:xmlps>
    

...

Now that you have XMLPS and Web-Grid configured, Tomcat running, etc., it's time to issue a query against it! Try a query for name=Test2 (should only return the 2nd product):

  1. curl http://localhost:8080/grid/prod?q=RETURN%3Did+AND+RETURN%3Dname+AND+name=%27Test2%27

    No Format
    
    2    Test2$
    
  2. you can also tell it to return other fields, like the constant field tag
  3. curl http://localhost:8080/grid/prod?q=RETURN%3Did+AND+RETURN%3Dname+AND+name=%27Test2%27+AND+RETURN%3Dquality_flag

    No Format
    
    2    Test2     sample$
    

That's it! You're up and running!

...