Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c0881bd
feat: configmap + secrets
omarsamyb Jun 27, 2021
c691fe7
feat: rabbitmq
omarsamyb Jun 27, 2021
ddffed4
feat: arangodb
omarsamyb Jun 27, 2021
6b5e1fb
feat: server
omarsamyb Jun 27, 2021
68d2af8
feat: couchbase
omarsamyb Jun 27, 2021
f7b9e2c
feat: search app
omarsamyb Jun 27, 2021
946ceb7
feat: recommendation app
omarsamyb Jun 27, 2021
2c9be2d
feat: thread app
omarsamyb Jun 27, 2021
d7a8b17
feat: subthread app
omarsamyb Jun 27, 2021
69f0174
feat: user_to_user_actions_app
omarsamyb Jun 27, 2021
31556ed
fix: namings
omarsamyb Jun 27, 2021
b891e97
feat: scripts
omarsamyb Jun 27, 2021
e8b73d7
Merge branch 'main' of https://github.com/Moe98/reddit into minikube
MoFarid Jun 27, 2021
6dd2b25
feat: add notification app deployment yml
MoFarid Jun 27, 2021
13c7f05
fix: couchbase resources + rec app image name
omarsamyb Jun 27, 2021
b841334
Merge branch 'minikube' of https://github.com/Moe98/reddit into minikube
omarsamyb Jun 27, 2021
93d912a
fix: incorrect hpa app reference
omarsamyb Jun 27, 2021
225d19e
feat: add couchbase op exe
omarsamyb Jun 27, 2021
a9cc7e8
fix: Only execute SQL scripts in dev mode
ZeyadKhattab Jun 27, 2021
b0b6329
feat: Added secrets for postegres
ZeyadKhattab Jun 27, 2021
dcbdc61
feat: Added postgres deployment
ZeyadKhattab Jun 27, 2021
8d1170d
feat: Added postgres env variables to postgres
ZeyadKhattab Jun 27, 2021
f1b5060
feat: Added command for creating sql files configmap
ZeyadKhattab Jun 27, 2021
afdebd9
feat: Added user app deployment
ZeyadKhattab Jun 27, 2021
90ee464
fix: use auto resource allocation
omarsamyb Jun 28, 2021
8c5cbc8
fix: update POSTGRES_HOST to postgres-service
MoFarid Jun 28, 2021
ad72a5e
fix: set selector for postgres-deployment
MoFarid Jun 28, 2021
fe873cd
fix: set secretKeyRef for authentication
MoFarid Jun 28, 2021
5bcfcbd
fix: incorrect hpa app reference
ZeyadKhattab Jun 28, 2021
dc15724
Added user app and postgres commands to .bat files
ZeyadKhattab Jun 28, 2021
7fe421f
Merge pull request #128 from Moe98/minikube-user-app
ZeyadKhattab Jun 28, 2021
2ed9f82
feat: add minIO secrets
ZeyadKhattab Jun 28, 2021
982c1a7
feat: Added MinIO_host to confimap
ZeyadKhattab Jun 28, 2021
9119c73
feat: Used MinIO secrets in user app deployment
ZeyadKhattab Jun 28, 2021
a990d71
Merge branch 'main' into minikube
omarsamyb Jun 28, 2021
55745ce
Added kube api
ZeyadKhattab Jun 28, 2021
57edbb8
feat: cassandra deployment
omarsamyb Jun 28, 2021
c4484f6
feat: chat app
omarsamyb Jun 28, 2021
8300254
refactor: remove dependency on Controller
MoFarid Jun 28, 2021
76f98c4
feat: make Controller jar executable
MoFarid Jun 28, 2021
f70610d
feat: read byte[] from file in Controller
MoFarid Jun 28, 2021
2b89ad2
feat: receive command ArrayList in ControlManager
MoFarid Jun 28, 2021
14c28e5
fix: typos in minIo password
ZeyadKhattab Jun 28, 2021
9424155
Merge branch 'minikube' of https://github.com/Moe98/reddit into contr…
ZeyadKhattab Jun 28, 2021
1dd9294
fix: changed the incorrect refactoring from X.class to original
ZeyadKhattab Jun 29, 2021
665eb52
Merge branch 'main' into controller-kubernetes
ZeyadKhattab Jun 29, 2021
ba072a9
fix: remove .class extension
ZeyadKhattab Jun 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions apps/controller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java</artifactId>
<version>10.0.0</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -88,5 +93,50 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>org.sab.controller.Controller</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.sab.controller.Controller</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.sab.controller;

import org.json.JSONObject;
import org.sab.classes.Reader;
import org.sab.io.IoUtils;

import java.io.BufferedReader;
Expand Down Expand Up @@ -108,8 +109,9 @@ private String fileNameToEncodedString(String fileName) throws IOException {
}

private void addOrUpdateClass(JSONObject request) throws Exception {
String fileName = request.getJSONArray(ARGS).getString(0);
addArg(request, fileNameToEncodedString(fileName));
String resource = request.getJSONArray(ARGS).getString(2);
final byte[] b = Reader.readBytesFromResource(resource);
request.getJSONArray(ARGS).put(2, b);
sendMessage(request);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.sab.controller;


import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.Configuration;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.openapi.models.V1Pod;
import io.kubernetes.client.openapi.models.V1PodList;
import io.kubernetes.client.openapi.models.V1PodStatus;
import io.kubernetes.client.util.Config;

import java.io.IOException;

public class PodsConnector {

private static String getPodIp(String podName) throws IOException, ApiException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api api = new CoreV1Api();
V1PodList list = api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null);
for(V1Pod pod: list.getItems()) {
if(pod.getMetadata().getName().equals(podName))
return pod.getStatus().getPodIP();
}
return null;

}

public static void main(String[] args) throws IOException, ApiException {

System.out.println(getPodIp("postgres-deployment-d98d5ffd7-zr74l"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void addCommand() {
invocationResult
);

app.getControlManager().addCommand(
app.getControlManager().addCommandWithBytes(
functionName,
"org.sab.demo.commands.MorningWorld",
Reader.readBytesFromResource("MorningWorld")
Expand Down Expand Up @@ -98,7 +98,7 @@ public void updateCommand() {
invocationResult
);

app.getControlManager().updateCommand(
app.getControlManager().updateCommandWithBytes(
functionName,
"org.sab.demo.commands.HelloWorld",
Reader.readBytesFromResource("ImprovedHello")
Expand Down
2 changes: 1 addition & 1 deletion apps/user_app/src/main/java/org/sab/user/UserApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void main(String[] args) throws IOException, EnvironmentVariableNo
}

public static void dbInit() throws IOException, EnvironmentVariableNotLoaded {
if (!Utilities.inContainerizationMode())
if (Utilities.isDevelopmentMode())
PostgresConnection.dbInit();
arangoDbInit();
}
Expand Down
2 changes: 1 addition & 1 deletion cli/hooks/chat-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const useChatService = () => {
}

useEffect(() => {
ws.current = new W3CWebSocket('ws://localhost:5000/ws')
ws.current = new W3CWebSocket('ws://chat.notreddit.com/ws')

ws.current.onopen = () => {
ws.current.send(
Expand Down
14 changes: 9 additions & 5 deletions libs/rabbitmq/src/main/java/org/sab/rabbitmq/RPCBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class RPCBase {

private static final String LOCALHOST = "localhost";

private RPCBase() {
}
Expand All @@ -18,10 +17,15 @@ public static Connection initConnection() throws TimeoutException, IOException {
ConnectionFactory factory = new ConnectionFactory();

String rabbitHost = System.getenv("RABBIT_HOST");
if(rabbitHost == null)
rabbitHost = LOCALHOST;

factory.setHost(rabbitHost);
String rabbitUser = System.getenv("RABBIT_USER");
String rabbitPassword = System.getenv("RABBIT_PASSWORD");

if (rabbitHost != null)
factory.setHost(rabbitHost);
if (rabbitUser != null)
factory.setUsername(rabbitUser);
if (rabbitPassword != null)
factory.setPassword(rabbitPassword);

return factory.newConnection();
}
Expand Down
6 changes: 0 additions & 6 deletions libs/service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@
<artifactId>netty-all</artifactId>
<version>4.1.60.Final</version>
</dependency>
<dependency>
<groupId>org.sab</groupId>
<artifactId>controller</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.sab.service.managers;

import org.json.JSONObject;
import org.sab.controller.Controller;
import org.sab.databases.PoolDoesNotExistException;
import org.sab.reflection.ReflectionUtils;
import org.sab.service.ServiceConstants;
Expand All @@ -10,6 +9,7 @@
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.concurrent.*;

public class ControlManager {
Expand All @@ -20,6 +20,7 @@ public class ControlManager {
private final PropertiesManager propertiesManager;
private final ClassManager classManager = new ClassManager();

private final static String ARGS = "args";
private final int DB_INIT_AWAIT_MINUTES = 1;

private boolean isFrozen = true;
Expand All @@ -34,8 +35,9 @@ public void handleControllerMessage(JSONObject message) {
System.out.printf("%s has received a message from the controller!\n%s\n", appUriName, message.toString());
Method method = ReflectionUtils.getMethod(ControlManager.class, message.getString("command"));
try {
boolean hasArgs = message.has(Controller.ARGS);
method.invoke(this, hasArgs ? message.optJSONArray(Controller.ARGS).toList().toArray() : null);
boolean hasArgs = message.has(ARGS);
final Object[] arguments = message.optJSONArray(ARGS).toList().toArray();
method.invoke(this, hasArgs ? arguments : null);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -170,11 +172,21 @@ private void reloadDBPool() throws IOException {
queueManager.startAcceptingNewRequests();
}

public void addCommand(String functionName, String className, byte[] b) {
public void addCommand(String functionName, String className, ArrayList<Integer> byteList) {
final byte[] b = convertIntArrayListToByteArray(byteList);
addCommandWithBytes(functionName, className, b);
}

public void addCommandWithBytes(String functionName, String className, byte[] b) {
classManager.addCommand(functionName, className, b);
}

public void updateCommand(String functionName, String className, byte[] b) {
public void updateCommand(String functionName, String className, ArrayList<Integer> byteList) {
final byte[] b = convertIntArrayListToByteArray(byteList);
updateCommandWithBytes(functionName, className, b);
}

public void updateCommandWithBytes(String functionName, String className, byte[] b) {
classManager.updateCommand(functionName, className, b);
}

Expand Down Expand Up @@ -217,4 +229,12 @@ public ClassManager getClassManager() {
public boolean isFrozen() {
return isFrozen;
}

private byte[] convertIntArrayListToByteArray(ArrayList<Integer> list) {
final byte[] b = new byte[list.size()];
for (int i = 0; i < list.size(); i++) {
b[i] = (byte) ((int) list.get(i));
}
return b;
}
}
9 changes: 9 additions & 0 deletions libs/service/src/main/resources/apps-ports.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
chat=4001
example=4002
notification=4003
recommendation=4004
search=4005
subthread=4006
thread=4007
user=4008
useraction=4009
61 changes: 61 additions & 0 deletions minikube/apps/chat-storage-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: chat-storage-deployment
spec:
selector:
matchLabels:
app: chat_storage
template:
metadata:
labels:
app: chat_storage
spec:
containers:
- name: chat-storage
image: chat_storage:alpine
imagePullPolicy: IfNotPresent
resources:
limits:
memory: "256Mi"
cpu: "500m"
requests:
memory: "128Mi"
cpu: "200m"
env:
- name: RABBIT_USER
valueFrom:
secretKeyRef:
name: rabbitmq-deployment-default-user
key: username
- name: RABBIT_PASSWORD
valueFrom:
secretKeyRef:
name: rabbitmq-deployment-default-user
key: password
- name: CASSANDRA_USERNAME
valueFrom:
secretKeyRef:
name: cassandra-cluster-superuser-default
key: username
- name: CASSANDRA_PASSWORD
valueFrom:
secretKeyRef:
name: cassandra-cluster-superuser-default
key: password
envFrom:
- configMapRef:
name: env-configmap
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: chat-storage-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: chat-storage-deployment
minReplicas: 1
maxReplicas: 5
targetCPUUtilizationPercentage: 60
51 changes: 51 additions & 0 deletions minikube/apps/notification-app-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: notification-app-deployment
spec:
selector:
matchLabels:
app: notification_app
template:
metadata:
labels:
app: notification_app
spec:
containers:
- name: notification-app
image: notification_app
imagePullPolicy: IfNotPresent
resources:
limits:
memory: "256Mi"
cpu: "500m"
requests:
memory: "128Mi"
cpu: "200m"
env:
- name: RABBIT_USER
valueFrom:
secretKeyRef:
name: rabbitmq-deployment-default-user
key: username
- name: RABBIT_PASSWORD
valueFrom:
secretKeyRef:
name: rabbitmq-deployment-default-user
key: password
envFrom:
- configMapRef:
name: env-configmap
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: notification-app-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: notification-app-deployment
minReplicas: 1
maxReplicas: 5
targetCPUUtilizationPercentage: 60
Loading