/******************************************************************************* * ============LICENSE_START================================================== * * org.onap.dmaap * * =========================================================================== * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. * * =========================================================================== * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * ============LICENSE_END==================================================== * * * * ECOMP is a trademark and service mark of AT&T Intellectual Property. * * ******************************************************************************/ package org.onap.dmaap.datarouter.node; import java.util.*; import java.io.*; /** * Processed configuration for this node. *
* The NodeConfig represents a processed configuration from the Data Router
* provisioning server. Each time configuration data is received from the
* provisioning server, a new NodeConfig is created and the previous one
* discarded.
*/
public class NodeConfig {
/**
* Raw configuration entry for a data router node
*/
public static class ProvNode {
private String cname;
/**
* Construct a node configuration entry.
*
* @param cname The cname of the node.
*/
public ProvNode(String cname) {
this.cname = cname;
}
/**
* Get the cname of the node
*/
public String getCName() {
return (cname);
}
}
/**
* Raw configuration entry for a provisioning parameter
*/
public static class ProvParam {
private String name;
private String value;
/**
* Construct a provisioning parameter configuration entry.
*
* @param name The name of the parameter.
* @param value The value of the parameter.
*/
public ProvParam(String name, String value) {
this.name = name;
this.value = value;
}
/**
* Get the name of the parameter.
*/
public String getName() {
return (name);
}
/**
* Get the value of the parameter.
*/
public String getValue() {
return (value);
}
}
/**
* Raw configuration entry for a data feed.
*/
public static class ProvFeed {
private String id;
private String logdata;
private String status;
/**
* Construct a feed configuration entry.
*
* @param id The feed ID of the entry.
* @param logdata String for log entries about the entry.
* @param status The reason why this feed cannot be used (Feed has been deleted, Feed has been suspended) or null if it is valid.
*/
public ProvFeed(String id, String logdata, String status) {
this.id = id;
this.logdata = logdata;
this.status = status;
}
/**
* Get the feed id of the data feed.
*/
public String getId() {
return (id);
}
/**
* Get the log data of the data feed.
*/
public String getLogData() {
return (logdata);
}
/**
* Get the status of the data feed.
*/
public String getStatus() {
return (status);
}
}
/**
* Raw configuration entry for a feed user.
*/
public static class ProvFeedUser {
private String feedid;
private String user;
private String credentials;
/**
* Construct a feed user configuration entry
*
* @param feedid The feed id.
* @param user The user that will publish to the feed.
* @param credentials The Authorization header the user will use to publish.
*/
public ProvFeedUser(String feedid, String user, String credentials) {
this.feedid = feedid;
this.user = user;
this.credentials = credentials;
}
/**
* Get the feed id of the feed user.
*/
public String getFeedId() {
return (feedid);
}
/**
* Get the user for the feed user.
*/
public String getUser() {
return (user);
}
/**
* Get the credentials for the feed user.
*/
public String getCredentials() {
return (credentials);
}
}
/**
* Raw configuration entry for a feed subnet
*/
public static class ProvFeedSubnet {
private String feedid;
private String cidr;
/**
* Construct a feed subnet configuration entry
*
* @param feedid The feed ID
* @param cidr The CIDR allowed to publish to the feed.
*/
public ProvFeedSubnet(String feedid, String cidr) {
this.feedid = feedid;
this.cidr = cidr;
}
/**
* Get the feed id of the feed subnet.
*/
public String getFeedId() {
return (feedid);
}
/**
* Get the CIDR of the feed subnet.
*/
public String getCidr() {
return (cidr);
}
}
/**
* Raw configuration entry for a subscription
*/
public static class ProvSubscription {
private String subid;
private String feedid;
private String url;
private String authuser;
private String credentials;
private boolean metaonly;
private boolean use100;
/**
* Construct a subscription configuration entry
*
* @param subid The subscription ID
* @param feedid The feed ID
* @param url The base delivery URL (not including the fileid)
* @param authuser The user in the credentials used to deliver
* @param credentials The credentials used to authenticate to the delivery URL exactly as they go in the Authorization header.
* @param metaonly Is this a meta data only subscription?
* @param use100 Should we send Expect: 100-continue?
*/
public ProvSubscription(String subid, String feedid, String url, String authuser, String credentials, boolean metaonly, boolean use100) {
this.subid = subid;
this.feedid = feedid;
this.url = url;
this.authuser = authuser;
this.credentials = credentials;
this.metaonly = metaonly;
this.use100 = use100;
}
/**
* Get the subscription ID
*/
public String getSubId() {
return (subid);
}
/**
* Get the feed ID
*/
public String getFeedId() {
return (feedid);
}
/**
* Get the delivery URL
*/
public String getURL() {
return (url);
}
/**
* Get the user
*/
public String getAuthUser() {
return (authuser);
}
/**
* Get the delivery credentials
*/
public String getCredentials() {
return (credentials);
}
/**
* Is this a meta data only subscription?
*/
public boolean isMetaDataOnly() {
return (metaonly);
}
/**
* Should we send Expect: 100-continue?
*/
public boolean isUsing100() {
return (use100);
}
}
/**
* Raw configuration entry for controlled ingress to the data router node
*/
public static class ProvForceIngress {
private String feedid;
private String subnet;
private String user;
private String[] nodes;
/**
* Construct a forced ingress configuration entry
*
* @param feedid The feed ID that this entry applies to
* @param subnet The CIDR for which publisher IP addresses this entry applies to or "" if it applies to all publisher IP addresses
* @param user The publishing user this entry applies to or "" if it applies to all publishing users.
* @param nodes The array of FQDNs of the data router nodes to redirect publication attempts to.
*/
public ProvForceIngress(String feedid, String subnet, String user, String[] nodes) {
this.feedid = feedid;
this.subnet = subnet;
this.user = user;
this.nodes = nodes;
}
/**
* Get the feed ID
*/
public String getFeedId() {
return (feedid);
}
/**
* Get the subnet
*/
public String getSubnet() {
return (subnet);
}
/**
* Get the user
*/
public String getUser() {
return (user);
}
/**
* Get the node
*/
public String[] getNodes() {
return (nodes);
}
}
/**
* Raw configuration entry for controlled egress from the data router
*/
public static class ProvForceEgress {
private String subid;
private String node;
/**
* Construct a forced egress configuration entry
*
* @param subid The subscription ID the subscription with forced egress
* @param node The node handling deliveries for this subscription
*/
public ProvForceEgress(String subid, String node) {
this.subid = subid;
this.node = node;
}
/**
* Get the subscription ID
*/
public String getSubId() {
return (subid);
}
/**
* Get the node
*/
public String getNode() {
return (node);
}
}
/**
* Raw configuration entry for routing within the data router network
*/
public static class ProvHop {
private String from;
private String to;
private String via;
/**
* A human readable description of this entry
*/
public String toString() {
return ("Hop " + from + "->" + to + " via " + via);
}
/**
* Construct a hop entry
*
* @param from The FQDN of the node with the data to be delivered
* @param to The FQDN of the node that will deliver to the subscriber
* @param via The FQDN of the node where the from node should send the data
*/
public ProvHop(String from, String to, String via) {
this.from = from;
this.to = to;
this.via = via;
}
/**
* Get the from node
*/
public String getFrom() {
return (from);
}
/**
* Get the to node
*/
public String getTo() {
return (to);
}
/**
* Get the next intermediate node
*/
public String getVia() {
return (via);
}
}
private static class Redirection {
public SubnetMatcher snm;
public String user;
public String[] nodes;
}
private static class Feed {
public String loginfo;
public String status;
public SubnetMatcher[] subnets;
public Hashtable