[ 
https://issues.apache.org/jira/browse/MINIFI-14?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15243480#comment-15243480
 ] 

ASF GitHub Bot commented on MINIFI-14:
--------------------------------------

Github user JPercivall commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi/pull/10#discussion_r59930579
  
    --- Diff: 
minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/RunMiNiFi.java 
---
    @@ -567,6 +586,104 @@ public void dump(final File dumpFile) throws 
IOException {
             }
         }
     
    +    public void reload() throws IOException {
    +        final Logger logger = cmdLogger;
    +        final Integer port = getCurrentPort(logger);
    +        if (port == null) {
    +            logger.info("Apache MiNiFi is not currently running");
    +            return;
    +        }
    +
    +        // indicate that a reload command is in progress
    +        final File reloadLockFile = getReloadFile(logger);
    +        if (!reloadLockFile.exists()) {
    +            reloadLockFile.createNewFile();
    +        }
    +
    +        final Properties nifiProps = loadProperties(logger);
    +        final String secretKey = nifiProps.getProperty("secret.key");
    +        final String pid = nifiProps.getProperty("pid");
    +
    +        try (final Socket socket = new Socket()) {
    +            logger.debug("Connecting to MiNiFi instance");
    +            socket.setSoTimeout(10000);
    +            socket.connect(new InetSocketAddress("localhost", port));
    +            logger.debug("Established connection to MiNiFi instance.");
    +            socket.setSoTimeout(10000);
    +
    +            logger.debug("Sending RELOAD Command to port {}", port);
    +            final OutputStream out = socket.getOutputStream();
    +            out.write((RELOAD_CMD + " " + secretKey + 
"\n").getBytes(StandardCharsets.UTF_8));
    +            out.flush();
    +            socket.shutdownOutput();
    +
    +            final InputStream in = socket.getInputStream();
    +            int lastChar;
    +            final StringBuilder sb = new StringBuilder();
    +            while ((lastChar = in.read()) > -1) {
    +                sb.append((char) lastChar);
    +            }
    +            final String response = sb.toString().trim();
    +
    +            logger.debug("Received response to RELOAD command: {}", 
response);
    +
    +            if (RELOAD_CMD.equals(response)) {
    +                logger.info("Apache MiNiFi has accepted the Reload Command 
and is reloading");
    +
    +                if (pid != null) {
    +                    final Properties bootstrapProperties = 
getBootstrapProperties();
    +
    +                    String gracefulShutdown = 
bootstrapProperties.getProperty(GRACEFUL_SHUTDOWN_PROP, 
DEFAULT_GRACEFUL_SHUTDOWN_VALUE);
    +                    int gracefulShutdownSeconds;
    +                    try {
    +                        gracefulShutdownSeconds = 
Integer.parseInt(gracefulShutdown);
    +                    } catch (final NumberFormatException nfe) {
    +                        gracefulShutdownSeconds = 
Integer.parseInt(DEFAULT_GRACEFUL_SHUTDOWN_VALUE);
    +                    }
    +
    +                    final long startWait = System.nanoTime();
    +                    while (isProcessRunning(pid, logger)) {
    +                        logger.info("Waiting for Apache MiNiFi to finish 
shutting down...");
    +                        final long waitNanos = System.nanoTime() - 
startWait;
    +                        final long waitSeconds = 
TimeUnit.NANOSECONDS.toSeconds(waitNanos);
    +                        if (waitSeconds >= gracefulShutdownSeconds && 
gracefulShutdownSeconds > 0) {
    +                            if (isProcessRunning(pid, logger)) {
    +                                logger.warn("MiNiFi has not finished 
shutting down after {} seconds. Killing process.", gracefulShutdownSeconds);
    --- End diff --
    
    Yeah, just adding something about it shutting down in order to reload would 
be fine.


> Add Listener/Notifier Logic to RunMiNiFi
> ----------------------------------------
>
>                 Key: MINIFI-14
>                 URL: https://issues.apache.org/jira/browse/MINIFI-14
>             Project: Apache NiFi MiNiFi
>          Issue Type: Sub-task
>          Components: Processing Configuration
>            Reporter: Joseph Percivall
>            Assignee: Aldrin Piri
>             Fix For: 0.0.1
>
>
> The interface for the ConfigurationChangeNotifier and 
> ConfigurationChangeListener is done as part of MINIFI-4 but configuration and 
> implementation in RunMiNiFi needs to be added. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to