generate
This commit is contained in:
+2
-2
@@ -25,5 +25,5 @@ RUN chown appuser:appgroup app.jar
|
|||||||
# Switch to the non-root user
|
# Switch to the non-root user
|
||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
# Run the jar file with JVM flags for heap dump generation on OutOfMemoryError
|
# Run the jar file with JVM flags for heap dump generation on OutOfMemoryError and headless mode
|
||||||
ENTRYPOINT ["java", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/dumps/heap.hprof", "-jar", "app.jar"]
|
ENTRYPOINT ["java", "-Djava.awt.headless=true", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/dumps/heap.hprof", "-jar", "app.jar"]
|
||||||
@@ -325,14 +325,28 @@ public class ReportGenerationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private byte[] buildSentimentChart(Map<String, Long> sentiment) {
|
private byte[] buildSentimentChart(Map<String, Long> sentiment) {
|
||||||
DefaultPieDataset<String> dataset = new DefaultPieDataset<>();
|
|
||||||
for (Map.Entry<String, Long> e : sentiment.entrySet()) {
|
|
||||||
dataset.setValue(e.getKey(), e.getValue());
|
|
||||||
}
|
|
||||||
JFreeChart chart = ChartFactory.createPieChart("Sentiment", dataset, true, false, false);
|
|
||||||
try {
|
try {
|
||||||
return EncoderUtil.encode(chart.createBufferedImage(800, 500), ImageFormat.PNG);
|
// Disable font rendering to avoid Docker font issues
|
||||||
|
System.setProperty("java.awt.headless", "true");
|
||||||
|
|
||||||
|
DefaultPieDataset<String> dataset = new DefaultPieDataset<>();
|
||||||
|
for (Map.Entry<String, Long> e : sentiment.entrySet()) {
|
||||||
|
dataset.setValue(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
JFreeChart chart = ChartFactory.createPieChart("Sentiment", dataset, true, false, false);
|
||||||
|
|
||||||
|
// Create buffered image with headless graphics
|
||||||
|
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(800, 500,
|
||||||
|
java.awt.image.BufferedImage.TYPE_INT_RGB);
|
||||||
|
java.awt.Graphics2D g2d = image.createGraphics();
|
||||||
|
g2d.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
chart.draw(g2d, new java.awt.geom.Rectangle2D.Double(0, 0, 800, 500));
|
||||||
|
g2d.dispose();
|
||||||
|
|
||||||
|
return EncoderUtil.encode(image, ImageFormat.PNG);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
// Return null if chart generation fails
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ minio.endpoint=http://92.38.48.166:9000
|
|||||||
minio.access-key=z9HhZTjzhVWqw3D20u7q
|
minio.access-key=z9HhZTjzhVWqw3D20u7q
|
||||||
minio.secret-key=lhhHtJow1b10z6EZRMTQIU1tsKkoaxCVpSypCrcb
|
minio.secret-key=lhhHtJow1b10z6EZRMTQIU1tsKkoaxCVpSypCrcb
|
||||||
minio.bucket-name=konturai
|
minio.bucket-name=konturai
|
||||||
|
|
||||||
|
# Headless mode for chart generation in Docker
|
||||||
|
java.awt.headless=true
|
||||||
spring.application.name=parser
|
spring.application.name=parser
|
||||||
|
|
||||||
# MongoDB Configuration
|
# MongoDB Configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user