예제 #1
0
  public void start() {
    try {
      // Construct and initialize the buffer manager
      this.bufferMgr = new BufferManagerImpl();
      this.bufferMgr.setProcessorBatchSize(processorBatchSize);
      this.bufferMgr.setMaxReserveKB(this.maxReserveKb);
      this.bufferMgr.setMaxProcessingKB(this.maxProcessingKb);
      this.bufferMgr.setInlineLobs(inlineLobs);
      this.bufferMgr.initialize();

      // If necessary, add disk storage manager
      if (useDisk) {
        LogManager.logDetail(
            LogConstants.CTX_DQP, "Starting BufferManager using", bufferDir); // $NON-NLS-1$
        if (!bufferDir.exists()) {
          this.bufferDir.mkdirs();
        }
        // start the file storage manager in clean state
        // wise FileStorageManager is smart enough to clean up after itself
        cleanDirectory(bufferDir);
        // Get the properties for FileStorageManager and create.
        fsm = new FileStorageManager();
        fsm.setStorageDirectory(bufferDir.getCanonicalPath());
        fsm.setMaxOpenFiles(maxOpenFiles);
        fsm.setMaxBufferSpace(maxBufferSpace * MB);
        SplittableStorageManager ssm = new SplittableStorageManager(fsm);
        ssm.setMaxFileSize(maxFileSize);
        fsc = new BufferFrontedFileStoreCache();
        fsc.setMaxStorageObjectSize(maxStorageObjectSize);
        fsc.setDirect(memoryBufferOffHeap);
        int batchOverheadKB =
            (int)
                    (this.memoryBufferSpace < 0
                        ? (this.bufferMgr.getMaxReserveKB() << 8)
                        : this.memoryBufferSpace)
                >> 20;
        this.bufferMgr.setMaxReserveKB(
            Math.max(0, this.bufferMgr.getMaxReserveKB() - batchOverheadKB));
        if (memoryBufferSpace < 0) {
          // use approximately 25% of what's set aside for the reserved
          fsc.setMemoryBufferSpace(((long) this.bufferMgr.getMaxReserveKB()) << 8);
        } else {
          // scale from MB to bytes
          fsc.setMemoryBufferSpace(memoryBufferSpace << 20);
        }
        if (!memoryBufferOffHeap && this.maxReserveKb < 0) {
          // adjust the value
          this.bufferMgr.setMaxReserveKB(
              this.bufferMgr.getMaxReserveKB()
                  - (int)
                      Math.min(
                          this.bufferMgr.getMaxReserveKB(), (fsc.getMemoryBufferSpace() >> 10)));
        }
        fsc.setStorageManager(ssm);
        fsc.initialize();
        this.bufferMgr.setCache(fsc);
        this.workingMaxReserveKb = this.bufferMgr.getMaxReserveKB();
      } else {
        this.bufferMgr.setCache(new MemoryStorageManager());
      }

    } catch (TeiidComponentException e) {
      throw new TeiidRuntimeException(
          RuntimePlugin.Event.TEIID40039, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40039));
    } catch (IOException e) {
      throw new TeiidRuntimeException(
          RuntimePlugin.Event.TEIID40039, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40039));
    }
  }
예제 #2
0
 public long getUsedDiskBufferSpaceMB() {
   if (fsm != null) {
     return fsm.getUsedBufferSpace() / MB;
   }
   return 0;
 }