Examples of IFileSystem


Examples of org.jcoredb.fs.IFileSystem

  }
 
  @Test
  public void createTest() throws Exception
  {
    IFileSystem fs = new FileSystem(Constants.ROOT_PATH);
   
    fs.create(0);
   
    assertTrue(new File(Constants.ROOT_PATH + org.jcoredb.system.Constants.PATH_SEP + 0).exists());
   
    fs.create(Integer.MAX_VALUE);
   
    assertTrue(new File(Constants.ROOT_PATH + org.jcoredb.system.Constants.PATH_SEP + Integer.MAX_VALUE).exists());
  }
View Full Code Here

Examples of org.jcoredb.fs.IFileSystem

  }

  @Override
  public void create() {
   
    IFileSystem fs = FileSystemRegistry.get(new FileSystemRegKey("localhost", Configs.getFSConfig().getRootDir()));
   
    BlockId blockId = new BlockId(containerId);
    Block block = new Block(blockId);
    block.setBytes(data);
   
    try
    {
      blockId = fs.append(block, only);
     
      JSONNode root = JSONHelper.createSuccessNode();
      JSONAttribute containerId = new JSONAttribute("containerId", ""+blockId.getContainerId(), AttrType.Number);
      JSONAttribute segmentId = new JSONAttribute("segmentId", ""+blockId.getSegmentId(), AttrType.Number);
      JSONAttribute id = new JSONAttribute("blockId", ""+blockId.getId(), AttrType.Number);
View Full Code Here

Examples of org.jcoredb.fs.IFileSystem

  }
 
  @Test
  public void deleteTest() throws Exception
  {
    IFileSystem fs = new FileSystem(Constants.ROOT_PATH);
    fs.create(0);
    fs.open();
   
    ArrayList<Block> blocks = new ArrayList<Block>();
    ArrayList<BlockId> blockIds = new ArrayList<BlockId>();
   
    for (int i = 0; i < 200; i++) {

      Block b = new Block(new BlockId(0));
      byte[] content = "<test> <content> Hello world! </content> </test>".getBytes();
      b.setBytes(content);
     
      blocks.add(b);
     
      BlockId bid = fs.append(b, false);

      blockIds.add(bid);
    }

    BlockId toDelete = blockIds.get(100);
   
    fs.delete(toDelete, true);
   
    Block b = fs.read(toDelete);
   
    assertEquals(null, b);
   
    fs.close();
  }
View Full Code Here

Examples of org.jcoredb.fs.IFileSystem

 
  @Test
  public void dropTest() throws Exception
  {
    //Create a File System
    IFileSystem fs = new FileSystem(Constants.ROOT_PATH);
    fs.create(0);
    fs.create(Integer.MAX_VALUE);
    fs.close();
   
    //Open the File System
    fs = new FileSystem(Constants.ROOT_PATH);
    fs.open();
    fs.drop(Integer.MAX_VALUE);
   
    assertTrue(new File(Constants.ROOT_PATH + org.jcoredb.system.Constants.PATH_SEP + 0).exists());
    assertFalse(new File(Constants.ROOT_PATH + org.jcoredb.system.Constants.PATH_SEP + Integer.MAX_VALUE).exists());
  }
View Full Code Here

Examples of org.jcoredb.fs.IFileSystem

  }
 
  @Test
  public void openAndCloseTest() throws Exception
  {
    IFileSystem fs = new FileSystem(Constants.ROOT_PATH);
    fs.create(0);
   
    fs = new FileSystem(Constants.ROOT_PATH);
    fs.open();
   
    FileSystemConfig cfg = Configs.getFSConfig();   
   
    ISegment[] segments = fs.getContainer(0).getSegments();
   
    assertEquals(cfg.getNumOfSegs(), segments.length);
   
    fs.close();
  }
View Full Code Here

Examples of org.jcoredb.fs.IFileSystem

  }
 
  @Test
  public void readTest() throws Exception
  {
    IFileSystem fs = new FileSystem(Constants.ROOT_PATH);
    fs.create(0);
    fs.open();
   
    ArrayList<Block> blocks = new ArrayList<Block>();
    ArrayList<BlockId> blockIds = new ArrayList<BlockId>();
   
    String testStr = "<test> <content> Hello world! </content> </test>";
    byte[] content = testStr.getBytes();
   
    for (int i = 0; i < 200; i++) {

      Block b = new Block(new BlockId(0));
      b.setBytes(content);
     
      blocks.add(b);
     
      BlockId bid = fs.append(b, false);

      blockIds.add(bid);
    }

       
    Block b = fs.read(new BlockId(0,0,111));
   
    assertEquals(testStr, new String(b.getBytes()).substring(0, testStr.length()));
   
    fs.close();
  }
View Full Code Here

Examples of org.jcoredb.fs.IFileSystem

  }

  @Override
  public void create() {
   
    IFileSystem fs = FileSystemRegistry.get(new FileSystemRegKey(Constants.HOST, Configs.getFSConfig().getRootDir()));
   
    BlockId blockId = new BlockId(containerId, segmentId, id);
    Block block = new Block(blockId);
    block.setBytes(data);
   
    try
    {
      fs.write(block);
     
      out.println(JSONHelper.createSuccessNode());
    }
    catch (Exception e) {
     
View Full Code Here

Examples of org.jcoredb.fs.IFileSystem

 
  @Test
  public void writeTest() throws Exception
  {

    IFileSystem fs = new FileSystem(Constants.ROOT_PATH);
    fs.create(0);
    fs.open();
   
    ArrayList<Block> blocks = new ArrayList<Block>();
    ArrayList<BlockId> blockIds = new ArrayList<BlockId>();
   
    String testStr = "<test> <content> Hello world! </content> </test>";
    byte[] content = testStr.getBytes();
   
    for (int i = 0; i < 200; i++) {

      Block b = new Block(new BlockId(0));
      b.setBytes(content);
     
      blocks.add(b);
     
      BlockId bid = fs.append(b, false);

      blockIds.add(bid);
    }
   
    String newTestStr = "<test> <content> Hello world, again! </content> </test>";
    byte[] newContent = newTestStr.getBytes();
 
    Block b = new Block(blockIds.get(78));
    b.setBytes(newContent);
    fs.write(b);
   
   
    Block rB = fs.read(blockIds.get(78));
   
    assertEquals(newTestStr, new String(rB.getBytes()).substring(0, newTestStr.length()))
  }
View Full Code Here

Examples of org.jcoredb.fs.IFileSystem

  }

  @Override
  public void create() {
   
    IFileSystem fs = FileSystemRegistry.get(new FileSystemRegKey(Constants.HOST, Configs.getFSConfig().getRootDir()));
   
    BlockId blockId = new BlockId(containerId, segmentId, id);
   
    try
    {
      fs.delete(blockId, soft);
     
      out.println(JSONHelper.createSuccessNode());
    }
    catch (Exception e) {
     
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.