http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java index 9a8ad28..27eca37 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/fingerprint/FingerprintFactory.java @@ -82,14 +82,13 @@ import org.xml.sax.SAXException; * the processor "settings" or "comments" tabs, position information, flow * controller settings, and counters. * - * @author unattributed */ public final class FingerprintFactory { /* * Developer Note: This class should be changed with care and coordinated - * with all classes that use fingerprinting. Improper coordination may - * lead to orphaning flow files, especially when flows are reloaded in a + * with all classes that use fingerprinting. Improper coordination may + * lead to orphaning flow files, especially when flows are reloaded in a * clustered environment. */ // no fingerprint value @@ -130,7 +129,7 @@ public final class FingerprintFactory { * the flow does not influence the fingerprint generation. * * @param flowBytes the flow represented as bytes - * @param controller + * @param controller the controller * * @return a generated fingerprint * @@ -161,8 +160,8 @@ public final class FingerprintFactory { * * @return the fingerprint * - * @throws NoSuchAlgorithmException - * @throws UnsupportedEncodingException + * @throws NoSuchAlgorithmException ex + * @throws UnsupportedEncodingException ex */ private String createFingerprint(final Document flowDoc, final FlowController controller) throws NoSuchAlgorithmException { if (flowDoc == null) { @@ -188,7 +187,7 @@ public final class FingerprintFactory { * templates does not influence the fingerprint generation. * * - * @param templates + * @param templates collection of templates * @return a generated fingerprint * * @throws FingerprintException if the fingerprint failed to be generated @@ -253,22 +252,21 @@ public final class FingerprintFactory { // root group final Element rootGroupElem = (Element) DomUtils.getChildNodesByTagName(flowControllerElem, "rootGroup").item(0); addProcessGroupFingerprint(builder, rootGroupElem, controller); - + final Element controllerServicesElem = DomUtils.getChild(flowControllerElem, "controllerServices"); - if ( controllerServicesElem != null ) { - for ( final Element serviceElem : DomUtils.getChildElementsByTagName(controllerServicesElem, "controllerService") ) { - addControllerServiceFingerprint(builder, serviceElem); - } + if (controllerServicesElem != null) { + for (final Element serviceElem : DomUtils.getChildElementsByTagName(controllerServicesElem, "controllerService")) { + addControllerServiceFingerprint(builder, serviceElem); + } } - + final Element reportingTasksElem = DomUtils.getChild(flowControllerElem, "reportingTasks"); - if ( reportingTasksElem != null ) { - for ( final Element taskElem : DomUtils.getChildElementsByTagName(reportingTasksElem, "reportingTask") ) { - addReportingTaskFingerprint(builder, taskElem); - } + if (reportingTasksElem != null) { + for (final Element taskElem : DomUtils.getChildElementsByTagName(reportingTasksElem, "reportingTask")) { + addReportingTaskFingerprint(builder, taskElem); + } } - - + return builder; } @@ -851,21 +849,21 @@ public final class FingerprintFactory { builder.append(funnel.getId()); return builder; } - + private void addControllerServiceFingerprint(final StringBuilder builder, final Element controllerServiceElem) { - final ControllerServiceDTO dto = FlowFromDOMFactory.getControllerService(controllerServiceElem, encryptor); - addControllerServiceFingerprint(builder, dto); + final ControllerServiceDTO dto = FlowFromDOMFactory.getControllerService(controllerServiceElem, encryptor); + addControllerServiceFingerprint(builder, dto); } - + private void addControllerServiceFingerprint(final StringBuilder builder, final ControllerServiceDTO dto) { - builder.append(dto.getId()); - builder.append(dto.getType()); - builder.append(dto.getName()); - builder.append(dto.getComments()); - builder.append(dto.getAnnotationData()); - - final Map<String, String> properties = dto.getProperties(); - if (properties == null) { + builder.append(dto.getId()); + builder.append(dto.getType()); + builder.append(dto.getName()); + builder.append(dto.getComments()); + builder.append(dto.getAnnotationData()); + + final Map<String, String> properties = dto.getProperties(); + if (properties == null) { builder.append("NO_PROPERTIES"); } else { final SortedMap<String, String> sortedProps = new TreeMap<>(properties); @@ -880,23 +878,23 @@ public final class FingerprintFactory { } } } - + private void addReportingTaskFingerprint(final StringBuilder builder, final Element element) { - final ReportingTaskDTO dto = FlowFromDOMFactory.getReportingTask(element, encryptor); - addReportingTaskFingerprint(builder, dto); + final ReportingTaskDTO dto = FlowFromDOMFactory.getReportingTask(element, encryptor); + addReportingTaskFingerprint(builder, dto); } - + private void addReportingTaskFingerprint(final StringBuilder builder, final ReportingTaskDTO dto) { - builder.append(dto.getId()); - builder.append(dto.getType()); - builder.append(dto.getName()); - builder.append(dto.getComments()); - builder.append(dto.getSchedulingPeriod()); - builder.append(dto.getSchedulingStrategy()); - builder.append(dto.getAnnotationData()); - - final Map<String, String> properties = dto.getProperties(); - if (properties == null) { + builder.append(dto.getId()); + builder.append(dto.getType()); + builder.append(dto.getName()); + builder.append(dto.getComments()); + builder.append(dto.getSchedulingPeriod()); + builder.append(dto.getSchedulingStrategy()); + builder.append(dto.getAnnotationData()); + + final Map<String, String> properties = dto.getProperties(); + if (properties == null) { builder.append("NO_PROPERTIES"); } else { final SortedMap<String, String> sortedProps = new TreeMap<>(properties);
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java index 6a26d09..e0181ea 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java @@ -336,10 +336,10 @@ public final class StandardProcessGroup implements ProcessGroup { } } - for ( final RemoteProcessGroup rpg : procGroup.getRemoteProcessGroups() ) { + for (final RemoteProcessGroup rpg : procGroup.getRemoteProcessGroups()) { rpg.shutdown(); } - + // Recursively shutdown child groups. for (final ProcessGroup group : procGroup.getProcessGroups()) { shutdown(group); @@ -677,19 +677,19 @@ public final class StandardProcessGroup implements ProcessGroup { throw new ComponentLifeCycleException("Failed to invoke 'OnRemoved' methods of " + processor, e); } - for ( final Map.Entry<PropertyDescriptor, String> entry : processor.getProperties().entrySet() ) { + for (final Map.Entry<PropertyDescriptor, String> entry : processor.getProperties().entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); - if (descriptor.getControllerServiceDefinition() != null ) { + if (descriptor.getControllerServiceDefinition() != null) { final String value = entry.getValue() == null ? descriptor.getDefaultValue() : entry.getValue(); - if ( value != null ) { + if (value != null) { final ControllerServiceNode serviceNode = controllerServiceProvider.getControllerServiceNode(value); - if ( serviceNode != null ) { + if (serviceNode != null) { serviceNode.removeReference(processor); } } } } - + processors.remove(id); LogRepositoryFactory.getRepository(processor.getIdentifier()).removeAllObservers(); @@ -773,7 +773,9 @@ public final class StandardProcessGroup implements ProcessGroup { } else if (sourceGroup != this || destinationGroup != this) { throw new IllegalStateException("Cannot add Connection to Process Group because source and destination are not both in this Process Group"); } - } else if (isOutputPort(source)) { // if source is an output port, its group must be a child of this group, and its destination must be in this group (processor/output port) or a child group (input port) + } else if (isOutputPort(source)) { + // if source is an output port, its group must be a child of this group, and its destination must be in this + // group (processor/output port) or a child group (input port) if (!processGroups.containsKey(sourceGroup.getIdentifier())) { throw new IllegalStateException("Cannot add Connection to Process Group because source is an Output Port that does not belong to a child Process Group"); } @@ -798,10 +800,12 @@ public final class StandardProcessGroup implements ProcessGroup { } } else if (isInputPort(destination)) { if (!processGroups.containsKey(destinationGroup.getIdentifier())) { - throw new IllegalStateException("Cannot add Connection to Process Group because its destination is an Input Port but the Input Port does not belong to a child Process Group"); + throw new IllegalStateException("Cannot add Connection to Process Group because its destination is an Input " + + "Port but the Input Port does not belong to a child Process Group"); } } else if (destinationGroup != this) { - throw new IllegalStateException("Cannot add Connection between " + source + " and " + destination + " because they are in different Process Groups and neither is an Input Port or Output Port"); + throw new IllegalStateException("Cannot add Connection between " + source + " and " + destination + + " because they are in different Process Groups and neither is an Input Port or Output Port"); } } @@ -1207,7 +1211,6 @@ public final class StandardProcessGroup implements ProcessGroup { } } - @Override public void disableInputPort(final Port port) { readLock.lock(); @@ -1379,6 +1382,7 @@ public final class StandardProcessGroup implements ProcessGroup { return allNodes; } + @Override public Connectable findConnectable(final String identifier) { return findConnectable(identifier, this); } @@ -1518,12 +1522,11 @@ public final class StandardProcessGroup implements ProcessGroup { return null; } - @Override public void addFunnel(final Funnel funnel) { addFunnel(funnel, true); } - + @Override public void addFunnel(final Funnel funnel, final boolean autoStart) { writeLock.lock(); @@ -1535,8 +1538,8 @@ public final class StandardProcessGroup implements ProcessGroup { funnel.setProcessGroup(this); funnels.put(funnel.getIdentifier(), funnel); - - if ( autoStart ) { + + if (autoStart) { startFunnel(funnel); } } finally { @@ -1634,12 +1637,13 @@ public final class StandardProcessGroup implements ProcessGroup { for (final Connectable connectable : connectables) { for (final Connection conn : connectable.getIncomingConnections()) { if (!connectionIds.contains(conn.getIdentifier()) && !connectables.contains(conn.getSource())) { - throw new IllegalStateException(connectable + " cannot be removed because it has incoming connections that are not selected to be deleted"); + throw new IllegalStateException(connectable + " cannot be removed because it has incoming connections " + + "that are not selected to be deleted"); } } } - // verify that all of the ProcessGroups in the snippet are empty + // verify that all of the ProcessGroups in the snippet are empty for (final String groupId : snippet.getProcessGroups()) { final ProcessGroup toRemove = getProcessGroup(groupId); if (!toRemove.isEmpty()) { @@ -1805,7 +1809,7 @@ public final class StandardProcessGroup implements ProcessGroup { * components within this ProcessGroup. If this is not the case, throws * {@link IllegalStateException}. * - * @param snippet + * @param snippet the snippet * @throws NullPointerException if the argument is null * @throws IllegalStateException if the snippet contains an ID that * references a component that is not part of this ProcessGroup @@ -1835,9 +1839,9 @@ public final class StandardProcessGroup implements ProcessGroup { * If the ids given are null, will do no validation. * </p> * - * @param ids - * @param map - * @param componentType + * @param ids ids + * @param map map + * @param componentType type */ private void verifyAllKeysExist(final Set<String> ids, final Map<String, ?> map, final String componentType) { if (ids != null) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/persistence/FlowConfigurationDAO.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/persistence/FlowConfigurationDAO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/persistence/FlowConfigurationDAO.java index 8957314..cc3dbea 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/persistence/FlowConfigurationDAO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/persistence/FlowConfigurationDAO.java @@ -73,7 +73,7 @@ public interface FlowConfigurationDAO { /** * Saves all changes made to the given flow to the given File. * - * @param flow + * @param flow to save * @throws NullPointerException if the given flow is null * @throws IOException If unable to persist state of given flow * @throws IllegalStateException if FileFlowDAO not in proper state for @@ -84,7 +84,7 @@ public interface FlowConfigurationDAO { /** * Saves all changes made to the given flow to the given File. * - * @param flow + * @param flow to save * @param outStream the OutputStream to which the FlowController will be * written * @throws NullPointerException if the given flow is null @@ -97,7 +97,7 @@ public interface FlowConfigurationDAO { /** * Saves all changes made to the given flow to the given File. * - * @param flow + * @param flow to save * @param archive if true will also attempt to archive the flow * configuration * @throws NullPointerException if the given flow is null http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/SimpleProcessLogger.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/SimpleProcessLogger.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/SimpleProcessLogger.java index 0a345a0..afd0c59 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/SimpleProcessLogger.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/SimpleProcessLogger.java @@ -269,11 +269,6 @@ public class SimpleProcessLogger implements ProcessorLog { logRepository.addLogMessage(LogLevel.DEBUG, msg, os, t); } - /** - * - * @param msg - * @param os - */ @Override public void debug(String msg, Object[] os) { os = addProcessor(os); http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardProcessContext.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardProcessContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardProcessContext.java index d14a459..3e1d1e6 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardProcessContext.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardProcessContext.java @@ -145,7 +145,7 @@ public class StandardProcessContext implements ProcessContext, ControllerService public boolean isControllerServiceEnabling(final String serviceIdentifier) { return controllerServiceProvider.isControllerServiceEnabling(serviceIdentifier); } - + @Override public ControllerServiceLookup getControllerServiceLookup() { return this; @@ -174,10 +174,10 @@ public class StandardProcessContext implements ProcessContext, ControllerService return set; } - + @Override public String getControllerServiceName(final String serviceIdentifier) { - return controllerServiceProvider.getControllerServiceName(serviceIdentifier); + return controllerServiceProvider.getControllerServiceName(serviceIdentifier); } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardPropertyValue.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardPropertyValue.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardPropertyValue.java index c3b7f4f..b320a61 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardPropertyValue.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardPropertyValue.java @@ -49,9 +49,9 @@ public final class StandardPropertyValue implements PropertyValue { * information should be provided so that calls to * {@link #evaluateAttributeExpressions()} are much more efficient * - * @param rawValue - * @param serviceLookup - * @param preparedQuery + * @param rawValue value + * @param serviceLookup lookup + * @param preparedQuery query */ public StandardPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup, final PreparedQuery preparedQuery) { this.rawValue = rawValue; http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardSchedulingContext.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardSchedulingContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardSchedulingContext.java index c37a80d..ef73728 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardSchedulingContext.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardSchedulingContext.java @@ -46,7 +46,7 @@ public class StandardSchedulingContext implements SchedulingContext { throw new IllegalArgumentException("Cannot lease Controller Service because no Controller Service exists with identifier " + identifier); } - if ( serviceNode.getState() != ControllerServiceState.ENABLED ) { + if (serviceNode.getState() != ControllerServiceState.ENABLED) { throw new IllegalStateException("Cannot lease Controller Service because Controller Service " + serviceNode.getProxiedControllerService() + " is not currently enabled"); } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardValidationContext.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardValidationContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardValidationContext.java index c51cb9a..e627dd3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardValidationContext.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/StandardValidationContext.java @@ -47,8 +47,12 @@ public class StandardValidationContext implements ValidationContext { public StandardValidationContext(final ControllerServiceProvider controllerServiceProvider, final Map<PropertyDescriptor, String> properties, final String annotationData) { this(controllerServiceProvider, Collections.<String>emptySet(), properties, annotationData); } - - public StandardValidationContext(final ControllerServiceProvider controllerServiceProvider, final Set<String> serviceIdentifiersToNotValidate, final Map<PropertyDescriptor, String> properties, final String annotationData) { + + public StandardValidationContext( + final ControllerServiceProvider controllerServiceProvider, + final Set<String> serviceIdentifiersToNotValidate, + final Map<PropertyDescriptor, String> properties, + final String annotationData) { this.controllerServiceProvider = controllerServiceProvider; this.properties = new HashMap<>(properties); this.annotationData = annotationData; @@ -67,7 +71,7 @@ public class StandardValidationContext implements ValidationContext { } expressionLanguageSupported = new HashMap<>(properties.size()); - for ( final PropertyDescriptor descriptor : properties.keySet() ) { + for (final PropertyDescriptor descriptor : properties.keySet()) { expressionLanguageSupported.put(descriptor.getName(), descriptor.isExpressionLanguageSupported()); } } @@ -113,17 +117,17 @@ public class StandardValidationContext implements ValidationContext { public boolean isValidationRequired(final ControllerService service) { return !serviceIdentifiersToNotValidate.contains(service.getIdentifier()); } - + @Override public boolean isExpressionLanguagePresent(final String value) { - if ( value == null ) { + if (value == null) { return false; } - + final List<Range> elRanges = Query.extractExpressionRanges(value); return (elRanges != null && !elRanges.isEmpty()); } - + @Override public boolean isExpressionLanguageSupported(final String propertyName) { final Boolean supported = expressionLanguageSupported.get(propertyName); http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/RemoteNiFiUtils.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/RemoteNiFiUtils.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/RemoteNiFiUtils.java index 23dfdda..bed5279 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/RemoteNiFiUtils.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/RemoteNiFiUtils.java @@ -37,51 +37,47 @@ import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.core.util.MultivaluedMapImpl; -/** - * - */ public class RemoteNiFiUtils { public static final String CONTROLLER_URI_PATH = "/controller"; private static final int CONNECT_TIMEOUT = 10000; private static final int READ_TIMEOUT = 10000; - + private final Client client; - + public RemoteNiFiUtils(final SSLContext sslContext) { this.client = getClient(sslContext); } - /** * Gets the content at the specified URI. * - * @param uri - * @param timeoutMillis - * @return - * @throws ClientHandlerException - * @throws UniformInterfaceException + * @param uri uri to retrieve + * @param timeoutMillis time to wait in millis + * @return response + * @throws ClientHandlerException ex + * @throws UniformInterfaceException ex */ public ClientResponse get(final URI uri, final int timeoutMillis) throws ClientHandlerException, UniformInterfaceException { return get(uri, timeoutMillis, null); } - + /** * Gets the content at the specified URI using the given query parameters. * - * @param uri - * @param timeoutMillis - * @param queryParams - * @return - * @throws ClientHandlerException - * @throws UniformInterfaceException + * @param uri to retrieve + * @param timeoutMillis wait period in millis + * @param queryParams query parameters + * @return response + * @throws ClientHandlerException ex + * @throws UniformInterfaceException ex */ public ClientResponse get(final URI uri, final int timeoutMillis, final Map<String, String> queryParams) throws ClientHandlerException, UniformInterfaceException { // perform the request WebResource webResource = client.resource(uri); - if ( queryParams != null ) { - for ( final Map.Entry<String, String> queryEntry : queryParams.entrySet() ) { + if (queryParams != null) { + for (final Map.Entry<String, String> queryEntry : queryParams.entrySet()) { webResource = webResource.queryParam(queryEntry.getKey(), queryEntry.getValue()); } } @@ -95,11 +91,11 @@ public class RemoteNiFiUtils { /** * Performs a HEAD request to the specified URI. * - * @param uri - * @param timeoutMillis - * @return - * @throws ClientHandlerException - * @throws UniformInterfaceException + * @param uri to retrieve + * @param timeoutMillis wait time in millis + * @return response + * @throws ClientHandlerException ex + * @throws UniformInterfaceException ex */ public ClientResponse head(final URI uri, final int timeoutMillis) throws ClientHandlerException, UniformInterfaceException { // perform the request @@ -109,12 +105,6 @@ public class RemoteNiFiUtils { return webResource.head(); } - /** - * Gets a client based on the specified URI. - * - * @param uri - * @return - */ private Client getClient(final SSLContext sslContext) { final Client client; if (sslContext == null) { @@ -128,26 +118,27 @@ public class RemoteNiFiUtils { return client; } - - + /** - * Returns the port on which the remote instance is listening for Flow File transfers, or <code>null</code> if the remote instance - * is not configured to use Site-to-Site transfers. - * - * @param uri the base URI of the remote instance. This should include the path only to the nifi-api level, as well as the protocol, host, and port. - * @param timeoutMillis - * @return - * @throws IOException + * Returns the port on which the remote instance is listening for Flow File + * transfers, or <code>null</code> if the remote instance is not configured + * to use Site-to-Site transfers. + * + * @param uri the base URI of the remote instance. This should include the + * path only to the nifi-api level, as well as the protocol, host, and port. + * @param timeoutMillis wait time in millis + * @return port number + * @throws IOException ex */ public Integer getRemoteListeningPort(final String uri, final int timeoutMillis) throws IOException { - try { - final URI uriObject = new URI(uri + CONTROLLER_URI_PATH); - return getRemoteListeningPort(uriObject, timeoutMillis); - } catch (URISyntaxException e) { - throw new IOException("Unable to establish connection to remote host because URI is invalid: " + uri); - } + try { + final URI uriObject = new URI(uri + CONTROLLER_URI_PATH); + return getRemoteListeningPort(uriObject, timeoutMillis); + } catch (URISyntaxException e) { + throw new IOException("Unable to establish connection to remote host because URI is invalid: " + uri); + } } - + public String getRemoteRootGroupId(final String uri, final int timeoutMillis) throws IOException { try { final URI uriObject = new URI(uri + CONTROLLER_URI_PATH); @@ -156,7 +147,7 @@ public class RemoteNiFiUtils { throw new IOException("Unable to establish connection to remote host because URI is invalid: " + uri); } } - + public String getRemoteInstanceId(final String uri, final int timeoutMillis) throws IOException { try { final URI uriObject = new URI(uri + CONTROLLER_URI_PATH); @@ -165,26 +156,27 @@ public class RemoteNiFiUtils { throw new IOException("Unable to establish connection to remote host because URI is invalid: " + uri); } } - + /** - * Returns the port on which the remote instance is listening for Flow File transfers, or <code>null</code> if the remote instance - * is not configured to use Site-to-Site transfers. - * + * Returns the port on which the remote instance is listening for Flow File + * transfers, or <code>null</code> if the remote instance is not configured + * to use Site-to-Site transfers. + * * @param uri the full URI to fetch, including the path. - * @return - * @throws IOException + * @return port + * @throws IOException ex */ private Integer getRemoteListeningPort(final URI uri, final int timeoutMillis) throws IOException { - return getController(uri, timeoutMillis).getRemoteSiteListeningPort(); + return getController(uri, timeoutMillis).getRemoteSiteListeningPort(); } - + private String getRemoteRootGroupId(final URI uri, final int timeoutMillis) throws IOException { return getController(uri, timeoutMillis).getId(); } - + public ControllerDTO getController(final URI uri, final int timeoutMillis) throws IOException { final ClientResponse response = get(uri, timeoutMillis); - + if (Status.OK.getStatusCode() == response.getStatusInfo().getStatusCode()) { final ControllerEntity entity = response.getEntity(ControllerEntity.class); return entity.getController(); @@ -193,12 +185,12 @@ public class RemoteNiFiUtils { throw new IOException("Got HTTP response Code " + response.getStatusInfo().getStatusCode() + ": " + response.getStatusInfo().getReasonPhrase() + " with explanation: " + responseMessage); } } - + /** * Issues a registration request on behalf of the current user. - * - * @param baseApiUri - * @return + * + * @param baseApiUri uri to register with + * @return response */ public ClientResponse issueRegistrationRequest(String baseApiUri) { final URI uri = URI.create(String.format("%s/%s", baseApiUri, "/controller/users")); @@ -206,10 +198,10 @@ public class RemoteNiFiUtils { // set up the query params MultivaluedMapImpl entity = new MultivaluedMapImpl(); entity.add("justification", "A Remote instance of NiFi has attempted to create a reference to this NiFi. This action must be approved first."); - + // create the web resource WebResource webResource = client.resource(uri); - + // get the client utils and make the request return webResource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_FORM_URLENCODED).entity(entity).post(ClientResponse.class); } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java index 55575c6..f4b5975 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java @@ -87,7 +87,7 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { public static final int OK_STATUS_CODE = Status.OK.getStatusCode(); public static final int UNAUTHORIZED_STATUS_CODE = Status.UNAUTHORIZED.getStatusCode(); public static final int FORBIDDEN_STATUS_CODE = Status.FORBIDDEN.getStatusCode(); - + private final String id; private final URI targetUri; @@ -194,7 +194,7 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { public void shutdown() { backgroundThreadExecutor.shutdown(); } - + @Override public String getIdentifier() { return id; @@ -381,7 +381,7 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { * Returns a boolean indicating whether or not an Output Port exists with * the given ID * - * @param id + * @param id identifier of port * @return <code>true</code> if an Output Port exists with the given ID, * <code>false</code> otherwise. */ @@ -562,11 +562,9 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { } /** - * Returns an {@link RemoteGroupPort} that can be used to send FlowFiles to - * the port whose ID is given on the remote instance - * * @param portIdentifier the ID of the Port to send FlowFiles to - * @return + * @return {@link RemoteGroupPort} that can be used to send FlowFiles to the + * port whose ID is given on the remote instance */ @Override public RemoteGroupPort getInputPort(final String portIdentifier) { @@ -602,7 +600,7 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { * Adds an InputPort to this ProcessGroup that is described by the given * DTO. * - * @param descriptor + * @param descriptor port descriptor * * @throws IllegalStateException if an Input Port already exists with the ID * given by the ID of the DTO. @@ -630,13 +628,6 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { } } - /** - * Returns an {@link RemoteGroupPort} that can be used to receive FlowFiles - * from the port whose name is given on the remote instance - * - * @param portIdentifier the name of the Port to receive FlowFiles from - * @return - */ @Override public RemoteGroupPort getOutputPort(final String portIdentifier) { readLock.lock(); @@ -776,7 +767,7 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { try { // perform the request final ClientResponse response = utils.get(uri, getCommunicationsTimeout(TimeUnit.MILLISECONDS)); - + if (!Response.Status.Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily())) { writeLock.lock(); try { @@ -799,7 +790,8 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { // consume the entity entirely response.getEntity(String.class); - throw new CommunicationsException("Unable to communicate with Remote NiFi at URI " + uriVal + ". Got HTTP Error Code " + response.getStatus() + ": " + response.getStatusInfo().getReasonPhrase()); + throw new CommunicationsException("Unable to communicate with Remote NiFi at URI " + uriVal + ". Got HTTP Error Code " + + response.getStatus() + ": " + response.getStatusInfo().getReasonPhrase()); } final ControllerEntity entity = response.getEntity(ControllerEntity.class); @@ -873,8 +865,8 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { /** * Converts a set of ports into a set of remote process group ports. * - * @param ports - * @return + * @param ports to convert + * @return descriptors of ports */ private Set<RemoteProcessGroupPortDescriptor> convertRemotePort(final Set<PortDTO> ports) { Set<RemoteProcessGroupPortDescriptor> remotePorts = null; @@ -1084,7 +1076,6 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { } } - @Override public EventReporter getEventReporter() { return eventReporter; @@ -1097,10 +1088,10 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { try { final RemoteNiFiUtils utils = new RemoteNiFiUtils(isWebApiSecure() ? sslContext : null); final ClientResponse response = utils.get(new URI(apiUri + CONTROLLER_URI_PATH), getCommunicationsTimeout(TimeUnit.MILLISECONDS)); - + final int statusCode = response.getStatus(); - - if ( statusCode == OK_STATUS_CODE ) { + + if (statusCode == OK_STATUS_CODE) { final ControllerEntity entity = response.getEntity(ControllerEntity.class); final ControllerDTO dto = entity.getController(); @@ -1121,10 +1112,10 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { final String remoteInstanceId = dto.getInstanceId(); boolean isPointingToCluster = flowController.getInstanceId().equals(remoteInstanceId); pointsToCluster.set(isPointingToCluster); - } else if ( statusCode == UNAUTHORIZED_STATUS_CODE ) { + } else if (statusCode == UNAUTHORIZED_STATUS_CODE) { try { final ClientResponse requestAccountResponse = utils.issueRegistrationRequest(apiUri.toString()); - if (Response.Status.Family.SUCCESSFUL.equals(requestAccountResponse.getStatusInfo().getFamily()) ) { + if (Response.Status.Family.SUCCESSFUL.equals(requestAccountResponse.getStatusInfo().getFamily())) { logger.info("{} Issued a Request to communicate with remote instance", this); } else { logger.error("{} Failed to request account: got unexpected response code of {}:{}", new Object[]{ @@ -1138,7 +1129,7 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { } authorizationIssue = response.getEntity(String.class); - } else if ( statusCode == FORBIDDEN_STATUS_CODE ) { + } else if (statusCode == FORBIDDEN_STATUS_CODE) { authorizationIssue = response.getEntity(String.class); } else { final String message = response.getEntity(String.class); @@ -1158,7 +1149,8 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { public void setYieldDuration(final String yieldDuration) { // verify the syntax if (!FormatUtils.TIME_DURATION_PATTERN.matcher(yieldDuration).matches()) { - throw new IllegalArgumentException("Improperly formatted Time Period; should be of syntax <number> <unit> where <number> is a positive integer and unit is one of the valid Time Units, such as nanos, millis, sec, min, hour, day"); + throw new IllegalArgumentException("Improperly formatted Time Period; should be of syntax <number> <unit> where " + + "<number> is a positive integer and unit is one of the valid Time Units, such as nanos, millis, sec, min, hour, day"); } this.yieldDuration = yieldDuration; @@ -1168,7 +1160,7 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup { public String getYieldDuration() { return yieldDuration; } - + @Override public void verifyCanDelete() { verifyCanDelete(false); http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/services/FlowService.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/services/FlowService.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/services/FlowService.java index 196358a..71cf969 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/services/FlowService.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/services/FlowService.java @@ -71,8 +71,8 @@ public interface FlowService extends LifeCycle { * that time the latest called state of the flow controller will be used. In * database terms this technique is referred to as 'write-delay'. * - * @param delayUnit - * @param delay + * @param delayUnit unit of delay + * @param delay period of delay */ void saveFlowChanges(TimeUnit delayUnit, long delay); @@ -82,8 +82,8 @@ public interface FlowService extends LifeCycle { * that time the latest called state of the flow controller will be used. In * database terms this technique is referred to as 'write-delay'. * - * @param delayUnit - * @param delay + * @param delayUnit unit of delay + * @param delay period of delay * @param archive if true means the user wants the flow configuration to be * archived as well */ @@ -131,8 +131,7 @@ public interface FlowService extends LifeCycle { void copyCurrentFlow(OutputStream os) throws IOException; /** - * Returns the managed controller. - * @return + * @return the managed controller */ FlowController getController(); http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/spring/FlowControllerFactoryBean.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/spring/FlowControllerFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/spring/FlowControllerFactoryBean.java index 1804f30..665738b 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/spring/FlowControllerFactoryBean.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/spring/FlowControllerFactoryBean.java @@ -45,7 +45,7 @@ public class FlowControllerFactoryBean implements FactoryBean, ApplicationContex @Override public Object getObject() throws Exception { /* - * If configured for the cluster manager, then the flow controller is never used. + * If configured for the cluster manager, then the flow controller is never used. */ if (properties.isClusterManager()) { return null; http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/spring/StandardFlowServiceFactoryBean.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/spring/StandardFlowServiceFactoryBean.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/spring/StandardFlowServiceFactoryBean.java index 92e8bfd..cfd855f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/spring/StandardFlowServiceFactoryBean.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/spring/StandardFlowServiceFactoryBean.java @@ -46,7 +46,7 @@ public class StandardFlowServiceFactoryBean implements FactoryBean, ApplicationC @Override public Object getObject() throws Exception { /* - * If configured for the cluster manager, then the flow controller is never used. + * If configured for the cluster manager, then the flow controller is never used. */ if (properties.isClusterManager()) { return null; http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/DomUtils.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/DomUtils.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/DomUtils.java index da4f04d..9cc3b1f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/DomUtils.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/DomUtils.java @@ -27,14 +27,14 @@ public class DomUtils { public static String getChildText(final Element element, final String tagName) { final Element childElement = getChild(element, tagName); - if ( childElement == null ) { + if (childElement == null) { return null; } - + final String text = childElement.getTextContent(); return (text == null) ? null : text.trim(); } - + public static Element getChild(final Element element, final String tagName) { final List<Element> children = getChildElementsByTagName(element, tagName); if (children.isEmpty()) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/ReflectionUtils.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/ReflectionUtils.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/ReflectionUtils.java index a8a4596..d7573c3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/ReflectionUtils.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/ReflectionUtils.java @@ -38,63 +38,65 @@ public class ReflectionUtils { * are supplied by the <code>args</code> parameter than needed, the extra * arguments will be ignored. * - * @param annotation - * @param instance - * @param args - * @throws InvocationTargetException - * @throws IllegalArgumentException - * @throws IllegalAccessException + * @param annotation annotation + * @param instance instance + * @param args args + * @throws InvocationTargetException ex + * @throws IllegalArgumentException ex + * @throws IllegalAccessException ex */ - public static void invokeMethodsWithAnnotation(final Class<? extends Annotation> annotation, final Object instance, final Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { + public static void invokeMethodsWithAnnotation( + final Class<? extends Annotation> annotation, final Object instance, final Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { invokeMethodsWithAnnotation(annotation, null, instance, args); } - /** * Invokes all methods on the given instance that have been annotated with - * the given preferredAnnotation and if no such method exists will invoke all - * methods on the given instance that have been annotated with the given - * alternateAnnotation, if any exists. If the signature of the method that is defined in - * <code>instance</code> uses 1 or more parameters, those parameters must be - * specified by the <code>args</code> parameter. However, if more arguments - * are supplied by the <code>args</code> parameter than needed, the extra - * arguments will be ignored. + * the given preferredAnnotation and if no such method exists will invoke + * all methods on the given instance that have been annotated with the given + * alternateAnnotation, if any exists. If the signature of the method that + * is defined in <code>instance</code> uses 1 or more parameters, those + * parameters must be specified by the <code>args</code> parameter. However, + * if more arguments are supplied by the <code>args</code> parameter than + * needed, the extra arguments will be ignored. * - * @param preferredAnnotation - * @param alternateAnnotation - * @param instance - * @param args - * @throws InvocationTargetException - * @throws IllegalArgumentException - * @throws IllegalAccessException + * @param preferredAnnotation preferred + * @param alternateAnnotation alternate + * @param instance instance + * @param args args + * @throws InvocationTargetException ex + * @throws IllegalArgumentException ex + * @throws IllegalAccessException ex */ - public static void invokeMethodsWithAnnotation(final Class<? extends Annotation> preferredAnnotation, final Class<? extends Annotation> alternateAnnotation, final Object instance, final Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { + public static void invokeMethodsWithAnnotation( + final Class<? extends Annotation> preferredAnnotation, final Class<? extends Annotation> alternateAnnotation, final Object instance, final Object... args) + throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { final List<Class<? extends Annotation>> annotationClasses = new ArrayList<>(alternateAnnotation == null ? 1 : 2); annotationClasses.add(preferredAnnotation); - if ( alternateAnnotation != null ) { + if (alternateAnnotation != null) { annotationClasses.add(alternateAnnotation); } - + boolean annotationFound = false; - for ( final Class<? extends Annotation> annotationClass : annotationClasses ) { - if ( annotationFound ) { + for (final Class<? extends Annotation> annotationClass : annotationClasses) { + if (annotationFound) { break; } - + try { for (final Method method : instance.getClass().getMethods()) { if (method.isAnnotationPresent(annotationClass)) { annotationFound = true; final boolean isAccessible = method.isAccessible(); method.setAccessible(true); - + try { final Class<?>[] argumentTypes = method.getParameterTypes(); if (argumentTypes.length > args.length) { throw new IllegalArgumentException(String.format("Unable to invoke method %1$s on %2$s because method expects %3$s parameters but only %4$s were given", method.getName(), instance, argumentTypes.length, args.length)); } - + for (int i = 0; i < argumentTypes.length; i++) { final Class<?> argType = argumentTypes[i]; if (!argType.isAssignableFrom(args[i].getClass())) { @@ -103,7 +105,7 @@ public class ReflectionUtils { method.getName(), instance, i, argType, args[i].getClass())); } } - + if (argumentTypes.length == args.length) { method.invoke(instance, args); } else { @@ -111,7 +113,7 @@ public class ReflectionUtils { for (int i = 0; i < argsToPass.length; i++) { argsToPass[i] = args[i]; } - + method.invoke(instance, argsToPass); } } finally { @@ -122,7 +124,7 @@ public class ReflectionUtils { } } } catch (final InvocationTargetException ite) { - if ( ite.getCause() instanceof RuntimeException ) { + if (ite.getCause() instanceof RuntimeException) { throw (RuntimeException) ite.getCause(); } else { throw ite; @@ -131,7 +133,6 @@ public class ReflectionUtils { } } - /** * Invokes all methods on the given instance that have been annotated with * the given Annotation. If the signature of the method that is defined in @@ -140,9 +141,9 @@ public class ReflectionUtils { * are supplied by the <code>args</code> parameter than needed, the extra * arguments will be ignored. * - * @param annotation - * @param instance - * @param args + * @param annotation annotation + * @param instance instance + * @param args args * @return <code>true</code> if all appropriate methods were invoked and * returned without throwing an Exception, <code>false</code> if one of the * methods threw an Exception or could not be invoked; if <code>false</code> @@ -151,8 +152,7 @@ public class ReflectionUtils { public static boolean quietlyInvokeMethodsWithAnnotation(final Class<? extends Annotation> annotation, final Object instance, final Object... args) { return quietlyInvokeMethodsWithAnnotation(annotation, null, instance, null, args); } - - + /** * Invokes all methods on the given instance that have been annotated with * the given Annotation. If the signature of the method that is defined in @@ -161,9 +161,10 @@ public class ReflectionUtils { * are supplied by the <code>args</code> parameter than needed, the extra * arguments will be ignored. * - * @param annotation - * @param instance - * @param args + * @param annotation annotation + * @param instance instance + * @param logger logger + * @param args args * @return <code>true</code> if all appropriate methods were invoked and * returned without throwing an Exception, <code>false</code> if one of the * methods threw an Exception or could not be invoked; if <code>false</code> @@ -172,78 +173,79 @@ public class ReflectionUtils { public static boolean quietlyInvokeMethodsWithAnnotation(final Class<? extends Annotation> annotation, final Object instance, final ProcessorLog logger, final Object... args) { return quietlyInvokeMethodsWithAnnotation(annotation, null, instance, logger, args); } - - + /** * Invokes all methods on the given instance that have been annotated with - * the given preferredAnnotation and if no such method exists will invoke all methods - * on the given instance that have been annotated with the given - * alternateAnnotation, if any exists. If the signature of the method that is defined in - * <code>instance</code> uses 1 or more parameters, those parameters must be - * specified by the <code>args</code> parameter. However, if more arguments - * are supplied by the <code>args</code> parameter than needed, the extra - * arguments will be ignored. + * the given preferredAnnotation and if no such method exists will invoke + * all methods on the given instance that have been annotated with the given + * alternateAnnotation, if any exists. If the signature of the method that + * is defined in <code>instance</code> uses 1 or more parameters, those + * parameters must be specified by the <code>args</code> parameter. However, + * if more arguments are supplied by the <code>args</code> parameter than + * needed, the extra arguments will be ignored. * - * @param preferredAnnotation - * @param alternateAnnotation - * @param instance - * @param logger the ProcessorLog to use for logging any errors. If null, will use own logger, but that will not generate bulletins - * or easily tie to the Processor's log messages. - * @param args + * @param preferredAnnotation preferred + * @param alternateAnnotation alternate + * @param instance instance + * @param logger the ProcessorLog to use for logging any errors. If null, + * will use own logger, but that will not generate bulletins or easily tie + * to the Processor's log messages. + * @param args args * @return <code>true</code> if all appropriate methods were invoked and * returned without throwing an Exception, <code>false</code> if one of the * methods threw an Exception or could not be invoked; if <code>false</code> * is returned, an error will have been logged. */ - public static boolean quietlyInvokeMethodsWithAnnotation(final Class<? extends Annotation> preferredAnnotation, final Class<? extends Annotation> alternateAnnotation, final Object instance, final ProcessorLog logger, final Object... args) { + public static boolean quietlyInvokeMethodsWithAnnotation( + final Class<? extends Annotation> preferredAnnotation, final Class<? extends Annotation> alternateAnnotation, final Object instance, final ProcessorLog logger, final Object... args) { final List<Class<? extends Annotation>> annotationClasses = new ArrayList<>(alternateAnnotation == null ? 1 : 2); annotationClasses.add(preferredAnnotation); - if ( alternateAnnotation != null ) { + if (alternateAnnotation != null) { annotationClasses.add(alternateAnnotation); } - + boolean annotationFound = false; - for ( final Class<? extends Annotation> annotationClass : annotationClasses ) { - if ( annotationFound ) { + for (final Class<? extends Annotation> annotationClass : annotationClasses) { + if (annotationFound) { break; } - + for (final Method method : instance.getClass().getMethods()) { if (method.isAnnotationPresent(annotationClass)) { annotationFound = true; - + final boolean isAccessible = method.isAccessible(); method.setAccessible(true); - + try { final Class<?>[] argumentTypes = method.getParameterTypes(); if (argumentTypes.length > args.length) { - if ( logger == null ) { + if (logger == null) { LOG.error("Unable to invoke method {} on {} because method expects {} parameters but only {} were given", - new Object[]{method.getName(), instance, argumentTypes.length, args.length}); + new Object[]{method.getName(), instance, argumentTypes.length, args.length}); } else { logger.error("Unable to invoke method {} on {} because method expects {} parameters but only {} were given", new Object[]{method.getName(), instance, argumentTypes.length, args.length}); } - + return false; } - + for (int i = 0; i < argumentTypes.length; i++) { final Class<?> argType = argumentTypes[i]; if (!argType.isAssignableFrom(args[i].getClass())) { - if ( logger == null ) { + if (logger == null) { LOG.error("Unable to invoke method {} on {} because method parameter {} is expected to be of type {} but argument passed was of type {}", - new Object[]{method.getName(), instance, i, argType, args[i].getClass()}); + new Object[]{method.getName(), instance, i, argType, args[i].getClass()}); } else { logger.error("Unable to invoke method {} on {} because method parameter {} is expected to be of type {} but argument passed was of type {}", new Object[]{method.getName(), instance, i, argType, args[i].getClass()}); } - + return false; } } - + try { if (argumentTypes.length == args.length) { method.invoke(instance, args); @@ -252,24 +254,24 @@ public class ReflectionUtils { for (int i = 0; i < argsToPass.length; i++) { argsToPass[i] = args[i]; } - + method.invoke(instance, argsToPass); } } catch (final InvocationTargetException ite) { - if ( logger == null ) { + if (logger == null) { LOG.error("Unable to invoke method {} on {} due to {}", new Object[]{method.getName(), instance, ite.getCause()}); LOG.error("", ite.getCause()); } else { logger.error("Unable to invoke method {} on {} due to {}", new Object[]{method.getName(), instance, ite.getCause()}); } } catch (final IllegalAccessException | IllegalArgumentException t) { - if ( logger == null ) { + if (logger == null) { LOG.error("Unable to invoke method {} on {} due to {}", new Object[]{method.getName(), instance, t}); LOG.error("", t); } else { logger.error("Unable to invoke method {} on {} due to {}", new Object[]{method.getName(), instance, t}); } - + return false; } } finally { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/SnippetUtils.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/SnippetUtils.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/SnippetUtils.java index ce39f08..81d00e6 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/SnippetUtils.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/util/SnippetUtils.java @@ -38,9 +38,9 @@ public final class SnippetUtils { * Moves the content of the specified template around the specified * location. * - * @param snippet - * @param x - * @param y + * @param snippet snippet + * @param x x location + * @param y y location */ public static void moveSnippet(FlowSnippetDTO snippet, Double x, Double y) { // ensure the point is specified @@ -85,8 +85,8 @@ public final class SnippetUtils { /** * Gets all connections that are part of the specified template. * - * @param contents - * @return + * @param contents snippet content + * @return connection dtos */ private static Collection<ConnectionDTO> getConnections(FlowSnippetDTO contents) { final Collection<ConnectionDTO> connections = new HashSet<>(); @@ -100,8 +100,8 @@ public final class SnippetUtils { * Gets all components, but not connections, that are part of the specified * template. * - * @param contents - * @return + * @param contents snippet + * @return component dtos */ private static Collection<NiFiComponentDTO> getComponents(FlowSnippetDTO contents) { final Collection<NiFiComponentDTO> components = new HashSet<>(); @@ -135,8 +135,8 @@ public final class SnippetUtils { /** * Builds a mapping of components to PositionDTO's. * - * @param components - * @return + * @param components components + * @return component and position map */ private static Map<NiFiComponentDTO, PositionDTO> getPositionLookup(Collection<NiFiComponentDTO> components) { final Map<NiFiComponentDTO, PositionDTO> positionLookup = new HashMap<>(); @@ -152,8 +152,8 @@ public final class SnippetUtils { /** * Builds a mapping of components to PositionDTO's. * - * @param connections - * @return + * @param connections connections + * @return position of connections map */ private static Map<ConnectionDTO, List<PositionDTO>> getConnectionPositionLookup(final Collection<ConnectionDTO> connections) { final Map<ConnectionDTO, List<PositionDTO>> positionLookup = new HashMap<>(); @@ -178,9 +178,9 @@ public final class SnippetUtils { /** * Gets the origin of the bounding box of all specified component positions * - * @param componentPositions - * @param connectionPositions - * @return + * @param componentPositions position list for components + * @param connectionPositions position list for connections + * @return position */ private static PositionDTO getOrigin(Collection<PositionDTO> componentPositions, Collection<List<PositionDTO>> connectionPositions) { Double x = null; @@ -222,8 +222,8 @@ public final class SnippetUtils { /** * Applies the updated positions to the corresponding components. * - * @param componentPositionLookup - * @param connectionPositionLookup + * @param componentPositionLookup lookup + * @param connectionPositionLookup lookup */ private static void applyUpdatedPositions(final Map<NiFiComponentDTO, PositionDTO> componentPositionLookup, final Map<ConnectionDTO, List<PositionDTO>> connectionPositionLookup) { for (final Map.Entry<NiFiComponentDTO, PositionDTO> entry : componentPositionLookup.entrySet()) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/resources/FlowConfiguration.xsd ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/resources/FlowConfiguration.xsd b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/resources/FlowConfiguration.xsd index 00c71ac..1809554 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/resources/FlowConfiguration.xsd +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/resources/FlowConfiguration.xsd @@ -333,42 +333,42 @@ </xs:simpleType> <xs:complexType name="ControllerServicesType"> - <xs:sequence> - <xs:element name="controllerService" type="ControllerServiceType" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> + <xs:sequence> + <xs:element name="controllerService" type="ControllerServiceType" minOccurs="0" maxOccurs="unbounded" /> + </xs:sequence> </xs:complexType> <xs:complexType name="ControllerServiceType"> - <xs:sequence> - <xs:element name="id" type="NonEmptyStringType" /> - <xs:element name="name" type="NonEmptyStringType" /> - <xs:element name="comment" type="xs:string" /> - <xs:element name="class" type="NonEmptyStringType" /> - <xs:element name="enabled" type="xs:boolean" /> + <xs:sequence> + <xs:element name="id" type="NonEmptyStringType" /> + <xs:element name="name" type="NonEmptyStringType" /> + <xs:element name="comment" type="xs:string" /> + <xs:element name="class" type="NonEmptyStringType" /> + <xs:element name="enabled" type="xs:boolean" /> <xs:element name="property" type="PropertyType" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="annotationData" type="xs:string" minOccurs="0" maxOccurs="1" /> - </xs:sequence> + </xs:sequence> </xs:complexType> <xs:complexType name="ReportingTasksType"> - <xs:sequence> - <xs:element name="reportingTask" type="ReportingTaskType" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> + <xs:sequence> + <xs:element name="reportingTask" type="ReportingTaskType" minOccurs="0" maxOccurs="unbounded" /> + </xs:sequence> </xs:complexType> <xs:complexType name="ReportingTaskType"> - <xs:sequence> - <xs:element name="id" type="NonEmptyStringType" /> - <xs:element name="name" type="NonEmptyStringType" /> - <xs:element name="comment" type="xs:string" /> - <xs:element name="class" type="NonEmptyStringType" /> + <xs:sequence> + <xs:element name="id" type="NonEmptyStringType" /> + <xs:element name="name" type="NonEmptyStringType" /> + <xs:element name="comment" type="xs:string" /> + <xs:element name="class" type="NonEmptyStringType" /> <xs:element name="schedulingPeriod" type="NonEmptyStringType"/> <xs:element name="schedulingState" type="ScheduledState" /> <xs:element name="schedulingStrategy" type="SchedulingStrategy" /> <xs:element name="property" type="PropertyType" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="annotationData" type="xs:string" minOccurs="0" maxOccurs="1" /> - </xs:sequence> + </xs:sequence> </xs:complexType> </xs:schema> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/888254b2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/HeartbeatPayloadTest.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/HeartbeatPayloadTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/HeartbeatPayloadTest.java index dc3a143..9205b7c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/HeartbeatPayloadTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/cluster/HeartbeatPayloadTest.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.cluster; -import org.apache.nifi.cluster.HeartbeatPayload; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.ArrayList; @@ -25,7 +24,8 @@ import org.apache.nifi.controller.Counter; import org.apache.nifi.controller.StandardCounter; import org.apache.nifi.diagnostics.SystemDiagnostics; import org.apache.nifi.util.NiFiProperties; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test;