blob: 63f4824d56a4295c5c7cb3a56faa05cfdc2f38cf [file] [log] [blame]
sunish vk30637eb2016-02-16 15:19:32 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
sunish vk30637eb2016-02-16 15:19:32 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.ospf.controller;
17
18/**
19 * Representation of LSDB aging process.
20 * The age of each LSA in the database must be incremented by 1 each second.
21 * We put all the LSAs of a given age into a single bin. The age of an LSA is the
22 * difference between its age bin and the bin representing LS age 0.
23 */
24public interface LsdbAge {
25
26 /**
27 * Adds LSA to bin for aging.
28 *
29 * @param binKey key to store the LSA in bin
30 * @param lsaBin LSA bin instance
31 */
32 public void addLsaBin(Integer binKey, LsaBin lsaBin);
33
34 /**
35 * Gets LSA from bin, this method is used while processing ls refresh and max age on LSA.
36 *
37 * @param binKey key to retreive the LSA from bin
38 * @return lsaBin bin instance
39 */
40 public LsaBin getLsaBin(Integer binKey);
41
42 /**
43 * Adds the lsa to maxAge bin if LSAs age is max age.
44 *
45 * @param key key to store the LSA in bin.
46 * @param wrapper wrapper instance which contains LSA
47 */
48 public void addLsaToMaxAgeBin(String key, LsaWrapper wrapper);
49
50 /**
51 * Gets the bin number out of LSAs age, in which the LSA can be placed.
52 * so that age can be calculated.
53 *
54 * @param x Can be either age or ageCounter
55 * @return bin number.
56 */
57 public int age2Bin(int x);
58
59 /**
60 * Gets the max age bin, a special bin is created which holds only max age LSAs.
61 *
62 * @return lsa bin instance
63 */
64 public LsaBin getMaxAgeBin();
65
66 /**
67 * Gets the age counter.
68 *
69 * @return age counter
70 */
71 public int getAgeCounter();
72
73
74 /**
75 * Refresh the LSAs which are in the refresh bin.
76 */
77 public void refreshLsa();
78
79 /**
80 * If the LSAs have completed the MaxAge stop aging and flood it.
81 */
82 public void maxAgeLsa();
83
84 /**
85 * Invoked every 1 second as part of the aging process, and increments age counter.
86 * It also verifies if any LSA has reached ls refresh time or max age.
87 */
88 public void ageLsaAndFlood();
89
90 /**
91 * Starts the aging timer thread which gets invokes every second.
92 */
93 public void startDbAging();
94
95 /**
96 * Removes LSA from Bin, when ever it reaches a max age or ls refresh time.
97 *
98 * @param lsaWrapper wrapper instance
99 */
100 public void removeLsaFromBin(LsaWrapper lsaWrapper);
101}