Warmup subreport cache
551351
public function warmupSubreport(string $subreport): Resultable
	{
		$subreport = $this->introspection->getService($subreport);

		if (!($subreport instanceof Subreport)) {
			throw new InvalidStateException(sprintf('Service "%s" is not subreport', get_class($subreport)));
		}

		return $subreport->getDataSource()->compile($subreport->getParameters());
	}
1188156
@Override
	public void cacheResult(CommerceSubscriptionEntry commerceSubscriptionEntry) {
		entityCache.putResult(CommerceSubscriptionEntryModelImpl.ENTITY_CACHE_ENABLED,
			CommerceSubscriptionEntryImpl.class,
			commerceSubscriptionEntry.getPrimaryKey(), commerceSubscriptionEntry);

		finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
			new Object[] {
				commerceSubscriptionEntry.getUuid(),
				commerceSubscriptionEntry.getGroupId()
			}, commerceSubscriptionEntry);

		finderCache.putResult(FINDER_PATH_FETCH_BY_C_C_C,
			new Object[] {
				commerceSubscriptionEntry.getCPInstanceUuid(),
				commerceSubscriptionEntry.getCProductId(),
				commerceSubscriptionEntry.getCommerceOrderItemId()
			}, commerceSubscriptionEntry);

		commerceSubscriptionEntry.resetOriginalValues();
	}
585862
public function __constructSubReport()
    {
        $this->registerEvent(
            "OnInit",
            function () {
                $params = array_merge($this->params, $_POST);
                if (isset($params["@subReport"])) {
                    $name = $params["@subReport"];
                    unset($params["@subReport"]);
                    $settings = $this->settings();
                    $subReports = Utility::get($settings, "subReports");
                    $class = Utility::get($subReports, $name);
                    if ($class!=null) {
                        $params["@reportName"] = $name;
                        $r = new $class($params);
                        echo "<subreport-partial>";
                        $r->run()->render();
                        echo "</subreport-partial>";
                    } else {
                        header("HTTP/1.1 404 Could not find [$name] sub report");
                    }
                    exit;              
                }    
            }
        );
        $this->registerEvent(
            "OnResourceInit",
            function () {
                $this->getResourceManager()->addScriptFileOnBegin(
                    $this->getResourceManager()->publishAssetFolder(
                        realpath(dirname(__FILE__)."/../clients/core")
                    )."/KoolReport.subReport.js"
                );
            }
        );
    }
1034556
public void onCacheHit(String template, int locality) {
        final String methodName = "onCacheHit()";

        CacheStatsModule csm = null;
        if ((csm = getCSM(template)) == null) {
            return;
        }
        if (tc.isDebugEnabled())
            Tr.debug(tc, methodName + " cacheName=" + _sCacheName + " template=" + template + " locality=" + locality + " enable=" + csm._enable
                    + " parentEnable=" + _enable + " " + this);

        switch (locality) {
        case REMOTE:
            if (csm._enable) {
                if (csm._remoteHitCount != null) {
                    csm._remoteHitCount.increment();
                }
                if (csm._inMemoryAndDiskCacheEntryCount != null) {
                    csm._inMemoryAndDiskCacheEntryCount.increment();
                }
                if (csm._remoteCreationCount != null) {
                    csm._remoteCreationCount.increment();
                }
            }
            break;
        case MEMORY:
            if (csm._enable && csm._hitsInMemoryCount != null)
                csm._hitsInMemoryCount.increment();
            break;
        case DISK:
            if (_csmDisk != null && _csmDisk._enable && _csmDisk._hitsOnDisk != null) {
                _csmDisk._hitsOnDisk.increment();
            }
            if (csm._enable && csm._hitsOnDiskCount != null)
                csm._hitsOnDiskCount.increment();
            break;
        default:
            if (tc.isDebugEnabled())
                Tr.debug(tc, methodName + " Error - Unrecognized locality " + locality + " cacheName=" + _sCacheName);
            break;
        }
        return;
    }
63934
public function warmUp($cacheDir): void
    {
        if ($this->configLoader instanceof WarmableInterface) {
            $this->configLoader->warmUp($cacheDir);
        }
    }
855829
public function warmUp($cacheDir)
    {
        $locator      = $this->locator->getLocator();
        $allTemplates = $this->finder->findAllTemplates();
        $templates    = [];
        foreach ($allTemplates as $template) {
            $this->locateTemplate($locator, $template, $templates);
        }
        
        $this->writeCacheFile($cacheDir . '/templates.php', sprintf('<?php return %s;', var_export($templates, true)));
    }
