start() public method

NB: The web service can take quite a bit longer than the process to start. So if you want to be sure you should instantiate SolrWebService and wait until it's status is SOLR_STATUS_ONLINE.
public start ( ) : boolean
return boolean true if the server started, otherwise false.
Example #1
0
 /**
  * @covers EmbeddedServer
  */
 public function testStartStopIsRunning()
 {
     // Check whether the server is currently running.
     $running = $this->embeddedServer->isRunning();
     if ($running) {
         // If the server is running we stop it, then start it.
         // Stop the server.
         self::assertTrue($this->embeddedServer->stopAndWait());
         // Restart the server.
         self::assertTrue($this->embeddedServer->start());
         self::assertTrue($this->embeddedServer->isRunning());
     } else {
         // If the server is stopped, we start it, then stop it.
         // Start the server.
         self::assertTrue($this->embeddedServer->start());
         self::assertTrue($this->embeddedServer->isRunning());
         // Stop the server.
         self::assertTrue($this->embeddedServer->stopAndWait());
     }
 }
Example #2
0
 /**
  * @see Plugin::manage()
  */
 function manage($verb, $args, &$message, &$messageParams, &$pluginModalContent = null)
 {
     if (!parent::manage($verb, $args, $message, $messageParams)) {
         return false;
     }
     $request = $this->getRequest();
     switch ($verb) {
         case 'settings':
             // Prepare the template manager.
             $templateMgr = TemplateManager::getManager($request);
             $templateMgr->register_function('plugin_url', array($this, 'smartyPluginUrl'));
             // Instantiate an embedded server instance.
             $this->import('classes.EmbeddedServer');
             $embeddedServer = new EmbeddedServer();
             // Instantiate the settings form.
             $this->import('classes.form.LuceneSettingsForm');
             $form = new LuceneSettingsForm($this, $embeddedServer);
             // Handle request to save configuration data.
             if ($request->getUserVar('save')) {
                 $form->readInputData();
                 if ($form->validate()) {
                     $form->execute();
                     $request->redirect(null, 'manager', 'plugins', 'generic');
                     return false;
                 } else {
                     $form->display($request);
                 }
                 // Handle administrative request.
             } else {
                 // Re-init data. It should be visible to users
                 // that whatever data they may have entered into
                 // the form was not saved.
                 $form->initData();
                 // Index rebuild.
                 if ($request->getUserVar('rebuildIndex')) {
                     // Check whether we got valid index rebuild options.
                     if ($form->validate()) {
                         // Check whether a journal was selected.
                         $journal = null;
                         $journalId = $request->getUserVar('journalToReindex');
                         if (!empty($journalId)) {
                             $journalDao = DAORegistry::getDAO('JournalDAO');
                             /* @var $journalDao JournalDAO */
                             $journal = $journalDao->getById($journalId);
                             if (!is_a($journal, 'Journal')) {
                                 $journal = null;
                             }
                         }
                         if (empty($journalId) || !empty($journalId) && is_a($journal, 'Journal')) {
                             // Rebuild index and dictionaries.
                             $messages = null;
                             $this->_rebuildIndex(false, $journal, true, true, true, $messages);
                             // Transfer indexing output to the form template.
                             $form->setData('rebuildIndexMessages', $messages);
                         }
                     }
                     // Dictionary rebuild.
                 } elseif ($request->getUserVar('rebuildDictionaries')) {
                     // Rebuild dictionaries.
                     $journal = null;
                     $this->_rebuildIndex(false, null, false, true, false, $messages);
                     // Transfer indexing output to the form template.
                     $form->setData('rebuildIndexMessages', $messages);
                     // Boost File Update.
                 } elseif ($request->getUserVar('updateBoostFile')) {
                     $this->_updateBoostFiles();
                     // Start/Stop solr server.
                 } elseif ($request->getUserVar('stopServer')) {
                     // As this is a system plug-in we follow usual
                     // plug-in policy and allow journal managers to start/
                     // stop the server although this will affect all journals
                     // of the installation.
                     $embeddedServer->stopAndWait();
                 } elseif ($request->getUserVar('startServer')) {
                     $embeddedServer->start();
                 }
                 // Re-display the settings page after executing
                 // an administrative task.
                 $form->display($request);
             }
             return true;
         default:
             // Unknown management verb
             assert(false);
             return false;
     }
 }
Example #3
0
 /**
  * @covers LucenePlugin
  */
 public function testArticleIndexingProblem()
 {
     // Make sure the embedded server is switched off.
     $embeddedServer = new EmbeddedServer();
     $this->assertTrue($embeddedServer->stopAndWait());
     // Mock email templates.
     $constructorArgs = array('LUCENE_ARTICLE_INDEXING_ERROR_NOTIFICATION', null, null, null, true, true);
     import('lib.pkp.classes.mail.MailTemplate');
     $techInfoMail = $this->getMock('MailTemplate', array('send'), $constructorArgs);
     /* @var $techInfoMail MailTemplate */
     $techInfoMail->expects($this->exactly(2))->method('send')->will($this->returnValue(true));
     $this->lucenePlugin->setMailTemplate('LUCENE_ARTICLE_INDEXING_ERROR_NOTIFICATION', $techInfoMail);
     // Reset the time of the last sent email.
     $this->lucenePlugin->updateSetting(0, 'lastEmailTimestamp', 0);
     // Trying to delete a document without the server running
     // should trigger an email to the tech contact.
     $params = array($articleId = 3, $type = null, $assocId = null);
     $this->lucenePlugin->callbackArticleFileDeleted('ArticleSearchIndex::articleFileDeleted', $params);
     $this->lucenePlugin->callbackArticleChangesFinished('ArticleSearchIndex::articleChangesFinished', array());
     // Check the mail.
     $this->assertEquals('Article Indexing Error', $techInfoMail->getSubject());
     $this->assertContains('An indexing error occurred while updating the article index.', $techInfoMail->getBody());
     $this->assertContains('##plugins.generic.lucene.message.searchServiceOffline##', $techInfoMail->getBody());
     if (Core::isWindows()) {
         $this->assertEquals('*****@*****.**', $techInfoMail->getRecipientString());
     } else {
         $this->assertEquals('"Open Journal Systems" <*****@*****.**>', $techInfoMail->getRecipientString());
     }
     $this->assertEquals('"Open Journal Systems" <*****@*****.**>', $techInfoMail->getFromString());
     // Call again to make sure that a second mail is not being sent.
     $this->lucenePlugin->callbackArticleChangesFinished('ArticleSearchIndex::articleChangesFinished', array());
     // Simulate that the last email is more than three hours ago.
     $this->lucenePlugin->updateSetting(0, 'lastEmailTimestamp', time() - 60 * 60 * 4);
     // This should trigger another email (see send() call count above).
     $this->lucenePlugin->callbackArticleChangesFinished('ArticleSearchIndex::articleChangesFinished', array());
     // Restart the embedded server.
     $this->assertTrue($embeddedServer->start());
 }