diff --git a/src/main/java/org/apache/nifi/controller/status/ConnectorStatus.java b/src/main/java/org/apache/nifi/controller/status/ConnectorStatus.java new file mode 100644 index 0000000..c2fc7fc --- /dev/null +++ b/src/main/java/org/apache/nifi/controller/status/ConnectorStatus.java @@ -0,0 +1,90 @@ +/* + * 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.nifi.controller.status; + +/** + * The status of a Connector, including the status of its managed root Process Group. + * + *
+ * Connector-managed flows live outside the controller's root Process Group, so reporting tasks that wish to observe + * metrics for them must consult {@link org.apache.nifi.reporting.EventAccess#getConnectorStatuses()} in addition to + * {@link org.apache.nifi.reporting.EventAccess#getControllerStatus()}. Each {@link ConnectorStatus} exposes the + * Connector's identity along with the {@link ProcessGroupStatus} for its managed root group. + *
+ * + *+ * The Connector API is experimental and this type is expected to grow over time to surface connector-level metrics + * that do not exist at the Process Group level (e.g. connector-wide backlog or idle time). + *
+ */ +public class ConnectorStatus implements Cloneable { + + private String id; + private String name; + private ProcessGroupStatus rootGroupStatus; + + /** + * @return the identifier of the Connector + */ + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + /** + * @return the name of the Connector + */ + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + /** + * @return the status of the Connector's managed root Process Group, or {@code null} if the Connector has no + * active managed flow at the time the status was captured + */ + public ProcessGroupStatus getRootGroupStatus() { + return rootGroupStatus; + } + + public void setRootGroupStatus(final ProcessGroupStatus rootGroupStatus) { + this.rootGroupStatus = rootGroupStatus; + } + + @Override + public ConnectorStatus clone() { + final ConnectorStatus clonedObj = new ConnectorStatus(); + clonedObj.id = id; + clonedObj.name = name; + clonedObj.rootGroupStatus = rootGroupStatus == null ? null : rootGroupStatus.clone(); + return clonedObj; + } + + @Override + public String toString() { + return "ConnectorStatus [id=" + id + + ", name=" + name + + ", rootGroupStatus=" + rootGroupStatus + + "]"; + } +} diff --git a/src/main/java/org/apache/nifi/reporting/EventAccess.java b/src/main/java/org/apache/nifi/reporting/EventAccess.java index 7cf15fb..4c53304 100644 --- a/src/main/java/org/apache/nifi/reporting/EventAccess.java +++ b/src/main/java/org/apache/nifi/reporting/EventAccess.java @@ -17,12 +17,15 @@ package org.apache.nifi.reporting; import org.apache.nifi.action.Action; +import org.apache.nifi.controller.status.ConnectorStatus; import org.apache.nifi.controller.status.ProcessGroupStatus; import org.apache.nifi.diagnostics.StorageUsage; import org.apache.nifi.provenance.ProvenanceEventRecord; import org.apache.nifi.provenance.ProvenanceEventRepository; import java.io.IOException; +import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -39,6 +42,24 @@ public interface EventAccess { */ ProcessGroupStatus getGroupStatus(final String groupId); + /** + * Returns one {@link ConnectorStatus} per Connector currently registered with the runtime. Each + * {@link ConnectorStatus} carries the Connector's identity together with the {@link ProcessGroupStatus} for the + * Connector's managed root Process Group. Connector-managed groups are siblings of the controller's root Process + * Group (they have no parent and are not reachable from {@link #getControllerStatus()}), so reporting tasks that + * wish to surface metrics for connector-managed flows must consult this method in addition to + * {@link #getControllerStatus()}. + * + * The default implementation returns an empty collection so that runtimes without Connector support — and existing + * callers compiled against earlier versions of this interface — continue to work unchanged. + * + * @return one status per Connector; empty if no Connectors are registered or if the runtime does not support + * Connectors + */ + default Collection