http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java deleted file mode 100644 index 3f966e5..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * 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.cluster.manager; - -import com.sun.jersey.api.client.ClientResponse; -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.URI; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.TimeUnit; - -import javax.ws.rs.HttpMethod; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.ResponseBuilder; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.core.StreamingOutput; -import org.apache.nifi.cluster.protocol.NodeIdentifier; -import org.apache.nifi.web.api.entity.Entity; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Encapsulates a node's response in regards to receiving a external API - * request. - * - * Both the ClientResponse and (server) Response may be obtained from this - * instance. The ClientResponse is stored as it is received from the node. This - * includes the entity input stream. The Response is constructed on demand when - * mapping a ClientResponse to the Response. The ClientResponse to Response - * mapping includes copying the ClientResponse's input stream to the Response. - * Therefore, the getResponse() method should not be called more than once. - * Furthermore, the method should not be called if the caller has already read - * the ClientResponse's input stream. - * - * If a ClientResponse was unable to be created, then a NodeResponse will store - * the Throwable, which may be obtained by calling getThrowable(). - * - * This class overrides hashCode and equals and considers two instances to be - * equal if they have the equal NodeIdentifiers. - * - * @author unattributed - */ -public class NodeResponse { - - private static final Logger logger = LoggerFactory.getLogger(NodeResponse.class); - private final String httpMethod; - private final URI requestUri; - private final ClientResponse clientResponse; - private final NodeIdentifier nodeId; - private final Throwable throwable; - private boolean hasCreatedResponse = false; - private final Entity updatedEntity; - private final long requestDurationNanos; - private final String requestId; - - public NodeResponse(final NodeIdentifier nodeId, final String httpMethod, final URI requestUri, final ClientResponse clientResponse, final long requestDurationNanos, final String requestId) { - if (nodeId == null) { - throw new IllegalArgumentException("Node identifier may not be null."); - } else if (StringUtils.isBlank(httpMethod)) { - throw new IllegalArgumentException("Http method may not be null or empty."); - } else if (requestUri == null) { - throw new IllegalArgumentException("Request URI may not be null."); - } else if (clientResponse == null) { - throw new IllegalArgumentException("ClientResponse may not be null."); - } - this.nodeId = nodeId; - this.httpMethod = httpMethod; - this.requestUri = requestUri; - this.clientResponse = clientResponse; - this.throwable = null; - this.updatedEntity = null; - this.requestDurationNanos = requestDurationNanos; - this.requestId = requestId; - } - - public NodeResponse(final NodeIdentifier nodeId, final String httpMethod, final URI requestUri, final Throwable throwable) { - if (nodeId == null) { - throw new IllegalArgumentException("Node identifier may not be null."); - } else if (StringUtils.isBlank(httpMethod)) { - throw new IllegalArgumentException("Http method may not be null or empty."); - } else if (requestUri == null) { - throw new IllegalArgumentException("Request URI may not be null."); - } else if (throwable == null) { - throw new IllegalArgumentException("Throwable may not be null."); - } - this.nodeId = nodeId; - this.httpMethod = httpMethod; - this.requestUri = requestUri; - this.clientResponse = null; - this.throwable = throwable; - this.updatedEntity = null; - this.requestDurationNanos = -1L; - this.requestId = null; - } - - public NodeResponse(final NodeResponse example, final Entity updatedEntity) { - Objects.requireNonNull(example, "NodeResponse cannot be null"); - Objects.requireNonNull(updatedEntity, "UpdatedEntity cannot be null"); - - this.nodeId = example.nodeId; - this.httpMethod = example.httpMethod; - this.requestUri = example.requestUri; - this.clientResponse = example.clientResponse; - this.throwable = example.throwable; - this.updatedEntity = updatedEntity; - this.requestDurationNanos = example.requestDurationNanos; - this.requestId = null; - } - - public NodeIdentifier getNodeId() { - return nodeId; - } - - public String getHttpMethod() { - return httpMethod; - } - - public URI getRequestUri() { - return requestUri; - } - - /** - * @return the HTTP response status code - */ - public int getStatus() { - if (hasThrowable()) { - /* - * since there is a throwable, there is no client input stream to - * worry about maintaining, so we can call getResponse() method - */ - return getResponse().getStatus(); - } else { - /* - * use client response's status instead of calling getResponse().getStatus() - * so that we don't read the client's input stream as part of creating - * the response in the getResponse() method - */ - return clientResponse.getStatus(); - } - } - - /** - * Returns true if the response status is 2xx, false otherwise. - * - * @return - */ - public boolean is2xx() { - final int statusCode = getStatus(); - return (200 <= statusCode && statusCode <= 299); - } - - /** - * Returns true if the response status is 5xx, false otherwise. - * - * @return - */ - public boolean is5xx() { - final int statusCode = getStatus(); - return (500 <= statusCode && statusCode <= 599); - } - - /** - * Returns null if hasThrowable() is true; otherwise the client's response - * is returned. - * - * The ClientResponse's input stream can only be read once. - * - * @return the client's response - */ - public ClientResponse getClientResponse() { - return clientResponse; - } - - /** - * Creates a Response by mapping the ClientResponse values to it. Since the - * ClientResponse's input stream can only be read once, this method should - * only be called once. Furthermore, the caller should not have already read - * the ClientResponse's input stream. - * - * @return the response - */ - public Response getResponse() { - // if the response encapsulates a throwable, then the input stream is never read and the below warning is irrelevant - if (hasCreatedResponse && !hasThrowable()) { - logger.warn("ClientResponse's input stream has already been read. The created response will not contain this data."); - } - hasCreatedResponse = true; - return createResponse(); - } - - /** - * Returns the throwable or null if no throwable exists. - * - * @return the throwable or null if no throwable exists - */ - public Throwable getThrowable() { - return throwable; - } - - /** - * Returns true if a throwable was thrown and a response was not able to be - * created; false otherwise. - * - * @return true if a throwable was thrown and a response was not able to be - * created; false otherwise - */ - public boolean hasThrowable() { - return getThrowable() != null; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final NodeResponse other = (NodeResponse) obj; - if (this.nodeId != other.nodeId && (this.nodeId == null || !this.nodeId.equals(other.nodeId))) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 13 * hash + (this.nodeId != null ? this.nodeId.hashCode() : 0); - return hash; - } - - public long getRequestDuration(final TimeUnit timeUnit) { - return timeUnit.convert(requestDurationNanos, TimeUnit.NANOSECONDS); - } - - public String getRequestId() { - return requestId; - } - - private Response createResponse() { - - // if no client response was created, then generate a 500 response - if (hasThrowable()) { - return Response.status(Status.INTERNAL_SERVER_ERROR).build(); - } - - // set the status - final ResponseBuilder responseBuilder = Response.status(clientResponse.getStatus()); - - // set the headers - for (final String key : clientResponse.getHeaders().keySet()) { - final List<String> values = clientResponse.getHeaders().get(key); - for (final String value : values) { - - if (key.equalsIgnoreCase("transfer-encoding") || key.equalsIgnoreCase("content-length")) { - /* - * do not copy the transfer-encoding header (i.e., chunked encoding) or - * the content-length. Let the outgoing response builder determine it. - */ - continue; - } else if (key.equals("X-ClusterContext")) { - /* - * do not copy the cluster context to the response because - * this information is private and should not be sent to - * the client - */ - continue; - } - responseBuilder.header(key, value); - } - } - - // head requests must not have a message-body in the response - if (!HttpMethod.HEAD.equalsIgnoreCase(httpMethod)) { - - // set the entity - if (updatedEntity == null) { - responseBuilder.entity(new StreamingOutput() { - @Override - public void write(final OutputStream output) throws IOException, WebApplicationException { - BufferedInputStream bis = null; - try { - bis = new BufferedInputStream(clientResponse.getEntityInputStream()); - IOUtils.copy(bis, output); - } finally { - IOUtils.closeQuietly(bis); - } - } - }); - } else { - responseBuilder.entity(updatedEntity); - } - } - - return responseBuilder.build(); - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("NodeResponse[nodeUri=").append(nodeId.getApiAddress()).append(":").append(nodeId.getApiPort()).append(",") - .append("method=").append(httpMethod) - .append(",URI=").append(requestUri) - .append(",ResponseCode=").append(getStatus()) - .append(",Duration=").append(TimeUnit.MILLISECONDS.convert(requestDurationNanos, TimeUnit.NANOSECONDS)).append(" ms]"); - return sb.toString(); - } -}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/BlockedByFirewallException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/BlockedByFirewallException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/BlockedByFirewallException.java deleted file mode 100644 index 49bcd35..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/BlockedByFirewallException.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.cluster.manager.exception; - -import org.apache.nifi.cluster.protocol.NodeIdentifier; - -/** - * - */ -public class BlockedByFirewallException extends ClusterException { - - private final NodeIdentifier nodeId; - private final boolean isExistingNode; - - public BlockedByFirewallException(NodeIdentifier nodeId, boolean isExistingNode, String msg, Throwable cause) { - super(msg, cause); - this.nodeId = nodeId; - this.isExistingNode = isExistingNode; - } - - public BlockedByFirewallException(NodeIdentifier nodeId, boolean isExistingNode, Throwable cause) { - super(cause); - this.nodeId = nodeId; - this.isExistingNode = isExistingNode; - } - - public BlockedByFirewallException(NodeIdentifier nodeId, boolean isExistingNode, String msg) { - super(msg); - this.nodeId = nodeId; - this.isExistingNode = isExistingNode; - } - - public BlockedByFirewallException(NodeIdentifier nodeId, boolean isExistingNode) { - this.nodeId = nodeId; - this.isExistingNode = isExistingNode; - } - - public NodeIdentifier getNodeId() { - return nodeId; - } - - public boolean isExistingNode() { - return isExistingNode; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java deleted file mode 100644 index 3bf9752..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ClusterException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * The base exception class for cluster related exceptions. - * - * @author unattributed - */ -public class ClusterException extends RuntimeException { - - public ClusterException() { - } - - public ClusterException(String msg) { - super(msg); - } - - public ClusterException(Throwable cause) { - super(cause); - } - - public ClusterException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java deleted file mode 100644 index 365b5f0..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/ConnectingNodeMutableRequestException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when a HTTP request that may change a node's - * dataflow is to be replicated while a node is connecting to the cluster. - * - * @author unattributed - */ -public class ConnectingNodeMutableRequestException extends MutableRequestException { - - public ConnectingNodeMutableRequestException() { - } - - public ConnectingNodeMutableRequestException(String msg) { - super(msg); - } - - public ConnectingNodeMutableRequestException(Throwable cause) { - super(cause); - } - - public ConnectingNodeMutableRequestException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java deleted file mode 100644 index 412a555..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/DisconnectedNodeMutableRequestException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when a HTTP request that may change a node's - * dataflow is to be replicated while one or more nodes are disconnected. - * - * @author unattributed - */ -public class DisconnectedNodeMutableRequestException extends MutableRequestException { - - public DisconnectedNodeMutableRequestException() { - } - - public DisconnectedNodeMutableRequestException(String msg) { - super(msg); - } - - public DisconnectedNodeMutableRequestException(Throwable cause) { - super(cause); - } - - public DisconnectedNodeMutableRequestException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java deleted file mode 100644 index 6c4e670..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalClusterStateException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Signals that an operation to be performed on a cluster has been invoked at an - * illegal or inappropriate time. - * - * @author unattributed - */ -public class IllegalClusterStateException extends ClusterException { - - public IllegalClusterStateException() { - } - - public IllegalClusterStateException(String msg) { - super(msg); - } - - public IllegalClusterStateException(Throwable cause) { - super(cause); - } - - public IllegalClusterStateException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java deleted file mode 100644 index adef62a..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDeletionException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when a deletion request is issued to a node - * that cannot be deleted (e.g., the node is not disconnected). - * - * @author unattributed - */ -public class IllegalNodeDeletionException extends IllegalClusterStateException { - - public IllegalNodeDeletionException() { - } - - public IllegalNodeDeletionException(String msg) { - super(msg); - } - - public IllegalNodeDeletionException(Throwable cause) { - super(cause); - } - - public IllegalNodeDeletionException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java deleted file mode 100644 index 7e61b24..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeDisconnectionException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when a disconnection request is issued to a - * node that cannot be disconnected (e.g., last node in cluster, node is primary - * node). - * - * @author unattributed - */ -public class IllegalNodeDisconnectionException extends IllegalClusterStateException { - - public IllegalNodeDisconnectionException() { - } - - public IllegalNodeDisconnectionException(String msg) { - super(msg); - } - - public IllegalNodeDisconnectionException(Throwable cause) { - super(cause); - } - - public IllegalNodeDisconnectionException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java deleted file mode 100644 index 96c76bc..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IllegalNodeReconnectionException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when a reconnection request is issued to a - * node that cannot be reconnected (e.g., the node is not disconnected). - * - * @author unattributed - */ -public class IllegalNodeReconnectionException extends IllegalClusterStateException { - - public IllegalNodeReconnectionException() { - } - - public IllegalNodeReconnectionException(String msg) { - super(msg); - } - - public IllegalNodeReconnectionException(Throwable cause) { - super(cause); - } - - public IllegalNodeReconnectionException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java deleted file mode 100644 index 4b0097a..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/IneligiblePrimaryNodeException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when the primary role cannot be assigned to a - * node because the node is ineligible for the role. - * - * @author unattributed - */ -public class IneligiblePrimaryNodeException extends IllegalClusterStateException { - - public IneligiblePrimaryNodeException() { - } - - public IneligiblePrimaryNodeException(String msg) { - super(msg); - } - - public IneligiblePrimaryNodeException(Throwable cause) { - super(cause); - } - - public IneligiblePrimaryNodeException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java deleted file mode 100644 index d160587..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/MutableRequestException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when a HTTP request that may change a node's - * state is to be replicated while the cluster or connected nodes are unable to - * change their state (e.g., a new node is connecting to the cluster). - * - * @author unattributed - */ -public class MutableRequestException extends IllegalClusterStateException { - - public MutableRequestException() { - } - - public MutableRequestException(String msg) { - super(msg); - } - - public MutableRequestException(Throwable cause) { - super(cause); - } - - public MutableRequestException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java deleted file mode 100644 index 8d704b9..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoConnectedNodesException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when the cluster is unable to service a - * request because no nodes are connected. - * - * @author unattributed - */ -public class NoConnectedNodesException extends ClusterException { - - public NoConnectedNodesException() { - } - - public NoConnectedNodesException(String msg) { - super(msg); - } - - public NoConnectedNodesException(Throwable cause) { - super(cause); - } - - public NoConnectedNodesException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java deleted file mode 100644 index 9e17a23..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NoResponseFromNodesException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when the cluster is unable to service a - * request because no nodes returned a response. When the given request is not - * mutable the nodes are left in their previous state. - * - * @author unattributed - */ -public class NoResponseFromNodesException extends ClusterException { - - public NoResponseFromNodesException() { - } - - public NoResponseFromNodesException(String msg) { - super(msg); - } - - public NoResponseFromNodesException(Throwable cause) { - super(cause); - } - - public NoResponseFromNodesException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java deleted file mode 100644 index 3bd2f4b..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeDisconnectionException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when a disconnection request to a node - * failed. - * - * @author unattributed - */ -public class NodeDisconnectionException extends ClusterException { - - public NodeDisconnectionException() { - } - - public NodeDisconnectionException(String msg) { - super(msg); - } - - public NodeDisconnectionException(Throwable cause) { - super(cause); - } - - public NodeDisconnectionException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java deleted file mode 100644 index 8c40cef..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/NodeReconnectionException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when a reconnection request to a node failed. - * - * @author unattributed - */ -public class NodeReconnectionException extends ClusterException { - - public NodeReconnectionException() { - } - - public NodeReconnectionException(String msg) { - super(msg); - } - - public NodeReconnectionException(Throwable cause) { - super(cause); - } - - public NodeReconnectionException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java deleted file mode 100644 index 403f7a5..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/PrimaryRoleAssignmentException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when the cluster is unable to update the - * primary role of a node. - * - * @author unattributed - */ -public class PrimaryRoleAssignmentException extends IllegalClusterStateException { - - public PrimaryRoleAssignmentException() { - } - - public PrimaryRoleAssignmentException(String msg) { - super(msg); - } - - public PrimaryRoleAssignmentException(Throwable cause) { - super(cause); - } - - public PrimaryRoleAssignmentException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java deleted file mode 100644 index f544f26..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/SafeModeMutableRequestException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when a HTTP request that may change a node's - * dataflow is to be replicated while the cluster is in safe mode. - * - * @author unattributed - */ -public class SafeModeMutableRequestException extends MutableRequestException { - - public SafeModeMutableRequestException() { - } - - public SafeModeMutableRequestException(String msg) { - super(msg); - } - - public SafeModeMutableRequestException(Throwable cause) { - super(cause); - } - - public SafeModeMutableRequestException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java deleted file mode 100644 index 914bb56..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UnknownNodeException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when a request is made for a node that does - * not exist. - * - * @author unattributed - */ -public class UnknownNodeException extends ClusterException { - - public UnknownNodeException() { - } - - public UnknownNodeException(String msg) { - super(msg); - } - - public UnknownNodeException(Throwable cause) { - super(cause); - } - - public UnknownNodeException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java deleted file mode 100644 index 773d7b5..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/exception/UriConstructionException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.cluster.manager.exception; - -/** - * Represents the exceptional case when a URI cannot be constructed from the - * given information. This exception is similar to Java's URISyntaxException - * except that it extends RuntimeException. - * - * @author unattributed - */ -public class UriConstructionException extends RuntimeException { - - public UriConstructionException() { - } - - public UriConstructionException(String msg) { - super(msg); - } - - public UriConstructionException(Throwable cause) { - super(cause); - } - - public UriConstructionException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredEventAccess.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredEventAccess.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredEventAccess.java deleted file mode 100644 index 2015530..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredEventAccess.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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.cluster.manager.impl; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.nifi.controller.status.ProcessGroupStatus; -import org.apache.nifi.events.EventReporter; -import org.apache.nifi.provenance.ProvenanceEventBuilder; -import org.apache.nifi.provenance.ProvenanceEventRecord; -import org.apache.nifi.provenance.ProvenanceEventRepository; -import org.apache.nifi.provenance.lineage.ComputeLineageSubmission; -import org.apache.nifi.provenance.search.Query; -import org.apache.nifi.provenance.search.QuerySubmission; -import org.apache.nifi.provenance.search.SearchableField; -import org.apache.nifi.reporting.EventAccess; - -public class ClusteredEventAccess implements EventAccess { - - private final WebClusterManager clusterManager; - - public ClusteredEventAccess(final WebClusterManager clusterManager) { - this.clusterManager = clusterManager; - } - - @Override - public ProcessGroupStatus getControllerStatus() { - return clusterManager.getProcessGroupStatus(WebClusterManager.ROOT_GROUP_ID_ALIAS); - } - - @Override - public List<ProvenanceEventRecord> getProvenanceEvents(long arg0, int arg1) throws IOException { - return new ArrayList<>(); - } - - @Override - public ProvenanceEventRepository getProvenanceRepository() { - // NCM doesn't have provenance events, because it doesn't process FlowFiles. - // So we just use a Provenance Event Repository that does nothing. - return new ProvenanceEventRepository() { - @Override - public void close() throws IOException { - } - - @Override - public ProvenanceEventRecord getEvent(long eventId) throws IOException { - return null; - } - - @Override - public List<ProvenanceEventRecord> getEvents(long startEventId, int maxEvents) throws IOException { - return new ArrayList<>(); - } - - @Override - public Long getMaxEventId() { - return null; - } - - @Override - public List<SearchableField> getSearchableAttributes() { - return new ArrayList<>(); - } - - @Override - public List<SearchableField> getSearchableFields() { - return new ArrayList<>(); - } - - @Override - public void registerEvent(final ProvenanceEventRecord event) { - } - - @Override - public void registerEvents(final Iterable<ProvenanceEventRecord> events) { - } - - @Override - public ComputeLineageSubmission retrieveLineageSubmission(final String submissionId) { - return null; - } - - @Override - public QuerySubmission retrieveQuerySubmission(final String submissionId) { - return null; - } - - @Override - public ComputeLineageSubmission submitExpandChildren(final long eventId) { - return null; - } - - @Override - public ComputeLineageSubmission submitExpandParents(final long eventId) { - return null; - } - - @Override - public ComputeLineageSubmission submitLineageComputation(final String flowFileUuid) { - return null; - } - - @Override - public QuerySubmission submitQuery(final Query query) { - return null; - } - - @Override - public ProvenanceEventBuilder eventBuilder() { - return null; - } - - @Override - public void initialize(EventReporter eventReporter) throws IOException { - - } - }; - } -} http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/f6d9354b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredReportingContext.java ---------------------------------------------------------------------- diff --git a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredReportingContext.java b/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredReportingContext.java deleted file mode 100644 index e546f87..0000000 --- a/nifi/nar-bundles/framework-bundle/framework/cluster/src/main/java/org/apache/nifi/cluster/manager/impl/ClusteredReportingContext.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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.cluster.manager.impl; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.apache.nifi.attribute.expression.language.PreparedQuery; -import org.apache.nifi.attribute.expression.language.Query; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.components.PropertyValue; -import org.apache.nifi.controller.ControllerServiceLookup; -import org.apache.nifi.controller.service.ControllerServiceProvider; -import org.apache.nifi.controller.status.PortStatus; -import org.apache.nifi.controller.status.ProcessGroupStatus; -import org.apache.nifi.controller.status.ProcessorStatus; -import org.apache.nifi.events.BulletinFactory; -import org.apache.nifi.processor.StandardPropertyValue; -import org.apache.nifi.reporting.Bulletin; -import org.apache.nifi.reporting.BulletinRepository; -import org.apache.nifi.reporting.EventAccess; -import org.apache.nifi.reporting.ReportingContext; -import org.apache.nifi.reporting.Severity; - -public class ClusteredReportingContext implements ReportingContext { - - private final EventAccess eventAccess; - private final BulletinRepository bulletinRepository; - private final ControllerServiceProvider serviceProvider; - private final Map<PropertyDescriptor, String> properties; - private final Map<PropertyDescriptor, PreparedQuery> preparedQueries; - - public ClusteredReportingContext(final EventAccess eventAccess, final BulletinRepository bulletinRepository, - final Map<PropertyDescriptor, String> properties, final ControllerServiceProvider serviceProvider) { - this.eventAccess = eventAccess; - this.bulletinRepository = bulletinRepository; - this.properties = Collections.unmodifiableMap(properties); - this.serviceProvider = serviceProvider; - - preparedQueries = new HashMap<>(); - for (final Map.Entry<PropertyDescriptor, String> entry : properties.entrySet()) { - final PropertyDescriptor desc = entry.getKey(); - String value = entry.getValue(); - if (value == null) { - value = desc.getDefaultValue(); - } - - final PreparedQuery pq = Query.prepare(value); - preparedQueries.put(desc, pq); - } - } - - @Override - public EventAccess getEventAccess() { - return eventAccess; - } - - @Override - public BulletinRepository getBulletinRepository() { - return bulletinRepository; - } - - @Override - public Bulletin createBulletin(final String category, final Severity severity, final String message) { - return BulletinFactory.createBulletin(category, severity.name(), message); - } - - @Override - public Bulletin createBulletin(final String componentId, final String category, final Severity severity, final String message) { - final ProcessGroupStatus rootGroupStatus = eventAccess.getControllerStatus(); - final String groupId = findGroupId(rootGroupStatus, componentId); - final String componentName = findComponentName(rootGroupStatus, componentId); - - return BulletinFactory.createBulletin(groupId, componentId, componentName, category, severity.name(), message); - } - - @Override - public Map<PropertyDescriptor, String> getProperties() { - return Collections.unmodifiableMap(properties); - } - - @Override - public PropertyValue getProperty(final PropertyDescriptor property) { - final String configuredValue = properties.get(property); - return new StandardPropertyValue(configuredValue == null ? property.getDefaultValue() : configuredValue, serviceProvider, preparedQueries.get(property)); - } - - @Override - public ControllerServiceLookup getControllerServiceLookup() { - return serviceProvider; - } - - String findGroupId(final ProcessGroupStatus groupStatus, final String componentId) { - for (final ProcessorStatus procStatus : groupStatus.getProcessorStatus()) { - if (procStatus.getId().equals(componentId)) { - return groupStatus.getId(); - } - } - - for (final PortStatus portStatus : groupStatus.getInputPortStatus()) { - if (portStatus.getId().equals(componentId)) { - return groupStatus.getId(); - } - } - - for (final PortStatus portStatus : groupStatus.getOutputPortStatus()) { - if (portStatus.getId().equals(componentId)) { - return groupStatus.getId(); - } - } - - for (final ProcessGroupStatus childGroup : groupStatus.getProcessGroupStatus()) { - final String groupId = findGroupId(childGroup, componentId); - if (groupId != null) { - return groupId; - } - } - - return null; - } - - private String findComponentName(final ProcessGroupStatus groupStatus, final String componentId) { - for (final ProcessorStatus procStatus : groupStatus.getProcessorStatus()) { - if (procStatus.getId().equals(componentId)) { - return procStatus.getName(); - } - } - - for (final PortStatus portStatus : groupStatus.getInputPortStatus()) { - if (portStatus.getId().equals(componentId)) { - return groupStatus.getName(); - } - } - - for (final PortStatus portStatus : groupStatus.getOutputPortStatus()) { - if (portStatus.getId().equals(componentId)) { - return groupStatus.getName(); - } - } - - for (final ProcessGroupStatus childGroup : groupStatus.getProcessGroupStatus()) { - final String componentName = findComponentName(childGroup, componentId); - if (componentName != null) { - return componentName; - } - } - - return null; - } -}
