Package scfs.cache

Examples of scfs.cache.MetadataCacheOnSyncDirectoryService


   * @throws IOException
   */
  public static void main(String[] args) throws IOException {

    int clientId = Integer.parseInt(args[0]);
    MetadataCacheOnSyncDirectoryService dis = null;
    ArrayList<String> list = new ArrayList<String>(NUM_IT);
    ArrayList<NodeMetadata> mList = new ArrayList<NodeMetadata>(NUM_IT);
    int[] put = new int[NUM_IT-NUM_START];
    int[] get = new int[NUM_IT-NUM_START];
    int[] update = new int[NUM_IT-NUM_START];
    int[] del = new int[NUM_IT-NUM_START];
    int[] getdir = new int[NUM_IT-NUM_START];

    SecretKey defaultKey = null;
    try {
      defaultKey = MyAESCipher.generateSecretKey();
    } catch (Exception e1) {
      e1.printStackTrace();
    }
    try {
      dis = new MetadataCacheOnSyncDirectoryService(new NoCacheDirectoryService(clientId, init("microBench", false, clientId)));
    } catch (DepSpaceException e) {
      e.printStackTrace();
      System.exit(0);
    }

    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)
          put[i-NUM_START] = (int)(System.currentTimeMillis()-start);
      } catch (DirectoryServiceException e) {
        e.printStackTrace();
      }
    }

    //UPDATE
    System.out.println("\t2 - UPDATE FILES.");
    for(int i = 0 ; i<NUM_IT ; i++) {
      try {
        FileStats fs = mList.get(i).getStats();
        fs.setSize(fs.getSize()+10);
        mList.get(i).setStats(fs);

        start = System.currentTimeMillis();
        dis.updateMetadata(list.get(i), mList.get(i));
        if(i>=NUM_START)
          update[i-NUM_START] = (int)(System.currentTimeMillis()-start);
      } catch (DirectoryServiceException e) {
        e.printStackTrace();
      }
    }

    //GET
    System.out.println("\t3 - GET FILES.");
    for(int i = 0 ; i<NUM_IT ; i++) {
      try {
        start = System.currentTimeMillis();
        dis.getMetadata(list.get(i));
        if(i>=NUM_START)
          get[i-NUM_START] = (int)(System.currentTimeMillis()-start);
      } catch (DirectoryServiceException e) {
        e.printStackTrace();
      }
    }

    //GET_DIR
    System.out.println("\t4 - DET DIR.");
    for(int i = 0 ; i<NUM_IT ; i++) {
      try {
        start = System.currentTimeMillis();
        dis.getNodeChildren("/DIR");
        if(i>=NUM_START)
          getdir[i-NUM_START] = (int)(System.currentTimeMillis()-start);
      } catch (DirectoryServiceException e) {
        e.printStackTrace();
      }
    }

    try {
      for(int i = 0; i<NUM_FILES_DIR ; i++){
        dis.removeMetadata("/DIR/000000000000000000000000000000"+i);
      }
      dis.removeMetadata("/DIR");
    } catch (DirectoryServiceException e) {
      e.printStackTrace();
    }
   
   
    //DEL
    System.out.println("\t5 - DELETE FILES.");
    for(int i = 0 ; i<NUM_IT ; i++) {
      try {

        start = System.currentTimeMillis();
        dis.removeMetadata(list.get(i));
        if(i>=NUM_START)
          del[i-NUM_START] = (int)(System.currentTimeMillis()-start);
      } catch (DirectoryServiceException e) {
        e.printStackTrace();
      }
View Full Code Here


    NoCacheDirectoryService noCacheDis = null;
    if(!config.isNonSharing()){
      this.accessor = init("SCFS", false, clientId);
      noCacheDis = new NoCacheDirectoryService(clientId, accessor);
      this.directoryService = new MetadataCacheOnSyncDirectoryService(noCacheDis);
    }else{
      SecretKey k = null;
      this.directoryService = new NoSharingDirectoryService(disId, k, false);
    }
View Full Code Here

TOP

Related Classes of scfs.cache.MetadataCacheOnSyncDirectoryService

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.