Skip to content

Commit c85708c

Browse files
committed
first commit
1 parent 06e4012 commit c85708c

Some content is hidden

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

47 files changed

+1560
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.gradle
2+
.idea
3+
*build/

api/build.gradle

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
}
5+
dependencies {
6+
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.10'
7+
}
8+
}
9+
10+
plugins {
11+
id 'com.google.protobuf' version '0.8.10'
12+
id 'java'
13+
id 'idea'
14+
id 'com.github.ben-manes.versions' version '0.19.0'
15+
}
16+
17+
repositories {
18+
mavenCentral()
19+
}
20+
21+
protobuf {
22+
protoc {
23+
// The version of protoc must match protobuf-java. If you don't depend on
24+
// protobuf-java directly, you will be transitively depending on the
25+
// protobuf-java version that grpc depends on.
26+
artifact = 'com.google.protobuf:protoc:3.11.3'
27+
}
28+
plugins {
29+
grpc {
30+
artifact = 'io.grpc:protoc-gen-grpc-java:1.24.0'
31+
}
32+
}
33+
generateProtoTasks {
34+
all()*.plugins {
35+
grpc {}
36+
}
37+
}
38+
// generatedFilesBaseDir = '$projectDir/src/'
39+
}
40+
41+
sourceCompatibility = 1.11
42+
43+
dependencies {
44+
compile 'io.grpc:grpc-all:1.27.0'
45+
compile('javax.annotation:javax.annotation-api:1.3.2')
46+
testCompile group: 'junit', name: 'junit', version: '4.13'
47+
48+
}

api/src/main/proto/dataset_info.proto

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
syntax = "proto3";
2+
3+
package sustain.synopsis.metadata;
4+
5+
message DatasetInfo {
6+
string dataset_id = 1;
7+
int64 temporal_bracket_length = 2;
8+
int32 geohash_length = 3;
9+
string bin_config = 4;
10+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
syntax = "proto3";
2+
3+
package sustain.synopsis.metadata;
4+
5+
import "dataset_info.proto";
6+
import "health_check.proto";
7+
8+
message RegisterDatasetRequest {
9+
DatasetInfo datasetInfo = 1;
10+
}
11+
12+
message RegisterDatasetResponse {
13+
14+
}
15+
16+
message GetDatasetInfoRequest {
17+
string id = 1;
18+
}
19+
20+
message GetDatasetInfoResponse {
21+
DatasetInfo datasetInfo = 1;
22+
}
23+
24+
message GetDatasetInfosRequest {
25+
26+
}
27+
28+
message GetDatasetInfosResponse {
29+
repeated DatasetInfo info = 1;
30+
}
31+
32+
service DatasetService {
33+
rpc checkHealth (HealthCheckRequest) returns (HealthCheckResponse);
34+
rpc registerDataset (RegisterDatasetRequest) returns (RegisterDatasetResponse);
35+
rpc getDatasetInfo (GetDatasetInfoRequest) returns (GetDatasetInfoResponse);
36+
rpc getDatasetInfos (GetDatasetInfosRequest) returns (GetDatasetInfosResponse);
37+
}

api/src/main/proto/health_check.proto

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
syntax = "proto3";
2+
3+
package sustain.synopsis.metadata;
4+
5+
message HealthCheckRequest {
6+
7+
}
8+
9+
message HealthCheckResponse {
10+
bool is_healthy = 1;
11+
}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
syntax = "proto3";
2+
3+
package sustain.synopsis.metadata;
4+
5+
import "google/protobuf/timestamp.proto";
6+
import "dataset_info.proto";
7+
import "health_check.proto";
8+
9+
message CreateSessionRequest {
10+
string dataset_id = 1;
11+
string client_id = 2;
12+
}
13+
14+
message CreateSessionResponse {
15+
int64 session_id = 1;
16+
DatasetInfo dataset = 2;
17+
google.protobuf.Timestamp created_at = 3;
18+
}
19+
20+
service IngestService {
21+
rpc checkHealth (HealthCheckRequest) returns (HealthCheckResponse);
22+
rpc createSession (CreateSessionRequest) returns (CreateSessionResponse);
23+
}
24+

api/src/main/proto/user_service.proto

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
syntax = "proto3";
2+
3+
package sustain.synopsis.metadata;
4+
5+
import "dataset_info.proto";
6+
import "health_check.proto";
7+
8+
message RegisterUserRequest {
9+
string email = 1;
10+
string password = 2;
11+
}
12+
13+
message RegisterUserResponse {
14+
bool success = 1;
15+
string description = 2;
16+
}
17+
18+
message AuthenticateRequest {
19+
string email = 1;
20+
string password = 2;
21+
}
22+
23+
message AuthenticateResponse {
24+
bool success = 1;
25+
string description = 2;
26+
string token = 3;
27+
}
28+
29+
30+
service UserService {
31+
rpc checkHealth (HealthCheckRequest) returns (HealthCheckResponse);
32+
rpc registerUser (RegisterUserRequest) returns (RegisterUserResponse);
33+
rpc authenticate (AuthenticateRequest) returns (AuthenticateResponse);
34+
}

build.gradle

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
allprojects {
3+
repositories {
4+
jcenter()
5+
mavenCentral()
6+
}
7+
}
8+
9+
subprojects {
10+
version = '1.0'
11+
}

common/build.gradle

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
compile project(':api')
11+
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.10.2'
12+
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.10.2'
13+
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.19'
14+
compile 'com.auth0:java-jwt:3.9.0'
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package sustain.synopsis.metadata;
2+
3+
4+
public class ClusterConfig {
5+
6+
private ServerConfig ingest_server;
7+
private ServerConfig dataset_server;
8+
private ServerConfig user_server;
9+
private DatabaseConfig database;
10+
11+
public ServerConfig getIngest_server() {
12+
return ingest_server;
13+
}
14+
15+
public void setIngest_server(ServerConfig ingest_server) {
16+
this.ingest_server = ingest_server;
17+
}
18+
19+
public ServerConfig getDataset_server() {
20+
return dataset_server;
21+
}
22+
23+
public void setDataset_server(ServerConfig dataset_server) {
24+
this.dataset_server = dataset_server;
25+
}
26+
27+
public ServerConfig getUser_server() {
28+
return user_server;
29+
}
30+
31+
public void setUser_server(ServerConfig user_server) {
32+
this.user_server = user_server;
33+
}
34+
35+
public DatabaseConfig getDatabase() {
36+
return database;
37+
}
38+
39+
public void setDatabase(DatabaseConfig database) {
40+
this.database = database;
41+
}
42+
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package sustain.synopsis.metadata;
2+
3+
public class DatabaseConfig {
4+
5+
private String host;
6+
private int port;
7+
private String user;
8+
private String password;
9+
private String database_name;
10+
11+
public String getHost() {
12+
return host;
13+
}
14+
15+
public void setHost(String host) {
16+
this.host = host;
17+
}
18+
19+
public int getPort() {
20+
return port;
21+
}
22+
23+
public void setPort(int port) {
24+
this.port = port;
25+
}
26+
27+
public String getUser() {
28+
return user;
29+
}
30+
31+
public void setUser(String user) {
32+
this.user = user;
33+
}
34+
35+
public String getPassword() {
36+
return password;
37+
}
38+
39+
public void setPassword(String password) {
40+
this.password = password;
41+
}
42+
43+
public String getDatabase_name() {
44+
return database_name;
45+
}
46+
47+
public void setDatabase_name(String database_name) {
48+
this.database_name = database_name;
49+
}
50+
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package sustain.synopsis.metadata;
2+
3+
import java.io.ByteArrayOutputStream;
4+
import java.io.IOException;
5+
import java.nio.charset.StandardCharsets;
6+
import java.security.MessageDigest;
7+
import java.security.NoSuchAlgorithmException;
8+
9+
public class HashAlgorithm {
10+
11+
// might want to cache a message digest instance per thread
12+
public static byte[] generateUserSecret(String email, String password) throws IOException, NoSuchAlgorithmException {
13+
ByteArrayOutputStream out = new ByteArrayOutputStream();
14+
out.write(email.getBytes(StandardCharsets.UTF_8));
15+
out.write(password.getBytes(StandardCharsets.UTF_8));
16+
byte[] bytes = out.toByteArray();
17+
byte[] hash = MessageDigest.getInstance("SHA-256").digest(bytes);
18+
return hash;
19+
}
20+
21+
}

0 commit comments

Comments
 (0)