private void getChunkProcess() {
    Chunk ch = null;
    Boolean found = false;
    for (int i = 0; i < Main.getDatabase().getChunksSize(); i++) {
      ch = Main.getDatabase().getChunk(i);
      if (ch.getFileId().equals(header.get(2))
          && (ch.getChunkNo() == Integer.parseInt(header.get(3)))) {
        found = true;
        break;
      }
    }

    if (found) {
      FileManager chunk = new FileManager(header.get(2), 0, true);
      chunk.readChunk(Integer.parseInt(header.get(3)), Main.getDatabase().getUsername());

      String ip = "";
      try {
        ip = InetAddress.getLocalHost().toString().split("/")[1];
      } catch (UnknownHostException e) {
        e.printStackTrace();
      }

      int tcp_port = Main.getTCPport();
      String message =
          "ME "
              + header.get(2)
              + " "
              + header.get(3)
              + " "
              + ip
              + " "
              + tcp_port
              + Main.getCRLF()
              + Main.getCRLF();

      byte[] msg = message.getBytes(StandardCharsets.ISO_8859_1);
      Main.getRestore().send(msg);
      Main.getLogger().log("Received: " + message);

      try {
        TCPCommunicator tcpSocket = new TCPCommunicator(ip, tcp_port, true);
        String chunkMsg =
            "CHUNK " + header.get(2) + " " + header.get(3) + Main.getCRLF() + Main.getCRLF();

        Main.getLogger().log("Sent: " + chunkMsg);

        byte[] chunkBytes =
            Main.appendArray(chunkMsg.getBytes(StandardCharsets.ISO_8859_1), chunk.getChunkData());
        tcpSocket.send(chunkBytes);

        tcpSocket.close();

      } catch (SocketTimeoutException e) {
        System.out.println("I was not the chosen one!");
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
 private void removedProcess() {
   for (int i = 0; i < Main.getDatabase().getChunksSize(); i++) {
     Chunk chunk = Main.getDatabase().getChunk(i);
     if (chunk.getFileId().equals(header.get(2))
         && (chunk.getChunkNo() == Integer.parseInt(header.get(3)))) {
       chunk.setKnownReps(-1);
       if (chunk.getKnownReps() < chunk.getRepDegree()) {
         BackupSend send =
             new BackupSend(
                 chunk.getFileId(),
                 chunk.getRepDegree(),
                 false,
                 chunk.getChunkNo(),
                 chunk.getKnownReps());
         Main.getBackup().addSending(send);
         Main.getService().submit(send);
       }
       break;
     }
   }
 }
  private void storedProcess() {

    for (int j = 0; j < Main.getBackup().getSending().size(); j++) {
      if (Main.getBackup().getSending().get(j).getFileHash().equals(header.get(2))) {
        Main.getBackup().getSending().get(j).incStoreds(1);
        break;
      }
    }

    for (int i = 0; i < Main.getDatabase().getChunksSize(); i++) {
      Chunk chunk = Main.getDatabase().getChunk(i);
      if (chunk.getFileId().equals(header.get(2))
          && (chunk.getChunkNo() == Integer.parseInt(header.get(3)))) {
        chunk.setKnownReps(1);
        break;
      }
    }
  }