mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-26 11:19:26 +02:00
Enhanced Pager performance, and new PDO Database driver.
I had to change the other drivers as well for the new pager logic.
This commit is contained in:
parent
cb1dcacc9b
commit
b81ba95db4
@ -175,6 +175,12 @@ abstract class LogStream {
|
||||
public abstract function GetLastPageUID();
|
||||
|
||||
|
||||
/**
|
||||
* This function returns the FIRST UID for the FIRST PAGE, if availbale! Otherwise will
|
||||
* return -1!
|
||||
*/
|
||||
public abstract function GetFirstPageUID();
|
||||
|
||||
/**
|
||||
* This function returns the current Page number, if availbale! Otherwise will
|
||||
* return -1!
|
||||
|
@ -57,6 +57,7 @@ class LogStreamDB extends LogStream {
|
||||
private $_totalRecordCount = -1;
|
||||
private $_previousPageUID = -1;
|
||||
private $_lastPageUID = -1;
|
||||
private $_firstPageUID = -1;
|
||||
private $_currentPageNumber = 0;
|
||||
|
||||
private $_SQLwhereClause = "";
|
||||
@ -335,6 +336,34 @@ class LogStreamDB extends LogStream {
|
||||
return $this->_previousPageUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the FIRST UID for the FIRST PAGE!
|
||||
* Will be done by a seperated SQL Statement.
|
||||
*/
|
||||
public function GetFirstPageUID()
|
||||
{
|
||||
global $querycount, $dbmapping;
|
||||
$szTableType = $this->_logStreamConfigObj->DBTableType;
|
||||
|
||||
$szSql = "SELECT MAX(" . $dbmapping[$szTableType][SYSLOG_UID] . ") FROM " . $this->_logStreamConfigObj->DBTableName . $this->_SQLwhereClause;
|
||||
$myQuery = mysql_query($szSql, $this->_dbhandle);
|
||||
if ($myQuery)
|
||||
{
|
||||
// obtain first and only row
|
||||
$myRow = mysql_fetch_row($myQuery);
|
||||
$this->_firstPageUID = $myRow[0];
|
||||
|
||||
// Free query now
|
||||
mysql_free_result ($myQuery);
|
||||
|
||||
// Increment for the Footer Stats
|
||||
$querycount++;
|
||||
}
|
||||
|
||||
// Return result!
|
||||
return $this->_firstPageUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the first UID for the last PAGE!
|
||||
* Will be done by a seperated SQL Statement.
|
||||
@ -389,7 +418,7 @@ class LogStreamDB extends LogStream {
|
||||
}
|
||||
*/
|
||||
|
||||
// finally return result!
|
||||
// Return result!
|
||||
return $this->_lastPageUID;
|
||||
}
|
||||
|
||||
|
@ -466,6 +466,15 @@ class LogStreamDisk extends LogStream {
|
||||
return $this->_previousPageUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the FIRST UID for the FIRST PAGE!
|
||||
* NOT IMPLEMENTED RIGHT NOW!
|
||||
*/
|
||||
public function GetFirstPageUID()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the first UID for the last PAGE!
|
||||
* This is not possible in this logstream, so it always returns -1!
|
||||
@ -500,16 +509,6 @@ class LogStreamDisk extends LogStream {
|
||||
// Now we move for one page, we do not need to process the syslog messages!
|
||||
$ret = $this->ReadNext($myuid, $tmpArray, false);
|
||||
|
||||
/* OLD CODE
|
||||
if ( $ret == SUCCESS )
|
||||
{
|
||||
do
|
||||
{
|
||||
// Increment Counter
|
||||
$counter++;
|
||||
} while ( $counter < $this->_logStreamConfigObj->_pageCount && ($ret = $this->ReadNext($myuid, $tmpArray, false)) == SUCCESS );
|
||||
}
|
||||
*/
|
||||
// Save the current UID as LastPage UID!
|
||||
$this->_lastPageUID = $myuid;
|
||||
|
||||
|
@ -53,6 +53,7 @@ class LogStreamPDO extends LogStream {
|
||||
private $_totalRecordCount = -1;
|
||||
private $_previousPageUID = -1;
|
||||
private $_lastPageUID = -1;
|
||||
private $_firstPageUID = -1;
|
||||
private $_currentPageNumber = -1;
|
||||
|
||||
private $_SQLwhereClause = "";
|
||||
@ -363,6 +364,36 @@ echo "mowl2";
|
||||
return $this->_previousPageUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the FIRST UID for the FIRST PAGE!
|
||||
* Will be done by a seperated SQL Statement.
|
||||
*/
|
||||
public function GetFirstPageUID()
|
||||
{
|
||||
global $querycount, $dbmapping;
|
||||
$szTableType = $this->_logStreamConfigObj->DBTableType;
|
||||
|
||||
$szSql = "SELECT MAX(" . $dbmapping[$szTableType][SYSLOG_UID] . ") FROM " . $this->_logStreamConfigObj->DBTableName . $this->_SQLwhereClause;
|
||||
$myQuery = $this->_dbhandle->query($szSql);
|
||||
if ( $myQuery )
|
||||
{
|
||||
$myRow = $myQuery->fetchColumn();
|
||||
$this->_firstPageUID = $myRow; // $myRow[0];
|
||||
|
||||
// Free query now
|
||||
$myQuery->closeCursor();
|
||||
|
||||
// Increment for the Footer Stats
|
||||
$querycount++;
|
||||
|
||||
}
|
||||
//echo $szSql . "<br>" . $this->_firstPageUID;
|
||||
//exit;
|
||||
|
||||
// finally return result!
|
||||
return $this->_firstPageUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the first UID for the last PAGE!
|
||||
* Will be done by a seperated SQL Statement.
|
||||
|
@ -262,7 +262,7 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'
|
||||
{
|
||||
// Enable Pager in any case here!
|
||||
$content['main_pagerenabled'] = true;
|
||||
|
||||
/*
|
||||
// --- Handle uid_first page button
|
||||
if ( $content['uid_fromgetrequest'] == $content['uid_first'] )
|
||||
$content['main_pager_first_found'] = false;
|
||||
@ -276,10 +276,19 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'
|
||||
$content['main_pager_first_found'] = false;
|
||||
}
|
||||
// ---
|
||||
|
||||
*/
|
||||
// --- Handle uid_last page button
|
||||
// Option the last UID from the stream!
|
||||
$content['uid_last'] = $stream->GetLastPageUID();
|
||||
$content['uid_first'] = $stream->GetFirstPageUID();
|
||||
|
||||
// --- Handle uid_first page button
|
||||
if ( $content['uid_current'] == $content['uid_first'] )
|
||||
$content['main_pager_first_found'] = false;
|
||||
else
|
||||
$content['main_pager_first_found'] = true;
|
||||
// ---
|
||||
|
||||
|
||||
// if we found a last uid, and if it is not the current one (which means we already are on the last page ;)!
|
||||
if ( $content['uid_last'] != -1 && $content['uid_last'] != $content['uid_current'])
|
||||
|
@ -108,7 +108,11 @@ function CreateCurrentUrl()
|
||||
for ( $i = 0; $i < count($queries); $i++ )
|
||||
{
|
||||
// Some properties need to be filtered out.
|
||||
if ( strpos($queries[$i], "direction") === false )
|
||||
if (
|
||||
strpos($queries[$i], "direction") === false
|
||||
&&
|
||||
strpos($queries[$i], "skipone") === false
|
||||
)
|
||||
{
|
||||
$tmpvars = explode ("=", $queries[$i]);
|
||||
if ( isset($tmpvars[1]) ) // Only if value param is set!
|
||||
|
@ -73,6 +73,17 @@ if ( $content['uid_current'] == UID_UNKNOWN )
|
||||
else
|
||||
$content['ViewEnableAutoReloadSeconds_visible'] = false;
|
||||
|
||||
// Read direction parameter
|
||||
if ( isset($_GET['direction']) && $_GET['direction'] == "desc" )
|
||||
$content['read_direction'] = EnumReadDirection::Forward;
|
||||
else
|
||||
$content['read_direction'] = EnumReadDirection::Backward;
|
||||
|
||||
// If direction is DESC, should we SKIP one?
|
||||
if ( isset($_GET['skipone']) && $_GET['skipone'] == "true" )
|
||||
$content['skipone'] = true;
|
||||
else
|
||||
$content['skipone'] = false;
|
||||
// ---
|
||||
|
||||
|
||||
@ -87,12 +98,6 @@ $content['main_pager_previous_found'] = false;
|
||||
$content['main_pager_next_found'] = false;
|
||||
$content['main_pager_last_found'] = false;
|
||||
|
||||
|
||||
if ( isset($_GET['direction']) && $_GET['direction'] == "desc" )
|
||||
$content['read_direction'] = EnumReadDirection::Forward;
|
||||
else
|
||||
$content['read_direction'] = EnumReadDirection::Backward;
|
||||
|
||||
// Init Sorting variables
|
||||
$content['sorting'] = "";
|
||||
$content['searchstr'] = "";
|
||||
@ -244,17 +249,18 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['Sources'][$c
|
||||
// --- Check if Read was successfull!
|
||||
if ( $ret == SUCCESS )
|
||||
{
|
||||
/* OLD CODE
|
||||
// If Forward direction is used, we need to SKIP one entry!
|
||||
if ( $content['read_direction'] == EnumReadDirection::Forward )
|
||||
{
|
||||
// Ok the current ID is our NEXT ID in this reading direction, so we save it!
|
||||
$content['uid_next'] = $uID;
|
||||
|
||||
// Skip this entry and move to the next
|
||||
$stream->ReadNext($uID, $logArray);
|
||||
if ( $content['skipone'] )
|
||||
{
|
||||
// Skip this entry and move to the next
|
||||
$stream->ReadNext($uID, $logArray);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -569,6 +575,9 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['Sources'][$c
|
||||
// Enable Pager in any case here!
|
||||
$content['main_pagerenabled'] = true;
|
||||
|
||||
// temporary store the current last $uID
|
||||
$lastUid = $uID;
|
||||
|
||||
// --- Handle uid_next page button
|
||||
if ( $content['read_direction'] == EnumReadDirection::Backward )
|
||||
{
|
||||
@ -610,6 +619,7 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['Sources'][$c
|
||||
// --- Handle uid_last page button
|
||||
// Option the last UID from the stream!
|
||||
$content['uid_last'] = $stream->GetLastPageUID();
|
||||
$content['uid_first'] = $stream->GetFirstPageUID();
|
||||
|
||||
// if we found a last uid, and if it is not the current one (which means we already are on the last page ;)!
|
||||
if ( $content['uid_last'] != -1 && $content['uid_last'] != $content['uid_current'])
|
||||
@ -629,13 +639,18 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['Sources'][$c
|
||||
$content['main_pager_next_found'] = true;
|
||||
|
||||
// As we went back, we need to change the currend uid to the latest read one
|
||||
$content['uid_current'] = $uID;
|
||||
$content['uid_current'] = $lastUid;
|
||||
}
|
||||
// ---
|
||||
|
||||
// --- Handle uid_first page button
|
||||
if ( $content['uid_current'] == $content['uid_first'] )
|
||||
if ( $content['main_pager_previous_found'] == false ||
|
||||
$content['uid_current'] == UID_UNKNOWN ||
|
||||
$content['uid_current'] == $content['uid_first'] )
|
||||
{
|
||||
$content['main_pager_first_found'] = false;
|
||||
$content['main_pager_previous_found'] = false; // If there is no FIRST, there is no going back!
|
||||
}
|
||||
else
|
||||
$content['main_pager_first_found'] = true;
|
||||
// ---
|
||||
|
@ -150,7 +150,7 @@
|
||||
<td class="cellmenu2" nowrap><B>Pager: </B></td>
|
||||
<td class="line0" width="20" nowrap>
|
||||
<!-- IF main_pager_first_found="true" -->
|
||||
<a href="?{additional_url_sortingonly}&uid={uid_first}{additional_url}" target="_top"><img src="{MENU_PAGER_BEGIN}" width="16" height="16" title="{LN_GEN_FIRSTPAGE}"></a>
|
||||
<a href="?{additional_url_sortingonly}&uid=-1{additional_url}" target="_top"><img src="{MENU_PAGER_BEGIN}" width="16" height="16" title="{LN_GEN_FIRSTPAGE}"></a>
|
||||
<!-- ENDIF main_pager_first_found="true" -->
|
||||
<!-- IF main_pager_first_found!="true" -->
|
||||
<img src="{MENU_PAGER_BEGIN_GREY}" width="16" height="16">
|
||||
@ -159,7 +159,7 @@
|
||||
|
||||
<td class="line1" width="20" nowrap>
|
||||
<!-- IF main_pager_previous_found="true" -->
|
||||
<a href="?{additional_url_sortingonly}&uid={uid_current}&direction=desc{additional_url}" target="_top"><img src="{MENU_PAGER_PREVIOUS}" width="16" title="{LN_GEN_PREVIOUSPAGE}"></a>
|
||||
<a href="?{additional_url_sortingonly}&uid={uid_current}&direction=desc&skipone=true{additional_url}" target="_top"><img src="{MENU_PAGER_PREVIOUS}" width="16" title="{LN_GEN_PREVIOUSPAGE}"></a>
|
||||
<!-- ENDIF main_pager_previous_found="true" -->
|
||||
<!-- IF main_pager_previous_found!="true" -->
|
||||
<img src="{MENU_PAGER_PREVIOUS_GREY}" width="16" height="16">
|
||||
@ -297,7 +297,7 @@
|
||||
<td class="cellmenu2" nowrap><B>Pager: </B></td>
|
||||
<td class="line0" width="20" nowrap>
|
||||
<!-- IF main_pager_first_found="true" -->
|
||||
<a href="?{additional_url_sortingonly}&uid={uid_first}{additional_url}" target="_top"><img src="{MENU_PAGER_BEGIN}" width="16" height="16" title="{LN_GEN_FIRSTPAGE}"></a>
|
||||
<a href="?{additional_url_sortingonly}&uid=-1{additional_url}" target="_top"><img src="{MENU_PAGER_BEGIN}" width="16" height="16" title="{LN_GEN_FIRSTPAGE}"></a>
|
||||
<!-- ENDIF main_pager_first_found="true" -->
|
||||
<!-- IF main_pager_first_found!="true" -->
|
||||
<img src="{MENU_PAGER_BEGIN_GREY}" width="16" height="16">
|
||||
@ -306,7 +306,7 @@
|
||||
|
||||
<td class="line1" width="20" nowrap>
|
||||
<!-- IF main_pager_previous_found="true" -->
|
||||
<a href="?{additional_url_sortingonly}&uid={uid_current}&direction=desc{additional_url}" target="_top"><img src="{MENU_PAGER_PREVIOUS}" width="16" title="{LN_GEN_PREVIOUSPAGE}"></a>
|
||||
<a href="?{additional_url_sortingonly}&uid={uid_current}&direction=desc&skipone=true{additional_url}" target="_top"><img src="{MENU_PAGER_PREVIOUS}" width="16" title="{LN_GEN_PREVIOUSPAGE}"></a>
|
||||
<!-- ENDIF main_pager_previous_found="true" -->
|
||||
<!-- IF main_pager_previous_found!="true" -->
|
||||
<img src="{MENU_PAGER_PREVIOUS_GREY}" width="16" height="16">
|
||||
|
Loading…
x
Reference in New Issue
Block a user