-
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
1 parent
d794a2e
commit 4bb2816
Showing
8 changed files
with
98 additions
and
13 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -5,4 +5,5 @@ QUEUE_HOST= | |
QUEUE_USER= | ||
QUEUE_PASSWD= | ||
SUBMISSION_QUEUE_NAME= | ||
RESULT_QUEUE_NAME= | ||
RESULT_QUEUE_NAME= | ||
FILE_PATH= |
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 |
---|---|---|
|
@@ -6,3 +6,5 @@ build | |
|
||
# Ignore env files | ||
.env | ||
|
||
fs |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.coder.judge.Model; | ||
|
||
public class Submission { | ||
private int id; | ||
private String lang; | ||
private String code; | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public String getLang() { | ||
return lang; | ||
} | ||
|
||
public void setLang(String lang) { | ||
this.lang = lang; | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.code = code; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/com/coder/judge/Queue/SubmissionCallback.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,26 @@ | ||
package com.coder.judge.Queue; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
import com.coder.judge.Model.Submission; | ||
import com.coder.judge.Serializer.SubmissionSerializer; | ||
import com.rabbitmq.client.DeliverCallback; | ||
import com.rabbitmq.client.Delivery; | ||
|
||
public class SubmissionCallback implements DeliverCallback { | ||
|
||
private static final Logger log = Logger.getLogger(SubmissionCallback.class.getName()); | ||
|
||
@Override | ||
public void handle(String consumerTag, Delivery delivery) { | ||
try { | ||
String message = new String(delivery.getBody(), StandardCharsets.UTF_8); | ||
Submission submission = SubmissionSerializer.getInstance().deserialize(message); | ||
log.info(submission.getId()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/coder/judge/Serializer/SubmissionSerializer.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,25 @@ | ||
package com.coder.judge.Serializer; | ||
|
||
import com.coder.judge.Model.Submission; | ||
import com.google.gson.Gson; | ||
|
||
public class SubmissionSerializer { | ||
|
||
private SubmissionSerializer() { | ||
} | ||
|
||
private static class SingletonHolder { | ||
|
||
private static final SubmissionSerializer INSTANCE = new SubmissionSerializer(); | ||
} | ||
|
||
public static SubmissionSerializer getInstance() { | ||
return SingletonHolder.INSTANCE; | ||
} | ||
|
||
public Submission deserialize(String message) { | ||
Gson gson = new Gson(); | ||
Submission sub = gson.fromJson(message, Submission.class); | ||
return sub; | ||
} | ||
} |
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 @@ | ||
ALTER TABLE "submission" ADD COLUMN "lang" text; |