Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. package backer;
  2.  
  3. /**
  4. * Class that contains all the constants that
  5. * Backer needs to run.
  6. *
  7. * @author João Loureiro
  8. */
  9.  
  10. public class Constants {
  11.  
  12. /** Size of the array that is used in the DatagramPackets. */
  13. public static final int DATAGRAM_DATA_SIZE = 65500;
  14.  
  15. /** Offset used for the extraction of data from a DatagramPacket. */
  16. public static final int DATAGRAM_DATA_OFFSET = 0;
  17.  
  18. /** Message type that a peer sends when backing up a chunk. */
  19. public static final String PUTCHUNK = "PUTCHUNK";
  20.  
  21. public static final int PUTCHUNK_MAX_ATTEMPTS = 5;
  22.  
  23. public static final String STORED = "STORED";
  24.  
  25. /** Version 1.0 */
  26. public static final String VERSION_1_0 = "1.0";
  27.  
  28. /** Header terminator string. */
  29. public static final String CRLF = "\r\n\r\n";
  30.  
  31. /** Encoding used in the packets exchanged. */
  32. public static final String ENCODING = "ISO-8859-1";
  33.  
  34. /** Regex that represents whitespaces */
  35. public static final String WHITESPACE_REGEX = "\\s";
  36.  
  37. public static final long ONE_SECOND = 1000;
  38.  
  39. public static final int SENDER_ID_LIMIT = 1000;
  40.  
  41. public static final int FOUR_HUNDRED_MILLISECONDS = 400;
  42.  
  43. public static final String PEER_DATABASE_NAME = "peer.db";
  44.  
  45. public static final String PEER_DATABASE_TABLE = "CREATE TABLE `Chunk` ( `ID` TEXT NOT NULL, `size` INTEGER NOT NULL, `perceived_replication_degree` INTEGER NOT NULL, PRIMARY KEY(`ID`));";
  46.  
  47. public static final String PEER_DATABASE_TABLE_CHECK = "SELECT name FROM sqlite_master WHERE type='table' AND name='Chunk';";
  48.  
  49. public static final String PEER_DATABASE_TABLE_CHECK_COLUMNS = "PRAGMA table_info(Chunk)";
  50.  
  51. public static final String PEER_DATABASE_SELECT = "SELECT * FROM Chunk WHERE ID='%s%s';";
  52.  
  53. public static final String PEER_DATABASE_INSERT = "INSERT INTO `Chunk`(`ID`,`size`, `perceived_replication_degree`) VALUES ('%s%s',%d,%d);";
  54.  
  55. public static final String DATABASE_DIRECTORY = "build/";
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement