Skip to content

Commit

Permalink
Fix code smells.
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
  • Loading branch information
gregschohn committed Nov 16, 2023
1 parent 1d1375c commit f7c9f28
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
import org.opensearch.migrations.coreutils.MetricsLogger;
import org.opensearch.migrations.trafficcapture.IChannelConnectionCaptureSerializer;

import java.io.IOException;
import java.net.SocketAddress;
import java.time.Instant;
import java.util.List;

@Slf4j
public class LoggingHttpResponseHandler<T> extends ChannelOutboundHandlerAdapter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import io.burt.jmespath.jcf.JcfRuntime;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class JsonJMESPathTransformerProvider implements IJsonTransformerProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public void channelInactive(ChannelHandlerContext ctx) {
FrontsideHandler.closeAndFlush(writeBackChannel);
metricsLogger.atSuccess(MetricsEvent.BACKSIDE_HANDLER_CHANNEL_CLOSED)
.setAttribute(MetricsAttributeKey.CHANNEL_ID, ctx.channel().id().asLongText()).emit();
// .setMessage("BacksideHandler channel is closed.").log();
}

@Override
Expand All @@ -54,6 +53,5 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
FrontsideHandler.closeAndFlush(ctx.channel());
metricsLogger.atError(MetricsEvent.BACKSIDE_HANDLER_EXCEPTION, cause)
.setAttribute(MetricsAttributeKey.CHANNEL_ID, channelId).emit();
// .setMessage("Exception caught by BacksideChannel").log();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ public class AdaptiveRateLimiter<D,T> {
.limitForPeriod(10) // adjust this dynamically based on your needs
.build();

var retry = Retry.of("Retry_" + System.identityHashCode(producer), retryConfig);
Retry.of("Retry_" + System.identityHashCode(producer), retryConfig);
var rateLimiter = RateLimiter.of("RateLimiter_" + System.identityHashCode(producer), rateLimiterConfig);

var rateLimitedSupplier =
RateLimiter.decorateCompletionStage(rateLimiter, () -> {
var df = producer.get();
return df.future;
});
RateLimiter.decorateCompletionStage(rateLimiter, () -> {
var df = producer.get();
return df.future;
});

// TODO: I'm still trying to figure out how to connect these together and to round-trip
// marshal the DTCF through as a CompletionStage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void updateContentTimeControllerWhenIdling() {
}

// See the comment on totalCountOfScheduledTasksOutstanding. We could do this on a per-thread basis and
// join the results all via `networkSendOrchestrator.clientConnectionPool.eventLoopGroup`;
// join the results all via `networkSendOrchestrator.clientConnectionPool.eventLoopGroup`
public boolean isWorkOutstanding() {
return totalCountOfScheduledTasksOutstanding.get() > 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import io.netty.util.concurrent.Future;
import lombok.AllArgsConstructor;
import lombok.Lombok;
import lombok.NonNull;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -643,10 +644,9 @@ Void handleCompletedTransaction(@NonNull UniqueReplayerRequestKey requestKey, Re
packageAndWriteResponse(resultTupleConsumer, requestKey, rrPair, summary, (Exception) t);
commitTrafficStreams(rrPair.trafficStreamKeysBeingHeld, rrPair.completionStatus);
return null;
} else if (t instanceof Error) {
throw (Error) t;
} else {
throw new Error("Unknown throwable type passed to handle().", t);
log.atError().setCause(t).setMessage(()->"Throwable passed to handle(). Rethrowing.").log();
throw Lombok.sneakyThrow(t);
}
} catch (Error error) {
log.atError()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public DiagnosticTrackableCompletableFuture<String, TransformedOutputAndResult<R
.setAttribute(MetricsAttributeKey.REQUEST_ID, requestKeyForMetricsLogging.toString())
.setAttribute(MetricsAttributeKey.CONNECTION_ID, requestKeyForMetricsLogging.getTrafficStreamKey().getConnectionId())
.setAttribute(MetricsAttributeKey.CHANNEL_ID, channel.id().asLongText()).emit();
// .setMessage("Request failed to be transformed").log();
throw new CompletionException(t);
}
} else {
Expand Down Expand Up @@ -184,7 +183,6 @@ private static Throwable unwindPossibleCompletionException(Throwable t) {
.setAttribute(MetricsAttributeKey.REQUEST_ID, requestKeyForMetricsLogging)
.setAttribute(MetricsAttributeKey.CONNECTION_ID, requestKeyForMetricsLogging.getTrafficStreamKey().getConnectionId())
.setAttribute(MetricsAttributeKey.CHANNEL_ID, channel.id().asLongText()).emit();
// .setMessage("Request was redriven without transformation").log();
return finalizedFuture.map(f->f.thenApply(r->reason == null ?
new TransformedOutputAndResult<R>(r, HttpRequestTransformationStatus.SKIPPED, null) :
new TransformedOutputAndResult<R>(r, HttpRequestTransformationStatus.ERROR, reason)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import java.time.Duration;
import java.time.Instant;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import java.time.Duration;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
Expand Down

0 comments on commit f7c9f28

Please sign in to comment.