Removing unused code
[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  *
42  * <p>The NodeConfigManager is the single point of contact for servlet, delivery, event logging, and log retention
43  * subsystems to access configuration information.
44  *
45  * <p>There are two basic sets of configuration data.  The static local configuration data, stored in a local
46  * configuration file (created as part of installation by SWM), and the dynamic global configuration data fetched from
47  * the data router 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         spooldir = drNodeProperties.getProperty("SpoolDir", "spool");
152         File fdir = new File(spooldir + "/f");
153         fdir.mkdirs();
154         for (File junk : fdir.listFiles()) {
155             if (junk.isFile()) {
156                 junk.delete();
157             }
158         }
159         logdir = drNodeProperties.getProperty("LogDir", "logs");
160         (new File(logdir)).mkdirs();
161         logretention = Long.parseLong(drNodeProperties.getProperty("LogRetention", "30")) * 86400000L;
162         eventlogprefix = logdir + "/events";
163         eventlogsuffix = ".log";
164         redirfile = drNodeProperties.getProperty("RedirectionFile", "etc/redirections.dat");
165         kstype = drNodeProperties.getProperty("KeyStoreType", "jks");
166         ksfile = drNodeProperties.getProperty("KeyStoreFile", "etc/keystore");
167         kspass = drNodeProperties.getProperty("KeyStorePassword", CHANGE_ME);
168         kpass = drNodeProperties.getProperty("KeyPassword", CHANGE_ME);
169         tstype = drNodeProperties.getProperty("TrustStoreType", "jks");
170         tsfile = drNodeProperties.getProperty("TrustStoreFile");
171         tspass = drNodeProperties.getProperty("TrustStorePassword", CHANGE_ME);
172         if (tsfile != null && tsfile.length() > 0) {
173             System.setProperty("javax.net.ssl.trustStoreType", tstype);
174             System.setProperty("javax.net.ssl.trustStore", tsfile);
175             System.setProperty("javax.net.ssl.trustStorePassword", tspass);
176         }
177         nak = drNodeProperties.getProperty("NodeAuthKey", "Node123!");
178         quiesce = new File(drNodeProperties.getProperty("QuiesceFile", "etc/SHUTDOWN"));
179         myname = NodeUtils.getCanonicalName(kstype, ksfile, kspass);
180         if (myname == null) {
181             NodeUtils.setIpAndFqdnForEelf(NODE_CONFIG_MANAGER);
182             eelfLogger.error(EelfMsgs.MESSAGE_KEYSTORE_FETCH_ERROR, ksfile);
183             eelfLogger.error("NODE0309 Unable to fetch canonical name from keystore file " + ksfile);
184             System.exit(1);
185         }
186         eelfLogger.info("NODE0304 My certificate says my name is " + myname);
187         pid = new PublishId(myname);
188         long minrsinterval = Long.parseLong(drNodeProperties.getProperty("MinRedirSaveInterval", "10000"));
189         long minpfinterval = Long.parseLong(drNodeProperties.getProperty("MinProvFetchInterval", "10000"));
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 reader = new InputStreamReader((new URL(provurl)).openStream());
289             config = new NodeConfig(new ProvData(reader), 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 publication is allowed for AAF Feed.
375      *
376      * @param feedid The ID of the feed being requested
377      * @param ip The requesting IP address
378      * @return True if the IP and credentials are valid for the specified feed.
379      */
380     public String isPublishPermitted(String feedid, String ip) {
381         return (config.isPublishPermitted(feedid, ip));
382     }
383
384     /**
385      * Check whether delete file is allowed.
386      *
387      * @param subId The ID of the subscription being requested
388      * @return True if the delete file is permitted for the subscriber.
389      */
390     public boolean isDeletePermitted(String subId) {
391         return (config.isDeletePermitted(subId));
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     public String getAafInstance() {
415         return aafInstance;
416     }
417
418     /**
419      * Check if the publish request should be sent to another node based on the feedid, user, and source IP address.
420      *
421      * @param feedid The ID of the feed specified
422      * @param user The publishing user
423      * @param ip The IP address of the publish endpoint
424      * @return Null if the request should be accepted or the correct hostname if it should be sent to another node.
425      */
426     public String getIngressNode(String feedid, String user, String ip) {
427         return (config.getIngressNode(feedid, user, ip));
428     }
429
430     /**
431      * Get a provisioned configuration parameter (from the provisioning server configuration).
432      *
433      * @param name The name of the parameter
434      * @return The value of the parameter or null if it is not defined.
435      */
436     public String getProvParam(String name) {
437         return (config.getProvParam(name));
438     }
439
440     /**
441      * Get a provisioned configuration parameter (from the provisioning server configuration).
442      *
443      * @param name The name of the parameter
444      * @param defaultValue The value to use if the parameter is not defined
445      * @return The value of the parameter or deflt if it is not defined.
446      */
447     public String getProvParam(String name, String defaultValue) {
448         name = config.getProvParam(name);
449         if (name == null) {
450             name = defaultValue;
451         }
452         return (name);
453     }
454
455     /**
456      * Generate a publish ID.
457      */
458     public String getPublishId() {
459         return (pid.next());
460     }
461
462     /**
463      * Get all the outbound spooling destinations. This will include both subscriptions and nodes.
464      */
465     public DestInfo[] getAllDests() {
466         return (config.getAllDests());
467     }
468
469     /**
470      * Register a task to run whenever the configuration changes.
471      */
472     public void registerConfigTask(Runnable task) {
473         configtasks.addTask(task);
474     }
475
476     /**
477      * Deregister a task to run whenever the configuration changes.
478      */
479     public void deregisterConfigTask(Runnable task) {
480         configtasks.removeTask(task);
481     }
482
483     /**
484      * Get the URL to deliver a message to.
485      *
486      * @param destinationInfo The destination information
487      * @param fileid The file ID
488      * @return The URL to deliver to
489      */
490     public String getDestURL(DestInfo destinationInfo, String fileid) {
491         String subid = destinationInfo.getSubId();
492         String purl = destinationInfo.getURL();
493         if (followredirects && subid != null) {
494             purl = rdmgr.lookup(subid, purl);
495         }
496         return (purl + "/" + fileid);
497     }
498
499     /**
500      * Set up redirection on receipt of a 3XX from a target URL.
501      */
502     public boolean handleRedirection(DestInfo destinationInfo, String redirto, String fileid) {
503         fileid = "/" + fileid;
504         String subid = destinationInfo.getSubId();
505         String purl = destinationInfo.getURL();
506         if (followredirects && subid != null && redirto.endsWith(fileid)) {
507             redirto = redirto.substring(0, redirto.length() - fileid.length());
508             if (!redirto.equals(purl)) {
509                 rdmgr.redirect(subid, purl, redirto);
510                 return (true);
511             }
512         }
513         return (false);
514     }
515
516     /**
517      * Handle unreachable target URL.
518      */
519     public void handleUnreachable(DestInfo destinationInfo) {
520         String subid = destinationInfo.getSubId();
521         if (followredirects && subid != null) {
522             rdmgr.forget(subid);
523         }
524     }
525
526     /**
527      * Get the timeout before retrying after an initial delivery failure.
528      */
529     public long getInitFailureTimer() {
530         return (initfailuretimer);
531     }
532
533     /**
534      * Get the timeout before retrying after delivery and wait for file processing.
535      */
536     public long getWaitForFileProcessFailureTimer() {
537         return (waitForFileProcessFailureTimer);
538     }
539
540     /**
541      * Get the maximum timeout between delivery attempts.
542      */
543     public long getMaxFailureTimer() {
544         return (maxfailuretimer);
545     }
546
547     /**
548      * Get the ratio between consecutive delivery attempts.
549      */
550     public double getFailureBackoff() {
551         return (failurebackoff);
552     }
553
554     /**
555      * Get the expiration timer for deliveries.
556      */
557     public long getExpirationTimer() {
558         return (expirationtimer);
559     }
560
561     /**
562      * Get the maximum number of file delivery attempts before checking if another queue has work to be performed.
563      */
564     public int getFairFileLimit() {
565         return (fairfilelimit);
566     }
567
568     /**
569      * Get the maximum amount of time spent delivering files before checking if another queue has work to be performed.
570      */
571     public long getFairTimeLimit() {
572         return (fairtimelimit);
573     }
574
575     /**
576      * Get the targets for a feed.
577      *
578      * @param feedid The feed ID
579      * @return The targets this feed should be delivered to
580      */
581     public Target[] getTargets(String feedid) {
582         return (config.getTargets(feedid));
583     }
584
585     /**
586      * Get the spool directory for temporary files.
587      */
588     public String getSpoolDir() {
589         return (spooldir + "/f");
590     }
591
592     /**
593      * Get the spool directory for a subscription.
594      */
595     public String getSpoolDir(String subid, String remoteaddr) {
596         if (provcheck.isFrom(remoteaddr)) {
597             String sdir = config.getSpoolDir(subid);
598             if (sdir != null) {
599                 eelfLogger.info("NODE0310 Received subscription reset request for subscription " + subid
600                         + " from provisioning server " + remoteaddr);
601             } else {
602                 eelfLogger.info("NODE0311 Received subscription reset request for unknown subscription " + subid
603                         + " from provisioning server " + remoteaddr);
604             }
605             return (sdir);
606         } else {
607             eelfLogger.info("NODE0312 Received subscription reset request from unexpected server " + remoteaddr);
608             return (null);
609         }
610     }
611
612     /**
613      * Get the base directory for spool directories.
614      */
615     public String getSpoolBase() {
616         return (spooldir);
617     }
618
619     /**
620      * Get the key store type.
621      */
622     public String getKSType() {
623         return (kstype);
624     }
625
626     /**
627      * Get the key store file.
628      */
629     public String getKSFile() {
630         return (ksfile);
631     }
632
633     /**
634      * Get the key store password.
635      */
636     public String getKSPass() {
637         return (kspass);
638     }
639
640     /**
641      * Get the key password.
642      */
643     public String getKPass() {
644         return (kpass);
645     }
646
647     /**
648      * Get the http port.
649      */
650     public int getHttpPort() {
651         return (gfport);
652     }
653
654     /**
655      * Get the https port.
656      */
657     public int getHttpsPort() {
658         return (svcport);
659     }
660
661     /**
662      * Get the externally visible https port.
663      */
664     public int getExtHttpsPort() {
665         return (port);
666     }
667
668     /**
669      * Get the external name of this machine.
670      */
671     public String getMyName() {
672         return (myname);
673     }
674
675     /**
676      * Get the number of threads to use for delivery.
677      */
678     public int getDeliveryThreads() {
679         return (deliverythreads);
680     }
681
682     /**
683      * Get the URL for uploading the event log data.
684      */
685     public String getEventLogUrl() {
686         return (eventlogurl);
687     }
688
689     /**
690      * Get the prefix for the names of event log files.
691      */
692     public String getEventLogPrefix() {
693         return (eventlogprefix);
694     }
695
696     /**
697      * Get the suffix for the names of the event log files.
698      */
699     public String getEventLogSuffix() {
700         return (eventlogsuffix);
701     }
702
703     /**
704      * Get the interval between event log file rollovers.
705      */
706     public String getEventLogInterval() {
707         return (eventloginterval);
708     }
709
710     /**
711      * Should I follow redirects from subscribers.
712      */
713     public boolean isFollowRedirects() {
714         return (followredirects);
715     }
716
717     /**
718      * Get the directory where the event and node log files live.
719      */
720     public String getLogDir() {
721         return (logdir);
722     }
723
724     /**
725      * How long do I keep log files (in milliseconds).
726      */
727     public long getLogRetention() {
728         return (logretention);
729     }
730
731     /**
732      * Get the timer.
733      */
734     public Timer getTimer() {
735         return (timer);
736     }
737
738     /**
739      * Get the feed ID for a subscription.
740      *
741      * @param subid The subscription ID
742      * @return The feed ID
743      */
744     public String getFeedId(String subid) {
745         return (config.getFeedId(subid));
746     }
747
748     /**
749      * Get the authorization string this node uses.
750      *
751      * @return The Authorization string for this node
752      */
753     public String getMyAuth() {
754         return (config.getMyAuth());
755     }
756
757     /**
758      * Get the fraction of free spool disk space where we start throwing away undelivered files.  This is
759      * FREE_DISK_RED_PERCENT / 100.0.  Default is 0.05.  Limited by 0.01 <= FreeDiskStart <= 0.5.
760      */
761     public double getFreeDiskStart() {
762         return (fdpstart);
763     }
764
765     /**
766      * Get the fraction of free spool disk space where we stop throwing away undelivered files.  This is
767      * FREE_DISK_YELLOW_PERCENT / 100.0.  Default is 0.2.  Limited by FreeDiskStart <= FreeDiskStop <= 0.5.
768      */
769     public double getFreeDiskStop() {
770         return (fdpstop);
771     }
772
773     /**
774      * Disable and enable protocols.
775      */
776     public String[] getEnabledprotocols() {
777         return enabledprotocols;
778     }
779
780     public String getAafType() {
781         return aafType;
782     }
783
784     public String getAafAction() {
785         return aafAction;
786     }
787
788     /*
789      * Get aafURL from SWM variable
790      * */
791     public String getAafURL() {
792         return aafURL;
793     }
794
795     public boolean getCadiEnabled() {
796         return cadiEnabled;
797     }
798
799     /**
800      * Builds the permissions string to be verified.
801      *
802      * @param aafInstance The aaf instance
803      * @return The permissions
804      */
805     protected String getPermission(String aafInstance) {
806         try {
807             String type = getAafType();
808             String action = getAafAction();
809             if ("".equals(aafInstance)) {
810                 aafInstance = getAafInstance();
811             }
812             return type + "|" + aafInstance + "|" + action;
813         } catch (Exception e) {
814             eelfLogger.error("NODE0543 NodeConfigManager.getPermission: ", e);
815         }
816         return null;
817     }
818 }