Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

99772: Merged 5.0.N (5.0.2) to HEAD-BUG-FIX (5.1/Cloud)
      99715: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.2)
         99478: Merged DEV (4.2.5) to V4.2-BUG-FIX (4.2.5)
            96530: MNT-13161: Disabling Archive Core in SOLR breaks admin-searchservice reporting for Alfresco core
               - Changed the logic of org.alfresco.repo.search.impl.solr.SolrChildApplicationContextFactory.getProperty(String) to gracefully parse the properties if one of the cores is missing.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@100499 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-03-27 22:57:29 +00:00
parent bc6720c6cc
commit 8109be0920

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2014 Alfresco Software Limited. * Copyright (C) 2005-2015 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -18,7 +18,6 @@
*/ */
package org.alfresco.repo.search.impl.solr; package org.alfresco.repo.search.impl.solr;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
@@ -112,31 +111,21 @@ public class SolrChildApplicationContextFactory extends ChildApplicationContextF
JSONObject json = adminClient.execute(args); JSONObject json = adminClient.execute(args);
JSONObject summary = json.getJSONObject("Summary"); JSONObject summary = json.getJSONObject("Summary");
Date now = new Date(); JSONObject alfresco = null;
try
JSONObject alfresco = summary.has("alfresco") ? summary.getJSONObject("alfresco") : null; {
String alfrescoLag = alfresco == null ? "Unavailable" : alfresco.getString("TX Lag"); alfresco = summary.getJSONObject("alfresco");
String alfrescoActive = alfresco == null ? "false" : alfresco.getString("Active"); }
String alfrescoDuration = alfresco == null ? "Unavailable" : alfresco.getString("TX Duration"); catch (JSONException e)
String alfrescoLastIndexedTxn = alfresco == null ? "Unavailable" : alfresco.getString("Id for last TX in index"); {
String alfrescoApproxTxnsReminaing = alfresco == null ? "Unavailable" : alfresco.getString("Approx transactions remaining"); // The core might be absent.
String alfrescoApproxIndexingTimeReminaing = alfresco == null ? "Unavailable" : alfresco.getString("Approx transaction indexing time remaining"); }
String alfrescoDisk = alfresco == null ? "Unavailable" : alfresco.getString("On disk (GB)");
String alfrescoMemory = alfresco == null ? "Unavailable" : alfresco.getString("Total Searcher Cache (GB)");
JSONObject archive = summary.has("archive") ? summary.getJSONObject("archive") : null;
String archiveLag = archive == null ? "Unavailable" : archive.getString("TX Lag");
String archiveActive = archive == null ? "false" : archive.getString("Active");
String archiveDuration = archive == null ? "Unavailable" : archive.getString("TX Duration");
String archiveLastIndexedTxn = archive == null ? "Unavailable" : archive.getString("Id for last TX in index");
String archiveApproxTxnsReminaing = archive == null ? "Unavailable" : archive.getString("Approx transactions remaining");
String archiveApproxIndexingTimeReminaing = archive == null ? "Unavailable" : archive.getString("Approx transaction indexing time remaining");
String archiveDisk = archive == null ? "Unavailable" : archive.getString("On disk (GB)");
String archiveMemory = archive == null ? "Unavailable" : archive.getString("Total Searcher Cache (GB)");
if (alfresco != null)
{
if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_ACTIVE)) if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_ACTIVE))
{ {
String alfrescoActive = alfresco.getString("Active");
if (alfrescoActive == null || alfrescoActive.isEmpty()) if (alfrescoActive == null || alfrescoActive.isEmpty())
{ {
// Admin Console is expecting a true/false value, not blank // Admin Console is expecting a true/false value, not blank
@@ -146,69 +135,83 @@ public class SolrChildApplicationContextFactory extends ChildApplicationContextF
} }
else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_LAG)) else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_LAG))
{ {
return alfrescoLag; return alfresco.getString("TX Lag");
} }
else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_LAG_DURATION)) else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_LAG_DURATION))
{ {
return alfrescoDuration; return alfresco.getString("TX Duration");
} }
else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_LAST_INDEXED_TXN)) else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_LAST_INDEXED_TXN))
{ {
return alfrescoLastIndexedTxn; return alfresco.getString("Id for last TX in index");
} }
else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_APPROX_TXNS_REMAINING)) else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_APPROX_TXNS_REMAINING))
{ {
return alfrescoApproxTxnsReminaing; return alfresco.getString("Approx transactions remaining");
} }
else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_APPROX_INDEXING_TIME_REMAINING)) else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_APPROX_INDEXING_TIME_REMAINING))
{ {
return alfrescoApproxIndexingTimeReminaing; return alfresco.getString("Approx transaction indexing time remaining");
} }
else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_DISK)) else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_DISK))
{ {
return alfrescoDisk; return alfresco.getString("On disk (GB)");
} }
else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_MEMORY)) else if (name.equals(SolrChildApplicationContextFactory.ALFRESCO_MEMORY))
{ {
return alfrescoMemory; return alfresco.getString("Total Searcher Cache (GB)");
} }
else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_ACTIVE)) }
JSONObject archive = null;
try
{ {
return archiveActive; archive = summary.getJSONObject("archive");
}
catch (JSONException e)
{
// The core might be absent.
}
if (archive != null)
{
if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_ACTIVE))
{
return archive.getString("Active");
} }
else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_LAG)) else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_LAG))
{ {
return archiveLag; return archive.getString("TX Lag");
} }
else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_LAG_DURATION)) else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_LAG_DURATION))
{ {
return archiveDuration; return archive.getString("TX Duration");
} }
else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_LAST_INDEXED_TXN)) else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_LAST_INDEXED_TXN))
{ {
return archiveLastIndexedTxn; return archive.getString("Id for last TX in index");
} }
else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_APPROX_TXNS_REMAINING)) else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_APPROX_TXNS_REMAINING))
{ {
return archiveApproxTxnsReminaing; return archive.getString("Approx transactions remaining");
} }
else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_APPROX_INDEXING_TIME_REMAINING)) else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_APPROX_INDEXING_TIME_REMAINING))
{ {
return archiveApproxIndexingTimeReminaing; return archive.getString("Approx transaction indexing time remaining");
} }
else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_DISK)) else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_DISK))
{ {
return archiveDisk; return archive.getString("On disk (GB)");
} }
else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_MEMORY)) else if (name.equals(SolrChildApplicationContextFactory.ARCHIVE_MEMORY))
{ {
return archiveMemory; return archive.getString("Total Searcher Cache (GB)");
} }
else }
{
// Did not find the property in JSON or the core is turned off
return "Unavailable"; return "Unavailable";
} }
}
catch (LuceneQueryParserException lqe) catch (LuceneQueryParserException lqe)
{ {
return "Unavailable: " + lqe.getMessage(); return "Unavailable: " + lqe.getMessage();