1211907
function onCacheResponse (
  error, record, recordName, socketWrapper, onComplete, onError, options, context, metaData
) {
  if (error) {
    sendError(
      C.EVENT.RECORD_LOAD_ERROR,
      `error while loading ${recordName} from cache:${error.toString()}`,
      recordName,
      socketWrapper,
      onError,
      options,
      context,
      metaData
    )
  } else if (record) {
    onComplete.call(context, record, recordName, socketWrapper)
  } else if (
      !options.storageExclusion ||
      !options.storageExclusion.test(recordName)
    ) {

    let storageTimedOut = false
    const storageTimeout = setTimeout(() => {
      storageTimedOut = true
      sendError(
        C.EVENT.STORAGE_RETRIEVAL_TIMEOUT,
        recordName, recordName, socketWrapper,
        onError, options, context, metaData
      )
    }, options.storageRetrievalTimeout)

    options.storage.get(recordName, (storageError, recordData) => {
      if (!storageTimedOut) {
        clearTimeout(storageTimeout)
        onStorageResponse(
          storageError,
          recordData,
          recordName,
          socketWrapper,
          onComplete,
          onError,
          options,
          context,
          metaData
        )
      }
    }, metaData)
  } else {
    onComplete.call(context, null, recordName, socketWrapper)
  }
}
741171
def initialize(self, run_tracker, all_options, start_time=None):
    

    run_id, run_uuid = run_tracker.initialize(all_options)
    run_dir = os.path.join(self.get_options().reports_dir, run_id)

    html_dir = os.path.join(run_dir, 'html')
    safe_mkdir(html_dir)
    relative_symlink(run_dir, os.path.join(self.get_options().reports_dir, 'latest'))

    report = Report()

    # Capture initial console reporting into a buffer. We'll do something with it once
    # we know what the cmd-line flag settings are.
    outfile = BytesIO()
    errfile = BytesIO()
    capturing_reporter_settings = PlainTextReporter.Settings(
      outfile=outfile, errfile=errfile, log_level=Report.INFO,
      color=False, indent=True, timing=False,
      cache_stats=False,
      label_format=self.get_options().console_label_format,
      tool_output_format=self.get_options().console_tool_output_format)
    capturing_reporter = PlainTextReporter(run_tracker, capturing_reporter_settings)
    report.add_reporter('capturing', capturing_reporter)

    # Set up HTML reporting. We always want that.
    html_reporter_settings = HtmlReporter.Settings(log_level=Report.INFO,
                                                   html_dir=html_dir,
                                                   template_dir=self.get_options().template_dir)
    html_reporter = HtmlReporter(run_tracker, html_reporter_settings)
    report.add_reporter('html', html_reporter)

    # Set up Zipkin reporting.
    zipkin_endpoint = self.get_options().zipkin_endpoint
    trace_id = self.get_options().zipkin_trace_id
    parent_id = self.get_options().zipkin_parent_id
    sample_rate = self.get_options().zipkin_sample_rate

    if zipkin_endpoint is None and trace_id is not None and parent_id is not None:
      raise ValueError(
        "The zipkin-endpoint flag must be set if zipkin-trace-id and zipkin-parent-id flags are given."
      )
    if (trace_id is None) != (parent_id is None):
      raise ValueError(
        "Flags zipkin-trace-id and zipkin-parent-id must both either be set or not set."
      )

    # If trace_id isn't set by a flag, use UUID from run_id
    if trace_id is None:
      trace_id = run_uuid

    if trace_id and (len(trace_id) != 16 and len(trace_id) != 32 or not is_hex_string(trace_id)):
      raise ValueError(
        "Value of the flag zipkin-trace-id must be a 16-character or 32-character hex string. "
        + "Got {}.".format(trace_id)
      )
    if parent_id and (len(parent_id) != 16 or not is_hex_string(parent_id)):
      raise ValueError(
        "Value of the flag zipkin-parent-id must be a 16-character hex string. "
        + "Got {}.".format(parent_id)
      )

    if zipkin_endpoint is not None:
      zipkin_reporter_settings = ZipkinReporter.Settings(log_level=Report.INFO)
      zipkin_reporter = ZipkinReporter(
        run_tracker, zipkin_reporter_settings, zipkin_endpoint, trace_id, parent_id, sample_rate
      )
      report.add_reporter('zipkin', zipkin_reporter)

    # Add some useful RunInfo.
    run_tracker.run_info.add_info('default_report', html_reporter.report_path())
    port = ReportingServerManager().socket
    if port:
      run_tracker.run_info.add_info('report_url', 'http://localhost:{}/run/{}'.format(port, run_id))

    # And start tracking the run.
    run_tracker.start(report, start_time)
