Example #1
0
  public OMultiFileSegment(
      final OStorageLocal iStorage,
      final OStorageSegmentConfiguration iConfig,
      final String iFileExtension,
      final int iRoundMaxSize)
      throws IOException {
    super(iStorage, iConfig.name);

    config = iConfig;
    fileExtension = iFileExtension;
    type = iConfig.fileType;
    defrag = iConfig.defrag;
    maxSize = OFileUtils.getSizeAsNumber(iConfig.maxSize);
    fileStartSize = (int) OFileUtils.getSizeAsNumber(iConfig.fileStartSize);
    final int tmpFileMaxSize = (int) OFileUtils.getSizeAsNumber(iConfig.fileMaxSize);
    fileIncrementSize = (int) OFileUtils.getSizeAsNumber(iConfig.fileIncrementSize);

    if (iRoundMaxSize > 0)
      // ROUND THE FILE SIZE TO AVOID ERRORS ON ROUNDING BY DIVIDING FOR FIXED RECORD SIZE
      fileMaxSize = (tmpFileMaxSize / iRoundMaxSize) * iRoundMaxSize;
    else fileMaxSize = tmpFileMaxSize;
    // INSTANTIATE ALL THE FILES
    int perFileMaxSize;

    if (iConfig.infoFiles.length == 0) {
      // EMPTY FILE: CREATE THE FIRST FILE BY DEFAULT
      files = new OFile[1];
      files[0] =
          OFileFactory.instance()
              .create(
                  type,
                  iStorage
                      .getVariableParser()
                      .resolveVariables(
                          config.getLocation() + "/" + name + "." + 0 + fileExtension),
                  iStorage.getMode());
      perFileMaxSize = fileMaxSize;
      files[0].setMaxSize(perFileMaxSize);
      files[0].setIncrementSize(fileIncrementSize);

    } else {
      files = new OFile[iConfig.infoFiles.length];
      for (int i = 0; i < files.length; ++i) {
        files[i] =
            OFileFactory.instance()
                .create(
                    type,
                    iStorage.getVariableParser().resolveVariables(iConfig.infoFiles[i].path),
                    iStorage.getMode());
        perFileMaxSize = fileMaxSize;

        files[i].setMaxSize(perFileMaxSize);
        files[i].setIncrementSize(fileIncrementSize);
      }
    }
  }
Example #2
0
 public OSingleFileSegment(
     final OStorageLocal iStorage, final OStorageFileConfiguration iConfig, final String iType)
     throws IOException {
   config = iConfig;
   storage = iStorage;
   file =
       OFileFactory.instance()
           .create(
               iType,
               iStorage.getVariableParser().resolveVariables(iConfig.path),
               iStorage.getMode());
   file.setMaxSize((int) OFileUtils.getSizeAsNumber(iConfig.maxSize));
   file.setIncrementSize((int) OFileUtils.getSizeAsNumber(iConfig.incrementSize));
 }
  @After
  public void tearDown() {
    testDocumentTx.activateOnCurrentThread();
    testDocumentTx.drop();

    baseDocumentTx.activateOnCurrentThread();
    baseDocumentTx.drop();

    OFileUtils.deleteRecursively(buildDir);
    Assert.assertFalse(buildDir.exists());
  }
Example #4
0
  public boolean open() throws IOException {
    boolean softClosed = file.open();
    if (!softClosed) {
      // LAST TIME THE FILE WAS NOT CLOSED IN SOFT WAY
      OLogManager.instance()
          .warn(
              this,
              "segment file '%s' was not closed correctly last time",
              OFileUtils.getPath(file.getName()));
      wasSoftlyClosedAtPreviousTime = false;
    }

    return softClosed;
  }
  public void create() throws Exception {
    OGlobalConfiguration.STORAGE_KEEP_OPEN.setValue(false);
    OFileUtils.deleteRecursively(new File("servers"));

    String confDir = System.getProperty("g1.server.conf.dir");
    if (confDir == null) {
      confDir = "target/classes";
      System.setProperty("g1.server.conf.dir", confDir);
    }

    String databaseUrl = getDatabaseURL();

    initializeExceptionRecordTable(databaseUrl);
  }
Example #6
0
 public void open() throws IOException {
   // @TODO: LAZY OPEN FILES
   for (OFile file : files)
     if (!file.open()) {
       // LAST TIME THE FILE WAS NOT CLOSED IN SOFT WAY
       OLogManager.instance()
           .warn(
               this,
               "segment file '%s' was not closed correctly last time",
               OFileUtils.getPath(file.getName()));
       // TODO VERIFY DATA?
       wasSoftlyClosedAtPreviousTime = false;
     }
 }
Example #7
0
  private void addInfoFileConfigEntry(final OFile file) throws IOException {
    OStorageFileConfiguration[] newConfigFiles =
        new OStorageFileConfiguration[config.infoFiles.length + 1];
    for (int i = 0; i < config.infoFiles.length; ++i) newConfigFiles[i] = config.infoFiles[i];
    config.infoFiles = newConfigFiles;

    // CREATE A NEW ENTRY FOR THE NEW FILE
    String fileNameToStore =
        storage.getVariableParser().convertPathToRelative(OFileUtils.getPath(file.getPath()));

    final OStorageSegmentConfiguration template = config.root.fileTemplate;

    config.infoFiles[config.infoFiles.length - 1] =
        new OStorageFileConfiguration(
            config,
            fileNameToStore,
            template.fileType,
            template.fileMaxSize,
            template.fileIncrementSize);
  }