Skip to content

Commit 9112921

Browse files
varuntechiepvoicu
authored andcommitted
Inital Commit
0 parents  commit 9112921

File tree

211 files changed

+32322
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+32322
-0
lines changed

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: go
2+
env:
3+
- GO111MODULE=on
4+
script:
5+
- go install github.com/paypal/hera/mux github.com/paypal/hera/worker/mysqlworker github.com/paypal/hera/worker/oracleworker
6+
- mvn install -f client/java/jdbc/pom.xml -Dmaven.test.skip=true

AUTHORS.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
hera
2+
3+
Original Authors
4+
----------------
5+
PayPal
6+
(c) 2019

LICENSE.txt

+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
Apache License
2+
3+
Version 2.0, January 2004
4+
5+
http://www.apache.org/licenses/
6+
7+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8+
9+
1. Definitions.
10+
11+
"License" shall mean the terms and conditions for use, reproduction, and
12+
distribution as defined by Sections 1 through 9 of this document.
13+
14+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
15+
owner that is granting the License.
16+
17+
"Legal Entity" shall mean the union of the acting entity and all other entities
18+
that control, are controlled by, or are under common control with that entity.
19+
For the purposes of this definition, "control" means (i) the power, direct or
20+
indirect, to cause the direction or management of such entity, whether by
21+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
22+
outstanding shares, or (iii) beneficial ownership of such entity.
23+
24+
"You" (or "Your") shall mean an individual or Legal Entity exercising
25+
permissions granted by this License.
26+
27+
"Source" form shall mean the preferred form for making modifications, including
28+
but not limited to software source code, documentation source, and
29+
configuration files.
30+
31+
"Object" form shall mean any form resulting from mechanical transformation or
32+
translation of a Source form, including but not limited to compiled object
33+
code, generated documentation, and conversions to other media types.
34+
35+
"Work" shall mean the work of authorship, whether in Source or Object form,
36+
made available under the License, as indicated by a copyright notice that is
37+
included in or attached to the work (an example is provided in the Appendix
38+
below).
39+
40+
"Derivative Works" shall mean any work, whether in Source or Object form, that
41+
is based on (or derived from) the Work and for which the editorial revisions,
42+
annotations, elaborations, or other modifications represent, as a whole, an
43+
original work of authorship. For the purposes of this License, Derivative
44+
Works shall not include works that remain separable from, or merely link (or
45+
bind by name) to the interfaces of, the Work and Derivative Works thereof.
46+
47+
"Contribution" shall mean any work of authorship, including the original
48+
version of the Work and any modifications or additions to that Work or
49+
Derivative Works thereof, that is intentionally submitted to Licensor for
50+
inclusion in the Work by the copyright owner or by an individual or Legal
51+
Entity authorized to submit on behalf of the copyright owner. For the purposes
52+
of this definition, "submitted" means any form of electronic, verbal, or
53+
written communication sent to the Licensor or its representatives, including
54+
but not limited to communication on electronic mailing lists, source code
55+
control systems, and issue tracking systems that are managed by, or on behalf
56+
of, the Licensor for the purpose of discussing and improving the Work, but
57+
excluding communication that is conspicuously marked or otherwise designated in
58+
writing by the copyright owner as "Not a Contribution."
59+
60+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
61+
of whom a Contribution has been received by Licensor and subsequently
62+
incorporated within the Work.
63+
64+
2. Grant of Copyright License. Subject to the terms and conditions of this
65+
License, each Contributor hereby grants to You a perpetual, worldwide, non-
66+
exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce,
67+
prepare Derivative Works of, publicly display, publicly perform, sublicense,
68+
and distribute the Work and such Derivative Works in Source or Object form.
69+
70+
3. Grant of Patent License. Subject to the terms and conditions of this
71+
License, each Contributor hereby grants to You a perpetual, worldwide, non-
72+
exclusive, no-charge, royalty-free, irrevocable (except as stated in this
73+
section) patent license to make, have made, use, offer to sell, sell, import,
74+
and otherwise transfer the Work, where such license applies only to those
75+
patent claims licensable by such Contributor that are necessarily infringed by
76+
their Contribution(s) alone or by combination of their Contribution(s) with the
77+
Work to which such Contribution(s) was submitted. If You institute patent
78+
litigation against any entity (including a cross-claim or counterclaim in a
79+
lawsuit) alleging that the Work or a Contribution incorporated within the Work
80+
constitutes direct or contributory patent infringement, then any patent
81+
licenses granted to You under this License for that Work shall terminate as of
82+
the date such litigation is filed.
83+
84+
4. Redistribution. You may reproduce and distribute copies of the Work or
85+
Derivative Works thereof in any medium, with or without modifications, and in
86+
Source or Object form, provided that You meet the following conditions:
87+
88+
You must give any other recipients of the Work or Derivative Works a copy of
89+
this License; and You must cause any modified files to carry prominent notices
90+
stating that You changed the files; and You must retain, in the Source form of
91+
any Derivative Works that You distribute, all copyright, patent, trademark, and
92+
attribution notices from the Source form of the Work, excluding those notices
93+
that do not pertain to any part of the Derivative Works; and If the Work
94+
includes a "NOTICE" text file as part of its distribution, then any Derivative
95+
Works that You distribute must include a readable copy of the attribution
96+
notices contained within such NOTICE file, excluding those notices that do not
97+
pertain to any part of the Derivative Works, in at least one of the following
98+
places: within a NOTICE text file distributed as part of the Derivative Works;
99+
within the Source form or documentation, if provided along with the Derivative
100+
Works; or, within a display generated by the Derivative Works, if and wherever
101+
such third-party notices normally appear. The contents of the NOTICE file are
102+
for informational purposes only and do not modify the License. You may add Your
103+
own attribution notices within Derivative Works that You distribute, alongside
104+
or as an addendum to the NOTICE text from the Work, provided that such
105+
additional attribution notices cannot be construed as modifying the License.
106+
107+
You may add Your own copyright statement to Your modifications and may provide
108+
additional or different license terms and conditions for use, reproduction, or
109+
distribution of Your modifications, or for any such Derivative Works as a
110+
whole, provided Your use, reproduction, and distribution of the Work otherwise
111+
complies with the conditions stated in this License.
112+
113+
5. Submission of Contributions. Unless You explicitly state otherwise, any
114+
Contribution intentionally submitted for inclusion in the Work by You to the
115+
Licensor shall be under the terms and conditions of this License, without any
116+
additional terms or conditions. Notwithstanding the above, nothing herein shall
117+
supersede or modify the terms of any separate license agreement you may have
118+
executed with Licensor regarding such Contributions.
119+
120+
6. Trademarks. This License does not grant permission to use the trade names,
121+
trademarks, service marks, or product names of the Licensor, except as required
122+
for reasonable and customary use in describing the origin of the Work and
123+
reproducing the content of the NOTICE file.
124+
125+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
126+
writing, Licensor provides the Work (and each Contributor provides its
127+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
128+
KIND, either express or implied, including, without limitation, any warranties
129+
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
130+
PARTICULAR PURPOSE. You are solely responsible for determining the
131+
appropriateness of using or redistributing the Work and assume any risks
132+
associated with Your exercise of permissions under this License.
133+
134+
8. Limitation of Liability. In no event and under no legal theory, whether in
135+
tort (including negligence), contract, or otherwise, unless required by
136+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
137+
writing, shall any Contributor be liable to You for damages, including any
138+
direct, indirect, special, incidental, or consequential damages of any
139+
character arising as a result of this License or out of the use or inability
140+
to use the Work (including but not limited to damages for loss of goodwill,
141+
work stoppage, computer failure or malfunction, or any and all other commercial
142+
damages or losses), even if such Contributor has been advised of the
143+
possibility of such damages.
144+
145+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
146+
Derivative Works thereof, You may choose to offer, and charge a fee for,
147+
acceptance of support, warranty, indemnity, or other liability obligations
148+
and/or rights consistent with this License. However, in accepting such
149+
obligations, You may act only on Your own behalf and on Your sole
150+
responsibility, not on behalf of any other Contributor, and only if You agree
151+
to indemnify, defend, and hold each Contributor harmless for any liability
152+
incurred by, or claims asserted against, such Contributor by reason of your
153+
accepting any such warranty or additional liability.
154+
155+
END OF TERMS AND CONDITIONS

README.md

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
[![Build Status](https://travis-ci.org/paypal/hera.svg?branch=master)](https://travis-ci.org/paypal/hera)
2+
[![License](http://img.shields.io/:license-Apache%202-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)
3+
# Hera - High Efficiency Reliable Access to data stores
4+
5+
Hera multiplexes connections for MySQL and
6+
Oracle databases. It supports sharding the databases for horizontal scaling.
7+
8+
* [Overview](docs/overview.md)
9+
* [Configuration](docs/configuration.md)
10+
* [Sharding](docs/sharding.md)
11+
* [Transparent failover](docs/taf.md)
12+
* [Contributing](docs/contributing.md)
13+
14+
# What is Hera
15+
16+
Hera is Data Access Gateway for databases and is a key enabler for scaling and improving availability databases.
17+
- It Protects the database from resource exhaustion by evicting poorly performing queries,
18+
- Intelligently routes read/write traffic appropriately for better load balancing,
19+
- Improves tolerance to database outages,
20+
- Provides high performance secured connections between applications and Hera
21+
- Provides domain agnostic database sharding for horizontal database scaling.
22+
- Automatic transaction application failover between replica databases
23+
- And many more site resiliency features.
24+
25+
# Getting Started
26+
27+
You can build mux using either [Docker](#docker-build) or [manual](#manual-build) build.
28+
29+
## Docker Build
30+
31+
For development, the following docker commands can help get started
32+
33+
docker run --network host --name mysql-11 -e MYSQL_ROOT_PASSWORD=62-AntHill -d mysql:latest
34+
docker exec -it mysql-11 bash -c 'echo "create database clocschema;" | mysql -u root -h 127.0.0.1 -p62-AntHill'
35+
cd hera/tests/devdocker
36+
rsync -av --exclude tests/devdocker ../.. src/github.com/paypal/hera
37+
docker build -t hera-oss .
38+
docker run -it --rm --name testRunHeraOss --network host -e password=62-AntHill hera-oss
39+
40+
To test it, in a separate terminal:
41+
42+
docker exec -it testRunHeraOss /bin/bash
43+
cd /go/src
44+
go run github.com/paypal/hera/client/gosqldriver/muxtls/example/sample_main.go
45+
46+
## Manual Build
47+
48+
The following sections explain the process for manually building mux without Docker. We only tested on RedHat and Ubuntu.
49+
50+
### Install Dependencies
51+
52+
1. [Install Go 1.10+](http://golang.org/doc/install).
53+
2. Install [MySQL](http://dev.mysql.com/downloads/mysql) or Oracle(https://www.oracle.com/index.html).
54+
3. Install the [MySQL driver](github.com/go-sql-driver/mysql) and the [Oracle driver](https://github.com/go-goracle/goracle)
55+
3. Install Oracle instant client
56+
57+
### Build Binaries
58+
59+
1. Navigate to the working directory.
60+
```
61+
cd $WORKSPACE
62+
export GOPATH=$WORKSPACE
63+
```
64+
2. Option 1
65+
66+
Clone the source code from [github](https://github.com/paypal/hera)
67+
```
68+
git clone [email protected]:paypal/hera src/github.com/paypal/hera
69+
```
70+
Option 2
71+
72+
(a) GO 1.12 is prerequisite
73+
74+
(b) export GO111MODULE=on ( to enable the go mod feature)
75+
```
76+
go get github.com/paypal/hera
77+
```
78+
3. Install the dependencies: MySQL and Oracle driver
79+
```
80+
go get gopkg.in/goracle.v2
81+
go get github.com/go-sql-driver/mysql
82+
```
83+
4. Build server binaries
84+
```
85+
go install github.com/paypal/hera/mux github.com/paypal/hera/worker/mysqlworker github.com/paypal/hera/worker/oracleworker
86+
```
87+
5. Build Go test client
88+
```
89+
go install github.com/paypal/hera/tests/e2e/client
90+
```
91+
6. Build Java test client under the client/java directory
92+
93+
### Running the server
94+
95+
To run mux there is minimal configuration required. Please see examples for running with [MySQL](https://github.com/paypal/hera/tree/master/tests/e2e/srvmysql) or [Oracle](https://github.com/paypal/hera/tree/master/tests/e2e/srvoracle).
96+
The main configuration file is hera.txt, which must contain the TCP port where the server listens and the number of workers. The user name, password and the data source are passsed via environment parameters.
97+
```
98+
# the proxy executable
99+
ln -s $GOPATH/bin/mux .
100+
# the MySQL worker
101+
ln -s $GOPATH/bin/mysqlworker mysqlworker
102+
# to use the Oracle worker use oracleworker instead of mysqlworker
103+
104+
# create the configuration file with the required configuration
105+
echo 'bind_ip=127.0.0.1' > hera.txt
106+
echo 'bind_port=11111' >> hera.txt
107+
echo 'opscfg.hera.server.max_connections=2' >> hera.txt
108+
# if using mysql run this
109+
# echo 'database_type=mysql' >> hera.txt
110+
111+
# create minimal CAL configuration, needed by ops config
112+
   echo 'cal_pool_name=stage_hera' > cal_client.txt
113+
114+
# the database user name
115+
export username='user'
116+
# the database password
117+
export password='pass'
118+
# the data source
119+
export TWO_TASK='tcp(127.0.0.1:3306)/myschema'
120+
# for Oracle the datasource can be like '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname)
121+
# (PORT=12345)))(CONNECT_DATA=(SERVICE_NAME=sn)))'.
122+
# for Oracle only add to LD_LIBRARY_PATH environment variable the path to the shared libraries of the
123+
# Oracle instant client
124+
125+
# start
126+
./mux --name hera-test
127+
```
128+
For details about the parameters see [configuration](docs/configuration.md)
129+
130+
## Running the client
131+
132+
There is a Java client implemented as JDBC driver. Please see the [documentation](https://github.com/paypal/hera/tree/master/client/java) for how to install and use it.
133+
134+
There is also a Go client implemented as [SQL driver](client/gosqldriver). Please see the [example](tests/e2e/client).
135+
136+
## License
137+
138+
Hera is licensed under Apache 2.0.
139+

cal/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# calclient
2+
3+
Needs the config package
4+

0 commit comments

Comments
 (0)