Merge pull request #355 from herbertsg/BUG-9482

BUG-9482 Solr reindex error solved
This commit is contained in:
julceslauhub
2012-07-20 07:50:16 -07:00
2 changed files with 52 additions and 35 deletions

View File

@@ -463,6 +463,7 @@ class AppSolr
$rows = array (); $rows = array ();
// number of found records // number of found records
$result ['totalCount'] = $solrQueryResult->iTotalDisplayRecords; $result ['totalCount'] = $solrQueryResult->iTotalDisplayRecords;
// complete the missing data to display it in the grid. // complete the missing data to display it in the grid.
foreach ($solrQueryResult->aaData as $i => $data) { foreach ($solrQueryResult->aaData as $i => $data) {
// complete empty values // complete empty values
@@ -479,6 +480,9 @@ class AppSolr
// get all the indexes // get all the indexes
$delIndexes = $this->getApplicationDelegationsIndex ($appUID); $delIndexes = $this->getApplicationDelegationsIndex ($appUID);
} }
else {
$delIndexes = array();
}
} }
foreach ($delIndexes as $delIndex) { foreach ($delIndexes as $delIndex) {
$aRow = array (); $aRow = array ();
@@ -966,10 +970,17 @@ class AppSolr
$oSearchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost); $oSearchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
try{
$oSearchIndex->updateIndexDocument ($oSolrUpdateDocument); $oSearchIndex->updateIndexDocument ($oSolrUpdateDocument);
// commit changes // commit changes
$oSearchIndex->commitIndexChanges ($this->_solrInstance); $oSearchIndex->commitIndexChanges ($this->_solrInstance);
} catch(Exception $ex)
{
//print "Excepcion indexing data: " . $ex->getMessage() . "\n"; die;
$fh = fopen("./SolrIndexErrors.txt", 'a') or die("can't open file to store Solr index errors.");
fwrite($fh, $ex->getMessage());
fclose($fh);
}
} }
/** /**
@@ -1016,7 +1027,7 @@ class AppSolr
// search data from DB // search data from DB
$xmlDoc = "<?xml version='1.0' encoding='UTF-8'?>\n"; $xmlDoc = "<?xml version='1.0' encoding='UTF-8'?>\n";
$xmlDoc .= "<add>\n"; $xmlDoc .= "<add>\n";
// echo "APP Uids to index \n";
foreach ($aaAPPUIDs as $aAPPUID) { foreach ($aaAPPUIDs as $aAPPUID) {
try { try {
$result = $this->getApplicationIndexData ($aAPPUID ['APP_UID']); $result = $this->getApplicationIndexData ($aAPPUID ['APP_UID']);
@@ -1049,11 +1060,9 @@ class AppSolr
} }
catch ( ApplicationAPP_DATAUnserializeException $e ) { catch ( ApplicationAPP_DATAUnserializeException $e ) {
// exception trying to get application information // exception trying to get application information
$fh = fopen("./SolrIndexErrors.txt", 'a') or die("can't open file to store Solr index errors.");
//print $e->message +" \n"; fwrite($fh, $e->getMessage());
//$fh = fopen("./UnserializeError_APP_DATA".".txt", 'a') or die("can't open file"); fclose($fh);
//fwrite($fh, $e->message . "\n");
//fclose($fh);
// skip and continue with the next application // skip and continue with the next application
continue; continue;
} }
@@ -1061,7 +1070,6 @@ class AppSolr
} }
$xmlDoc .= "</add>\n"; $xmlDoc .= "</add>\n";
return $xmlDoc; return $xmlDoc;
} }
@@ -1339,8 +1347,14 @@ class AppSolr
$typeSufix = '_t'; $typeSufix = '_t';
break; break;
case 'Int' : case 'Int' :
if(intval ($value) > 2147483647) {
$typeSufix = '_tl'; //for long values
$value = intval ($value);
}
else {
$typeSufix = '_ti'; $typeSufix = '_ti';
$value = intval ($value); $value = intval ($value);
}
break; break;
case 'Real' : case 'Real' :
$typeSufix = '_td'; $typeSufix = '_td';
@@ -1383,6 +1397,7 @@ class AppSolr
break; break;
case 'currency' : case 'currency' :
$typeSufix = '_td'; $typeSufix = '_td';
$value = floatval ($value);
break; break;
case 'percentage' : case 'percentage' :
$typeSufix = '_t'; $typeSufix = '_t';
@@ -1620,15 +1635,18 @@ class AppSolr
// All the datatypes of the process => all variables in all dynaforms in the // All the datatypes of the process => all variables in all dynaforms in the
// process // process
$dynaformFieldTypes = array (); $dynaformFieldTypes = array ();
// get cache instance // get cache instance
$oMemcache = PMmemcached::getSingleton ($this->_solrInstance); $oMemcache = PMmemcached::getSingleton ($this->_solrInstance);
$dynaformFieldTypes = $oMemcache->get ($documentInformation ['PRO_UID']); $dynaformFieldTypes = $oMemcache->get ($documentInformation ['PRO_UID']);
if (! $dynaformFieldTypes) { if (! $dynaformFieldTypes) {
G::LoadClass ('dynaformhandler'); G::LoadClass ('dynaformhandler');
$dynaformFileNames = $this->getProcessDynaformFileNames ($documentInformation ['PRO_UID']); $dynaformFileNames = $this->getProcessDynaformFileNames ($documentInformation ['PRO_UID']);
$dynaformFields = array (); $dynaformFields = array ();
foreach ($dynaformFileNames as $dynaformFileName) { foreach ($dynaformFileNames as $dynaformFileName) {
if (file_exists (PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml')) { if (file_exists (PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml') &&
filesize(PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml') >0 ) {
$dyn = new dynaFormHandler (PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml'); $dyn = new dynaFormHandler (PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml');
$dynaformFields [] = $dyn->getFields (); $dynaformFields [] = $dyn->getFields ();
} }
@@ -1651,7 +1669,6 @@ class AppSolr
// create cache of dynaformfields // create cache of dynaformfields
$oMemcache->set ($documentInformation ['PRO_UID'], $dynaformFieldTypes); $oMemcache->set ($documentInformation ['PRO_UID'], $dynaformFieldTypes);
} }
// return result values // return result values
$result = array ( $result = array (
$documentInformation, $documentInformation,

View File

@@ -87,7 +87,7 @@ class BpmnEngine_SearchIndexAccess_Solr
// verify the result of solr // verify the result of solr
$responseSolrTotal = G::json_decode ($responseTotal); $responseSolrTotal = G::json_decode ($responseTotal);
if ($responseSolrTotal->responseHeader->status != 0) { if ($responseSolrTotal->responseHeader->status != 0) {
throw new Exception ("Error returning the total number of documents in Solr." . $solrIntruct); throw new Exception ("Error returning the total number of documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
} }
$numTotalDocs = $responseSolrTotal->response->numFound; $numTotalDocs = $responseSolrTotal->response->numFound;
return $numTotalDocs; return $numTotalDocs;
@@ -156,7 +156,7 @@ class BpmnEngine_SearchIndexAccess_Solr
// decode // decode
$responseSolr = G::json_decode ($response); $responseSolr = G::json_decode ($response);
if ($responseSolr->responseHeader->status != 0) { if ($responseSolr->responseHeader->status != 0) {
throw new Exception ("Error executing query to Solr." . $solrIntruct); throw new Exception ("Error executing query to Solr." . $solrIntruct . " response error: " . $response . "\n");
} }
return $responseSolr; return $responseSolr;
@@ -192,7 +192,7 @@ class BpmnEngine_SearchIndexAccess_Solr
$swOk = strpos ($response, '<int name="status">0</int>'); $swOk = strpos ($response, '<int name="status">0</int>');
if (! $swOk) { if (! $swOk) {
throw new Exception ("Error updating document in Solr." . $solrIntruct); throw new Exception ("Error updating document in Solr." . $solrIntruct . " response error: " . $response . "\n");
} }
} }
@@ -226,7 +226,7 @@ class BpmnEngine_SearchIndexAccess_Solr
$swOk = strpos ($response, '<int name="status">0</int>'); $swOk = strpos ($response, '<int name="status">0</int>');
if (! $swOk) { if (! $swOk) {
throw new Exception ("Error commiting changes in Solr." . $solrIntruct); throw new Exception ("Error commiting changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
} }
} }
@@ -261,7 +261,7 @@ class BpmnEngine_SearchIndexAccess_Solr
$swOk = strpos ($response, '<int name="status">0</int>'); $swOk = strpos ($response, '<int name="status">0</int>');
if (! $swOk) { if (! $swOk) {
throw new Exception ("Error rolling back changes in Solr." . $solrIntruct); throw new Exception ("Error rolling back changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
} }
} }
@@ -296,7 +296,7 @@ class BpmnEngine_SearchIndexAccess_Solr
$swOk = strpos ($response, '<int name="status">0</int>'); $swOk = strpos ($response, '<int name="status">0</int>');
if (! $swOk) { if (! $swOk) {
throw new Exception ("Error optimizing changes in Solr." . $solrIntruct); throw new Exception ("Error optimizing changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
} }
} }
@@ -326,7 +326,7 @@ class BpmnEngine_SearchIndexAccess_Solr
// decode // decode
$responseSolr = G::json_decode ($response); $responseSolr = G::json_decode ($response);
if ($responseSolr->responseHeader->status != 0) { if ($responseSolr->responseHeader->status != 0) {
throw new Exception ("Error getting index fields in Solr." . $solrIntruct); throw new Exception ("Error getting index fields in Solr." . $solrIntruct . " response error: " . $response . "\n");
} }
return $responseSolr; return $responseSolr;
} }
@@ -364,7 +364,7 @@ class BpmnEngine_SearchIndexAccess_Solr
$swOk = strpos ($response, '<int name="status">0</int>'); $swOk = strpos ($response, '<int name="status">0</int>');
if (! $swOk) { if (! $swOk) {
throw new Exception ("Error deleting all documents in Solr." . $solrIntruct); throw new Exception ("Error deleting all documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
} }
} }
@@ -401,7 +401,7 @@ class BpmnEngine_SearchIndexAccess_Solr
$swOk = strpos ($response, '<int name="status">0</int>'); $swOk = strpos ($response, '<int name="status">0</int>');
if (! $swOk) { if (! $swOk) {
throw new Exception ("Error deleting document in Solr." . $solrIntruct); throw new Exception ("Error deleting document in Solr." . $solrIntruct . " response error: " . $response . "\n");
} }
} }
@@ -472,7 +472,7 @@ class BpmnEngine_SearchIndexAccess_Solr
// decode // decode
$responseSolr = G::json_decode ($response); $responseSolr = G::json_decode ($response);
if ($responseSolr->responseHeader->status != 0) { if ($responseSolr->responseHeader->status != 0) {
throw new Exception ("Error getting faceted list from Solr." . $solrIntruct); throw new Exception ("Error getting faceted list from Solr." . $solrIntruct . " response error: " . $response . "\n");
} }
return $responseSolr; return $responseSolr;