[
https://issues.apache.org/jira/browse/ARTEMIS-4626?focusedWorklogId=903304&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-903304
]
ASF GitHub Bot logged work on ARTEMIS-4626:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 02/Feb/24 11:23
Start Date: 02/Feb/24 11:23
Worklog Time Spent: 10m
Work Description: gemmellr commented on code in PR #4797:
URL: https://github.com/apache/activemq-artemis/pull/4797#discussion_r1475845813
##########
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/federation/internal/FederationAddressEntry.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.activemq.artemis.protocol.amqp.federation.internal;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.activemq.artemis.core.postoffice.Binding;
+
+/**
+ * Am entry type class used to hold a {@link FederationConsumerInternal} and
Review Comment:
Typo, Am entry - > An entry
##########
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/federation/internal/FederationAddressEntry.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.activemq.artemis.protocol.amqp.federation.internal;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.activemq.artemis.core.postoffice.Binding;
+
+/**
+ * Am entry type class used to hold a {@link FederationConsumerInternal} and
+ * any other state data needed by the manager that is creating them based on
the
+ * policy configuration for the federation instance. The entry can be extended
+ * by federation implementation to hold additional state data for the
federation
+ * consumer and the managing of its lifetime.
+ *
+ * This entry type provides a reference counter that can be used to register
demand
+ * on a federation resource such that it is not torn down until all demand has
been
+ * removed from the local resource.
+ */
+public class FederationAddressEntry {
+
+ private final FederationConsumerInternal consumer;
+
+ private final Set<Binding> demandBindings = new HashSet<>();
+
+ /**
+ * Creates a new address entry with a single reference
+ *
+ * @param consumer
+ * The federation consumer that will be carried in this entry.
+ */
+ public FederationAddressEntry(FederationConsumerInternal consumer) {
+ this.consumer = consumer;
+ }
+
+ /**
+ * @return the address that this entry is acting to federate.
+ */
+ public String getAddress() {
+ return consumer.getConsumerInfo().getAddress();
+ }
+
+ /**
+ * @return the consumer managed by this entry
+ */
+ public FederationConsumerInternal getConsumer() {
+ return consumer;
+ }
+
+ /**
+ * @return true if there are bindings that are mapped to this federation
entry.
+ */
+ public boolean hasDemand() {
+ return !demandBindings.isEmpty();
+ }
+
+ /**
+ * Add demand on this federation address consumer from the given binding.
+ *
+ * @return this federation address consumer entry.
+ */
+ public FederationAddressEntry addDemand(Binding binding) {
+ demandBindings.add(binding);
+ return this;
+ }
+
+ /**
+ * Reduce demand on this federation address consumer from the given binding.
+ *
+ * @return this federation address consumer entry.
+ */
+ public FederationAddressEntry removeDenamd(Binding binding) {
Review Comment:
Typo, Denamd - > Demand
EDIT: Also, the method on FederationQueueEntry is called _reduce_Demand
rather than _remove_Demand, possibly they should align.
Issue Time Tracking
-------------------
Worklog Id: (was: 903304)
Time Spent: 1.5h (was: 1h 20m)
> AMQP Federation demand tracking can overcount demand
> ----------------------------------------------------
>
> Key: ARTEMIS-4626
> URL: https://issues.apache.org/jira/browse/ARTEMIS-4626
> Project: ActiveMQ Artemis
> Issue Type: Bug
> Components: AMQP
> Affects Versions: 2.32.0
> Reporter: Timothy A. Bish
> Assignee: Timothy A. Bish
> Priority: Major
> Fix For: 2.33.0
>
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> The demand tracking for Address bindings and Queue consumers that controls
> when a federation consumer is created and destroyed can race on start of
> federation with consumers or bindings being added and removed and over count
> the demand leading to the federation consumers not being shutdown when demand
> on the local broker drops to zero. A better mechanism of tracking needs to
> be added to make demand tracking idempotent for additions and removals of
> local demand and the startup demand checks
--
This message was sent by Atlassian Jira
(v8.20.10#820010)