Author: rande
Date: 2010-02-22 23:28:02 +0100 (Mon, 22 Feb 2010)
New Revision: 28198
Modified:
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexer.class.php
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexerHandler.class.php
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneModelIndexer.class.php
plugins/sfSolrPlugin/branches/sf1.2/lib/results/sfLucenePager.class.php
plugins/sfSolrPlugin/branches/sf1.2/lib/task/sfLuceneServiceTask.class.php
plugins/sfSolrPlugin/branches/sf1.2/lib/util/sfLuceneService.class.php
plugins/sfSolrPlugin/branches/sf1.2/test/unit/results/sfLuceneFacetsResultsTest.php
plugins/sfSolrPlugin/branches/sf1.2/test/unit/results/sfLuceneModelResultTest.php
plugins/sfSolrPlugin/branches/sf1.2/test/unit/results/sfLucenePagerTest.php
Log:
[sfSolrPlugin] fix tests, add Xms and Xmn option
Modified:
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexer.class.php
===================================================================
---
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexer.class.php
2010-02-22 18:27:24 UTC (rev 28197)
+++
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexer.class.php
2010-02-22 22:28:02 UTC (rev 28198)
@@ -25,10 +25,10 @@
if (!$this->shouldIndex())
{
+ $this->getSearch()->getEventDispatcher()->notify(new sfEvent($this,
'indexer.log', array('model "%s" cancelled indexation - primary key = %s',
$this->getModelName(), current($this->getModel()->identifier()))));
return false;
}
-
$old_culture = null;
// automatic symfony i18n detection
@@ -56,9 +56,9 @@
return $doc;
}
- /**
+ /**
* Inserts the provided model into the index based off parameters in
search.yml.
- *
+ *
* @param BaseObject $this->getModel() The model to insert
*/
public function insert()
@@ -204,7 +204,7 @@
$value = null;
}
}
-
+
if((is_array($value) || $value instanceof Doctrine_Collection) &&
!$properties->get('multiValued'))
{
Modified:
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexerHandler.class.php
===================================================================
---
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexerHandler.class.php
2010-02-22 18:27:24 UTC (rev 28197)
+++
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexerHandler.class.php
2010-02-22 22:28:02 UTC (rev 28198)
@@ -96,8 +96,8 @@
if(!$doc)
{
- $this->getSearch()->getEventDispatcher()->notify( new sfEvent($this,
'application.log', array( sprintf('invalid document %s [id:%s]: ',
get_class($record), $record->identifier()), 'priority' => sfLogger::ALERT )));
- $this->getSearch()->getEventDispatcher()->notify( new sfEvent($this,
'indexer.log', array( sprintf(' - invalid document %s [id:%s]: ',
get_class($record), $record->identifier()), 'priority' => sfLogger::ALERT )));
+ $this->getSearch()->getEventDispatcher()->notify( new sfEvent($this,
'application.log', array( sprintf('invalid document %s [id:%s]: ',
get_class($record), current($record->identifier())), 'priority' =>
sfLogger::ALERT )));
+ $this->getSearch()->getEventDispatcher()->notify( new sfEvent($this,
'indexer.log', array( sprintf(' - invalid document %s [id:%s]: ',
get_class($record), current($record->identifier())), 'priority' =>
sfLogger::ALERT )));
continue;
}
Modified:
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneModelIndexer.class.php
===================================================================
---
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneModelIndexer.class.php
2010-02-22 18:27:24 UTC (rev 28197)
+++
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneModelIndexer.class.php
2010-02-22 22:28:02 UTC (rev 28198)
@@ -203,7 +203,7 @@
$value = $this->getFieldValue($field, $field_properties);
// do not index null value
- if($value == null)
+ if($value == null || (is_array($value) && empty($value)))
{
continue;
Modified:
plugins/sfSolrPlugin/branches/sf1.2/lib/results/sfLucenePager.class.php
===================================================================
--- plugins/sfSolrPlugin/branches/sf1.2/lib/results/sfLucenePager.class.php
2010-02-22 18:27:24 UTC (rev 28197)
+++ plugins/sfSolrPlugin/branches/sf1.2/lib/results/sfLucenePager.class.php
2010-02-22 22:28:02 UTC (rev 28198)
@@ -31,7 +31,12 @@
$search_parameters,
$must_reload = false;
- public function __construct(sfLuceneResults $lucene_results, sfLucene
$search = null)
+ /**
+ *
+ * @param sfLuceneResults $lucene_results
+ * @param sfLucene $search
+ */
+ public function __construct($lucene_results, $search = null)
{
if(!$lucene_results instanceof sfLuceneResults)
@@ -39,7 +44,7 @@
throw new sfLuceneException('first arguments must be a sfLuceneResults
instance');
}
-
+
$this->lucene_results = $lucene_results;
$this->results = $lucene_results->toArray();
$this->search_parameters =
$lucene_results->getRawResult()->sf_lucene_search;
@@ -128,8 +133,8 @@
/**
* return an array of available page numbers
*
- * @param integer> $nb_links
- * @return <type>
+ * @param integer $nb_links
+ * @return array
*/
public function getLinks($nb_links = 5)
{
Modified:
plugins/sfSolrPlugin/branches/sf1.2/lib/task/sfLuceneServiceTask.class.php
===================================================================
--- plugins/sfSolrPlugin/branches/sf1.2/lib/task/sfLuceneServiceTask.class.php
2010-02-22 18:27:24 UTC (rev 28197)
+++ plugins/sfSolrPlugin/branches/sf1.2/lib/task/sfLuceneServiceTask.class.php
2010-02-22 22:28:02 UTC (rev 28198)
@@ -43,6 +43,8 @@
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED,
'The environment', 'prod'),
new sfCommandOption('java', null, sfCommandOption::PARAMETER_REQUIRED,
'the java binary', $java),
new sfCommandOption('nohup', null, sfCommandOption::PARAMETER_REQUIRED,
'the nohup binary', $nohup),
+ new sfCommandOption('Xmx', null, sfCommandOption::PARAMETER_REQUIRED,
'maximum java heap size', '512m'),
+ new sfCommandOption('Xms', null, sfCommandOption::PARAMETER_REQUIRED,
'initial java heap size', '256m'),
));
$this->aliases = array('lucene-service');
@@ -104,32 +106,32 @@
switch($action)
{
case 'start':
- $this->start($app, $env);
+ $this->start($app, $env, $options);
break;
case 'stop':
- $this->stop($app, $env);
+ $this->stop($app, $env, $options);
break;
case 'restart':
- $this->stop($app, $env);
- $this->start($app, $env);
+ $this->stop($app, $env, $options);
+ $this->start($app, $env, $options);
break;
case 'status':
- $this->status($app, $env);
+ $this->status($app, $env, $options);
break;
}
}
- public function isRunning($app, $env)
+ public function isRunning($app, $env, $options = array())
{
return @file_exists($this->getPidFile($app, $env));
}
- public function start($app, $env)
+ public function start($app, $env, $options = array())
{
if($this->isRunning($app, $env))
{
@@ -150,14 +152,17 @@
$base_url = $instances[0]->getParameter('base_url');
// start the jetty built in server
- $command = sprintf('cd %s/plugins/sfSolrPlugin/lib/vendor/Solr/example; %s
%s -Dsolr.solr.home=%s/config/solr/ -Dsolr.data.dir=%s/data/solr_index
-Djetty.port=%s -jar start.jar > %s/solr_server_%s_%s.log 2>&1 & echo $!',
+ $command = sprintf('cd %s/plugins/sfSolrPlugin/lib/vendor/Solr/example; %s
%s -Xmx%s -Xms%s -Dsolr.solr.home=%s/config/solr/
-Dsolr.data.dir=%s/data/solr_index -Djetty.port=%s -Djetty.logs=%s -jar
start.jar > %s/solr_server_%s_%s.log 2>&1 & echo $!',
sfConfig::get('sf_root_dir'),
$this->nohup,
$this->java,
+ $options['Xmx'],
+ $options['Xms'],
sfConfig::get('sf_root_dir'),
sfConfig::get('sf_root_dir'),
$port,
sfConfig::get('sf_root_dir').'/log',
+ sfConfig::get('sf_root_dir').'/log',
$app,
$env
);
@@ -176,7 +181,7 @@
$this->logSection("solr", "server started :
http://".$host.":".$port.$base_url);
}
- public function stop($app, $env)
+ public function stop($app, $env, $options = array())
{
if(!$this->isRunning($app, $env))
{
@@ -197,7 +202,7 @@
unlink($this->getPidFile($app, $env));
}
- public function status($app, $env)
+ public function status($app, $env, $options = array())
{
if(!$this->isRunning($app, $env))
Modified: plugins/sfSolrPlugin/branches/sf1.2/lib/util/sfLuceneService.class.php
===================================================================
--- plugins/sfSolrPlugin/branches/sf1.2/lib/util/sfLuceneService.class.php
2010-02-22 18:27:24 UTC (rev 28197)
+++ plugins/sfSolrPlugin/branches/sf1.2/lib/util/sfLuceneService.class.php
2010-02-22 22:28:02 UTC (rev 28198)
@@ -95,7 +95,7 @@
if ($response->getHttpStatus() != 200)
{
- throw new Exception('"' . $response->getHttpStatus() . '" Status: ' .
$response->getHttpStatusMessage(), $response->getHttpStatus());
+ throw new Apache_Solr_HttpTransportException('"' .
$response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(),
$response->getHttpStatus());
}
return $response;
@@ -143,11 +143,12 @@
//$http_response_header is set by file_get_contents
$class = $this->response_class;
+
$response = new $class(@file_get_contents($url, false,
$this->_postContext), $http_response_header, $this->_createDocuments,
$this->_collapseSingleValueArrays);
if ($response->getHttpStatus() != 200)
{
- throw new Exception('"' . $response->getHttpStatus() . '" Status: ' .
$response->getHttpStatusMessage(), $response->getHttpStatus());
+ throw new Apache_Solr_HttpTransportException('"' .
$response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(),
$response->getHttpStatus());
}
return $response;
Modified:
plugins/sfSolrPlugin/branches/sf1.2/test/unit/results/sfLuceneFacetsResultsTest.php
===================================================================
---
plugins/sfSolrPlugin/branches/sf1.2/test/unit/results/sfLuceneFacetsResultsTest.php
2010-02-22 18:27:24 UTC (rev 28197)
+++
plugins/sfSolrPlugin/branches/sf1.2/test/unit/results/sfLuceneFacetsResultsTest.php
2010-02-22 22:28:02 UTC (rev 28198)
@@ -48,7 +48,7 @@
$standard_response = sprintf($standard_response, 3, implode(", ", $results),
$facets);
-$response = new Apache_Solr_Response($standard_response);
+$response = new sfLuceneResponse($standard_response);
$search = sfLucene::getInstance('index', 'en', $app_configuration);
Modified:
plugins/sfSolrPlugin/branches/sf1.2/test/unit/results/sfLuceneModelResultTest.php
===================================================================
---
plugins/sfSolrPlugin/branches/sf1.2/test/unit/results/sfLuceneModelResultTest.php
2010-02-22 18:27:24 UTC (rev 28197)
+++
plugins/sfSolrPlugin/branches/sf1.2/test/unit/results/sfLuceneModelResultTest.php
2010-02-22 22:28:02 UTC (rev 28198)
@@ -47,8 +47,13 @@
$t->diag('testing constructor');
+class sfLuceneModelMockResult extends sfLuceneModelResult
+{
+
+}
+
try {
- $result = new sfLuceneModelResult($doc, $lucene);
+ $result = new sfLuceneModelMockResult($doc, $lucene);
$t->pass('__construct() accepts a valid result and valid sfLucene instance');
} catch (Exception $e) {
$t->fail('__construct() accepts a valid result and valid sfLucene instance');
Modified:
plugins/sfSolrPlugin/branches/sf1.2/test/unit/results/sfLucenePagerTest.php
===================================================================
--- plugins/sfSolrPlugin/branches/sf1.2/test/unit/results/sfLucenePagerTest.php
2010-02-22 18:27:24 UTC (rev 28197)
+++ plugins/sfSolrPlugin/branches/sf1.2/test/unit/results/sfLucenePagerTest.php
2010-02-22 22:28:02 UTC (rev 28198)
@@ -37,7 +37,7 @@
}
$standard_response = sprintf($standard_response, $offset, implode(", ",
$results));
- $response = new Apache_Solr_Response($standard_response);
+ $response = new sfLuceneResponse($standard_response);
$response->sf_lucene_search = array(
'query' => $query,
@@ -52,7 +52,7 @@
}
$lucene = sfLucene::getInstance('index', 'en', $app_configuration);
-$lucene->setLucene(new sfMockApacheService);
+$lucene->setSearchService(new sfMockApacheService);
$t->diag('testing constructor');
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.