Skip to content

Commit

Permalink
[INLONG-11360][Audit] Optimize HTTPServer to exit gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
doleyzi committed Oct 16, 2024
1 parent d551eef commit 41134dc
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
public interface AbstractMetric {

public void report();
public void stop();
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ public void addSendFailed(long count) {
}
public void shutdown() {
timer.shutdown();
metric.stop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,9 @@ private MetricFamilySamples.Sample createSample(MetricDimension key, double valu
public void report() {
LOGGER.info("Report proxy prometheus metric: {} ", metricItem.toString());
}

@Override
public void stop() {
server.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@ public void addSendFailed(long count, long duration) {

public void shutdown() {
timer.shutdown();
metric.stop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,10 @@ private MetricFamilySamples.Sample createSample(MetricDimension key, double valu
public void report() {
LOGGER.info("Report store prometheus metric: {} ", metricItem.toString());
}

@Override
public void stop() {
server.close();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PreDestroy;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -180,4 +182,9 @@ private List<MQInfo> getMQConfig(String host, String clusterTag) {
}
return null;
}

@PreDestroy
public void shutdown() {
MetricsManager.getInstance().shutdown();
}
}

0 comments on commit 41134dc

Please sign in to comment.