2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.lispflowmapping.interfaces.dao;
10 import java.util.Date;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.lispaddress.LispAddressContainer;
15 * Request source RLOC in the mapping service with it's properties.
17 public class MappingServiceSubscriberRLOC {
18 private LispAddressContainer rloc;
19 private LispAddressContainer eid;
20 private Date lastRequestDate;
21 private static final long SUBSCRIBER_TIMEOUT = 600000; /* milliseconds */
23 public MappingServiceSubscriberRLOC(LispAddressContainer srcRloc, LispAddressContainer srcEid) {
24 this(srcRloc, srcEid, new Date(System.currentTimeMillis()));
27 public MappingServiceSubscriberRLOC(LispAddressContainer srcRloc, LispAddressContainer srcEid,
28 Date lastRequestDate) {
32 this.lastRequestDate = lastRequestDate;
35 public LispAddressContainer getSrcRloc() {
39 public void setSrcRloc(LispAddressContainer srcRloc) {
43 public LispAddressContainer getSrcEid() {
47 public void setSrcEid(LispAddressContainer srcEid) {
51 public Date getLastRequestDate() {
52 return lastRequestDate;
55 public void setLastRequestDate(Date lastRequestDate) {
56 this.lastRequestDate = lastRequestDate;
59 public boolean timedOut() {
60 return System.currentTimeMillis() - lastRequestDate.getTime() > SUBSCRIBER_TIMEOUT;
64 public int hashCode() {
67 result = prime * result + ((rloc == null) ? 0 : rloc.hashCode());
68 result = prime * result + ((eid == null) ? 0 : eid.hashCode());
73 public boolean equals(Object obj) {
78 if (getClass() != obj.getClass())
80 MappingServiceSubscriberRLOC other = (MappingServiceSubscriberRLOC) obj;
81 if (!rloc.equals(other.rloc))
87 public String toString() {
88 return "_rloc=" + rloc.toString() + ", _eid=" + eid.toString()
89 + ", last request @ " + lastRequestDate.toString();