예제 #1
0
 //throws IOException
 public override void FromBinary(DataInputStream s)
 {
     base.FromBinary(s);
     QueryString = s.readString();
     TableName = s.readString();
     IsCreate = s.readBoolean();
     TableVersion = s.readInt();
 }
예제 #2
0
	    override public void FromBinary(DataInputStream s)  {
		    // read count
		    int count = s.readInt();
            setTables(new List<TableVersion>());

            // read contents
            for(int i = 0; i < count; ++i)
                getTables().Add(new TableVersion(s));
	    }
예제 #3
0
파일: UdpListener.cs 프로젝트: Mofsy/sr-rbd
        public void run()
        {
            try
            {
                IPEndPoint ip = new IPEndPoint(IPAddress.Any, listenPort);
                Socket socket = new Socket(AddressFamily.InterNetwork,
                                SocketType.Dgram, ProtocolType.Udp);
                socket.Bind(ip);
                Logger.getInstance().log("Listening on port " + listenPort,
                                         LOGGING_NAME, Logger.Level.INFO);
                while (true)
                {
                    IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
                    EndPoint senderEP = (EndPoint)(sender);

                    Byte[] buffer = new Byte[DATAGRAM_SIZE];
                    socket.ReceiveFrom(buffer, ref senderEP);

                    MemoryStream ms = new MemoryStream(buffer);
                    DataInputStream dis = new DataInputStream(ms);

                    int size = dis.readInt();
                    int type = dis.readInt();

                    byte[] data = new byte[size];
                    System.Array.Copy(buffer, 2*sizeof(Int32) /*8*/, data, 0, size);

                    Message m = Message.Unserialize(Message.fromInt(type), data, (IPEndPoint)senderEP);
                    storage.put(m);
                }
            }
            catch (SocketException)
            {
                Logger.getInstance().log("Could not listen on port " + listenPort,
                        LOGGING_NAME, Logger.Level.SEVERE);
            }
            catch (IOException)
            {
                Logger.getInstance().log("Error reading packet!",
                        LOGGING_NAME, Logger.Level.INFO);
            }
            catch (InvalidMessageTypeException e)
            {
                Logger.getInstance().log("InvalidMessageTypeException " + e.Message,
                        LOGGING_NAME,
                        Logger.Level.WARNING);
            }
            catch (ThreadInterruptedException e)
            {
                Logger.getInstance().log("InterruptedException " + e.Message,
                        LOGGING_NAME,
                        Logger.Level.WARNING);
            }
            Thread.CurrentThread.Abort();
        }
예제 #4
0
        //throws IOException
        public override void FromBinary(DataInputStream s)
        {
            // read port
            ListeningPort = s.readInt();

            // read count
            int count = s.readInt();
            Tables = new List<TableVersion>();

            // read contents
            while (count-- > 0)
                Tables.Add(new TableVersion(s));
        }
예제 #5
0
 //throws IOException
 public override void FromBinary(DataInputStream s)
 {
     Exception = new DBException(s);
 }
예제 #6
0
파일: Message.cs 프로젝트: Mofsy/sr-rbd
        //throws IOException
        public static Message Unserialize(MessageType type, byte[] bytes, IPEndPoint sender)
        {
            // create message object of given type
            Message result = MessageFactory.create(type);

            // unserialize it
            MemoryStream data = new MemoryStream(bytes);
            DataInputStream dataStream = new DataInputStream(data);
            result.FromBinary(dataStream);

            // mark sender
            result.Sender = sender;
            return result;
        }
예제 #7
0
파일: Message.cs 프로젝트: Mofsy/sr-rbd
 public abstract void FromBinary(DataInputStream dis);
예제 #8
0
 public void FromBinary(DataInputStream s) //throws IOException 
 {
     QueryString = s.ReadString();
 }
예제 #9
0
 public void FromBinary(DataInputStream s) //throws IOException 
 {
     base.FromBinary(s);
 }
예제 #10
0
        override public void FromBinary(DataInputStream s)
        {
		    tableVersion = s.readInt();
		    tableName = s.ReadString();
		    tableDump = s.ReadString();
	    }
예제 #11
0
파일: TPCMessage.cs 프로젝트: Mofsy/sr-rbd
 public void FromBinary(DataInputStream s)
 {
     TransactionId = s.ReadString();
 }
예제 #12
0
 //throws IOException
 public void FromBinary(DataInputStream dis)
 {
     Name = dis.readString();
     Version = dis.readInt();
 }
예제 #13
0
 //throws IOException
 public TableVersion(DataInputStream dis)
 {
     FromBinary(dis);
 }
예제 #14
0
파일: DBException.cs 프로젝트: Mofsy/sr-rbd
 public DBException(DataInputStream dis) //throws IOException 
 {
     FromBinary(dis);
 }
예제 #15
0
 public void FromBinary(DataInputStream s) //throws IOException 
 {
     // empty
 }
예제 #16
0
파일: DBException.cs 프로젝트: Mofsy/sr-rbd
 public void FromBinary(DataInputStream dis) //throws IOException 
 {
     vErrorMessage = dis.ReadString();
     vErrorCode = dis.ReadString();
 }
예제 #17
0
 public void FromBinary(DataInputStream s) //throws IOException 
 {
     databaseMessage = s.readString();
 }
예제 #18
0
파일: RestoreNack.cs 프로젝트: Mofsy/sr-rbd
        override public void FromBinary(DataInputStream s)
        {
		    // empty
	    }
예제 #19
0
파일: Message.cs 프로젝트: Mofsy/sr-rbd
 public void fromBinary(DataInputStream dis)
 {
     FromBinary(dis);
 }
예제 #20
0
파일: TcpWorker.cs 프로젝트: Mofsy/sr-rbd
        public void run()
        {
            IPEndPoint address = (IPEndPoint)socket.RemoteEndPoint;
            Logger.getInstance().log("New connection from: "
                + address.ToString(), LOGGING_NAME, Logger.Level.INFO);
            try
            {
                int size;
                int type;
                socket.SendTimeout = 0;
                NetworkStream networkStream = new NetworkStream(socket);
                DataInputStream dis = new DataInputStream(networkStream);

                while (true)
                {
                    try
                    {
                        size = dis.readInt();
                    }
                    catch (EndOfStreamException)
                    {
                        break; // node has disconnected legally
                    }

                    type = dis.readInt();
                    byte[] b = new byte[size];

                    Logger.getInstance().log("Size = " + size,
                            LOGGING_NAME, Logger.Level.INFO);

                    int left;
                    for (left = size; left > 0; )
                        left -= dis.Read(b, size - left, left);

                    Message m = Message.Unserialize(Message.FromInt(type), b, address);
                    storage.put(m);
                }
                Thread.CurrentThread.Abort();
            }
            catch (IOException ex)
            {
                Logger.getInstance().log("Socket exception! " + ex.Message,
                        LOGGING_NAME,
                        Logger.Level.WARNING);
            }
            catch (ThreadInterruptedException ex)
            {
                Logger.getInstance().log("InterruptedException " + ex.Message,
                        LOGGING_NAME,
                        Logger.Level.WARNING);
            }
            catch (InvalidMessageTypeException ex)
            {
                Logger.getInstance().log("InvalidMessageTypeException " + ex.Message,
                        LOGGING_NAME,
                        Logger.Level.WARNING);
            }
            finally
            {
                TcpSender.getInstance().removeNode(address);
            }
        }
예제 #21
0
 public void FromBinary(DataInputStream s)
 {
     base.FromBinary(s);
 }