Key Information

Register
Submit
The challenge is finished.

Challenge Overview

Welcome to Topcoder Submission - Marathon Match Java Score System.

Contest Details

We are creating a new processor to handle Marathon Matches challenges based on NodeJs 8.x. We hava already created the base skeleton on previous challenge.

Project Background

Topcoder is updating its api and one of the apis being updated is the Submission api. One of the scenarios that we are taking care of here is that when a user uploads a submission to Topcoder for a Maratho Match contest, an app (not relevant for this contest) creates a message that contains details about this submission and sends it to an Apache Kafka instance.

This will be a challenge among a series of challenge that will build the Marathon Match processor.

Technology Stack
 
  • Nodejs
  • Kafka
  • Java

Individual Requirements

1. We are extending the existing base process to be able to execute the score of Marathon Match member submission written in Java.

2. The workflow for the Marathon Match Java Score System as shown below:


3. The DynamoDB will be used to store the Job and Verification Information. The verification information will be used to validate the source code and produce score. The Java source code must conform with the class name and methods provided in the Verification Record.

The data model is:

entity name = Job
{
  "id": "<uuid - the job id>",
  "submissionId": "<submission id from kafka bus>",
  "challengeId": "<challenge id from kafka bus>",
  "memberId": "<member id from kafka bus>",
  "status": "<Start | Compile | Verification | Finished | Error",
  "error": "<error message>",
  "score": "<submission score>"
}

entity name = Verification
{
   "id": "<uuid - the verification id>",
   "challengeId": "<challenge id>",
   "className": <the class name used Java code>",
   "methods": [
         {
               "name": "aMethod", // the method should be made static and public
               "input": [ "int" ] // can have many inputs of different types (like String, int, double, String[], int[], double[])
               "output": "int" // can have one output of different types (like String, int, double, String[], int[], double[])
         }
   ],
   "inputs": [ // optional
       [ 0 ],
       [ 1 ],
       [ 2 ]
   ],
   "outputs": [ // optional
       0,
       0,
       0
   ],
   "url": "<an url with the verification code>"
}


4. After fetching the member code, we should check the extension. If it's .java we continue the process. Otherwise, log and ignore.

5. A gradle project template must be provided in the submission. The template must allow the submitted Java code to be compiled. The template files will be placed in the folder "java/template".

6. A folder called "java/job/<jobId>/project" will hold the project copied from the template along with the member java code. The compilation will be executed from within Node.js using a method like spawn, for instance. If better methods are available your are free to use it.

7. After compilation the jar file will be placed in "java/job/<jobId>/build" folder to be used later on.

8. All the code after the MM challenge check must be placed on a different folder called "java/", including any configuration needed. The service inside this folder will expose only one method to the current MM codebase, which is calculateScore(submissionId, memberId, challengeId, submissionURL, jobId). The method will return a Promise that in case of success will resolve to the object below (will be extended in the future) and in case of failure will reject with the appropriated error message.


{
    "finalScore": 10 // null if submission is not java
}


9. The "Verification Process" will first download the verification JavaScript code from the provided URL in the database, check the member submitted Java code for the correct class name and methods, run the submitted code and determine the submission score. To help building the verification and scoring process a simple problem is provided below.

a) The problem is guessing a random number from 1 to 100.

b) The java code will have no inputs and will return an integer that is a random number between 1 and 100. The class name will be Random and the method signature will be int guess().

c) The verification will also run a random generator using as seeds the input data array [1, 2, 3] and produce a result. A comparision will be made and the score will be: score = Y > X ? 0.0 : 100 - X + Y. Where X is the member submission result and Y is the verification code result. Pseudo code below.

score = []
for seed in input
    Y = random1to100(seed) // generate a random number from 1 to 100 using seed.
    X = Random.guess() // generate a random number from 1 to 100.
    score.push(Y > X ? 0.0 : 100 - X + Y)
finalScore = average(score)

d) The final score will be stored in database using the job id before returning to the main MM processor code.

10. You are required to provide a verification code based on the pseudo code above, place it in a URL that can be downloaded by the MM java scoring system. Also, populate manually the verification record for testing purposes.

11. You are also required to provide a Java code to run the problem described above, place it in a URL that can be download by the MM java scoring system. The URL will be sent along the rest of the submission data in the Kafka bus.

12. The challenge id must be with the submission data in the Kafka bus and will be used to retrieve the verification record.

13. To run the java code from Node.js application, please use the node-java library - https://github.com/joeferner/node-java. When running the java code you will use the generated jar in steps 6 and 7.

14. Integration test is in scope. Use the above example for testing.

15. Although an example has been provided the system must be able to run the verification and submission codes for all arbitrary configuration provided in the MM problem statement. This means different class names, different method names, different method signatures, different input and ouput data samples.

16. It's important that the node.js event loop is not blocked during executing as multiple verification / score processes will happen in parallel.

Deployment Guide and Validation Documentation


You will need to create a deployment guide (README.md) and validation document (Validation.md).

The README.md created must show how to:
  • Configure the application
  • Build application

The Validation.md created must show all the steps necessary to verify the application:
  • How to run and validate the code using the test example provided


Final Submission Guidelines

  • Updated code
  • Required Documentation
     

ELIGIBLE EVENTS:

Topcoder Open 2019

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30072473