-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.TXT
61 lines (37 loc) · 1.59 KB
/
README.TXT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
TASK DESCRIPTION:
Requirements.
1. Highly loaded multyuser service for calculation "special coefficients".
2. Unit and integration tests required.
3. JAX-RS implementation required (for example Jersey)
5. Need to handle synchronization of resource access.
Input data.
Service should work directly with 2 files in file system f1 and f2:
1. Input file (f1) (contains numbers in csv format)
2. File with pre computed data (f2) (contains numbers in csv format)
Resulting service should support 2 methods:
1. Get (v1) - get v1-n result from f2 file(index starts from 0) f2 and improve result in following way:
if (f2[v1] >10 )
then
return f2[v1] - 10
else
return f2[v1]
2. Post (v2,v3,v4) method:
if ( f1[v3]+v2 ) <10,
then
f2[v4] = f1[v3]+v2 +10
return true;
else
f2[v4] = f1[v3]+v2
return false;
f2[v4] should be saved in f2 file
Result should be returned in xml format. Input parameters should be encoded in url.
SOLUTION COMMENTS.
Implemented solution support full consistency on read and write, by locking each individual item.
Probably each-item-locking strategy not the best idea for performance, could be improved by moving to partition based locking mechanism Sure it also dedens on how much eventual consistency we could allow our self to have, so we could possible could remove synchronization during get().
To run:
mvn jetty:run
http://localhost:8080/calc/
To execute integration tests:
mvn clean install -Pitest
To stop:
mvn jetty:stop