Ejemplo n.º 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));
    }
  }
Ejemplo n.º 2
0
 public long getDiskWriteCount() {
   if (fsc != null) {
     return fsc.getStorageWrites();
   }
   return 0;
 }
Ejemplo n.º 3
0
 public long getMemoryBufferUsedKB() {
   if (fsc != null) {
     return fsc.getMemoryInUseBytes() >> 10;
   }
   return 0;
 }
Ejemplo n.º 4
0
 public long getDiskReadCount() {
   if (fsc != null) {
     return fsc.getStorageReads();
   }
   return 0;
 }