392377
def subcache(self, path):
        """"""

        cache = self.clone()
        cache.prefix = os.path.join(cache.prefix if cache.prefix else '', path)

        return cache
1136161
public function cacheDataByArchiveNameReports()
    {
        $api = API::getInstance();
        $api->getIndividualReportsSummary(true);
        $api->getIndividualMetricsSummary(true);

        $now = Date::now()->getLocalized(Date::DATE_FORMAT_SHORT);
        Option::set(DBStats::TIME_OF_LAST_TASK_RUN_OPTION, $now);
    }
1147596
public function warmUp($cacheDir)
    {
        if (empty($this->activeTheme)) {
            return;
        }

        $locator = $this->locator->getLocator();

        /** @var TemplateReferenceInterface[] $allTemplates */
        $allTemplates = $this->finder->findAllTemplates();

        $templates = array();
        foreach ($this->activeTheme->getThemes() as $theme) {
            $this->activeTheme->setName($theme);
            foreach ($allTemplates as $template) {
                try {
                    $templates[$template->getLogicalName().'|'.$theme] = $locator->locate($template->getPath());
                } catch (\InvalidArgumentException $e) {
                }
            }
        }

        $this->writeCacheFile($cacheDir.'/templates.php', sprintf('<?php return %s;', var_export($templates, true)));
    }
1300315
private static void initCaches() {

        if (m_cacheTemporary == null) {
            m_cacheTemporary = CmsMemoryMonitor.createLRUCacheMap(1024);

            m_cachePermanent = new ConcurrentHashMap<String, byte[]>(32);

            m_cacheContentDefinitions = CmsMemoryMonitor.createLRUCacheMap(CONTENT_DEFINITION_CACHE_SIZE);
        }
        if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_1_CORE_OBJECT) {
            if ((OpenCms.getMemoryMonitor() != null)
                && !OpenCms.getMemoryMonitor().isMonitoring(CmsXmlEntityResolver.class.getName() + ".cacheTemporary")) {
                // reinitialize the caches after the memory monitor is set up
                Map<String, byte[]> cacheTemporary = CmsMemoryMonitor.createLRUCacheMap(128);
                cacheTemporary.putAll(m_cacheTemporary);
                m_cacheTemporary = cacheTemporary;
                OpenCms.getMemoryMonitor().register(
                    CmsXmlEntityResolver.class.getName() + ".cacheTemporary",
                    cacheTemporary);

                Map<String, byte[]> cachePermanent = new ConcurrentHashMap<String, byte[]>(32);
                cachePermanent.putAll(m_cachePermanent);
                m_cachePermanent = cachePermanent;
                OpenCms.getMemoryMonitor().register(
                    CmsXmlEntityResolver.class.getName() + ".cachePermanent",
                    cachePermanent);

                Map<String, CmsXmlContentDefinition> cacheContentDefinitions = CmsMemoryMonitor.createLRUCacheMap(
                    CONTENT_DEFINITION_CACHE_SIZE);
                cacheContentDefinitions.putAll(m_cacheContentDefinitions);
                m_cacheContentDefinitions = cacheContentDefinitions;
                OpenCms.getMemoryMonitor().register(
                    CmsXmlEntityResolver.class.getName() + ".cacheContentDefinitions",
                    cacheContentDefinitions);
            }
        }
    }
702896
def subproc_map(self, f, items):
    
    try:
      # Pool.map (and async_map().get() w/o timeout) can miss SIGINT.
      # See: http://stackoverflow.com/a/1408476, http://bugs.python.org/issue8844
      # Instead, we map_async(...), wait *with a timeout* until ready, then .get()
      # NB: in 2.x, wait() with timeout wakes up often to check, burning CPU. Oh well.
      res = SubprocPool.foreground().map_async(f, items)
      while not res.ready():
        res.wait(60)  # Repeatedly wait for up to a minute.
        if not res.ready():
          self.log.debug('subproc_map result still not ready...')
      return res.get()
    except KeyboardInterrupt:
      SubprocPool.shutdown(True)
      raise
