Package scfs.directoryService

Examples of scfs.directoryService.NodeMetadata


          statistics.getRdev(), Statistics.getReport().length() + getOpsString().length(), statistics.getBlocks(), statistics.getAtime(),
          statistics.getMtime(), statistics.getCtime());
      return 0;
    }

    NodeMetadata metadata = null;
    if(!config.isNonSharing()){
      try {
        metadata = namespace.getMetadata(path);

      } catch (DirectoryServiceConnectionProblemException e) {
        throw new FuseException(e.getMessage()).initErrno(FuseException.ECONNABORTED);
      } catch (DirectoryServiceException e) {
        long time = System.currentTimeMillis();
        try {
          metadata = directoryService.getMetadata(path);
        } catch (DirectoryServiceException e1) {
          throw new FuseException(e1.getMessage()).initErrno(FuseException.ENOENT);
        }
        Statistics.incGetMeta(System.currentTimeMillis()-time);
      }
    }else{
      long time = System.currentTimeMillis();
      try {
        metadata = directoryService.getMetadata(path);
      } catch (DirectoryServiceException e1) {
        throw new FuseException(e1.getMessage()).initErrno(FuseException.ENOENT);
      }
      Statistics.incGetMeta(System.currentTimeMillis()-time);
    }
    FileStats stats = metadata.getStats();
    getattrSetter.set(stats.getInode(), stats.getMode(), stats.getNlink(), Integer.parseInt(System.getProperty("uid")), Integer.parseInt(System.getProperty("gid")),
        stats.getRdev(), stats.getSize(), stats.getBlocks(), stats.getAtime(),
        stats.getMtime(), stats.getCtime());

    return 0;
View Full Code Here


    try {

      String[] vec = dividePath(path);
      String idPath = getNextIdPath();
      FileStats fs = createDefaultFileStats(NodeType.DIR, Long.parseLong(idPath), mode);
      NodeMetadata m = new NodeMetadata(NodeType.DIR, vec[0], vec[1], fs, idPath, defaultKey, new int[]{clientId}, new int[]{clientId});

      long time = System.currentTimeMillis();
      directoryService.putMetadata(m);
      Statistics.incPutMeta(System.currentTimeMillis()-time);
      //      }
View Full Code Here

      String idPath = getNextIdPath();

      FileStats fs = createDefaultFileStats(NodeType.FILE, Long.parseLong(idPath), mode);
      fs.setMode(mode);
      fs.setRdev(rdev);
      NodeMetadata m = new NodeMetadata(NodeType.FILE, vec[0], vec[1], fs, idPath, MyAESCipher.generateSecretKey(), new int[]{clientId}, new int[]{clientId});

      long time = System.currentTimeMillis();
      directoryService.putMetadata(m);
      Statistics.incPutMeta(System.currentTimeMillis()-time);
View Full Code Here

    numOp[9]++;

    if(path.equals("/.statistics.txt"))
      return 0;
    NodeMetadata nm = null;
    if(!config.isNonSharing()){

      nm = this.getMetadata(path);

      if ((flags & SCFSConstants.O_ACCMODE) == O_WRONLY || (flags & SCFSConstants.O_ACCMODE) == O_RDWR && !nm.getStats().isPrivate()) { 
        if(lockService.tryAcquire(nm.getId_path(), LOCK_TIME)){
          lockedFiles.put(nm.getId_path(), true);
        }else{
          throw new FuseException("No Lock available.").initErrno(FuseException.ENOLCK);
        }
      }
    }else {
      try {
        long time = System.currentTimeMillis();
        nm = directoryService.getMetadata(path);
        Statistics.incGetMeta(System.currentTimeMillis() - time);
      } catch (DirectoryServiceException e1) {
        throw new FuseException(e1.getMessage()).initErrno(FuseException.ENOENT);
      }
    }


    daS.updateCache(nm.getId_path(), nm.getKey(), nm.getStats().getDataHash(), nm.getStats().isPending());
    openSetter.setFh(nm);

    return 0;
  }
