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

Flush all control commands on ws client close or open #272

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public Thread newThread(Runnable r) {
});
}

public BlockingQueue<Runnable> getQueue() {
return executor.getQueue();
}

public static ControlCommandProcessorThreadPool getInstance() {

if (instance == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.newrelic.agent.security.instrumentator.utils.AgentUtils;
import com.newrelic.agent.security.instrumentator.utils.INRSettingsKey;
import com.newrelic.agent.security.intcodeagent.controlcommand.ControlCommandProcessor;
import com.newrelic.agent.security.intcodeagent.controlcommand.ControlCommandProcessorThreadPool;
import com.newrelic.agent.security.intcodeagent.filelogging.FileLoggerThreadPool;
import com.newrelic.api.agent.security.utils.logging.LogLevel;
import com.newrelic.agent.security.intcodeagent.logging.IAgentConstants;
Expand Down Expand Up @@ -182,10 +183,7 @@ public void onOpen(ServerHandshake handshakedata) {
logger.logInit(LogLevel.INFO, String.format(IAgentConstants.INIT_WS_CONNECTION, AgentConfig.getInstance().getConfig().getK2ServiceInfo().getValidatorServiceEndpointURL()),
WSClient.class.getName());
logger.logInit(LogLevel.INFO, String.format(IAgentConstants.SENDING_APPLICATION_INFO_ON_WS_CONNECT, AgentInfo.getInstance().getApplicationInfo()), WSClient.class.getName());
// RestRequestThreadPool.getInstance().resetIASTProcessing();
// GrpcClientRequestReplayHelper.getInstance().resetIASTProcessing();
// DispatcherPool.getInstance().reset();
// EventSendPool.getInstance().reset();
cleanIASTState();
super.send(JsonConverter.toJSON(AgentInfo.getInstance().getApplicationInfo()));
WSUtils.getInstance().setReconnecting(false);
synchronized (WSUtils.getInstance()) {
Expand All @@ -196,6 +194,15 @@ public void onOpen(ServerHandshake handshakedata) {
logger.logInit(LogLevel.INFO, String.format(IAgentConstants.APPLICATION_INFO_SENT_ON_WS_CONNECT, AgentInfo.getInstance().getApplicationInfo()), WSClient.class.getName());
}

private static void cleanIASTState() {
RestRequestThreadPool.getInstance().resetIASTProcessing();
GrpcClientRequestReplayHelper.getInstance().resetIASTProcessing();
RestRequestThreadPool.getInstance().getRejectedIds().clear();
GrpcClientRequestReplayHelper.getInstance().getRejectedIds().clear();
DispatcherPool.getInstance().reset();
EventSendPool.getInstance().reset();
}

@Override
public void onMessage(String message) {
// Receive communication from IC side.
Expand All @@ -218,6 +225,8 @@ public void onClose(int code, String reason, boolean remote) {
if (code == CloseFrame.NEVER_CONNECTED) {
return;
}
ControlCommandProcessorThreadPool.getInstance().getQueue().clear();
cleanIASTState();
WSUtils.getInstance().setConnected(false);
if (code == CloseFrame.POLICY_VALIDATION) {
WSReconnectionST.cancelTask(true);
Expand Down
Loading