-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Далбеев Георгий / ИТМО DWS / Stage 5 #195
Merged
Merged
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
05e9923
stage1
88a5902
stage1
d67f73f
stage1
7491aad
report stage1
98ffc92
Merge branch 'main' into lab1
202f435
fix issues
efd4138
lab2 code and move lab1 dir
a6d1fea
fix codestyle
a352103
fix codestyle
585536f
Merge branch 'main' into lab2
incubos 85d43c1
Merge branch 'main' into lab2
98e3447
fix code
f081371
Merge remote-tracking branch 'origin/lab2' into lab2
502073a
fix codestyle
5dc8c66
fix report
e70d901
Merge branch 'main' into lab2
goshadalbeev dc68806
Merge branch 'main' into lab2
incubos 027a623
Merge branch 'main' into lab3
goshadalbeev 8cbc001
code
goshadalbeev 5696a00
fix codestyle
goshadalbeev 4d227fa
fix codestyle
goshadalbeev b67da69
Merge branch 'main' into lab3
goshadalbeev 0eb99ad
Merge branch 'main' into lab3
goshadalbeev 839dd28
add report
2c64471
add report
b132288
Merge branch 'main' into lab3
goshadalbeev e879893
fix code
goshadalbeev fddbbc2
stage 4 init commmit - only code
goshadalbeev 5bd4502
fixcodestyle
goshadalbeev 4aa017b
Merge branch 'main' into lab4
goshadalbeev 4f92069
fixcodestyle
goshadalbeev 86a093c
Merge remote-tracking branch 'origin/lab4' into lab4
goshadalbeev f70ce2e
Merge branch 'main' into lab4
2ef960f
wrk and async
c822bb5
add report
2e0092b
Merge branch 'main' into lab4
goshadalbeev 8da9866
Merge branch 'main' into lab4
goshadalbeev 857c3a3
add code
goshadalbeev 67aefed
fix
goshadalbeev 02459ba
fix codestyle
goshadalbeev 7216161
fix codestyle
goshadalbeev 78619ce
fix codestyle
goshadalbeev c965e1d
Merge branch 'main' into lab5
goshadalbeev 2fccbce
Merge branch 'main' into lab5
goshadalbeev b450da6
fix codestyle
goshadalbeev 1376ebf
Merge remote-tracking branch 'origin/lab5' into lab5
goshadalbeev 116f834
fix codestyle
goshadalbeev c49a053
fix codestyle
goshadalbeev 9597989
fix codestyle
goshadalbeev 8a0949d
Merge branch 'main' into lab5
goshadalbeev 48800e2
Merge branch 'main' into lab5
goshadalbeev 50d9272
add wrk and profiling. add report
81601ea
Merge remote-tracking branch 'origin/lab5' into lab5
869f602
add wrk and profiling. add report
eb11798
fix report
goshadalbeev 05e6121
fix some words in report
goshadalbeev 85185eb
Merge branch 'main' into lab5
goshadalbeev e5c9345
fix log
goshadalbeev d510473
Merge branch 'main' into lab5
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
35 changes: 0 additions & 35 deletions
35
src/main/java/ru/vk/itmo/test/georgiidalbeev/ConsistentHashing.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
src/main/java/ru/vk/itmo/test/georgiidalbeev/MyHandleResult.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,14 @@ | ||
package ru.vk.itmo.test.georgiidalbeev; | ||
|
||
public record MyHandleResult(int status, byte[] data, long timestamp) { | ||
|
||
public MyHandleResult(int status, byte[] data, long timestamp) { | ||
this.status = status; | ||
this.data = data; | ||
this.timestamp = timestamp; | ||
} | ||
|
||
public MyHandleResult(int status, byte[] data) { | ||
this(status, data, 0); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/ru/vk/itmo/test/georgiidalbeev/MyMergeHandleResult.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,69 @@ | ||
package ru.vk.itmo.test.georgiidalbeev; | ||
|
||
import one.nio.http.HttpSession; | ||
import one.nio.http.Response; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.net.HttpURLConnection; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
public class MyMergeHandleResult { | ||
private static final Logger log = LoggerFactory.getLogger(MyMergeHandleResult.class); | ||
private final AtomicInteger count; | ||
private final AtomicInteger success; | ||
private final int ack; | ||
private final int from; | ||
private final HttpSession session; | ||
private boolean isSent; | ||
MyHandleResult mergedResult = new MyHandleResult(HttpURLConnection.HTTP_GATEWAY_TIMEOUT, null); | ||
|
||
public MyMergeHandleResult(HttpSession session, int size, int ack) { | ||
this.session = session; | ||
this.count = new AtomicInteger(); | ||
this.ack = ack; | ||
this.from = size; | ||
this.success = new AtomicInteger(); | ||
} | ||
|
||
public void add(MyHandleResult handleResult) { | ||
int get = count.incrementAndGet(); | ||
|
||
if (handleResult.status() == HttpURLConnection.HTTP_OK | ||
|| handleResult.status() == HttpURLConnection.HTTP_CREATED | ||
|| handleResult.status() == HttpURLConnection.HTTP_ACCEPTED | ||
|| handleResult.status() == HttpURLConnection.HTTP_NOT_FOUND) { | ||
success.incrementAndGet(); | ||
if (mergedResult.timestamp() <= handleResult.timestamp()) { | ||
mergedResult = handleResult; | ||
} | ||
if (success.get() >= ack && !isSent) { | ||
isSent = true; | ||
sendResult(); | ||
} | ||
} | ||
|
||
if (get == from && success.get() < ack && !isSent) { | ||
sendResult(); | ||
} | ||
} | ||
|
||
private void sendResult() { | ||
try { | ||
if (success.get() < ack) { | ||
session.sendResponse(new Response(Response.GATEWAY_TIMEOUT, Response.EMPTY)); | ||
} else { | ||
session.sendResponse(new Response(String.valueOf(mergedResult.status()), mergedResult.data())); | ||
} | ||
} catch (Exception e) { | ||
log.error("Exception during handleRequest", e); | ||
try { | ||
session.sendResponse(new Response(Response.INTERNAL_ERROR, Response.EMPTY)); | ||
} catch (IOException ex) { | ||
log.error("Exception while sending close connection", e); | ||
session.scheduleClose(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не атомарная проверка переменной и ее изменение. можем 2 раза отправить ответ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
у меня коммит после дедлайна, потому что идея решила перенести чужие файлы, в моей директории я ничего не трогал, проверьте.