View Full Code Here

    return 0;
  }

  private NodeMetadata getMetadata(String path) throws FuseException{
    boolean inPNS = true;
    NodeMetadata nm = null;
    try{
      nm = namespace.getMetadata(path);

    } catch (DirectoryServiceConnectionProblemException e) {
      throw new FuseException(e.getMessage()).initErrno(FuseException.ECONNABORTED);
    }catch (DirectoryServiceException e) {
      try {
        long time = System.currentTimeMillis();
        nm = directoryService.getMetadata(path);
        inPNS=false;
        Statistics.incGetMeta(System.currentTimeMillis() - time);
      } catch (DirectoryServiceException e1) {
        throw new FuseException(e.getMessage()).initErrno(FuseException.ENOENT);
      }
    }
    nm.getStats().setPrivate(inPNS);
    return nm;

  }
View Full Code Here

  public int read(String path, Object fh, ByteBuffer buf, long offset) throws FuseException {
    Printer.println("\n :::: READ( " + path + ", offset:" + offset + " )", "amarelo");

    numOp[10]++;

    NodeMetadata metadata = this.getMetadata(path);
    if (path.equals("/.statistics.txt") || !metadata.isDirectory() && !metadata.getStats().isPending()) {

      byte[] value = null;

      if(path.equals("/.statistics.txt")){
        value = Statistics.getReport().concat("\n").concat(getOpsString()).getBytes();
        for(int i=0;i<numOp.length;i++){
          numOp[i]=0;
        }
        Statistics.reset();
      }else
        value = daS.readData(metadata.getId_path(), (int)offset, buf.capacity(), metadata.getKey(), metadata.getStats().getDataHash(), metadata.getStats().isPending());

      if(value == null)
        throw new FuseException("Cannot read.").initErrno(FuseException.EIO);
      try{
        buf.put(value);
View Full Code Here

    if(path.equals("/.statistics.txt"))
      return 0;

    try {
      NodeMetadata metadata = this.getMetadata(path);
      byte[] a = new byte[buf.capacity()];
      int i = 0;
      while (buf.hasRemaining()) {
        a[i] = buf.get();
        i++;
      }
      int size = daS.writeData(metadata.getId_path(), a, (int)offset);
      if(size==-1)
        throw new FuseException("IOException on write.").initErrno(FuseException.ECONNABORTED);

      NodeMetadata meta = null;
      try {
        meta = (NodeMetadata) metadata.clone();
      } catch (CloneNotSupportedException e) { e.printStackTrace()}
      meta.getStats().setSize(size);
      meta.getStats().setPending(false);
      metadata.getStats().setSize(size);
      metadata.getStats().setPending(false);
      if(!config.isNonSharing() && namespace.containsMetadata(path))
        namespace.insertMetadataInBuffer(metadata.getId_path(), meta);
      else
View Full Code Here

    Printer.println("\n :::: RENAME( from: " + from + ", to: " + to + " )", "amarelo");
    if(from.equals("/.statistics.txt"))
      return 0;

    String[] vec = dividePath(to);
    NodeMetadata metadata=null;
    if(!config.isNonSharing()){
      boolean isInPNS;
      try {
        metadata = namespace.getMetadata(from);
        isInPNS = true;
      } catch (DirectoryServiceException e) {
        try {
          long time = System.currentTimeMillis();
          metadata = directoryService.getMetadata(from);
          Statistics.incGetMeta(System.currentTimeMillis() - time);
        } catch (DirectoryServiceException e1) {
          throw new FuseException(e.getMessage()).initErrno(FuseException.ECONNABORTED);
        }
        isInPNS = false;
      }


      try{
        if(isInPNS){
          namespace.updateMetadata(from, new NodeMetadata(metadata.getNodeType(), vec[0], vec[1], metadata.getStats(), metadata.getId_path(), metadata.getKey(), metadata.getC_r(), metadata.getC_w()));
        }else{
          NodeMetadata node=null;

          node = new NodeMetadata(metadata.getNodeType(), vec[0], vec[1], metadata.getStats(), metadata.getId_path(), metadata.getKey(), metadata.getC_r(), metadata.getC_w());

          long time = System.currentTimeMillis();
          directoryService.updateMetadata(from, node);
          Statistics.incUpdateMeta(System.currentTimeMillis() - time);

        }
      } catch (DirectoryServiceConnectionProblemException e) {
        throw new FuseException(e.getMessage()).initErrno(FuseException.ECONNABORTED);
      } catch (DirectoryServiceException e) {
        throw new FuseException(e.getMessage()).initErrno(FuseException.ECONNABORTED);
      }
    }else{
      try {
        long time = System.currentTimeMillis();
        metadata = directoryService.getMetadata(from);
        Statistics.incGetMeta(System.currentTimeMillis() - time);

        NodeMetadata node=new NodeMetadata(metadata.getNodeType(), vec[0], vec[1], metadata.getStats(), metadata.getId_path(), metadata.getKey(), metadata.getC_r(), metadata.getC_w());

        time = System.currentTimeMillis();
        directoryService.updateMetadata(from, node);
        Statistics.incUpdateMeta(System.currentTimeMillis() - time);
      } catch (DirectoryServiceException e1) {
View Full Code Here

    if(path.equals("/.statistics.txt"))
      return 0;

    numOp[0]++;

    NodeMetadata metadata=null;
    if(!config.isNonSharing()){
      boolean isInPNS;
      try {
        metadata = namespace.getMetadata(path);
        isInPNS = true;
      } catch (DirectoryServiceException e1) {
        try {
          long time = System.currentTimeMillis();
          metadata = directoryService.getMetadata(path);
          Statistics.incGetMeta(System.currentTimeMillis() - time);
        } catch (DirectoryServiceException e) {
          throw new FuseException(e.getMessage()).initErrno(FuseException.ECONNABORTED);
        }
        isInPNS = false;
      }

      if (mode == metadata.getStats().getMode())
        return 0;

      try {
        FileStats fs = metadata.getStats();
        fs.setMode(mode);
        NodeMetadata node = new NodeMetadata(metadata.getNodeType(), metadata.getParent(), metadata.getName(), fs, metadata.getId_path(), metadata.getKey(), ((mode & SCFSConstants.S_IRGRP) == 0 && (mode & SCFSConstants.S_IROTH) == 0) ? new int[] { clientId } : null, metadata.getC_w());

        if(isInPNS){
          namespace.updateMetadata(path, node);
        }else{
          long time = System.currentTimeMillis();
          directoryService.updateMetadata(path, node);
          Statistics.incUpdateMeta(System.currentTimeMillis() - time);
        }
      } catch (DirectoryServiceConnectionProblemException e) {
        throw new FuseException(e.getMessage()).initErrno(FuseException.ECONNABORTED);
      } catch (DirectoryServiceException e) {
        e.printStackTrace();
        throw new FuseException(e.getMessage()).initErrno(FuseException.ECONNABORTED);
      }
    }else{
      try {
        long time = System.currentTimeMillis();
        metadata = directoryService.getMetadata(path);
        Statistics.incGetMeta(System.currentTimeMillis() - time);

        if (mode == metadata.getStats().getMode())
          return 0;

        FileStats fs = metadata.getStats();
        fs.setMode(mode);
        NodeMetadata node = new NodeMetadata(metadata.getNodeType(), metadata.getParent(), metadata.getName(), fs, metadata.getId_path(), metadata.getKey(), ((mode & SCFSConstants.S_IRGRP) == 0 && (mode & SCFSConstants.S_IROTH) == 0) ? new int[] { clientId } : null, metadata.getC_w());

        time = System.currentTimeMillis();
        directoryService.updateMetadata(path, node);
        Statistics.incUpdateMeta(System.currentTimeMillis() - time);
View Full Code Here

    Printer.println("\n :::: FLUSH( " + path + " )", "amarelo");
    if(path.equals("/.statistics.txt"))
      return 0;

    numOp[2]++;
    NodeMetadata mdata = (NodeMetadata) fh;
    if(mdata != null && !mdata.getStats().isPending()){
      daS.syncWClouds(mdata.getId_path(), mdata.getKey());
    }

    return 0;
  }
View Full Code Here

TOP

Related Classes of scfs.directoryService.NodeMetadata

Copyright © 2018 www.massapicom. 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.