当前位置: 首页>>代码示例>>PHP>>正文


PHP eZClusterFileHandler::addGeneratingFile方法代码示例

本文整理汇总了PHP中eZClusterFileHandler::addGeneratingFile方法的典型用法代码示例。如果您正苦于以下问题:PHP eZClusterFileHandler::addGeneratingFile方法的具体用法?PHP eZClusterFileHandler::addGeneratingFile怎么用?PHP eZClusterFileHandler::addGeneratingFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZClusterFileHandler的用法示例。


在下文中一共展示了eZClusterFileHandler::addGeneratingFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: startCacheGeneration

 /**
  * Starts cache generation for the current file.
  *
  * This is done by creating a file named by the original file name, prefixed
  * with '.generating'.
  *
  * @return bool false if the file is being generated, true if it is not
  */
 public function startCacheGeneration()
 {
     eZDebugSetting::writeDebug('kernel-clustering', "Starting cache generation", "dfs::startCacheGeneration( '{$this->filePath}' )");
     $generatingFilePath = $this->filePath . '.generating';
     try {
         $ret = self::$dbbackend->_startCacheGeneration($this->filePath, $generatingFilePath);
     } catch (RuntimeException $e) {
         eZDebug::writeError($e->getMessage());
         return false;
     }
     // generation granted
     if ($ret['result'] == 'ok') {
         eZClusterFileHandler::addGeneratingFile($this);
         $this->realFilePath = $this->filePath;
         $this->filePath = $generatingFilePath;
         $this->generationStartTimestamp = $ret['mtime'];
         return true;
     } elseif ($ret['result'] == 'ko') {
         return $ret['remaining'];
     } else {
         eZLog::write("An error occured starting cache generation on '{$generatingFilePath}'", 'cluster.log');
         return false;
     }
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:32,代码来源:ezdfsfilehandler.php

示例2: startCacheGeneration

    /**
     * Starts cache generation for the current file.
     *
     * This is done by creating a file named by the original file name, prefixed
     * with '.generating'.
     *
     * @return bool false if the file is being generated, true if it is not
     */
    public function startCacheGeneration()
    {
        $generatingFilePath = $this->filePath . '.generating';
        $ret = self::$dbbackend->_startCacheGeneration( $this->filePath, $generatingFilePath );

        // generation granted
        if ( $ret['result'] == 'ok' )
        {
            eZClusterFileHandler::addGeneratingFile( $this );
            $this->realFilePath = $this->filePath;
            $this->filePath = $generatingFilePath;
            $this->generationStartTimestamp = $ret['mtime'];
            return true;
        }
        // failure: the file is being generated
        elseif ( $ret['result'] == 'ko' )
        {
            return $ret['remaining'];
        }
        // unhandled error case, should not happen
        else
        {
            eZLog::write( "An error occured starting cache generation on '$generatingFilePath'", 'cluster.log' );
            return false;
        }
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:34,代码来源:ezdbfilehandler.php

示例3: startCacheGeneration

    /**
     * Starts cache generation for the current file.
     *
     * This is done by creating a file named by the original file name, prefixed
     * with '.generating'.
     *
     * @todo add timeout handling...
     *
     * @return mixed true if generation lock was granted, an integer matching the
     *               time before the current generation times out
     */
    public function startCacheGeneration()
    {
        eZDebugSetting::writeDebug( "kernel-clustering", $this->filePath, __METHOD__ );

        $ret = true;

        $generatingFilePath = $this->filePath . '.generating';

        // the x flag will throw a warning if the file exists. Allows existence
        // check AND creation at the same time
        if ( !$fp = @fopen( $generatingFilePath, 'x' ) )
        {
            $directory = dirname( $generatingFilePath ) . DIRECTORY_SEPARATOR;

            // the directory we're trying to create the file in does not exist
            eZDebugSetting::writeDebug( 'kernel-clustering', $this->filePath . " creation failed, checking if '$directory' exists", __METHOD__ );

            if ( !file_exists( $directory ) )
            {
                eZDebugSetting::writeDebug( 'kernel-clustering', $this->filePath . " target directory does not exist, creating and trying again", __METHOD__ );

                if ( eZDir::mkdir( $directory, false, true ) )
                    eZDebugSetting::writeDebug( 'kernel-clustering', "Directory '$directory' created, trying to start generation again", __METHOD__ );
                else
                    eZDebugSetting::writeDebug( 'kernel-clustering', "Directory '$directory' failed to be created, it might have been created by another process", __METHOD__ );

                // we check again since the folder may have been created by another
                // process in between. Not likely, though.
                if ( !$fp = @fopen( $generatingFilePath, 'x' ) )
                {
                    $ret = $this->remainingCacheGenerationTime( $generatingFilePath );
                }
            }
            // directory exists, we now check for timeout
            else
            {
                // timeout check
                if ( $mtime = @filemtime( $generatingFilePath ) )
                {
                    $remainingGenerationTime = $this->remainingCacheGenerationTime( $generatingFilePath );
                    eZDebugSetting::writeDebug( 'kernel-clustering', "Remaining generation time: $remainingGenerationTime", __METHOD__ );
                    if ( $remainingGenerationTime < 0 )
                    {
                        eZDebugSetting::writeDebug( 'kernel-clustering', $this->filePath . " generating file exists, but generation has timedout, taking over", __METHOD__ );
                        touch( $generatingFilePath, time(), time() );
                    }
                    else
                    {
                        eZDebugSetting::writeDebug( 'kernel-clustering', $this->filePath . " failed opening file for writing, generation is underway", __METHOD__ );
                        $ret = $remainingGenerationTime;
                    }
                }
            }
        }

        // if the generation lock was granted, we can perform our specific file
        // operations: change the file name to the generation name, and store
        // required generating informations
        if ( $ret === true )
        {
            // $fp might not be a valid handle if timeout has occured
            if ( $fp )
                fclose( $fp );

            eZClusterFileHandler::addGeneratingFile( $this );
            $this->realFilePath = $this->filePath;
            $this->filePath = $generatingFilePath;
            $this->generationStartTimestamp = filemtime( $this->filePath );
        }

        return $ret;
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:83,代码来源:ezfs2filehandler.php

示例4: startCacheGeneration

 /**
  * Starts cache generation for the current file.
  *
  * This is done by creating a file named by the original file name, prefixed
  * with '.generating'.
  *
  * @return bool false if the file is being generated, true if it is not
  **/
 public function startCacheGeneration()
 {
     $generatingFilePath = $this->filePath . '.generating';
     $ret = $this->backend->_startCacheGeneration($this->filePath, $generatingFilePath);
     // generation granted
     if ($ret['result'] == 'ok') {
         eZClusterFileHandler::addGeneratingFile($this);
         $this->realFilePath = $this->filePath;
         $this->filePath = $generatingFilePath;
         $this->generationStartTimestamp = $ret['mtime'];
         return true;
     } elseif ($ret['result'] == 'ko') {
         return $ret['remaining'];
     } else {
         eZLog::write("An error occured starting cache generation on '{$generatingFilePath}'", 'cluster.log');
         return false;
     }
 }
开发者ID:rmiguel,项目名称:ezpublish,代码行数:26,代码来源:ezdbfilehandler.php


注:本文中的eZClusterFileHandler::addGeneratingFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。