Package scfs.directoryService

Examples of scfs.directoryService.NodeMetadata


  @Override
  public int getxattrsize(String path, String name, FuseSizeSetter setter)
      throws FuseException {
    Printer.println("\n :::: GETXATTRSIZE(" + path + ", name: " + name + " )", "amarelo");

    NodeMetadata m = null;
    if(!config.isNonSharing()){
      m = this.getMetadata(path);
      byte[] array = m.getStats().getXattr().get(name);
      if(array!=null)
        setter.setSize(array.length);
    }
    return 0;
  }
View Full Code Here


  @Override
  public int listxattr(String path, XattrLister list) throws FuseException {
    Printer.println("\n :::: LISTXATTR(" + path + " )", "amarelo");

    NodeMetadata m = null;
    if(!config.isNonSharing()){
      m = this.getMetadata(path);
      for(String name : m.getStats().getXattr().keySet())
        list.add(name);
    }
    return 0;
  }
View Full Code Here

  @Override
  public int removexattr(String path, String name) throws FuseException {
    Printer.println("\n :::: REMOVEXATTR(" + path + ", name: " + name + " )", "amarelo");

    NodeMetadata m = null;
    if(!config.isNonSharing()){
      m=this.getMetadata(path);
    }
    byte[] array = m.getStats().getXattr().remove(name);
    if(array!=null){

      try {
        if(m.getStats().isPrivate())
          namespace.updateMetadata(path, m);
        else
          directoryService.updateMetadata(path, m);
      } catch (DirectoryServiceException e) {
        throw new FuseException(e.getMessage()).initErrno(FuseException.ENOENT);
View Full Code Here

    int perm = value.getShort();
    int id = value.getInt();

    try {
      boolean inPNS = true;
      NodeMetadata m = null;
      if(!config.isNonSharing()){
        try {
          m = namespace.getMetadata(path);
        } catch (DirectoryServiceException e) {
          inPNS = false;
        }
      }else{
        inPNS=false;
      }
      if(!inPNS)
        m = directoryService.getMetadata(path);
      m.getStats().getXattr().put(name, buff);


      LinkedList<Pair<String, String>> cannonicalIds=new LinkedList<Pair<String,String>>();
      if(!config.isNonSharing()){
        try{
          List<String[]> l = directoryService.getCredentials(id);
          for(String[] sx : l)
            cannonicalIds.add(new Pair<String, String>(sx[0], sx[1]));
        }catch (DirectoryServiceConnectionProblemException e){
          System.err.println("DirectoryServiceConnectionProblemException - getCredential.");
        }catch (DirectoryServiceException e){
          System.err.println("DirectoryServiceException - getCredential.");
        }


        if(perm!=1){
          if(perm == 4 || perm == 5){
            daS.setPermition( m.getId_path(),"r", cannonicalIds);
            updated=privateToPublic(path, m, id);
          }else if(perm == 2 || perm == 3){
            daS.setPermition( m.getId_path(),"w", cannonicalIds);
            updated=privateToPublic(path, m, id);

          }else if(perm == 0){
            daS.setPermition( m.getId_path(),"", cannonicalIds);
            if(!m.getStats().isPrivate())
              updated=publicToPrivate(path, m, id);
          }else{
            daS.setPermition( m.getId_path(), "rw",cannonicalIds);
            updated=privateToPublic(path, m, id);
          }
        }else{
          daS.setPermition( m.getId_path(),"",cannonicalIds);
          updated=publicToPrivate(path, m, id);
        }
      }

      if(!updated){
View Full Code Here


  @Override
  public NodeMetadata getMetadata(String path) throws DirectoryServiceException {

    NodeMetadata metadata = null;   
    if(!inCache(path)){
      metadata = directoryService.getMetadata(path);
    }else{
      if( DELTA_TIME>0 && System.currentTimeMillis() <= (pathToMetadata.get(path).getTime()+DELTA_TIME)){
        metadata = pathToMetadata.get(path).getMetadata();
      }else{
        pathToMetadata.remove(path);
        metadata = directoryService.getMetadata(path);
      }

    }


    if(!inCache(path) && DELTA_TIME>0 ){
      pathToMetadata.put(path, new MetadataCacheEntry(metadata, System.currentTimeMillis(), false, -1));
    }
    NodeMetadata res = null;

    if(buffer.containsKey(metadata.getId_path())){
      try {
        res = (NodeMetadata) metadata.clone();
        res.getStats().setDataHash(buffer.get(metadata.getId_path()).getStats().getDataHash());
        res.getStats().setSize(buffer.get(metadata.getId_path()).getStats().getSize());
        res.getStats().setPending(buffer.get(metadata.getId_path()).getStats().isPending());
      } catch (CloneNotSupportedException e) {
        e.printStackTrace();
      }

      return res;
View Full Code Here


    for(NodeMetadata m : links){
      if(buffer.containsKey(m.getId_path())){
        try {
          NodeMetadata res = (NodeMetadata) m.clone();
          res.getStats().setDataHash(buffer.get(m.getId_path()).getStats().getDataHash());
          res.getStats().setSize(buffer.get(m.getId_path()).getStats().getSize());
          res.getStats().setPending(buffer.get(m.getId_path()).getStats().isPending());
          result.add(res);
        } catch (CloneNotSupportedException e) {
          e.printStackTrace();
        }
View Full Code Here

  }

  @Override
  public void commitMetadataBuffer(String idPath, byte[] hash) throws DirectoryServiceException {

    NodeMetadata m_buffer =null;
    if(buffer.containsKey(idPath))
      m_buffer = buffer.get(idPath);

    Collection<NodeMetadata> list;
    try{
      list = directoryService.getAllLinks(idPath);
    }catch (DirectoryServiceException e) {
      e.printStackTrace();
      return;
    }
    for(NodeMetadata m_new : list ){
      if(m_buffer != null)
        m_new.getStats().setSize(m_buffer.getStats().getSize());

      m_new.getStats().setDataHash(hash);
      m_new.getStats().setPending(false);
      directoryService.updateMetadata(m_new.getPath(), m_new);
    }
View Full Code Here

  public void readExternal(ObjectInput in) throws IOException,
      ClassNotFoundException {
    int len = in.readInt();
    for(int i = 0; i<len ; i++){
      String key = in.readUTF();
      NodeMetadata m = new NodeMetadata();
      m.readExternal(in);
      this.put(key, m);
    }
  }
View Full Code Here

  }

  public void run(){
    for(int i=0 ; i<2000 ; i++){
      try{
        dis.putMetadata(new NodeMetadata(NodeType.DIR, "/", i+"", SCFS.createDefaultFileStats(NodeType.DIR, 0, 0), "", MyAESCipher.generateSecretKey(), new int[]{4}, new int [] {4}));
      }catch (DirectoryServiceException e){
        e.printStackTrace();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    for(int i=0 ; i<2000 ; i++){
      try{
        dis.updateMetadata("/"+i, new NodeMetadata(NodeType.DIR, "/", i+"", SCFS.createDefaultFileStats(NodeType.DIR, 0, 0), "", MyAESCipher.generateSecretKey(), new int[]{4}, new int [] {4}));

      }catch (DirectoryServiceException e){
        e.printStackTrace();
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here

    System.out.println("Will Start Now.");
    long start;
    System.out.println("\t0 - ALLOCATING RESOURCES.");
    start = System.currentTimeMillis();
    NodeMetadata m = new NodeMetadata(NodeType.DIR, "/", "DIR" , createDefaultFileStats(NodeType.DIR, start, 0), ""+clientId+start, defaultKey, new int[] {clientId}, new int[] {clientId});
    try {
      dis.putMetadata( m );
    } catch (DirectoryServiceException e) {
      e.printStackTrace();
    }

    for(int i=0; i<NUM_FILES_DIR ; i++){
      m = new NodeMetadata(NodeType.FILE, "/DIR", "000000000000000000000000000000" + i, createDefaultFileStats(NodeType.FILE, start, 0), ""+clientId+start, defaultKey, new int[] {clientId}, new int[] {clientId});
    }
    //PUT
    System.out.println("\t1 - PUT FILES.");
    for(int i = 0 ; i<NUM_IT ; i++) {
      String parent = "/";
      list.add(parent.concat("/000000000000000000000000000000" + i));

      start = System.currentTimeMillis();
      m = new NodeMetadata(NodeType.FILE, parent, "000000000000000000000000000000" + i, createDefaultFileStats(NodeType.FILE, start, 0), ""+clientId+start, defaultKey, new int[] {clientId}, new int[] {clientId});
      mList.add(m);
      try {
        start = System.currentTimeMillis();
        dis.putMetadata( m );
        if(i>=NUM_START)
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.