Logging changes and unit tests
[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.debug("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.debug("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.debug("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.debug("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.debug("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.debug("NODE0307 Received configuration fetch request from provisioning server " + remoteAddr);
320             pfetcher.request();
321         } else {
322             eelfLogger.debug("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      * Is a destination redirected.
501      */
502     public boolean isDestRedirected(DestInfo destinfo) {
503         return (followredirects && rdmgr.isRedirected(destinfo.getSubId()));
504     }
505
506     /**
507      * Set up redirection on receipt of a 3XX from a target URL.
508      */
509     public boolean handleRedirection(DestInfo destinationInfo, String redirto, String fileid) {
510         fileid = "/" + fileid;
511         String subid = destinationInfo.getSubId();
512         String purl = destinationInfo.getURL();
513         if (followredirects && subid != null && redirto.endsWith(fileid)) {
514             redirto = redirto.substring(0, redirto.length() - fileid.length());
515             if (!redirto.equals(purl)) {
516                 rdmgr.redirect(subid, purl, redirto);
517                 return (true);
518             }
519         }
520         return (false);
521     }
522
523     /**
524      * Set up redirection on receipt of a 3XX from a target URL.
525      */
526     public boolean handleRedirectionSubLevel(DeliveryTask task, DestInfo destinfo, String redirto, String fileid) {
527         fileid = "/" + fileid;
528         String subid = destinfo.getSubId();
529         String purl = destinfo.getURL();
530         if (task.getFollowRedirects() && subid != null && redirto.endsWith(fileid)) {
531             redirto = redirto.substring(0, redirto.length() - fileid.length());
532             if (!redirto.equals(purl)) {
533                 rdmgr.redirect(subid, purl, redirto);
534                 return true;
535             }
536         }
537         return false;
538     }
539
540     /**
541      * Handle unreachable target URL.
542      */
543     public void handleUnreachable(DestInfo destinationInfo) {
544         String subid = destinationInfo.getSubId();
545         if (followredirects && subid != null) {
546             rdmgr.forget(subid);
547         }
548     }
549
550     /**
551      * Get the timeout before retrying after an initial delivery failure.
552      */
553     public long getInitFailureTimer() {
554         return (initfailuretimer);
555     }
556
557     /**
558      * Get the timeout before retrying after delivery and wait for file processing.
559      */
560     public long getWaitForFileProcessFailureTimer() {
561         return (waitForFileProcessFailureTimer);
562     }
563
564     /**
565      * Get the maximum timeout between delivery attempts.
566      */
567     public long getMaxFailureTimer() {
568         return (maxfailuretimer);
569     }
570
571     /**
572      * Get the ratio between consecutive delivery attempts.
573      */
574     public double getFailureBackoff() {
575         return (failurebackoff);
576     }
577
578     /**
579      * Get the expiration timer for deliveries.
580      */
581     public long getExpirationTimer() {
582         return (expirationtimer);
583     }
584
585     /**
586      * Get the maximum number of file delivery attempts before checking if another queue has work to be performed.
587      */
588     public int getFairFileLimit() {
589         return (fairfilelimit);
590     }
591
592     /**
593      * Get the maximum amount of time spent delivering files before checking if another queue has work to be performed.
594      */
595     public long getFairTimeLimit() {
596         return (fairtimelimit);
597     }
598
599     /**
600      * Get the targets for a feed.
601      *
602      * @param feedid The feed ID
603      * @return The targets this feed should be delivered to
604      */
605     public Target[] getTargets(String feedid) {
606         return (config.getTargets(feedid));
607     }
608
609     /**
610      * Get the creation date for a feed.
611      *
612      * @param feedid The feed ID
613      * @return the timestamp of creation date of feed id passed
614      */
615     public String getCreatedDate(String feedid) {
616         return (config.getCreatedDate(feedid));
617     }
618
619     /**
620      * Get the spool directory for temporary files.
621      */
622     public String getSpoolDir() {
623         return (spooldir + "/f");
624     }
625
626     /**
627      * Get the spool directory for a subscription.
628      */
629     public String getSpoolDir(String subid, String remoteaddr) {
630         if (provcheck.isFrom(remoteaddr)) {
631             String sdir = config.getSpoolDir(subid);
632             if (sdir != null) {
633                 eelfLogger.debug("NODE0310 Received subscription reset request for subscription " + subid
634                         + " from provisioning server " + remoteaddr);
635             } else {
636                 eelfLogger.debug("NODE0311 Received subscription reset request for unknown subscription " + subid
637                         + " from provisioning server " + remoteaddr);
638             }
639             return (sdir);
640         } else {
641             eelfLogger.debug("NODE0312 Received subscription reset request from unexpected server " + remoteaddr);
642             return (null);
643         }
644     }
645
646     /**
647      * Get the base directory for spool directories.
648      */
649     public String getSpoolBase() {
650         return (spooldir);
651     }
652
653     /**
654      * Get the key store type.
655      */
656     public String getKSType() {
657         return (kstype);
658     }
659
660     /**
661      * Get the key store file.
662      */
663     public String getKSFile() {
664         return (ksfile);
665     }
666
667     /**
668      * Get the key store password.
669      */
670     public String getKSPass() {
671         return (kspass);
672     }
673
674     /**
675      * Get the key password.
676      */
677     public String getKPass() {
678         return (kpass);
679     }
680
681     /**
682      * Get the http port.
683      */
684     public int getHttpPort() {
685         return (gfport);
686     }
687
688     /**
689      * Get the https port.
690      */
691     public int getHttpsPort() {
692         return (svcport);
693     }
694
695     /**
696      * Get the externally visible https port.
697      */
698     public int getExtHttpsPort() {
699         return (port);
700     }
701
702     /**
703      * Get the external name of this machine.
704      */
705     public String getMyName() {
706         return (myname);
707     }
708
709     /**
710      * Get the number of threads to use for delivery.
711      */
712     public int getDeliveryThreads() {
713         return (deliverythreads);
714     }
715
716     /**
717      * Get the URL for uploading the event log data.
718      */
719     public String getEventLogUrl() {
720         return (eventlogurl);
721     }
722
723     /**
724      * Get the prefix for the names of event log files.
725      */
726     public String getEventLogPrefix() {
727         return (eventlogprefix);
728     }
729
730     /**
731      * Get the suffix for the names of the event log files.
732      */
733     public String getEventLogSuffix() {
734         return (eventlogsuffix);
735     }
736
737     /**
738      * Get the interval between event log file rollovers.
739      */
740     public String getEventLogInterval() {
741         return (eventloginterval);
742     }
743
744     /**
745      * Should I follow redirects from subscribers.
746      */
747     public boolean isFollowRedirects() {
748         return (followredirects);
749     }
750
751     /**
752      * Get the directory where the event and node log files live.
753      */
754     public String getLogDir() {
755         return (logdir);
756     }
757
758     /**
759      * How long do I keep log files (in milliseconds).
760      */
761     public long getLogRetention() {
762         return (logretention);
763     }
764
765     /**
766      * Get the timer.
767      */
768     public Timer getTimer() {
769         return (timer);
770     }
771
772     /**
773      * Get the feed ID for a subscription.
774      *
775      * @param subid The subscription ID
776      * @return The feed ID
777      */
778     public String getFeedId(String subid) {
779         return (config.getFeedId(subid));
780     }
781
782     /**
783      * Get the authorization string this node uses.
784      *
785      * @return The Authorization string for this node
786      */
787     public String getMyAuth() {
788         return (config.getMyAuth());
789     }
790
791     /**
792      * Get the fraction of free spool disk space where we start throwing away undelivered files.  This is
793      * FREE_DISK_RED_PERCENT / 100.0.  Default is 0.05.  Limited by 0.01 <= FreeDiskStart <= 0.5.
794      */
795     public double getFreeDiskStart() {
796         return (fdpstart);
797     }
798
799     /**
800      * Get the fraction of free spool disk space where we stop throwing away undelivered files.  This is
801      * FREE_DISK_YELLOW_PERCENT / 100.0.  Default is 0.2.  Limited by FreeDiskStart <= FreeDiskStop <= 0.5.
802      */
803     public double getFreeDiskStop() {
804         return (fdpstop);
805     }
806
807     /**
808      * Disable and enable protocols.
809      */
810     public String[] getEnabledprotocols() {
811         return enabledprotocols;
812     }
813
814     public void setEnabledprotocols(String[] enabledprotocols) {
815         this.enabledprotocols = enabledprotocols.clone();
816     }
817
818     public String getAafType() {
819         return aafType;
820     }
821
822     public void setAafType(String aafType) {
823         this.aafType = aafType;
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 }