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 Date lastRequestDate;
20 private static final long SUBSCRIBER_TIMEOUT = 600000; /* milliseconds */
22 public MappingServiceSubscriberRLOC(LispAddressContainer srcRloc) {
23 this(srcRloc, new Date(System.currentTimeMillis()));
26 public MappingServiceSubscriberRLOC(LispAddressContainer srcRloc, Date lastRequestDate) {
29 this.lastRequestDate = lastRequestDate;
32 public LispAddressContainer getSrcRloc() {
36 public void setSrcRloc(LispAddressContainer srcRloc) {
40 public Date getLastRequestDate() {
41 return lastRequestDate;
44 public void setLastRequestDate(Date lastRequestDate) {
45 this.lastRequestDate = lastRequestDate;
48 public boolean timedOut() {
49 return System.currentTimeMillis() - lastRequestDate.getTime() > SUBSCRIBER_TIMEOUT;
53 public int hashCode() {
54 return rloc.hashCode();
58 public boolean equals(Object obj) {
63 if (getClass() != obj.getClass())
65 MappingServiceSubscriberRLOC other = (MappingServiceSubscriberRLOC) obj;
66 if (!rloc.equals(other.rloc))
72 public String toString() {
73 return rloc.toString() + ", last request @ " + lastRequestDate.toString();