2 package org.opendaylight.bgpmanager.thrift.client.implementation;
4 import java.io.IOException;
5 import java.net.Socket;
6 import java.net.SocketException;
8 public class BgpSyncHandle {
9 private static BgpSyncHandle handle = null;
13 public static final int INITED = 1;
14 public static final int ITERATING = 2;
15 public static final int DONE = 3;
16 public static final int ABORTED = 4;
17 public static final int NEVER_DONE = 5;
19 public static final int default_tcp_sock_sz = 87380; //default receive buffer size on linux > 2.4 (SLES 11)
21 private BgpSyncHandle() {
26 public static synchronized BgpSyncHandle getInstance() {
28 handle = new BgpSyncHandle();
32 public synchronized int getState() {
36 public int getMaxCount() {
37 //compute the max count of routes we would like to send
38 Socket skt = new Socket();
39 int sockBufSz = default_tcp_sock_sz;
41 sockBufSz = skt.getReceiveBufferSize();
42 } catch (SocketException s) {
46 } catch (IOException e) {
48 return sockBufSz/getRouteSize();
51 public int getRouteSize() {
52 //size of one update structure on the wire. ideally
53 //this should be computed; or thrift sure has a nice
54 //way to tell this to the applciation, but for the
55 //moment, we just use 8 bytes more than the size of
61 public int setState(int state) {
62 int retval = this.state;
67 public int setMore(int more) {
68 int retval = this.more;