Challenge Overview

Previously, we have created AWS Lambda Function for Get User Projects, which works against Informix Database. But we decides to move away from AWS Lambda and AWS API Gateway. We'd like to continue with our own microservice architecture, which uses dropwizard.

For this challenge, we'd like you to create a new microservice by reimplementing the same logic as AWS Lambda function (source code will be provided in forum). For how to create new microservice, we will provide a codebase for reference. Please raise any question if you have.

1.  Implement the logic as in AWS Lambda Function, but use the formal way used in the current challenge microservice.
2.  We will use project or Project as the name base, like project-service.yaml, com.appirio.service.project as the main package etc.
2.  New configurations should be added to src/main/resources/project-service.yaml
3.  Describe the new API using apiary.apib
4.  Update the pom.xml to include the new libraries, For required libraries, use a lib directory to store them, since we don't have them in maven repositories yet.

About Microservice Architecture

Maven

Apache Maven will be used to the build the microservice.

Supply Library

The supply library is a shared library used by all of our microservices, among other things the supply library provides jdbc persistence and base classes that simplify the initialization and execution of dropwizard applications. The most relevant classes to use in the supply library are:

BaseApplication

This class is the superclass for all dropwizard application classes. It provides the entrypoint (main method) for the dropwizard application, and its subclasses are responsible for instantiating, initializing and registering all necessary resources for the microservice;

BaseAppConfiguration

This is the superclass for all dropwizard configuration classes. The configuration class is responsible for loading configs from the configuration yaml file and exposing it to the application. The subclasses of this class should have the same properties as the yaml file.

project-service.yaml 

Configuration file contains microservice specific configurations, such as datastore connection information, authentication domain, logging, etc. 

no private information should be stored in the configuration file, this includes database passwords, third party service keys like sumo logic and new relic, etc.

A file with environment specific private information to be used for substitution at build time can be introduced, and it will be stored in the jenkins server to be used by the build job.

Note that some environment specific and private information cam be injected to the task-service.yml file using vm arguments e.g.:

java -Ddw.databases[0].password=123 … -jar service.jar server xxx-service.yml

The above would set 123 to the password property below in xxx-service.yml:

# Database settings.
databases:
- datasourceName: oltp
# the name of your JDBC driver
driverClass: com.informix.jdbc.IfxDriver
# the username
user: coder
# the password
# NOTE: password is set as a java system property: i.e., -Ddw.database.password=<password>
validationQuery: select 1 from systables
- datasourceName: dw
# the name of your JDBC driver
driverClass: com.informix.jdbc.IfxDriver
# the username
user: coder
# the password
# NOTE: password is set as a java system property: i.e., -Ddw.database.password=<password>
validationQuery: select 1 from systables

Main Classes

com.appirio.service.project.ProjectServiceConfiguration 

It should inherit from BaseAppConfiguration (part of the supply library)

It should contain all the relevant properties from the project-service.yml file to this specific microservice. 

com.appirio.service.project.ProjectServiceApplication

It should extend BaseApplication parameterized with the configuration class created in the previous step: e.g. : ProjectServiceApplication extends  BaseApplication<ProjectServiceConfiguration>

The getName method should return the name of the microservice;

The logServiceSpecificConfiguration should use the logger to output all configurations for the microservice that are NOT private information, i.e. don’t output tokens, keys, db passwords, etc.

A main method should exist that simple invokes the run method, e.g.:
   public static void main(String[] args) throws Exception {
       new TasksServiceApplication().run(args);
   }

The registerResources method should register all resources found in the project-service.yml resources property. We simple want the resources to be created and registered in a more traditional fashion, e.g.: 
   @Override
   protected void registerResources(ChallengeServiceConfiguration config, Environment env) throws Exception {
       // Register resources here
       env.jersey().register(new ChallengeFactory(config, env).getResourceInstance());
       env.jersey().register(new ChallengeResultsFactory(config, env).getResourceInstance());

The prepare method should configure the databases: 
configDatabases(config, config.getDatabases(), env);

Add the execution plugin to the microservice pom.xml fixing the main class name, like
<build>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-shade-plugin</artifactId>
               <version>2.3</version>
               <configuration>
                   <createDependencyReducedPom>true</createDependencyReducedPom>
                   <filters>
                       <filter>
                           <artifact>*:*</artifact>
                           <excludes>
                               <exclude>META-INF/*.SF</exclude>
                               <exclude>META-INF/*.DSA</exclude>
                               <exclude>META-INF/*.RSA</exclude>
                           </excludes>
                       </filter>
                   </filters>
               </configuration>
               <executions>
                   <execution>
                       <phase>package</phase>
                       <goals>
                           <goal>shade</goal>
                       </goals>
                       <configuration>
                           <transformers>
                               <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                               <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.appirio.service.project.ProjectServiceApplication</mainClass>
                               </transformer>
                           </transformers>
                       </configuration>
                   </execution>
               </executions>
           </plugin>
       </plugins>

Add informix dependency and both springsource repositories to the microservice pom.xml.

About Testing

For this microservice, it solely use informix for data retrieveal. but in order to create projects, you need to use Topcoder Direct.
Generally, you don't need to request VM for testing, I will a common VM for your testing.  But if you want to setup your own, you can follow https://github.com/appirio-tech/direct-app/blob/dev/LOCAL_SETUP.md to setup your local environment or request a VM to work on.

In order to request your VM, please request your VM in the challenge forum.

Information about VM can be found below:

VM specific information is found here: http://www.topcoder.com/wiki/display/docs/VM+Image+2.5

Upon registration as a submitter or reviewer you will need to request a VM based on the new TopCoder Cockpit/Direct image. To request your image, please use the forum. Before requesting your VM, you need to ensure that you have an SSH key created and in your member profile. If you don't have your SSH key set in your profile, please follow https://help.github.com/articles/generating-an-ssh-key/, and send the public ssh key to support@topcoder.com, once it is setup, you can request your VM in forum



Final Submission Guidelines

1. Complete Source Code for this microservice2
2. A README.md in the root directory for general steps to setup and run the microservice
3. Verification Document About how to carry out the testing

ELIGIBLE EVENTS:

2016 TopCoder(R) Open

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30053994