Package org.jcoredb.fs

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
    {
      Block block = fs.read(blockId);
     
      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


  }

  @Override
  public void create() {
 
    IFileSystem fs = FileSystemRegistry.get(new FileSystemRegKey(Constants.HOST, Configs.getFSConfig().getRootDir()));
   
    IContainer[] cs = fs.getContainers();
       
    JSONNode root = new JSONNode();
   
    JSONAttribute path = new JSONAttribute("path", fs.getPath(), AttrType.String);
   
    root.add(path);
   
    JSONArray childs = new JSONArray("containers");
   
View Full Code Here

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

      Block b = new Block(new BlockId(0));
      b.setBytes(content);     
      blocks[i] = b;
    }

    long startMs = System.currentTimeMillis();
   
    fs.append(blocks, false);
       
    long endMs = System.currentTimeMillis();
   
    System.out.println(endMs - startMs + "ms");
     
View Full Code Here

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

      Block b = new Block(new BlockId(0));
      b.setBytes(content);     
      blocks[i] = b;
    }

    long startMs = System.currentTimeMillis();
   
    fs.append(blocks, false);
       
    long endMs = System.currentTimeMillis();
   
    System.out.println(endMs - startMs + "ms");
     
View Full Code Here

  }

  @Override
  public void create() {
 
    IFileSystem fs = FileSystemRegistry.get(new FileSystemRegKey(Constants.HOST, Configs.getFSConfig().getRootDir()));
   
    try
    {
      fs.drop(id);
     
      out.println(JSONHelper.createSuccessNode());     
    }
    catch (Exception e)
    {
View Full Code Here

   *
   */
  @Override
  public void create() {
   
    IFileSystem fs = FileSystemRegistry.get(new FileSystemRegKey(Constants.HOST, Configs.getFSConfig().getRootDir()));
    IContainer c = fs.getContainer(id);
   
    if (c!=null)
    {
   
      JSONNode root = JSONHelper.createSuccessNode();
View Full Code Here

  }

  @Test
  public void appendTest() throws Exception {
 
    IFileSystem fs = new FileSystem(Constants.ROOT_PATH);
    fs.create(0);
    fs.open();
   
    Block b = new Block(new BlockId(0));
    byte[] content = "<test> <content> Hello world! </content> </test>".getBytes();
    b.setBytes(content);
   
    Block b2 = new Block(new BlockId(0));
    b.setBytes(content);
   
    BlockId bid = fs.append(b, false);
    BlockId bid2 = fs.append(b2, false);
   
    assertEquals(0, bid.getContainerId());
    assertEquals(0, bid.getSegmentId());
    assertEquals(0, bid.getId());
   
    assertEquals(0, bid2.getContainerId());
    assertEquals(0, bid2.getSegmentId());
    assertEquals(1, bid2.getId());
       
    fs.close();
  }
View Full Code Here

  }
 
  @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

  }

  @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

  }
 
  @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

TOP

Related Classes of org.jcoredb.fs.IFileSystem

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.