Skip to content
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

Осипов Даниил ИТМО ФИТИП HW5 #188

Merged
merged 32 commits into from
May 25, 2024
Merged

Conversation

Sbread
Copy link
Contributor

@Sbread Sbread commented Apr 11, 2024

No description provided.

instance.start().get(1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define and throw a dedicated exception instead of using a generic one.

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid unused imports such as 'java.util.concurrent.ExecutorService'

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid unused imports such as 'java.util.concurrent.TimeUnit'

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 29831 lines exceeds the maximum allowed for the inline comments feature.

public boolean add(int index, HandleResult handleResult) {
handleResults[index] = handleResult;
int valid = validateResultStatus(handleResult.status()) ? countValid.getAndIncrement() : countValid.get();
if (valid >= ack) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Получается, если у тебя ack = 3, а from = 5, то ты 3 раза сделаешь sendResult. Лучше проверяй не на >=, а на =

: HttpRequest.BodyPublishers.ofByteArray(request.getBody())
)
.header(HEADER_REMOTE, "true")
.timeout(Duration.ofMillis(500))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все числа в константы. В твоём случае лучше вообще Duration.ofMillis(500), чтобы не аллоцировать каждый раз

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

поправил

}

for (int i = count; i < config.clusterUrls().size(); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему не посчитать хеш от всех clusterUrls, отсортировать и взять первые count?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем, у нас будет count * log(count), а так count + count * (cluster.size() - count). Тут ситуативно + у нас дефолтное значение count как раз cluster.size(), то есть я считаю что у нас достаточно случаев когда эта реализация работает лучше

}

void shutdownAndAwaitTermination(ExecutorService pool) {
private void shutdownAndAwaitTermination(ExecutorService pool) {
try {
if (!pool.awaitTermination(60, TimeUnit.MILLISECONDS)) {
pool.shutdownNow();
if (!pool.awaitTermination(60, TimeUnit.MILLISECONDS)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут тоже все числа в константы

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

поправил

@@ -0,0 +1,49 @@
# Отчёт по 5 стейджу.

К сожалению, так как 4 стейдж я не делал, сравнений не будет,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В 3 стейдже ты шардировал свою систему.

  1. Попробуй в том стейдже выключить один шард, посмотри сколько будет неудачных (статус не 200 и не 300) запросов
  2. В этом стейдже попробуй выключить один шард, посмотри сколько будет неудачных запросов

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавил в конец отчёта

Copy link
Contributor

@FedosOnGIT FedosOnGIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пока 8 баллов. Поправь, можно получить больше

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 29941 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 30061 lines exceeds the maximum allowed for the inline comments feature.

Copy link

@codeclimate codeclimate bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR diff size of 29382 lines exceeds the maximum allowed for the inline comments feature.

@@ -29,7 +29,7 @@ public MergeHandleResult(HttpSession session, int size, int ack) {
public boolean add(int index, HandleResult handleResult) {
handleResults[index] = handleResult;
int valid = validateResultStatus(handleResult.status()) ? countValid.getAndIncrement() : countValid.get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Единственное, тебе нужен incrementAndGet иначе тебе будет нужно ack + 1 ответов и например, если у тебя ack = 2, from = 3, то придётся ждать пока доработает последний

Copy link
Contributor

@FedosOnGIT FedosOnGIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ОК 12

@incubos incubos merged commit 7323e7a into polis-vk:main May 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants