Exemplo n.º 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();
 }
Exemplo n.º 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));
	    }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 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));
        }
Exemplo n.º 5
0
 //throws IOException
 public override void FromBinary(DataInputStream s)
 {
     Exception = new DBException(s);
 }
Exemplo n.º 6
0
        //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;
        }
Exemplo n.º 7
0
 public abstract void FromBinary(DataInputStream dis);
Exemplo n.º 8
0
 public void FromBinary(DataInputStream s) //throws IOException 
 {
     QueryString = s.ReadString();
 }
Exemplo n.º 9
0
 public void FromBinary(DataInputStream s) //throws IOException 
 {
     base.FromBinary(s);
 }
Exemplo n.º 10
0
        override public void FromBinary(DataInputStream s)
        {
		    tableVersion = s.readInt();
		    tableName = s.ReadString();
		    tableDump = s.ReadString();
	    }
Exemplo n.º 11
0
 public void FromBinary(DataInputStream s)
 {
     TransactionId = s.ReadString();
 }
Exemplo n.º 12
0
 //throws IOException
 public void FromBinary(DataInputStream dis)
 {
     Name = dis.readString();
     Version = dis.readInt();
 }
Exemplo n.º 13
0
 //throws IOException
 public TableVersion(DataInputStream dis)
 {
     FromBinary(dis);
 }
Exemplo n.º 14
0
 public DBException(DataInputStream dis) //throws IOException 
 {
     FromBinary(dis);
 }
Exemplo n.º 15
0
 public void FromBinary(DataInputStream s) //throws IOException 
 {
     // empty
 }
Exemplo n.º 16
0
 public void FromBinary(DataInputStream dis) //throws IOException 
 {
     vErrorMessage = dis.ReadString();
     vErrorCode = dis.ReadString();
 }
Exemplo n.º 17
0
 public void FromBinary(DataInputStream s) //throws IOException 
 {
     databaseMessage = s.readString();
 }
Exemplo n.º 18
0
        override public void FromBinary(DataInputStream s)
        {
		    // empty
	    }
Exemplo n.º 19
0
 public void fromBinary(DataInputStream dis)
 {
     FromBinary(dis);
 }
Exemplo n.º 20
0
        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);
            }
        }
Exemplo n.º 21
0
 public void FromBinary(DataInputStream s)
 {
     base.FromBinary(s);
 }