diff --git a/api-server/src/main/java/com/repoachiever/entity/common/ConfigEntity.java b/api-server/src/main/java/com/repoachiever/entity/common/ConfigEntity.java index 0bd5340..2cab6b1 100644 --- a/api-server/src/main/java/com/repoachiever/entity/common/ConfigEntity.java +++ b/api-server/src/main/java/com/repoachiever/entity/common/ConfigEntity.java @@ -82,21 +82,6 @@ public String toString() { @JsonProperty("content") public Content content; - /** - * Represents RepoAchiever API Server configuration used for database setup. - */ - @Getter - public static class Database { - @NotNull - @JsonProperty("re-init") - public Boolean reInit; - } - - @Valid - @NotNull - @JsonProperty("database") - public Database database; - /** * Represents RepoAchiever API Server configuration used for diagnostics. */ diff --git a/api-server/src/main/java/com/repoachiever/resource/communication/ApiServerCommunicationResource.java b/api-server/src/main/java/com/repoachiever/resource/communication/ApiServerCommunicationResource.java index 6d81ac6..ced4119 100644 --- a/api-server/src/main/java/com/repoachiever/resource/communication/ApiServerCommunicationResource.java +++ b/api-server/src/main/java/com/repoachiever/resource/communication/ApiServerCommunicationResource.java @@ -55,6 +55,8 @@ public ApiServerCommunicationResource() throws RemoteException { @Override public void performRawContentUpload( String workspaceUnitKey, String location, String name, RemoteInputStream content) throws RemoteException { + telemetryService.increaseRawContentUploadAmount(); + StateService.getCommunicationGuard().lock(); InputStream contentRaw; @@ -62,6 +64,10 @@ public void performRawContentUpload( try { contentRaw = RemoteInputStreamClient.wrap(content); } catch (IOException e) { + StateService.getCommunicationGuard().unlock(); + + telemetryService.decreaseRawContentUploadAmount(); + throw new RuntimeException(e); } @@ -70,10 +76,14 @@ public void performRawContentUpload( } catch (RawContentCreationFailureException e) { StateService.getCommunicationGuard().unlock(); + telemetryService.decreaseRawContentUploadAmount(); + throw new RemoteException(e.getMessage()); } StateService.getCommunicationGuard().unlock(); + + telemetryService.decreaseRawContentUploadAmount(); } /** @@ -105,10 +115,16 @@ public Boolean retrieveRawContentPresent(String workspaceUnitKey, String locatio @Override public void performAdditionalContentUpload( String workspaceUnitKey, String location, String name, String data) throws RemoteException { + telemetryService.increaseAdditionalContentUploadAmount(); + StateService.getCommunicationGuard().lock(); Map rawData = JsonToAdditionalContentDataConverter.convert(data); if (Objects.isNull(rawData)) { + StateService.getCommunicationGuard().unlock(); + + telemetryService.decreaseAdditionalContentUploadAmount(); + throw new RemoteException(); } @@ -124,10 +140,14 @@ public void performAdditionalContentUpload( } catch (AdditionalContentCreationFailureException e) { StateService.getCommunicationGuard().unlock(); + telemetryService.decreaseAdditionalContentUploadAmount(); + throw new RemoteException(e.getMessage()); } StateService.getCommunicationGuard().unlock(); + + telemetryService.decreaseAdditionalContentUploadAmount(); } /** diff --git a/api-server/src/main/java/com/repoachiever/service/cluster/facade/ClusterFacade.java b/api-server/src/main/java/com/repoachiever/service/cluster/facade/ClusterFacade.java index ebe8b02..89bb95f 100644 --- a/api-server/src/main/java/com/repoachiever/service/cluster/facade/ClusterFacade.java +++ b/api-server/src/main/java/com/repoachiever/service/cluster/facade/ClusterFacade.java @@ -463,18 +463,6 @@ public void removeContent(ContentCleanup contentCleanup) throws ClusterCleanupFa } if (Objects.nonNull(clusterAllocation)) { - logger.info( - String.format( - "Resetting RepoAchiever Cluster content retrieval: '%s'", clusterAllocation.getName())); - - try { - clusterCommunicationResource.performRetrievalReset(clusterAllocation.getName()); - } catch (ClusterOperationFailureException e) { - logger.fatal(new ClusterCleanupFailureException(e.getMessage()).getMessage()); - - return; - } - logger.info( String.format( "Setting RepoAchiever Cluster suspended allocation to serve state: '%s'", @@ -542,18 +530,6 @@ public void removeAll(ContentCleanupAll contentCleanupAll) throws ClusterFullCle } for (ClusterAllocationDto suspended : suspends) { - logger.info( - String.format( - "Resetting RepoAchiever Cluster content retrieval: '%s'", suspended.getName())); - - try { - clusterCommunicationResource.performRetrievalReset(suspended.getName()); - } catch (ClusterOperationFailureException e) { - logger.fatal(new ClusterCleanupFailureException(e.getMessage()).getMessage()); - - return; - } - logger.info( String.format( "Setting RepoAchiever Cluster suspended allocation to serve state: '%s'", diff --git a/api-server/src/main/java/com/repoachiever/service/cluster/resource/ClusterCommunicationResource.java b/api-server/src/main/java/com/repoachiever/service/cluster/resource/ClusterCommunicationResource.java index ffb90c5..d092468 100644 --- a/api-server/src/main/java/com/repoachiever/service/cluster/resource/ClusterCommunicationResource.java +++ b/api-server/src/main/java/com/repoachiever/service/cluster/resource/ClusterCommunicationResource.java @@ -92,22 +92,6 @@ public void performServe(String name) throws ClusterOperationFailureException { } } - /** - * Performs RepoAchiever Cluster content retrieval reset operation. - * - * @param name given name of RepoAchiever Cluster. - * @throws ClusterOperationFailureException if RepoAchiever Cluster operation fails. - */ - public void performRetrievalReset(String name) throws ClusterOperationFailureException { - IClusterCommunicationService allocation = retrieveAllocation(name); - - try { - allocation.performRetrievalReset(); - } catch (RemoteException e) { - throw new ClusterOperationFailureException(e.getMessage()); - } - } - /** * Retrieves health check status of the RepoAchiever Cluster with the given name. * diff --git a/api-server/src/main/java/com/repoachiever/service/communication/cluster/IClusterCommunicationService.java b/api-server/src/main/java/com/repoachiever/service/communication/cluster/IClusterCommunicationService.java index b8f9b94..01ed33c 100644 --- a/api-server/src/main/java/com/repoachiever/service/communication/cluster/IClusterCommunicationService.java +++ b/api-server/src/main/java/com/repoachiever/service/communication/cluster/IClusterCommunicationService.java @@ -21,13 +21,6 @@ public interface IClusterCommunicationService extends Remote { */ void performServe() throws RemoteException; - /** - * Performs RepoAchiever Cluster content retrieval reset operation. - * - * @throws RemoteException if remote request fails. - */ - void performRetrievalReset() throws RemoteException; - /** * Retrieves latest RepoAchiever Cluster health check states. * diff --git a/api-server/src/main/java/com/repoachiever/service/telemetry/TelemetryService.java b/api-server/src/main/java/com/repoachiever/service/telemetry/TelemetryService.java index 61fe253..58de9e1 100644 --- a/api-server/src/main/java/com/repoachiever/service/telemetry/TelemetryService.java +++ b/api-server/src/main/java/com/repoachiever/service/telemetry/TelemetryService.java @@ -32,7 +32,11 @@ public class TelemetryService { private final ConcurrentLinkedQueue clusterHealthCheckQueue = new ConcurrentLinkedQueue<>(); - private final static ScheduledExecutorService executorService = Executors.newScheduledThreadPool(3); + private final ConcurrentLinkedQueue rawContentUploadQueue = new ConcurrentLinkedQueue<>(); + + private final ConcurrentLinkedQueue additionalContentUploadQueue = new ConcurrentLinkedQueue<>(); + + private final static ScheduledExecutorService executorService = Executors.newScheduledThreadPool(5); /** * Starts telemetries listener, which handles incoming telemetries to be processed in a sequential way. @@ -56,6 +60,20 @@ private void configure() { clusterStateQueue.poll().run(); } }, 0, properties.getDiagnosticsScrapeDelay(), TimeUnit.MILLISECONDS); + + executorService.scheduleWithFixedDelay(() -> { + if (!rawContentUploadQueue.isEmpty()) { + System.out.println("RECEIVED"); + + rawContentUploadQueue.poll().run(); + } + }, 0, properties.getDiagnosticsScrapeDelay(), TimeUnit.MILLISECONDS); + + executorService.scheduleWithFixedDelay(() -> { + if (!additionalContentUploadQueue.isEmpty()) { + additionalContentUploadQueue.poll().run(); + } + }, 0, properties.getDiagnosticsScrapeDelay(), TimeUnit.MILLISECONDS); } /** @@ -147,4 +165,42 @@ public void decreaseClusterHealthCheckAmount() { clusterHealthCheckQueue.add(() -> telemetryBinding.getClusterHealthCheckAmount().set(telemetryBinding.getClusterHealthCheckAmount().get() - 1)); } } + + /** + * Increases raw content uploads for RepoAchiever Cluster allocations amount counter. + */ + public void increaseRawContentUploadAmount() { + if (configService.getConfig().getDiagnostics().getEnabled()) { + System.out.println("GOT DATA"); + + rawContentUploadQueue.add(() -> telemetryBinding.getRawContentUploadAmount().set(telemetryBinding.getRawContentUploadAmount().get() + 1)); + } + } + + /** + * Decreases raw content uploads for RepoAchiever Cluster allocations amount counter. + */ + public void decreaseRawContentUploadAmount() { + if (configService.getConfig().getDiagnostics().getEnabled()) { + rawContentUploadQueue.add(() -> telemetryBinding.getRawContentUploadAmount().set(telemetryBinding.getRawContentUploadAmount().get() - 1)); + } + } + + /** + * Increases additional content uploads for RepoAchiever Cluster allocations amount counter. + */ + public void increaseAdditionalContentUploadAmount() { + if (configService.getConfig().getDiagnostics().getEnabled()) { + additionalContentUploadQueue.add(() -> telemetryBinding.getAdditionalContentUploadAmount().set(telemetryBinding.getAdditionalContentUploadAmount().get() + 1)); + } + } + + /** + * Decreases additional content uploads for RepoAchiever Cluster allocations amount counter. + */ + public void decreaseAdditionalContentUploadAmount() { + if (configService.getConfig().getDiagnostics().getEnabled()) { + additionalContentUploadQueue.add(() -> telemetryBinding.getAdditionalContentUploadAmount().set(telemetryBinding.getAdditionalContentUploadAmount().get() - 1)); + } + } } diff --git a/api-server/src/main/java/com/repoachiever/service/telemetry/binding/TelemetryBinding.java b/api-server/src/main/java/com/repoachiever/service/telemetry/binding/TelemetryBinding.java index b7d27c3..8078752 100644 --- a/api-server/src/main/java/com/repoachiever/service/telemetry/binding/TelemetryBinding.java +++ b/api-server/src/main/java/com/repoachiever/service/telemetry/binding/TelemetryBinding.java @@ -30,6 +30,12 @@ public class TelemetryBinding implements MeterBinder { @Getter private final AtomicInteger clusterHealthCheckAmount = new AtomicInteger(); + @Getter + private final AtomicInteger rawContentUploadAmount = new AtomicInteger(); + + @Getter + private final AtomicInteger additionalContentUploadAmount = new AtomicInteger(); + /** * @see MeterBinder */ @@ -54,5 +60,13 @@ public void bindTo(@NotNull MeterRegistry meterRegistry) { Gauge.builder("general.cluster_health_check_amount", clusterHealthCheckAmount, AtomicInteger::get) .description("Represents amount of performed health check requests for RepoAchiever Cluster allocations") .register(meterRegistry); + + Gauge.builder("general.raw_content_upload_amount", rawContentUploadAmount, AtomicInteger::get) + .description("Represents amount of performed raw content upload requests for RepoAchiever Cluster allocations") + .register(meterRegistry); + + Gauge.builder("general.additional_content_upload_amount", additionalContentUploadAmount, AtomicInteger::get) + .description("Represents amount of performed additional content upload requests for RepoAchiever Cluster allocations") + .register(meterRegistry); } } diff --git a/cluster/src/main/java/com/repoachiever/resource/communication/ClusterCommunicationResource.java b/cluster/src/main/java/com/repoachiever/resource/communication/ClusterCommunicationResource.java index f0cae0c..467bd06 100644 --- a/cluster/src/main/java/com/repoachiever/resource/communication/ClusterCommunicationResource.java +++ b/cluster/src/main/java/com/repoachiever/resource/communication/ClusterCommunicationResource.java @@ -63,14 +63,6 @@ public void performServe() throws RemoteException { StateService.getSuspendGuard().unlock(); } - /** - * @see IClusterCommunicationService - */ - @Override - public void performRetrievalReset() throws RemoteException { -// StateService.resetContentUpdatesHeadCounter(); - } - /** * @see IClusterCommunicationService */ diff --git a/cluster/src/main/java/com/repoachiever/service/communication/cluster/IClusterCommunicationService.java b/cluster/src/main/java/com/repoachiever/service/communication/cluster/IClusterCommunicationService.java index b8f9b94..01ed33c 100644 --- a/cluster/src/main/java/com/repoachiever/service/communication/cluster/IClusterCommunicationService.java +++ b/cluster/src/main/java/com/repoachiever/service/communication/cluster/IClusterCommunicationService.java @@ -21,13 +21,6 @@ public interface IClusterCommunicationService extends Remote { */ void performServe() throws RemoteException; - /** - * Performs RepoAchiever Cluster content retrieval reset operation. - * - * @throws RemoteException if remote request fails. - */ - void performRetrievalReset() throws RemoteException; - /** * Retrieves latest RepoAchiever Cluster health check states. * diff --git a/config/grafana/dashboards/diagnostics.tmpl b/config/grafana/dashboards/diagnostics.tmpl index ba717a3..562aa11 100644 --- a/config/grafana/dashboards/diagnostics.tmpl +++ b/config/grafana/dashboards/diagnostics.tmpl @@ -115,6 +115,208 @@ "x": 0, "y": 2 }, + "id": 36, + "interval": "500ms", + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P21B111CBFE6E8FCA" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "general_raw_content_upload_amount", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "RepoAchiever API Server raw content upload ongoing requests", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P21B111CBFE6E8FCA" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 0, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 2 + }, + "id": 37, + "interval": "500ms", + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P21B111CBFE6E8FCA" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "general_additional_content_upload_amount", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "RepoAchiever API Server additional content upload ongoing requests", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P21B111CBFE6E8FCA" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 0, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 10 + }, "id": 33, "interval": "0.1", "options": { @@ -213,7 +415,7 @@ "h": 8, "w": 12, "x": 12, - "y": 2 + "y": 10 }, "id": 34, "interval": "0.1", @@ -315,7 +517,7 @@ "h": 8, "w": 12, "x": 0, - "y": 10 + "y": 18 }, "id": 31, "interval": "0.1", @@ -416,7 +618,7 @@ "h": 8, "w": 12, "x": 12, - "y": 10 + "y": 18 }, "id": 32, "interval": "0.1", @@ -483,7 +685,7 @@ "h": 8, "w": 12, "x": 0, - "y": 18 + "y": 26 }, "id": 35, "options": { @@ -531,7 +733,7 @@ "h": 1, "w": 24, "x": 0, - "y": 26 + "y": 34 }, "id": 28, "panels": [], @@ -580,7 +782,7 @@ "h": 7, "w": 3, "x": 0, - "y": 27 + "y": 35 }, "id": 15, "maxDataPoints": 100, @@ -665,7 +867,7 @@ "h": 6, "w": 6, "x": 3, - "y": 27 + "y": 35 }, "id": 6, "maxDataPoints": 100, @@ -751,7 +953,7 @@ "h": 6, "w": 6, "x": 9, - "y": 27 + "y": 35 }, "id": 4, "maxDataPoints": 100, @@ -996,6 +1198,6 @@ "timezone": "browser", "title": "RepoAchiever Diagnostics", "uid": "64nrElFmk", - "version": 3, + "version": 7, "weekStart": "" } \ No newline at end of file diff --git a/gui/src/main/java/com/repoachiever/service/state/StateService.java b/gui/src/main/java/com/repoachiever/service/state/StateService.java index 5e4c999..cd4f904 100644 --- a/gui/src/main/java/com/repoachiever/service/state/StateService.java +++ b/gui/src/main/java/com/repoachiever/service/state/StateService.java @@ -74,7 +74,7 @@ public class StateService { * @return result of the check. */ @SneakyThrows - public static synchronized Boolean isWindowHeightChanged() { + public static Boolean isWindowHeightChanged() { if (Objects.isNull(prevMainWindowHeight) && !Objects.isNull(mainWindowHeight)) { return true; } else if (Objects.isNull(prevMainWindowHeight)) { @@ -92,7 +92,7 @@ public static synchronized Boolean isWindowHeightChanged() { * @return result of the check. */ @SneakyThrows - public static synchronized Boolean isWindowWidthChanged() { + public static Boolean isWindowWidthChanged() { if (Objects.isNull(prevMainWindowWidth) && !Objects.isNull(mainWindowWidth)) { return true; } else if (Objects.isNull(prevMainWindowWidth)) { @@ -107,14 +107,14 @@ public static synchronized Boolean isWindowWidthChanged() { /** * Synchronizes main window height. */ - public static synchronized void synchronizeWindowHeight() { + public static void synchronizeWindowHeight() { prevMainWindowHeight = mainWindowHeight; } /** * Synchronizes main window width. */ - public static synchronized void synchronizeWindowWidth() { + public static void synchronizeWindowWidth() { prevMainWindowWidth = mainWindowWidth; } } diff --git a/samples/config/api-server/api-server.yaml b/samples/config/api-server/api-server.yaml index 268b475..2304e29 100644 --- a/samples/config/api-server/api-server.yaml +++ b/samples/config/api-server/api-server.yaml @@ -13,11 +13,6 @@ content: # Represents format used for content download requests. format: "zip" -# Represents section used for RepoAchiever API Server database configuration. -database: - # Enables re-initialization of database if core user configuration has been changed. - re-init: true - # Represents section used for RepoAchiever API Server diagnostics configuration. diagnostics: # Enables diagnostics functionality.