blob: 01e0587171f559771416c4a76b75d2d04af8a0d9 [file] [log] [blame]
TeruU3c049c42014-04-15 10:13:25 -07001package net.onrc.onos.core.datastore;
2
3import java.net.InetAddress;
4
5import net.onrc.onos.core.datastore.IKVTable.IKVEntry;
6
7import org.slf4j.Logger;
8import org.slf4j.LoggerFactory;
9
10public class KVArpCache {
11
12 private static final Logger log = LoggerFactory.getLogger(KVArpCache.class);
13
14 private static final String GLOBAL_ARPCACHE_TABLE_NAME = "arp_cache";
15 private final IKVTable table;
16
17 public long getVersionNonexistant() {
18 return table.getVersionNonexistant();
19 }
20
21 public KVArpCache() {
22 table = DataStoreClient.getClient().getTable(GLOBAL_ARPCACHE_TABLE_NAME);
23 log.debug("create table {}", table.getTableId());
24 }
25
26 public void dropArpCache() {
27 DataStoreClient.getClient().dropTable(table);
28 log.debug("drop table {}", table.getTableId());
29 }
30
31 public long create(InetAddress ip, byte[] mac) throws ObjectExistsException {
32 return table.create(ip.getAddress(), mac);
33 }
34
35 public long forceCreate(InetAddress ip, byte[] mac) {
36 return table.forceCreate(ip.getAddress(), mac);
37 }
38
39 public IKVEntry read(InetAddress ip) throws ObjectDoesntExistException {
40 return table.read(ip.getAddress());
41 }
42
43 public long update(InetAddress ip, byte[] mac) throws ObjectDoesntExistException {
44 return table.update(ip.getAddress(), mac);
45 }
46
47 public long forceDelete(InetAddress ip) {
48 return table.forceDelete(ip.getAddress());
49 }
50
51 public Iterable<IKVEntry> getAllEntries() {
52 return table.getAllEntries();
53 }
54}