Examples of BalanceFileReceivingProgress


Examples of com.splout.db.dnode.beans.BalanceFileReceivingProgress

      }
    }

    @Override
    public void onFileReceived(String tablespace, Integer partition, Long version, File file) {
      BalanceFileReceivingProgress progress = getProgressFromLocalPanel(tablespace, partition, version);
      if(file.getName().endsWith(".meta")) {
        progress.metaFileReceived(file);
      } else if(file.getName().endsWith(".db")) {
        progress.binaryFileReceived(file);
      }

      // this can be reached simultaneously by 2 different threads so we must synchronized it
      // (thread that downloaded the .meta file and thread that downloaded the .db file)
      synchronized(FileReceiverCallback.this) {
        if(progress.isReceivedMetaFile() && progress.isReceivedBinaryFile()) {
          // This assures that the move will only be done once
          if(new File(progress.getMetaFile()).exists() && new File(progress.getBinaryFile()).exists()) {
            // check if we already have the binary & meta -> then move partition
            // and then remove this action from the panel so that it's completed.
            try {
              // we need to remove existing files if they exist
              // they might be stalled from old deployments
              File meta = getLocalMetadataFile(tablespace, partition, version);
              if(meta.exists()) {
                meta.delete();
              }
              FileUtils.moveFile(new File(progress.getMetaFile()), meta);
              File binaryToMove = new File(progress.getBinaryFile());
              File binary = new File(getLocalStorageFolder(tablespace, partition, version),
                  binaryToMove.getName());
              if(binary.exists()) {
                binary.delete();
              }
View Full Code Here

Examples of com.splout.db.dnode.beans.BalanceFileReceivingProgress

     * Will obtain a bean to fill some progress in a local hashmap or create it and put it otherwise.
     */
    private synchronized BalanceFileReceivingProgress getProgressFromLocalPanel(String tablespace,
        Integer partition, Long version) {
      String lookupKey = tablespace + "_" + partition + "_" + version;
      BalanceFileReceivingProgress progress = balanceActionsStateMap.get(lookupKey);
      if(progress == null) {
        progress = new BalanceFileReceivingProgress(tablespace, partition, version);
        balanceActionsStateMap.put(lookupKey, progress);
      }
      return progress;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.