-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Conor Flynn
committed
Sep 22, 2022
1 parent
7796f44
commit c390be4
Showing
26 changed files
with
845 additions
and
90 deletions.
There are no files selected for viewing
Binary file modified
BIN
+1.55 KB
(110%)
Data Engine/Documents/Internal Manual/Packet Spreadsheet.xlsx
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
DeFi-Data-Engine/DeFi Data Engine/config/output.properties
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
DeFi-Data-Engine/DeFi Data Engine/config/stream.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # === GENERAL PROPERTIES === | ||
|
|
||
| # consumer types for accepting input | ||
| general.consumer.types=null | ||
|
|
||
| # producer types for writing output | ||
| general.producer.types=null | ||
|
|
||
| # === REST SOCKET PROPERTIES === | ||
|
|
||
| # Rest socket address | ||
| rest.socket.address=localhost | ||
|
|
||
| # Rest socket port | ||
| rest.socket.port=61100 | ||
|
|
||
| # Rest socket key | ||
| rest.socket.key=rest-key-reserved | ||
|
|
||
| # === OUTPUT SOCKET PROPERTIES === | ||
|
|
||
| # Output socket address | ||
| output.socket.address=localhost | ||
|
|
||
| # Output socket port | ||
| output.socket.port=61200 | ||
|
|
||
| # === LOCAL STREAM PROPERTIES === | ||
|
|
||
| # local stream type used for database configuration | ||
| local.stream.type=mongo_db | ||
|
|
||
| # === MONGO DB PROPERTIES === | ||
|
|
||
| # local MongoDB client URI | ||
| mongodb.properties.uri=mongodb://localhost:27017 | ||
|
|
||
| # local MongoDB state database name | ||
| mongodb.database.state=main-state-db | ||
|
|
||
| # local MongoDB main database name | ||
| mongodb.database.main=main-db | ||
|
|
||
| # authorization collection | ||
| mongodb.auth.collection=auth-collection | ||
|
|
||
| # query delim | ||
| mongodb.query.delim=, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # === TESTING PROPERTIES === | ||
| lsh.authorized=true | ||
| lsh.ready=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
... Engine/src/main/java/org/stream/local/connected/connections/MongoDatabaseConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| package org.stream.local.connected.connections; | ||
|
|
||
| import java.util.Set; | ||
|
|
||
| import org.bson.Document; | ||
| import org.bson.conversions.Bson; | ||
| import org.properties.Config; | ||
| import org.stream.local.connected.mongodb.MongoDatabaseRequestHandler; | ||
| import org.stream.local.handler.DataState; | ||
| import org.stream.local.handler.LocalStreamConnection; | ||
| import org.stream.local.handler.LocalStreamManager; | ||
|
|
||
| import com.mongodb.MongoClient; | ||
| import com.mongodb.MongoClientURI; | ||
| import com.mongodb.client.MongoCollection; | ||
| import com.mongodb.client.MongoDatabase; | ||
| import com.mongodb.client.model.Filters; | ||
|
|
||
| // https://www.mongodb.com/docs/drivers/java/sync/current/fundamentals/builders/filters/ | ||
| public class MongoDatabaseConnection extends LocalStreamConnection { | ||
|
|
||
| private MongoClient client; | ||
| private MongoDatabase state_db; | ||
| private MongoDatabase main_db; | ||
|
|
||
| private boolean authorized = false; | ||
|
|
||
| public MongoDatabaseConnection(LocalStreamManager manager) { | ||
| super(manager); | ||
| } | ||
|
|
||
| @Override | ||
| public String getUUID() { | ||
| return "mongo_db"; | ||
| } | ||
|
|
||
| public boolean init() { | ||
| client = new MongoClient(new MongoClientURI(Config.getProperty("stream", "mongodb.properties.uri"))); | ||
| state_db = client.getDatabase(Config.getProperty("stream", "mongodb.database.state")); | ||
| main_db = client.getDatabase(Config.getProperty("stream", "mongodb.database.main")); | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean authorize() { | ||
| if(client == null || state_db == null || main_db == null) | ||
| return false; | ||
|
|
||
| Bson filter = Filters.eq("title", "test"); | ||
| MongoCollection<Document> collection = main_db.getCollection(Config.getProperty("stream", "mongodb.auth.collection")); | ||
| collection.deleteOne(filter); | ||
|
|
||
| Document document = new Document("title", "test"); | ||
| collection.insertOne(document); | ||
|
|
||
| Document resolved = collection.find().filter(filter).first(); | ||
|
|
||
| authorized = resolved != null && resolved.get("title").equals("test"); | ||
|
|
||
| return authorized; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isAuthorized() { | ||
| return authorized; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isReady() { | ||
| return authorized; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean validate(String... query) { | ||
| // parse query | ||
| return MongoDatabaseRequestHandler.validate(query); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean contains(String... query) { | ||
| if(!validate(query)) | ||
| return false; | ||
|
|
||
| return MongoDatabaseRequestHandler.contains(main_db, query); | ||
| } | ||
|
|
||
| @Override | ||
| public DataState state(String... query) { | ||
| // TODO Integrate state handler | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Set<String> get(String... query) { | ||
| if(!validate(query)) | ||
| return null; | ||
|
|
||
| return MongoDatabaseRequestHandler.get(main_db, query); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean push(String data, String collection) { | ||
| return MongoDatabaseRequestHandler.push(main_db, data, collection); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean modify(String data, String... query) { | ||
| // TODO Auto-generated method stub | ||
| return false; | ||
| } | ||
| } |
5 changes: 0 additions & 5 deletions
5
... Data Engine/src/main/java/org/stream/local/connected/connections/TemplateConnection.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.