\r
package org.onap.dmaap.datarouter.provisioning.beans;\r
\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
import java.net.InetAddress;\r
import java.net.UnknownHostException;\r
import java.sql.Connection;\r
import java.sql.PreparedStatement;\r
import java.sql.ResultSet;\r
import java.sql.SQLException;\r
-import java.sql.Statement;\r
-import java.util.ArrayList;\r
import java.util.Collection;\r
import java.util.Set;\r
import java.util.SortedSet;\r
import java.util.TreeSet;\r
-\r
import javax.servlet.http.HttpServletRequest;\r
-\r
import org.apache.commons.codec.binary.Base64;\r
-import org.apache.log4j.Logger;\r
import org.json.JSONArray;\r
import org.json.JSONObject;\r
-import org.onap.dmaap.datarouter.provisioning.utils.DB;\r
+import org.onap.dmaap.datarouter.provisioning.utils.ProvDbUtils;\r
\r
/**\r
* The representation of one route in the Ingress Route Table.\r
* @author Robert P. Eby\r
* @version $Id: IngressRoute.java,v 1.3 2013/12/16 20:30:23 eby Exp $\r
*/\r
+\r
public class IngressRoute extends NodeClass implements Comparable<IngressRoute> {\r
\r
- private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");\r
+ private static final String NODESET = "NODESET";\r
+ private static EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog");\r
+ private static final String SQLEXCEPTION = "SQLException: ";\r
private final int seq;\r
private final int feedid;\r
private final String userid;\r
private int nodelist;\r
private SortedSet<String> nodes;\r
\r
+ /**\r
+ * Ingress route constructor.\r
+ * @param seq squence number\r
+ * @param feedid id for feed\r
+ * @param user user name\r
+ * @param subnet subnet string\r
+ * @param nodes collection of nodes\r
+ */\r
+ public IngressRoute(int seq, int feedid, String user, String subnet, Collection<String> nodes) {\r
+ this(seq, feedid, user, subnet);\r
+ this.nodelist = -1;\r
+ this.nodes = new TreeSet<>(nodes);\r
+ }\r
+\r
+ private IngressRoute(int seq, int feedid, String user, String subnet, int nodeset) {\r
+ this(seq, feedid, user, subnet);\r
+ this.nodelist = nodeset;\r
+ this.nodes = new TreeSet<>(readNodes());\r
+ }\r
+\r
+ private IngressRoute(int seq, int feedid, String user, String subnet) {\r
+ this.seq = seq;\r
+ this.feedid = feedid;\r
+ this.userid = (user == null) ? "-" : user;\r
+ this.subnet = (subnet == null) ? "-" : subnet;\r
+ this.nodelist = -1;\r
+ this.nodes = null;\r
+ if (Feed.getFeedById(feedid) == null) {\r
+ throw new IllegalArgumentException("No such feed: " + feedid);\r
+ }\r
+ if (!"-".equals(this.subnet)) {\r
+ SubnetMatcher sm = new SubnetMatcher(subnet);\r
+ if (!sm.isValid()) {\r
+ throw new IllegalArgumentException("Invalid subnet: " + subnet);\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Ingress route constructor.\r
+ * @param jo JSONObject\r
+ */\r
+ public IngressRoute(JSONObject jo) {\r
+ this.seq = jo.optInt("seq");\r
+ this.feedid = jo.optInt("feedid");\r
+ String user = jo.optString("user");\r
+ this.userid = "".equals(user) ? "-" : user;\r
+ user = jo.optString("subnet");\r
+ this.subnet = "".equals(user) ? "-" : user;\r
+ this.nodelist = -1;\r
+ this.nodes = new TreeSet<>();\r
+ JSONArray ja = jo.getJSONArray("node");\r
+ for (int i = 0; i < ja.length(); i++) {\r
+ this.nodes.add(ja.getString(i));\r
+ }\r
+ }\r
+\r
+\r
/**\r
* Get all IngressRoutes in the database, sorted in order according to their sequence field.\r
*\r
*/\r
public static Set<IngressRoute> getIngressRoutesForSeq(int seq) {\r
return getAllIngressRoutesForSQL(\r
- "select SEQUENCE, FEEDID, USERID, SUBNET, NODESET from INGRESS_ROUTES where SEQUENCE = " + seq);\r
+ "select SEQUENCE, FEEDID, USERID, SUBNET, NODESET from INGRESS_ROUTES where SEQUENCE = " + seq);\r
}\r
\r
private static SortedSet<IngressRoute> getAllIngressRoutesForSQL(String sql) {\r
- SortedSet<IngressRoute> set = new TreeSet<IngressRoute>();\r
- try {\r
- DB db = new DB();\r
- @SuppressWarnings("resource")\r
- Connection conn = db.getConnection();\r
- try (Statement stmt = conn.createStatement()) {\r
- try (ResultSet rs = stmt.executeQuery(sql)) {\r
- while (rs.next()) {\r
- int seq = rs.getInt("SEQUENCE");\r
- int feedid = rs.getInt("FEEDID");\r
- String user = rs.getString("USERID");\r
- String subnet = rs.getString("SUBNET");\r
- int nodeset = rs.getInt("NODESET");\r
- set.add(new IngressRoute(seq, feedid, user, subnet, nodeset));\r
- }\r
- }\r
- }\r
- db.release(conn);\r
+ SortedSet<IngressRoute> set = new TreeSet<>();\r
+ try (Connection conn = ProvDbUtils.getInstance().getConnection();\r
+ PreparedStatement ps = conn.prepareStatement(sql);\r
+ ResultSet rs = ps.executeQuery()) {\r
+ addIngressRouteToSet(set, rs);\r
} catch (SQLException e) {\r
- intlogger.error("SQLException " + e.getMessage());\r
+ intlogger.error("PROV0001 getAllIngressRoutesForSQL: " + e.getMessage(), e);\r
}\r
return set;\r
}\r
\r
+ private static void addIngressRouteToSet(SortedSet<IngressRoute> set, ResultSet rs) throws SQLException {\r
+ while (rs.next()) {\r
+ int seq = rs.getInt("SEQUENCE");\r
+ int feedid = rs.getInt("FEEDID");\r
+ String user = rs.getString("USERID");\r
+ String subnet = rs.getString("SUBNET");\r
+ int nodeset = rs.getInt(NODESET);\r
+ set.add(new IngressRoute(seq, feedid, user, subnet, nodeset));\r
+ }\r
+ }\r
+\r
/**\r
* Get the maximum node set ID in use in the DB.\r
*\r
* @return the integer value of the maximum\r
*/\r
- public static int getMaxNodeSetID() {\r
+ private static int getMaxNodeSetID() {\r
return getMax("select max(SETID) as MAX from NODESETS");\r
}\r
\r
\r
private static int getMax(String sql) {\r
int rv = 0;\r
- try {\r
- DB db = new DB();\r
- @SuppressWarnings("resource")\r
- Connection conn = db.getConnection();\r
- try (Statement stmt = conn.createStatement()) {\r
- try (ResultSet rs = stmt.executeQuery(sql)) {\r
- if (rs.next()) {\r
- rv = rs.getInt("MAX");\r
- }\r
- }\r
+ try (Connection conn = ProvDbUtils.getInstance().getConnection();\r
+ PreparedStatement ps = conn.prepareStatement(sql);\r
+ ResultSet rs = ps.executeQuery(sql)) {\r
+ if (rs.next()) {\r
+ rv = rs.getInt("MAX");\r
}\r
- db.release(conn);\r
} catch (SQLException e) {\r
- intlogger.error("SQLException " + e.getMessage());\r
+ intlogger.error("PROV0002 getMax: " + e.getMessage(), e);\r
}\r
return rv;\r
}\r
\r
/**\r
- * Get an Ingress Route for a particular feed ID, user, and subnet\r
+ * Get an Ingress Route for a particular feed ID, user, and subnet.\r
*\r
* @param feedid the Feed ID to look for\r
* @param user the user name to look for\r
* @return the Ingress Route, or null of there is none\r
*/\r
public static IngressRoute getIngressRoute(int feedid, String user, String subnet) {\r
- IngressRoute v = null;\r
- PreparedStatement ps = null;\r
- try {\r
- DB db = new DB();\r
- @SuppressWarnings("resource")\r
- Connection conn = db.getConnection();\r
- String sql = "select SEQUENCE, NODESET from INGRESS_ROUTES where FEEDID = ? AND USERID = ? and SUBNET = ?";\r
- ps = conn.prepareStatement(sql);\r
+ IngressRoute ir = null;\r
+ try (Connection conn = ProvDbUtils.getInstance().getConnection();\r
+ PreparedStatement ps = conn.prepareStatement(\r
+ "select SEQUENCE, NODESET from INGRESS_ROUTES where FEEDID = ? AND USERID = ? and SUBNET = ?")) {\r
ps.setInt(1, feedid);\r
ps.setString(2, user);\r
ps.setString(3, subnet);\r
try (ResultSet rs = ps.executeQuery()) {\r
if (rs.next()) {\r
int seq = rs.getInt("SEQUENCE");\r
- int nodeset = rs.getInt("NODESET");\r
- v = new IngressRoute(seq, feedid, user, subnet, nodeset);\r
+ int nodeset = rs.getInt(NODESET);\r
+ ir = new IngressRoute(seq, feedid, user, subnet, nodeset);\r
}\r
}\r
- ps.close();\r
- db.release(conn);\r
} catch (SQLException e) {\r
- intlogger.error("SQLException " + e.getMessage());\r
- } finally {\r
- try {\r
- if (ps != null) {\r
- ps.close();\r
- }\r
- } catch (SQLException e) {\r
- intlogger.error("SQLException " + e.getMessage());\r
- }\r
- }\r
- return v;\r
- }\r
-\r
- /**\r
- * Get a collection of all Ingress Routes with a particular sequence number.\r
- *\r
- * @param seq the sequence number to look for\r
- * @return the collection (may be empty).\r
- */\r
- public static Collection<IngressRoute> getIngressRoute(int seq) {\r
- Collection<IngressRoute> rv = new ArrayList<IngressRoute>();\r
- try {\r
- DB db = new DB();\r
- @SuppressWarnings("resource")\r
- Connection conn = db.getConnection();\r
- String sql = "select FEEDID, USERID, SUBNET, NODESET from INGRESS_ROUTES where SEQUENCE = ?";\r
- try (PreparedStatement ps = conn.prepareStatement(sql)) {\r
- ps.setInt(1, seq);\r
- try (ResultSet rs = ps.executeQuery()) {\r
- while (rs.next()) {\r
- int feedid = rs.getInt("FEEDID");\r
- String user = rs.getString("USERID");\r
- String subnet = rs.getString("SUBNET");\r
- int nodeset = rs.getInt("NODESET");\r
- rv.add(new IngressRoute(seq, feedid, user, subnet, nodeset));\r
- }\r
- }\r
- }\r
- db.release(conn);\r
- } catch (SQLException e) {\r
- intlogger.error("SQLException " + e.getMessage());\r
- }\r
- return rv;\r
- }\r
-\r
- public IngressRoute(int seq, int feedid, String user, String subnet, Collection<String> nodes)\r
- throws IllegalArgumentException {\r
- this(seq, feedid, user, subnet);\r
- this.nodelist = -1;\r
- this.nodes = new TreeSet<String>(nodes);\r
- }\r
-\r
- public IngressRoute(int seq, int feedid, String user, String subnet, int nodeset)\r
- throws IllegalArgumentException {\r
- this(seq, feedid, user, subnet);\r
- this.nodelist = nodeset;\r
- this.nodes = new TreeSet<String>(readNodes());\r
- }\r
-\r
- private IngressRoute(int seq, int feedid, String user, String subnet)\r
- throws IllegalArgumentException {\r
- this.seq = seq;\r
- this.feedid = feedid;\r
- this.userid = (user == null) ? "-" : user;\r
- this.subnet = (subnet == null) ? "-" : subnet;\r
- this.nodelist = -1;\r
- this.nodes = null;\r
- if (Feed.getFeedById(feedid) == null) {\r
- throw new IllegalArgumentException("No such feed: " + feedid);\r
- }\r
- if (!this.subnet.equals("-")) {\r
- SubnetMatcher sm = new SubnetMatcher(subnet);\r
- if (!sm.isValid()) {\r
- throw new IllegalArgumentException("Invalid subnet: " + subnet);\r
- }\r
- }\r
- }\r
-\r
- public IngressRoute(JSONObject jo) {\r
- this.seq = jo.optInt("seq");\r
- this.feedid = jo.optInt("feedid");\r
- String t = jo.optString("user");\r
- this.userid = t.equals("") ? "-" : t;\r
- t = jo.optString("subnet");\r
- this.subnet = t.equals("") ? "-" : t;\r
- this.nodelist = -1;\r
- this.nodes = new TreeSet<String>();\r
- JSONArray ja = jo.getJSONArray("node");\r
- for (int i = 0; i < ja.length(); i++) {\r
- this.nodes.add(ja.getString(i));\r
+ intlogger.error("PROV0003 getIngressRoute: " + e.getMessage(), e);\r
}\r
+ return ir;\r
}\r
\r
/**\r
if (this.feedid != feedid) {\r
return false;\r
}\r
-\r
// Get user from request and compare\r
// Note: we don't check the password; the node will do that\r
- if (userid.length() > 0 && !userid.equals("-")) {\r
+ if (userid.length() > 0 && !"-".equals(userid)) {\r
String credentials = req.getHeader("Authorization");\r
if (credentials == null || !credentials.startsWith("Basic ")) {\r
return false;\r
}\r
- String t = new String(Base64.decodeBase64(credentials.substring(6)));\r
- int ix = t.indexOf(':');\r
+ String cred = new String(Base64.decodeBase64(credentials.substring(6)));\r
+ int ix = cred.indexOf(':');\r
if (ix >= 0) {\r
- t = t.substring(0, ix);\r
+ cred = cred.substring(0, ix);\r
}\r
- if (!t.equals(this.userid)) {\r
+ if (!cred.equals(this.userid)) {\r
return false;\r
}\r
}\r
-\r
// If this route has a subnet, match it against the requester's IP addr\r
- if (subnet.length() > 0 && !subnet.equals("-")) {\r
+ if (subnet.length() > 0 && !"-".equals(subnet)) {\r
try {\r
InetAddress inet = InetAddress.getByName(req.getRemoteAddr());\r
SubnetMatcher sm = new SubnetMatcher(subnet);\r
return sm.matches(inet.getAddress());\r
} catch (UnknownHostException e) {\r
+ intlogger.error("PROV0008 matches: " + e.getMessage(), e);\r
return false;\r
}\r
}\r
* Compare IP addresses as byte arrays to a subnet specified as a CIDR. Taken from\r
* org.onap.dmaap.datarouter.node.SubnetMatcher and modified somewhat.\r
*/\r
- public class SubnetMatcher {\r
+ public static class SubnetMatcher {\r
\r
private byte[] sn;\r
private int len;\r
private boolean valid;\r
\r
/**\r
- * Construct a subnet matcher given a CIDR\r
+ * Construct a subnet matcher given a CIDR.\r
*\r
* @param subnet The CIDR to match\r
*/\r
- public SubnetMatcher(String subnet) {\r
- int i = subnet.lastIndexOf('/');\r
- if (i == -1) {\r
+ SubnetMatcher(String subnet) {\r
+ int index = subnet.lastIndexOf('/');\r
+ if (index == -1) {\r
try {\r
sn = InetAddress.getByName(subnet).getAddress();\r
len = sn.length;\r
valid = true;\r
} catch (UnknownHostException e) {\r
+ intlogger.error("PROV0008 SubnetMatcher: " + e.getMessage(), e);\r
len = 0;\r
valid = false;\r
}\r
mask = 0;\r
} else {\r
- int n = Integer.parseInt(subnet.substring(i + 1));\r
+ int num = Integer.parseInt(subnet.substring(index + 1));\r
try {\r
- sn = InetAddress.getByName(subnet.substring(0, i)).getAddress();\r
+ sn = InetAddress.getByName(subnet.substring(0, index)).getAddress();\r
valid = true;\r
} catch (UnknownHostException e) {\r
+ intlogger.error("PROV0008 SubnetMatcher: " + e.getMessage(), e);\r
valid = false;\r
}\r
- len = n / 8;\r
- mask = ((0xff00) >> (n % 8)) & 0xff;\r
+ len = num / 8;\r
+ mask = ((0xff00) >> (num % 8)) & 0xff;\r
}\r
}\r
\r
- public boolean isValid() {\r
+ boolean isValid() {\r
return valid;\r
}\r
\r
/**\r
- * Is the IP address in the CIDR?\r
+ * Is the IP address in the CIDR?.\r
*\r
* @param addr the IP address as bytes in network byte order\r
* @return true if the IP address matches.\r
*/\r
- public boolean matches(byte[] addr) {\r
- if (!valid || addr.length != sn.length) {\r
+ boolean matches(byte[] addr) {\r
+ if (!valid || (addr.length != sn.length)) {\r
return false;\r
}\r
for (int i = 0; i < len; i++) {\r
}\r
\r
private Collection<String> readNodes() {\r
- Collection<String> set = new TreeSet<String>();\r
- try {\r
- DB db = new DB();\r
- @SuppressWarnings("resource")\r
- Connection conn = db.getConnection();\r
- String sql = "select NODEID from NODESETS where SETID = ?";\r
- try (PreparedStatement ps = conn.prepareStatement(sql)) {\r
- ps.setInt(1, nodelist);\r
- try (ResultSet rs = ps.executeQuery()) {\r
- while (rs.next()) {\r
- int id = rs.getInt("NODEID");\r
- set.add(lookupNodeID(id));\r
- }\r
- }\r
- }\r
- db.release(conn);\r
+ Collection<String> set = new TreeSet<>();\r
+ try (Connection conn = ProvDbUtils.getInstance().getConnection();\r
+ PreparedStatement ps = conn.prepareStatement("select NODEID from NODESETS where SETID = ?")) {\r
+ ps.setInt(1, nodelist);\r
+ addNodeToSet(set, ps);\r
} catch (SQLException e) {\r
- intlogger.error("SQLException " + e.getMessage());\r
+ intlogger.error(SQLEXCEPTION + e.getMessage(), e);\r
}\r
return set;\r
}\r
\r
+ private void addNodeToSet(Collection<String> set, PreparedStatement ps) throws SQLException {\r
+ try (ResultSet rs = ps.executeQuery()) {\r
+ while (rs.next()) {\r
+ int id = rs.getInt("NODEID");\r
+ set.add(lookupNodeID(id));\r
+ }\r
+ }\r
+ }\r
+\r
/**\r
* Delete the IRT route having this IngressRoutes feed ID, user ID, and subnet from the database.\r
*\r
* @return true if the delete succeeded\r
*/\r
@Override\r
- public boolean doDelete(Connection c) {\r
+ public boolean doDelete(Connection conn) {\r
boolean rv = true;\r
- PreparedStatement ps = null;\r
- try {\r
- ps = c.prepareStatement("delete from INGRESS_ROUTES where FEEDID = ? and USERID = ? and SUBNET = ?");\r
+ try (PreparedStatement ps = conn.prepareStatement(\r
+ "delete from INGRESS_ROUTES where FEEDID = ? and USERID = ? and SUBNET = ?");\r
+ PreparedStatement ps2 = conn.prepareStatement("delete from NODESETS where SETID = ?")) {\r
+ // Delete the Ingress Route\r
ps.setInt(1, feedid);\r
ps.setString(2, userid);\r
ps.setString(3, subnet);\r
ps.execute();\r
- ps.close();\r
-\r
- ps = c.prepareStatement("delete from NODESETS where SETID = ?");\r
- ps.setInt(1, nodelist);\r
- ps.execute();\r
+ // Delete the NodeSet\r
+ ps2.setInt(1, nodelist);\r
+ ps2.execute();\r
} catch (SQLException e) {\r
rv = false;\r
- intlogger.warn("PROV0007 doDelete: " + e.getMessage());\r
- } finally {\r
- try {\r
- if (ps != null) {\r
- ps.close();\r
- }\r
- } catch (SQLException e) {\r
- intlogger.error("SQLException " + e.getMessage());\r
- }\r
+ intlogger.error("PROV0007 doDelete: " + e.getMessage(), e);\r
}\r
return rv;\r
}\r
\r
- @SuppressWarnings("resource")\r
@Override\r
- public boolean doInsert(Connection c) {\r
+ public boolean doInsert(Connection conn) {\r
boolean rv = false;\r
- PreparedStatement ps = null;\r
- try {\r
+ try (PreparedStatement ps = conn.prepareStatement("insert into NODESETS (SETID, NODEID) values (?,?)");\r
+ PreparedStatement ps2 = conn.prepareStatement("insert into INGRESS_ROUTES (SEQUENCE, FEEDID, USERID,"\r
+ + " SUBNET, NODESET) values (?, ?, ?, ?, ?)")) {\r
// Create the NODESETS rows & set nodelist\r
- int set = getMaxNodeSetID() + 1;\r
- this.nodelist = set;\r
+ this.nodelist = getMaxNodeSetID() + 1;\r
for (String node : nodes) {\r
int id = lookupNodeName(node);\r
- ps = c.prepareStatement("insert into NODESETS (SETID, NODEID) values (?,?)");\r
ps.setInt(1, this.nodelist);\r
ps.setInt(2, id);\r
ps.execute();\r
- ps.close();\r
}\r
-\r
// Create the INGRESS_ROUTES row\r
- ps = c.prepareStatement(\r
- "insert into INGRESS_ROUTES (SEQUENCE, FEEDID, USERID, SUBNET, NODESET) values (?, ?, ?, ?, ?)");\r
- ps.setInt(1, this.seq);\r
- ps.setInt(2, this.feedid);\r
- ps.setString(3, this.userid);\r
- ps.setString(4, this.subnet);\r
- ps.setInt(5, this.nodelist);\r
- ps.execute();\r
- ps.close();\r
+ ps2.setInt(1, this.seq);\r
+ ps2.setInt(2, this.feedid);\r
+ ps2.setString(3, this.userid);\r
+ ps2.setString(4, this.subnet);\r
+ ps2.setInt(5, this.nodelist);\r
+ ps2.execute();\r
rv = true;\r
} catch (SQLException e) {\r
- intlogger.warn("PROV0005 doInsert: " + e.getMessage());\r
- } finally {\r
- try {\r
- if (ps != null) {\r
- ps.close();\r
- }\r
- } catch (SQLException e) {\r
- intlogger.error("SQLException " + e.getMessage());\r
- }\r
+ intlogger.error("PROV0005 doInsert: " + e.getMessage(), e);\r
}\r
return rv;\r
}\r
\r
@Override\r
- public boolean doUpdate(Connection c) {\r
- return doDelete(c) && doInsert(c);\r
+ public boolean doUpdate(Connection conn) {\r
+ return doDelete(conn) && doInsert(conn);\r
}\r
\r
@Override\r
JSONObject jo = new JSONObject();\r
jo.put("feedid", feedid);\r
// Note: for user and subnet, null, "", and "-" are equivalent\r
- if (userid != null && !userid.equals("-") && !userid.equals("")) {\r
+ if (userid != null && !"-".equals(userid) && !"".equals(userid)) {\r
jo.put("user", userid);\r
}\r
- if (subnet != null && !subnet.equals("-") && !subnet.equals("")) {\r
+ if (subnet != null && !"-".equals(subnet) && !"".equals(subnet)) {\r
jo.put("subnet", subnet);\r
}\r
jo.put("seq", seq);\r
@Override\r
public String getKey() {\r
return String\r
- .format("%d/%s/%s/%d", feedid, (userid == null) ? "" : userid, (subnet == null) ? "" : subnet, seq);\r
+ .format("%d/%s/%s/%d", feedid, (userid == null) ? "" : userid, (subnet == null) ? "" : subnet, seq);\r
}\r
\r
@Override\r
\r
@Override\r
public boolean equals(Object obj) {\r
- try {\r
- if (!(obj instanceof IngressRoute)) {\r
- return false;\r
- }\r
- return this.compareTo((IngressRoute) obj) == 0;\r
- } catch (NullPointerException e) {\r
+ if (!(obj instanceof IngressRoute)) {\r
return false;\r
}\r
+ return this.compareTo((IngressRoute) obj) == 0;\r
}\r
\r
@Override\r
if (in == null) {\r
throw new NullPointerException();\r
}\r
- int n = this.feedid - in.feedid;\r
- if (n != 0) {\r
- return n;\r
+ int num = this.feedid - in.feedid;\r
+ if (num != 0) {\r
+ return num;\r
}\r
- n = this.seq - in.seq;\r
- if (n != 0) {\r
- return n;\r
+ num = this.seq - in.seq;\r
+ if (num != 0) {\r
+ return num;\r
}\r
- n = this.userid.compareTo(in.userid);\r
- if (n != 0) {\r
- return n;\r
+ num = this.userid.compareTo(in.userid);\r
+ if (num != 0) {\r
+ return num;\r
}\r
- n = this.subnet.compareTo(in.subnet);\r
- if (n != 0) {\r
- return n;\r
+ num = this.subnet.compareTo(in.subnet);\r
+ if (num != 0) {\r
+ return num;\r
}\r
return this.nodes.equals(in.nodes) ? 0 : 1;\r
}\r
@Override\r
public String toString() {\r
return String.format("INGRESS: feed=%d, userid=%s, subnet=%s, seq=%d", feedid, (userid == null) ? "" : userid,\r
- (subnet == null) ? "" : subnet, seq);\r
+ (subnet == null) ? "" : subnet, seq);\r
}\r
}\r