davsclaus commented on code in PR #29504:
URL: https://github.com/apache/camel/pull/29504#discussion_r4518304395


##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/HealthHistory.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.tui;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Whether each integration was ready and live, second by second over the last 
minutes, as the TUI read its health: a
+ * check that went DOWN and came back between two looks at the Health tab is 
seen on its strip.
+ */
+final class HealthHistory {
+
+    static final int SECONDS = 300;
+    /** Not known for that second: before the TUI read the integration, or the 
integration did not say. */
+    static final byte UNKNOWN = -1;
+    static final byte READY = 1;
+    static final byte LIVE = 2;
+
+    // per pid: a ring of the last SECONDS seconds, and the second its last 
value is of
+    private final Map<String, Ring> rings = new ConcurrentHashMap<>();
+
+    private static final class Ring {
+        final byte[] values = new byte[SECONDS];
+        long last = -1;
+
+        Ring() {
+            Arrays.fill(values, UNKNOWN);
+        }
+    }
+
+    /** Records the state of the integration at the second (epoch seconds) it 
was read. */
+    void record(IntegrationInfo info, long second) {
+        if (info.pid == null || info.healthReady == null && info.healthLive == 
null) {

Review Comment:
   Done in 34d541d3a793: parentheses added.
   
   _Claude Code on behalf of davsclaus_



##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/HealthHistory.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.tui;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Whether each integration was ready and live, second by second over the last 
minutes, as the TUI read its health: a
+ * check that went DOWN and came back between two looks at the Health tab is 
seen on its strip.
+ */
+final class HealthHistory {
+
+    static final int SECONDS = 300;
+    /** Not known for that second: before the TUI read the integration, or the 
integration did not say. */
+    static final byte UNKNOWN = -1;
+    static final byte READY = 1;
+    static final byte LIVE = 2;
+
+    // per pid: a ring of the last SECONDS seconds, and the second its last 
value is of
+    private final Map<String, Ring> rings = new ConcurrentHashMap<>();
+
+    private static final class Ring {
+        final byte[] values = new byte[SECONDS];
+        long last = -1;
+
+        Ring() {
+            Arrays.fill(values, UNKNOWN);
+        }
+    }
+
+    /** Records the state of the integration at the second (epoch seconds) it 
was read. */
+    void record(IntegrationInfo info, long second) {
+        if (info.pid == null || info.healthReady == null && info.healthLive == 
null) {
+            return;
+        }
+        byte value = (byte) ((Boolean.TRUE.equals(info.healthReady) ? READY : 
0)
+                             | (Boolean.TRUE.equals(info.healthLive) ? LIVE : 
0));

Review Comment:
   Right, a second holds one value for both, so it cannot say "ready unknown, 
live up". Camel reports both together, so I added a comment that says what 
happens if only one is known (34d541d3a793) rather than a third state.
   
   _Claude Code on behalf of davsclaus_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to