351293
@Override
   public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
      BasicComponentRegistry gcr = cr.getGlobalComponentRegistry().getComponent(BasicComponentRegistry.class);
      InternalCacheRegistry icr = gcr.getComponent(InternalCacheRegistry.class).running();
      if (!icr.isInternalCache(cacheName)) {
         ProtobufMetadataManagerImpl protobufMetadataManager =
            (ProtobufMetadataManagerImpl) gcr.getComponent(ProtobufMetadataManager.class).running();
         protobufMetadataManager.addCacheDependency(cacheName);

         SerializationContext serCtx = protobufMetadataManager.getSerializationContext();
         RemoteQueryManager remoteQueryManager = buildQueryManager(cfg, serCtx, cr);
         cr.registerComponent(remoteQueryManager, RemoteQueryManager.class);

      }
   }
1053773
public void enableObjectCacheStats() {
        final String methodName = "enableObjectCacheStats";
        try {
            if (null == _statsInstance) {
                _iCacheType = TYPE_OBJECT;

                if (tc.isDebugEnabled())
                    Tr.debug(tc, methodName + " Creating statistic for " + _sCacheName + " instance (object cache)");
                _statsInstance = StatsFactory.createStatsInstance(WSDynamicCacheStats.OBJECT_CACHE_TYPE_PREFIX + _sCacheName, _cacheRootStatsGroup,
                        null, this);

                if (null == _cacheObjectStatsGroup) {
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, methodName + " Creating object cache group" + " for cacheName=" + _sCacheName);
                    _cacheObjectStatsGroup = StatsFactory.createStatsGroup(WSDynamicCacheStats.OBJECT_GROUP, templateCount15, _statsInstance, null,
                            this);
                    _csmObject = new CacheStatsModule(_sCacheName, WSDynamicCacheStats.OBJECT_COUNTERS, _cacheObjectStatsGroup, this);
                }

                if (_diskOffloadEnabled) {
                    if (_cacheDiskStatsGroup == null) {
                        if (tc.isDebugEnabled())
                            Tr.debug(tc, methodName + " Creating disk group" + " for cacheName=" + _sCacheName);
                        _cacheDiskStatsGroup = StatsFactory.createStatsGroup(WSDynamicCacheStats.DISK_GROUP, templateCount13, _statsInstance, null,
                                this);
                    }
                    _csmDisk = new CacheStatsModule(_sCacheName, WSDynamicCacheStats.DISK_OFFLOAD_ENABLED, _cacheDiskStatsGroup, this);
                }
            }
        } catch (StatsFactoryException e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.cache.stat.CacheStatsModule", "176", this);
            if (tc.isDebugEnabled())
                Tr.debug(tc,
                        methodName + " Exception while enabling object cache stats for" + _sCacheName + " : " + ExceptionUtility.getStackTrace(e));
        }

    }
201334
@Inject
   public void preStart() {
      // We have to do this before start, since some components may start before the actual cache and they
      // have to have access to the default metadata on some operations
      defaultMetadata = new EmbeddedMetadata.Builder()
            .lifespan(config.expiration().lifespan()).maxIdle(config.expiration().maxIdle()).build();
      transactional = config.transaction().transactionMode().isTransactional();
      batchingEnabled = config.invocationBatching().enabled();
   }
1333096
def warmup(self):
        
        self.logger.debug("Warming up...")

        try:
            if not isinstance(self.source, Manifest) and self.source:
                self.source = load_manifest(self.source)
            if not isinstance(self.target, Manifest) and self.target:
                self.target = load_manifest(self.target)
            self.main_manifest = self.target or self.source
        except lib.BadCredentialsException:
            e = sys.exc_info()[1]
            self.logger.error(str(e))
            raise SprinterException("Fatal error! Bad credentials to grab manifest!")

        if not getattr(self, 'namespace', None):
            if self.target:
                self.namespace = self.target.namespace
            elif not self.namespace and self.source:
                self.namespace = self.source.namespace
            else:
                raise SprinterException("No environment name has been specified!")

        self.directory_root = self.custom_directory_root

        if not self.directory:
            if not self.directory_root:
                self.directory_root = os.path.join(self.root, self.namespace)

            self.directory = Directory(self.directory_root,
                                       shell_util_path=self.shell_util_path)

        if not self.injections:
            self.injections = Injections(wrapper="%s_%s" % (self.sprinter_namespace.upper(),
                                                            self.namespace),
                                         override="SPRINTER_OVERRIDES")
        if not self.global_injections:
            self.global_injections = Injections(wrapper="%s" % self.sprinter_namespace.upper() + "GLOBALS",
                                                override="SPRINTER_OVERRIDES")
        # append the bin, in the case sandboxes are necessary to
        # execute commands further down the sprinter lifecycle
        os.environ['PATH'] = self.directory.bin_path() + ":" + os.environ['PATH']
        self.warmed_up = True