Remove major and minor code smells in dr-node
[dmaap/datarouter.git] / datarouter-node / src / main / java / org / onap / dmaap / datarouter / node / NodeConfigManager.java
1 /*******************************************************************************
2  * ============LICENSE_START==================================================
3  * * org.onap.dmaap
4  * * ===========================================================================
5  * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * * ===========================================================================
7  * * Licensed under the Apache License, Version 2.0 (the "License");
8  * * you may not use this file except in compliance with the License.
9  * * You may obtain a copy of the License at
10  * *
11  *  *      http://www.apache.org/licenses/LICENSE-2.0
12  * *
13  *  * Unless required by applicable law or agreed to in writing, software
14  * * distributed under the License is distributed on an "AS IS" BASIS,
15  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * * See the License for the specific language governing permissions and
17  * * limitations under the License.
18  * * ============LICENSE_END====================================================
19  * *
20  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  * *
22  ******************************************************************************/
23
24
25 package org.onap.dmaap.datarouter.node;
26
27 import com.att.eelf.configuration.EELFLogger;
28 import com.att.eelf.configuration.EELFManager;
29 import java.io.File;
30 import java.io.FileInputStream;
31 import java.io.InputStreamReader;
32 import java.io.Reader;
33 import java.net.URL;
34 import java.util.Properties;
35 import java.util.Timer;
36 import org.onap.dmaap.datarouter.node.eelf.EelfMsgs;
37
38
39 /**
40  * Maintain the configuration of a Data Router node
41  * <p>
42  * The NodeConfigManager is the single point of contact for servlet, delivery, event logging, and log retention
43  * subsystems to access configuration information.
44  * <p>
45  * There are two basic sets of configuration data.  The static local configuration data, stored in a local configuration
46  * file (created as part of installation by SWM), and the dynamic global configuration data fetched from the data router
47  * provisioning server.
48  */
49 public class NodeConfigManager implements DeliveryQueueHelper {
50
51     private static final String CHANGE_ME = "changeme";
52     private static final String NODE_CONFIG_MANAGER = "NodeConfigManager";
53     private static EELFLogger eelfLogger = EELFManager.getInstance().getLogger(NodeConfigManager.class);
54     private static NodeConfigManager base = new NodeConfigManager();
55
56     private Timer timer = new Timer("Node Configuration Timer", true);
57     private long maxfailuretimer;
58     private long initfailuretimer;
59     private long waitForFileProcessFailureTimer;
60     private long expirationtimer;
61     private double failurebackoff;
62     private long fairtimelimit;
63     private int fairfilelimit;
64     private double fdpstart;
65     private double fdpstop;
66     private int deliverythreads;
67     private String provurl;
68     private String provhost;
69     private IsFrom provcheck;
70     private int gfport;
71     private int svcport;
72     private int port;
73     private String spooldir;
74     private String logdir;
75     private long logretention;
76     private String redirfile;
77     private String kstype;
78     private String ksfile;
79     private String kspass;
80     private String kpass;
81     private String tstype;
82     private String tsfile;
83     private String tspass;
84     private String myname;
85     private RedirManager rdmgr;
86     private RateLimitedOperation pfetcher;
87     private NodeConfig config;
88     private File quiesce;
89     private PublishId pid;
90     private String nak;
91     private TaskList configtasks = new TaskList();
92     private String eventlogurl;
93     private String eventlogprefix;
94     private String eventlogsuffix;
95     private String eventloginterval;
96     private boolean followredirects;
97     private String[] enabledprotocols;
98     private String aafType;
99     private String aafInstance;
100     private String aafAction;
101     private String aafURL;
102     private boolean cadiEnabled;
103
104
105     /**
106      * Initialize the configuration of a Data Router node
107      */
108     private NodeConfigManager() {
109
110         Properties drNodeProperties = new Properties();
111         try {
112             eelfLogger.info("NODE0301 Loading local config file node.properties");
113             drNodeProperties.load(new FileInputStream(System
114                     .getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties")));
115         } catch (Exception e) {
116             NodeUtils.setIpAndFqdnForEelf(NODE_CONFIG_MANAGER);
117             eelfLogger.error(EelfMsgs.MESSAGE_PROPERTIES_LOAD_ERROR, e,
118                     System.getProperty("org.onap.dmaap.datarouter.node.properties",
119                             "/opt/app/datartr/etc/node.properties"));
120         }
121         provurl = drNodeProperties.getProperty("ProvisioningURL", "https://dmaap-dr-prov:8443/internal/prov");
122         /*
123          * START - AAF changes: TDP EPIC US# 307413
124          * Pull AAF settings from node.properties
125          */
126         aafType = drNodeProperties.getProperty("AAFType", "org.onap.dmaap-dr.feed");
127         aafInstance = drNodeProperties.getProperty("AAFInstance", "legacy");
128         aafAction = drNodeProperties.getProperty("AAFAction", "publish");
129         aafURL = drNodeProperties.getProperty("AafUrl", "https://aaf-onap-test.osaaf.org:8095");
130         cadiEnabled = Boolean.parseBoolean(drNodeProperties.getProperty("CadiEnabled", "false"));
131         /*
132          * END - AAF changes: TDP EPIC US# 307413
133          * Pull AAF settings from node.properties
134          */
135         //Disable and enable protocols*/
136         enabledprotocols = ((drNodeProperties.getProperty("NodeHttpsProtocols")).trim()).split("\\|");
137
138         try {
139             provhost = (new URL(provurl)).getHost();
140         } catch (Exception e) {
141             NodeUtils.setIpAndFqdnForEelf(NODE_CONFIG_MANAGER);
142             eelfLogger.error(EelfMsgs.MESSAGE_BAD_PROV_URL, e, provurl);
143             System.exit(1);
144         }
145         eelfLogger.info("NODE0303 Provisioning server is " + provhost);
146         eventlogurl = drNodeProperties.getProperty("LogUploadURL", "https://feeds-drtr.web.att.com/internal/logs");
147         provcheck = new IsFrom(provhost);
148         gfport = Integer.parseInt(drNodeProperties.getProperty("IntHttpPort", "8080"));
149         svcport = Integer.parseInt(drNodeProperties.getProperty("IntHttpsPort", "8443"));
150         port = Integer.parseInt(drNodeProperties.getProperty("ExtHttpsPort", "443"));
151         long minpfinterval = Long.parseLong(drNodeProperties.getProperty("MinProvFetchInterval", "10000"));
152         long minrsinterval = Long.parseLong(drNodeProperties.getProperty("MinRedirSaveInterval", "10000"));
153         spooldir = drNodeProperties.getProperty("SpoolDir", "spool");
154         File fdir = new File(spooldir + "/f");
155         fdir.mkdirs();
156         for (File junk : fdir.listFiles()) {
157             if (junk.isFile()) {
158                 junk.delete();
159             }
160         }
161         logdir = drNodeProperties.getProperty("LogDir", "logs");
162         (new File(logdir)).mkdirs();
163         logretention = Long.parseLong(drNodeProperties.getProperty("LogRetention", "30")) * 86400000L;
164         eventlogprefix = logdir + "/events";
165         eventlogsuffix = ".log";
166         redirfile = drNodeProperties.getProperty("RedirectionFile", "etc/redirections.dat");
167         kstype = drNodeProperties.getProperty("KeyStoreType", "jks");
168         ksfile = drNodeProperties.getProperty("KeyStoreFile", "etc/keystore");
169         kspass = drNodeProperties.getProperty("KeyStorePassword", CHANGE_ME);
170         kpass = drNodeProperties.getProperty("KeyPassword", CHANGE_ME);
171         tstype = drNodeProperties.getProperty("TrustStoreType", "jks");
172         tsfile = drNodeProperties.getProperty("TrustStoreFile");
173         tspass = drNodeProperties.getProperty("TrustStorePassword", CHANGE_ME);
174         if (tsfile != null && tsfile.length() > 0) {
175             System.setProperty("javax.net.ssl.trustStoreType", tstype);
176             System.setProperty("javax.net.ssl.trustStore", tsfile);
177             System.setProperty("javax.net.ssl.trustStorePassword", tspass);
178         }
179         nak = drNodeProperties.getProperty("NodeAuthKey", "Node123!");
180         quiesce = new File(drNodeProperties.getProperty("QuiesceFile", "etc/SHUTDOWN"));
181         myname = NodeUtils.getCanonicalName(kstype, ksfile, kspass);
182         if (myname == null) {
183             NodeUtils.setIpAndFqdnForEelf(NODE_CONFIG_MANAGER);
184             eelfLogger.error(EelfMsgs.MESSAGE_KEYSTORE_FETCH_ERROR, ksfile);
185             eelfLogger.error("NODE0309 Unable to fetch canonical name from keystore file " + ksfile);
186             System.exit(1);
187         }
188         eelfLogger.info("NODE0304 My certificate says my name is " + myname);
189         pid = new PublishId(myname);
190         rdmgr = new RedirManager(redirfile, minrsinterval, timer);
191         pfetcher = new RateLimitedOperation(minpfinterval, timer) {
192             public void run() {
193                 fetchconfig();
194             }
195         };
196         eelfLogger.info("NODE0305 Attempting to fetch configuration at " + provurl);
197         pfetcher.request();
198     }
199
200     /**
201      * Get the default node configuration manager
202      */
203     public static NodeConfigManager getInstance() {
204         return base;
205     }
206
207     private void localconfig() {
208         followredirects = Boolean.parseBoolean(getProvParam("FOLLOW_REDIRECTS", "false"));
209         eventloginterval = getProvParam("LOGROLL_INTERVAL", "30s");
210         initfailuretimer = 10000;
211         waitForFileProcessFailureTimer = 600000;
212         maxfailuretimer = 3600000;
213         expirationtimer = 86400000;
214         failurebackoff = 2.0;
215         deliverythreads = 40;
216         fairfilelimit = 100;
217         fairtimelimit = 60000;
218         fdpstart = 0.05;
219         fdpstop = 0.2;
220         try {
221             initfailuretimer = (long) (Double.parseDouble(getProvParam("DELIVERY_INIT_RETRY_INTERVAL")) * 1000);
222         } catch (Exception e) {
223             eelfLogger.trace("Error parsing DELIVERY_INIT_RETRY_INTERVAL", e);
224         }
225         try {
226             waitForFileProcessFailureTimer = (long) (Double.parseDouble(getProvParam("DELIVERY_FILE_PROCESS_INTERVAL"))
227                     * 1000);
228         } catch (Exception e) {
229             eelfLogger.trace("Error parsing DELIVERY_FILE_PROCESS_INTERVAL", e);
230         }
231         try {
232             maxfailuretimer = (long) (Double.parseDouble(getProvParam("DELIVERY_MAX_RETRY_INTERVAL")) * 1000);
233         } catch (Exception e) {
234             eelfLogger.trace("Error parsing DELIVERY_MAX_RETRY_INTERVAL", e);
235         }
236         try {
237             expirationtimer = (long) (Double.parseDouble(getProvParam("DELIVERY_MAX_AGE")) * 1000);
238         } catch (Exception e) {
239             eelfLogger.trace("Error parsing DELIVERY_MAX_AGE", e);
240         }
241         try {
242             failurebackoff = Double.parseDouble(getProvParam("DELIVERY_RETRY_RATIO"));
243         } catch (Exception e) {
244             eelfLogger.trace("Error parsing DELIVERY_RETRY_RATIO", e);
245         }
246         try {
247             deliverythreads = Integer.parseInt(getProvParam("DELIVERY_THREADS"));
248         } catch (Exception e) {
249             eelfLogger.trace("Error parsing DELIVERY_THREADS", e);
250         }
251         try {
252             fairfilelimit = Integer.parseInt(getProvParam("FAIR_FILE_LIMIT"));
253         } catch (Exception e) {
254             eelfLogger.trace("Error parsing FAIR_FILE_LIMIT", e);
255         }
256         try {
257             fairtimelimit = (long) (Double.parseDouble(getProvParam("FAIR_TIME_LIMIT")) * 1000);
258         } catch (Exception e) {
259             eelfLogger.trace("Error parsing FAIR_TIME_LIMIT", e);
260         }
261         try {
262             fdpstart = Double.parseDouble(getProvParam("FREE_DISK_RED_PERCENT")) / 100.0;
263         } catch (Exception e) {
264             eelfLogger.trace("Error parsing FREE_DISK_RED_PERCENT", e);
265         }
266         try {
267             fdpstop = Double.parseDouble(getProvParam("FREE_DISK_YELLOW_PERCENT")) / 100.0;
268         } catch (Exception e) {
269             eelfLogger.trace("Error parsing FREE_DISK_YELLOW_PERCENT", e);
270         }
271         if (fdpstart < 0.01) {
272             fdpstart = 0.01;
273         }
274         if (fdpstart > 0.5) {
275             fdpstart = 0.5;
276         }
277         if (fdpstop < fdpstart) {
278             fdpstop = fdpstart;
279         }
280         if (fdpstop > 0.5) {
281             fdpstop = 0.5;
282         }
283     }
284
285     private void fetchconfig() {
286         try {
287             eelfLogger.info("NodeConfigMan.fetchConfig: provurl:: " + provurl);
288             Reader r = new InputStreamReader((new URL(provurl)).openStream());
289             config = new NodeConfig(new ProvData(r), myname, spooldir, port, nak);
290             localconfig();
291             configtasks.startRun();
292             runTasks();
293         } catch (Exception e) {
294             NodeUtils.setIpAndFqdnForEelf("fetchconfigs");
295             eelfLogger.error(EelfMsgs.MESSAGE_CONF_FAILED, e.toString());
296             eelfLogger.error("NODE0306 Configuration failed " + e.toString() + " - try again later", e);
297             pfetcher.request();
298         }
299     }
300
301     private void runTasks() {
302         Runnable rr;
303         while ((rr = configtasks.next()) != null) {
304             try {
305                 rr.run();
306             } catch (Exception e) {
307                 eelfLogger.error("NODE0518 Exception fetchconfig: " + e);
308             }
309         }
310     }
311
312     /**
313      * Process a gofetch request from a particular IP address.  If the IP address is not an IP address we would go to to
314      * fetch the provisioning data, ignore the request.  If the data has been fetched very recently (default 10
315      * seconds), wait a while before fetching again.
316      */
317     public synchronized void gofetch(String remoteAddr) {
318         if (provcheck.isReachable(remoteAddr)) {
319             eelfLogger.info("NODE0307 Received configuration fetch request from provisioning server " + remoteAddr);
320             pfetcher.request();
321         } else {
322             eelfLogger.info("NODE0308 Received configuration fetch request from unexpected server " + remoteAddr);
323         }
324     }
325
326     /**
327      * Am I configured?
328      */
329     public boolean isConfigured() {
330         return (config != null);
331     }
332
333     /**
334      * Am I shut down?
335      */
336     public boolean isShutdown() {
337         return (quiesce.exists());
338     }
339
340     /**
341      * Given a routing string, get the targets.
342      *
343      * @param routing Target string
344      * @return array of targets
345      */
346     public Target[] parseRouting(String routing) {
347         return (config.parseRouting(routing));
348     }
349
350     /**
351      * Given a set of credentials and an IP address, is this request from another node?
352      *
353      * @param credentials Credentials offered by the supposed node
354      * @param ip IP address the request came from
355      * @return If the credentials and IP address are recognized, true, otherwise false.
356      */
357     public boolean isAnotherNode(String credentials, String ip) {
358         return (config.isAnotherNode(credentials, ip));
359     }
360
361     /**
362      * Check whether publication is allowed.
363      *
364      * @param feedid The ID of the feed being requested
365      * @param credentials The offered credentials
366      * @param ip The requesting IP address
367      * @return True if the IP and credentials are valid for the specified feed.
368      */
369     public String isPublishPermitted(String feedid, String credentials, String ip) {
370         return (config.isPublishPermitted(feedid, credentials, ip));
371     }
372
373     /**
374      * Check whether delete file is allowed.
375      *
376      * @param subId The ID of the subscription being requested
377      * @return True if the delete file is permitted for the subscriber.
378      */
379     public boolean isDeletePermitted(String subId) {
380         return (config.isDeletePermitted(subId));
381     }
382
383     /**
384      * Check whether publication is allowed for AAF Feed.
385      *
386      * @param feedid The ID of the feed being requested
387      * @param ip The requesting IP address
388      * @return True if the IP and credentials are valid for the specified feed.
389      */
390     public String isPublishPermitted(String feedid, String ip) {
391         return (config.isPublishPermitted(feedid, ip));
392     }
393
394     /**
395      * Check who the user is given the feed ID and the offered credentials.
396      *
397      * @param feedid The ID of the feed specified
398      * @param credentials The offered credentials
399      * @return Null if the credentials are invalid or the user if they are valid.
400      */
401     public String getAuthUser(String feedid, String credentials) {
402         return (config.getAuthUser(feedid, credentials));
403     }
404
405     /**
406      * AAF changes: TDP EPIC US# 307413 Check AAF_instance for feed ID in NodeConfig
407      *
408      * @param feedid The ID of the feed specified
409      */
410     public String getAafInstance(String feedid) {
411         return (config.getAafInstance(feedid));
412     }
413
414     /**
415      * Check if the publish request should be sent to another node based on the feedid, user, and source IP address.
416      *
417      * @param feedid The ID of the feed specified
418      * @param user The publishing user
419      * @param ip The IP address of the publish endpoint
420      * @return Null if the request should be accepted or the correct hostname if it should be sent to another node.
421      */
422     public String getIngressNode(String feedid, String user, String ip) {
423         return (config.getIngressNode(feedid, user, ip));
424     }
425
426     /**
427      * Get a provisioned configuration parameter (from the provisioning server configuration)
428      *
429      * @param name The name of the parameter
430      * @return The value of the parameter or null if it is not defined.
431      */
432     public String getProvParam(String name) {
433         return (config.getProvParam(name));
434     }
435
436     /**
437      * Get a provisioned configuration parameter (from the provisioning server configuration)
438      *
439      * @param name The name of the parameter
440      * @param defaultValue The value to use if the parameter is not defined
441      * @return The value of the parameter or deflt if it is not defined.
442      */
443     public String getProvParam(String name, String defaultValue) {
444         name = config.getProvParam(name);
445         if (name == null) {
446             name = defaultValue;
447         }
448         return (name);
449     }
450
451     /**
452      * Generate a publish ID
453      */
454     public String getPublishId() {
455         return (pid.next());
456     }
457
458     /**
459      * Get all the outbound spooling destinations. This will include both subscriptions and nodes.
460      */
461     public DestInfo[] getAllDests() {
462         return (config.getAllDests());
463     }
464
465     /**
466      * Register a task to run whenever the configuration changes
467      */
468     public void registerConfigTask(Runnable task) {
469         configtasks.addTask(task);
470     }
471
472     /**
473      * Deregister a task to run whenever the configuration changes
474      */
475     public void deregisterConfigTask(Runnable task) {
476         configtasks.removeTask(task);
477     }
478
479     /**
480      * Get the URL to deliver a message to.
481      *
482      * @param destinationInfo The destination information
483      * @param fileid The file ID
484      * @return The URL to deliver to
485      */
486     public String getDestURL(DestInfo destinationInfo, String fileid) {
487         String subid = destinationInfo.getSubId();
488         String purl = destinationInfo.getURL();
489         if (followredirects && subid != null) {
490             purl = rdmgr.lookup(subid, purl);
491         }
492         return (purl + "/" + fileid);
493     }
494
495     /**
496      * Is a destination redirected?
497      */
498     public boolean isDestRedirected(DestInfo destinfo) {
499         return (followredirects && rdmgr.isRedirected(destinfo.getSubId()));
500     }
501
502     /**
503      * Set up redirection on receipt of a 3XX from a target URL
504      */
505     public boolean handleRedirection(DestInfo destinationInfo, String redirto, String fileid) {
506         fileid = "/" + fileid;
507         String subid = destinationInfo.getSubId();
508         String purl = destinationInfo.getURL();
509         if (followredirects && subid != null && redirto.endsWith(fileid)) {
510             redirto = redirto.substring(0, redirto.length() - fileid.length());
511             if (!redirto.equals(purl)) {
512                 rdmgr.redirect(subid, purl, redirto);
513                 return (true);
514             }
515         }
516         return (false);
517     }
518
519     /**
520      * Set up redirection on receipt of a 3XX from a target URL
521      */
522     public boolean handleRedirectionSubLevel(DeliveryTask task, DestInfo destinfo, String redirto, String fileid) {
523         fileid = "/" + fileid;
524         String subid = destinfo.getSubId();
525         String purl = destinfo.getURL();
526         if (task.getFollowRedirects() && subid != null && redirto.endsWith(fileid)) {
527             redirto = redirto.substring(0, redirto.length() - fileid.length());
528             if (!redirto.equals(purl)) {
529                 rdmgr.redirect(subid, purl, redirto);
530                 return true;
531             }
532         }
533         return false;
534     }
535
536     /**
537      * Handle unreachable target URL
538      */
539     public void handleUnreachable(DestInfo destinationInfo) {
540         String subid = destinationInfo.getSubId();
541         if (followredirects && subid != null) {
542             rdmgr.forget(subid);
543         }
544     }
545
546     /**
547      * Get the timeout before retrying after an initial delivery failure
548      */
549     public long getInitFailureTimer() {
550         return (initfailuretimer);
551     }
552
553     /**
554      * Get the timeout before retrying after delivery and wait for file processing
555      */
556     public long getWaitForFileProcessFailureTimer() {
557         return (waitForFileProcessFailureTimer);
558     }
559
560     /**
561      * Get the maximum timeout between delivery attempts
562      */
563     public long getMaxFailureTimer() {
564         return (maxfailuretimer);
565     }
566
567     /**
568      * Get the ratio between consecutive delivery attempts
569      */
570     public double getFailureBackoff() {
571         return (failurebackoff);
572     }
573
574     /**
575      * Get the expiration timer for deliveries
576      */
577     public long getExpirationTimer() {
578         return (expirationtimer);
579     }
580
581     /**
582      * Get the maximum number of file delivery attempts before checking if another queue has work to be performed.
583      */
584     public int getFairFileLimit() {
585         return (fairfilelimit);
586     }
587
588     /**
589      * Get the maximum amount of time spent delivering files before checking if another queue has work to be performed.
590      */
591     public long getFairTimeLimit() {
592         return (fairtimelimit);
593     }
594
595     /**
596      * Get the targets for a feed
597      *
598      * @param feedid The feed ID
599      * @return The targets this feed should be delivered to
600      */
601     public Target[] getTargets(String feedid) {
602         return (config.getTargets(feedid));
603     }
604
605     /**
606      * Get the creation date for a feed
607      *
608      * @param feedid The feed ID
609      * @return the timestamp of creation date of feed id passed
610      */
611     public String getCreatedDate(String feedid) {
612         return (config.getCreatedDate(feedid));
613     }
614
615     /**
616      * Get the spool directory for temporary files
617      */
618     public String getSpoolDir() {
619         return (spooldir + "/f");
620     }
621
622     /**
623      * Get the base directory for spool directories
624      */
625     public String getSpoolBase() {
626         return (spooldir);
627     }
628
629     /**
630      * Get the key store type
631      */
632     public String getKSType() {
633         return (kstype);
634     }
635
636     /**
637      * Get the key store file
638      */
639     public String getKSFile() {
640         return (ksfile);
641     }
642
643     /**
644      * Get the key store password
645      */
646     public String getKSPass() {
647         return (kspass);
648     }
649
650     /**
651      * Get the key password
652      */
653     public String getKPass() {
654         return (kpass);
655     }
656
657     /**
658      * Get the http port
659      */
660     public int getHttpPort() {
661         return (gfport);
662     }
663
664     /**
665      * Get the https port
666      */
667     public int getHttpsPort() {
668         return (svcport);
669     }
670
671     /**
672      * Get the externally visible https port
673      */
674     public int getExtHttpsPort() {
675         return (port);
676     }
677
678     /**
679      * Get the external name of this machine
680      */
681     public String getMyName() {
682         return (myname);
683     }
684
685     /**
686      * Get the number of threads to use for delivery
687      */
688     public int getDeliveryThreads() {
689         return (deliverythreads);
690     }
691
692     /**
693      * Get the URL for uploading the event log data
694      */
695     public String getEventLogUrl() {
696         return (eventlogurl);
697     }
698
699     /**
700      * Get the prefix for the names of event log files
701      */
702     public String getEventLogPrefix() {
703         return (eventlogprefix);
704     }
705
706     /**
707      * Get the suffix for the names of the event log files
708      */
709     public String getEventLogSuffix() {
710         return (eventlogsuffix);
711     }
712
713     /**
714      * Get the interval between event log file rollovers
715      */
716     public String getEventLogInterval() {
717         return (eventloginterval);
718     }
719
720     /**
721      * Should I follow redirects from subscribers?
722      */
723     public boolean isFollowRedirects() {
724         return (followredirects);
725     }
726
727     /**
728      * Get the directory where the event and node log files live
729      */
730     public String getLogDir() {
731         return (logdir);
732     }
733
734     /**
735      * How long do I keep log files (in milliseconds)
736      */
737     public long getLogRetention() {
738         return (logretention);
739     }
740
741     /**
742      * Get the timer
743      */
744     public Timer getTimer() {
745         return (timer);
746     }
747
748     /**
749      * Get the feed ID for a subscription
750      *
751      * @param subid The subscription ID
752      * @return The feed ID
753      */
754     public String getFeedId(String subid) {
755         return (config.getFeedId(subid));
756     }
757
758     /**
759      * Get the authorization string this node uses
760      *
761      * @return The Authorization string for this node
762      */
763     public String getMyAuth() {
764         return (config.getMyAuth());
765     }
766
767     /**
768      * Get the fraction of free spool disk space where we start throwing away undelivered files.  This is
769      * FREE_DISK_RED_PERCENT / 100.0.  Default is 0.05.  Limited by 0.01 <= FreeDiskStart <= 0.5.
770      */
771     public double getFreeDiskStart() {
772         return (fdpstart);
773     }
774
775     /**
776      * Get the fraction of free spool disk space where we stop throwing away undelivered files.  This is
777      * FREE_DISK_YELLOW_PERCENT / 100.0.  Default is 0.2.  Limited by FreeDiskStart <= FreeDiskStop <= 0.5.
778      */
779     public double getFreeDiskStop() {
780         return (fdpstop);
781     }
782
783     /**
784      * Disable and enable protocols
785      */
786     public String[] getEnabledprotocols() {
787         return enabledprotocols;
788     }
789
790     public void setEnabledprotocols(String[] enabledprotocols) {
791         this.enabledprotocols = enabledprotocols.clone();
792     }
793
794     /**
795      * Get the spool directory for a subscription
796      */
797     public String getSpoolDir(String subid, String remoteaddr) {
798         if (provcheck.isFrom(remoteaddr)) {
799             String sdir = config.getSpoolDir(subid);
800             if (sdir != null) {
801                 eelfLogger.info("NODE0310 Received subscription reset request for subscription " + subid
802                         + " from provisioning server " + remoteaddr);
803             } else {
804                 eelfLogger.info("NODE0311 Received subscription reset request for unknown subscription " + subid
805                         + " from provisioning server " + remoteaddr);
806             }
807             return (sdir);
808         } else {
809             eelfLogger.info("NODE0312 Received subscription reset request from unexpected server " + remoteaddr);
810             return (null);
811         }
812     }
813
814     public String getAafType() {
815         return aafType;
816     }
817
818     public void setAafType(String aafType) {
819         this.aafType = aafType;
820     }
821
822     public String getAafInstance() {
823         return aafInstance;
824     }
825
826     public void setAafInstance(String aafInstance) {
827         this.aafInstance = aafInstance;
828     }
829
830     public String getAafAction() {
831         return aafAction;
832     }
833
834     public void setAafAction(String aafAction) {
835         this.aafAction = aafAction;
836     }
837
838     /*
839      * Get aafURL from SWM variable
840      * */
841     public String getAafURL() {
842         return aafURL;
843     }
844
845     public void setAafURL(String aafURL) {
846         this.aafURL = aafURL;
847     }
848
849     public boolean getCadiEnabled() {
850         return cadiEnabled;
851     }
852
853     public void setCadiEnabled(boolean cadiEnabled) {
854         this.cadiEnabled = cadiEnabled;
855     }
856
857     /**
858      * Builds the permissions string to be verified
859      *
860      * @param aafInstance The aaf instance
861      * @return The permissions
862      */
863     protected String getPermission(String aafInstance) {
864         try {
865             String type = getAafType();
866             String action = getAafAction();
867             if ("".equals(aafInstance)) {
868                 aafInstance = getAafInstance();
869             }
870             return type + "|" + aafInstance + "|" + action;
871         } catch (Exception e) {
872             eelfLogger.error("NODE0543 NodeConfigManager.getPermission: ", e);
873         }
874         return null;
875     }
876 }