Project

General

Profile

Wiki » History » Version 19

Tomek Dziemidowicz, 2019-07-04 07:56 PM

1 2 Tomek Dziemidowicz
h1. SQLite-sync documentation
2
3
*Owner* : AMPLIFIER sp. z o.o.
4
*Contact* : support (at) ampliapps.com
5
*website* : https://ampliapps.com
6
7 3 Tomek Dziemidowicz
{{>toc}}
8
9 9 Tomek Dziemidowicz
Welcome to the AMPLI-SYNC documentation!
10
We have language bindings in JavaScript, .NET C#, Java and Objective-C! 
11 1 Tomek Dziemidowicz
12 9 Tomek Dziemidowicz
h2. AMPLI-SYNC concept
13
14
h3. Solution diagram
15
16 8 Tomek Dziemidowicz
!{width:700px}SQLite-sync-structure.png!
17 1 Tomek Dziemidowicz
18 13 Tomek Dziemidowicz
* Devices communicate with server using HTTP/HTTPS protocol. 
19
* Proxy Load Balancer. If necessary, proxy can redirect request to another instance of SQLite-core.
20
* Authorization provider will generate token based on response from authorization provider.
21 9 Tomek Dziemidowicz
22
h3. Proxy Balancer flowchart
23
24
!{width:400px}SQLite-sync-proxy-balancer.png!
25
26
h3. Authorization Provider flowchart
27
28
!{width:350px}SQLite-sync-authentication-process.png!
29
30 2 Tomek Dziemidowicz
h2. REST API (server API)
31
32 10 Tomek Dziemidowicz
h3. Protocol version
33
34
This document describes integration with the REST API 3.x protocol.
35
36
h3. Service description
37
38
There are two stages to processing a request:
39
40 12 Tomek Dziemidowicz
* Device places an request.
41
* SQLite-sync server confirms the request has been processed successfully and sends confirmation with eventual conflict list that need to be resolved.
42 10 Tomek Dziemidowicz
43 11 Tomek Dziemidowicz
h3. Synchronization flowchart
44
45
!{width:200px;}Device-synchronization-diagram.png!
46 10 Tomek Dziemidowicz
47 2 Tomek Dziemidowicz
h2. Conflict Resolution
48
49
h2. Update procedure
50
51
h2. Data filtering
52
53 1 Tomek Dziemidowicz
h2. Installation
54 9 Tomek Dziemidowicz
55 18 Tomek Dziemidowicz
h3. Server Prerequisites
56
57
To make ampli-sync server work you need:
58
* Apache Tomcat 8.
59
* Java
60
* Linux/Windows environment. 
61
62 9 Tomek Dziemidowicz
h3. Manual
63
64 14 Tomek Dziemidowicz
Steps needed to install AMPLI-SYNC manually on Ubuntu.
65
66 15 Tomek Dziemidowicz
# Install Tomcat on Ubuntu:
67 14 Tomek Dziemidowicz
https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04
68
# Create new user
69
<pre>
70
sudo adduser amplisync
71
</pre>
72
System will ask you for password for newly created user.
73
# Add user to group ‘tomcat’
74
<pre>
75
sudo usermod -a -G tomcat amplisync
76
</pre>
77
# Chang in web.xml path variable to 
78
<pre>
79
\home/sqlitesync/demo
80
</pre>
81
# Install new application in Tomcat. Start with switching to amplisync user.
82
<pre>
83
su amplisync
84
</pre>
85
# Create new folder /home/sqlitesync/demo
86 16 Tomek Dziemidowicz
# Upload new service amplisync-demo to Tomcat. You can do that using Tomcat application manager, or you can put WAR file in Tomcat webapps folder. Name of your WAR file is app name in Tomcat environment. Remember to not place spaces and special chars in name of your WAR file.
87 17 Tomek Dziemidowicz
# Restart Tomcat:
88 14 Tomek Dziemidowicz
<pre>
89
service tomcat restart
90
</pre>
91
Now you can access your installation using link:
92
<pre>
93
http://your_ip:8080/amplisync-app-name/API3
94
</pre>
95
# Setup permissions:
96
<pre>
97
chown -R sqlitesync:tomcat /home/amplisync/demo/
98
</pre>
99
100 9 Tomek Dziemidowicz
h3. Docker
101 2 Tomek Dziemidowicz
102 19 Tomek Dziemidowicz
h3. Configuring AMPLI-SYNCI service
103
104
First you need to adjust website configuration file (web.xml), then you need to change main configuration file (sync.properties).
105
*Service configuration (web.xml)*
106
Go to your_webapps_folder/SqliteSync/WEB-INF/web.xml and open for edit. Navigate to section:
107
<pre><code class="xml">
108
<env-entry>
109
<env-entry-name>working-dir</env-entry-name>
110
<env-entry-type>java.lang.String</env-entry-type>
111
<env-entry-value>/your/working/dir/sqlite-sync/</env-entry-value>
112
</env-entry>
113
</code></pre>
114
change env-entry-value key and point to working dir where SQLite-sync.com server will store log files, temporary files and configuration. Create manually a subfolder named config. Create a text file sync.properties in folder config. The path should look like this:
115
<pre>
116
\working_dir\config\sync.properties
117
</pre>
118
*IMPORTANT* Restart service after changing web.xml. Make sure that Tomcat has read/write access to working dir.
119
Sample configurations for MySQL server
120
<pre>
121
DB_ENGINE = mysql
122
DBURL = jdbc:mysql://server:3306/dbname?rewriteBatchedStatements=true
123
DBUSER = user
124
DBPASS = pass
125
DBDRIVER = com.mysql.cj.jdbc.Driver
126
DATE_FORMAT = yyyy-MM-dd HH:mm:ss
127
HISTORY_DAYS = 7
128
LOG_LEVEL = 4
129
</pre>
130
If you faced a timezone error after configuration in `sync.properties` add at the end of connection string:
131
<pre>
132
&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
133
</pre>
134
*Keys explanation*
135
*LOG_LEVEL* - defain details level for log
136
> 4: TRACE, DEBUG, INFO, WARN; (default)
137
> 3: DEBUG, INFO, WARN; 
138
> 2: INFO,WARN; 
139
> 1: WARN; 
140
> 0 - disable logs
141
*DATE_FORMAT* - set format of date 
142
default format: yyyy-MM-dd HH:mm:ss 
143
*HISTORY_DAYS* - How long files with sync data will be kept
144
default value: 7
145
When you use MySQL database DO NOT remove from the end of the connection string:
146
<pre>
147
?rewriteBatchedStatements=true
148
</pre> 
149
150 2 Tomek Dziemidowicz
h2. Supported databases
151
152
h2. Samples
Go to top