2 package org.opendaylight.bgpmanager.thrift.client.implementation;
4 import java.io.IOException;
5 import java.net.Socket;
6 import java.net.SocketException;
7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory;
10 public class BgpSyncHandle {
11 private static BgpSyncHandle handle = null;
12 private static final Logger LOGGER = LoggerFactory.getLogger(BgpSyncHandle.class);
16 public static final int INITED = 1;
17 public static final int ITERATING = 2;
18 public static final int DONE = 3;
19 public static final int ABORTED = 4;
20 public static final int NEVER_DONE = 5;
22 public static final int DEFAULT_TCP_SOCK_SZ = 87380; //default receive buffer size on linux > 2.4
24 private BgpSyncHandle() {
29 public static synchronized BgpSyncHandle getInstance() {
31 handle = new BgpSyncHandle();
36 public synchronized int getState() {
40 public int getMaxCount() {
41 //compute the max count of routes we would like to send
42 Socket skt = new Socket();
43 int sockBufSz = DEFAULT_TCP_SOCK_SZ;
45 sockBufSz = skt.getReceiveBufferSize();
46 } catch (SocketException s) {
47 LOGGER.warn("Socket Exception while retrieving default socket buffer size");
51 } catch (IOException e) {
52 LOGGER.warn("IO Exception while closing socket for retrieving default socket buffer size");
54 return sockBufSz/getRouteSize();
57 public int getRouteSize() {
58 //size of one update structure on the wire. ideally
59 //this should be computed; or thrift sure has a nice
60 //way to tell this to the applciation, but for the
61 //moment, we just use 8 bytes more than the size of
67 public int setState(int state) {
68 int retval = this.state;
73 public int setMore(int more) {
74 int retval = this.more;