statistics for solr-cache

pull/1/head
sixcooler 13 years ago
parent d8425e6809
commit 9ee2e09983

@ -194,6 +194,30 @@
<td>Insert</td>
<td>Delete</td>
</tr>
<tr class="TableCellLight">
<td>Solr-Cache/Hit</td>
<td>#[solrcacheHit.size]#</td>
<td>#[solrcacheHit.Hit]#</td>
<td>#[solrcacheHit.Miss]#</td>
<td>#[solrcacheHit.Insert]#</td>
<td>(ARC)</td>
</tr>
<tr class="TableCellLight">
<td>Solr-Cache/Miss</td>
<td>#[solrcacheMiss.size]#</td>
<td>#[solrcacheMiss.Hit]#</td>
<td>#[solrcacheMiss.Miss]#</td>
<td>#[solrcacheMiss.Insert]#</td>
<td>(ARC)</td>
</tr>
<tr class="TableCellLight">
<td>Solr-Cache/Document</td>
<td>#[solrcacheDocument.size]#</td>
<td>#[solrcacheDocument.Hit]#</td>
<td>#[solrcacheDocument.Miss]#</td>
<td>#[solrcacheDocument.Insert]#</td>
<td>(ARC)</td>
</tr>
<tr class="TableCellLight">
<td>DNSCache/Hit</td>
<td>#[namecacheHit.size]#</td>

@ -32,6 +32,7 @@ import java.util.Map;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.services.federated.solr.MirrorSolrConnector;
import net.yacy.kelondro.index.Cache;
import net.yacy.kelondro.index.RAMIndex;
import net.yacy.kelondro.table.Table;
@ -202,6 +203,22 @@ public class PerformanceMemory_p {
prop.putNum("objectMissCacheTotalMem", totalmissmem / (1024d * 1024d));
// other caching structures
final MirrorSolrConnector solr = (MirrorSolrConnector) Switchboard.getSwitchboard().index.fulltext().getSolr();
prop.putNum("solrcacheHit.size", solr.nameCacheHitSize());
prop.putNum("solrcacheHit.Hit", solr.cacheHit_Hit);
prop.putNum("solrcacheHit.Miss", solr.cacheHit_Miss);
prop.putNum("solrcacheHit.Insert", solr.cacheHit_Insert);
prop.putNum("solrcacheMiss.size", solr.nameCacheMissSize());
prop.putNum("solrcacheMiss.Hit", solr.cacheMiss_Hit);
prop.putNum("solrcacheMiss.Miss", solr.cacheMiss_Miss);
prop.putNum("solrcacheMiss.Insert", solr.cacheMiss_Insert);
prop.putNum("solrcacheDocument.size", solr.nameCacheDocumentSize());
prop.putNum("solrcacheDocument.Hit", solr.cacheDocument_Hit);
prop.putNum("solrcacheDocument.Miss", solr.cacheDocument_Miss);
prop.putNum("solrcacheDocument.Insert", solr.cacheDocument_Insert);
prop.putNum("namecacheHit.size", Domains.nameCacheHitSize());
prop.putNum("namecacheHit.Hit", Domains.cacheHit_Hit);
prop.putNum("namecacheHit.Miss", Domains.cacheHit_Miss);

@ -53,6 +53,9 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
private SolrConnector solr1;
private final ARC<String, Object> hitCache, missCache;
private final ARC<String, SolrDocument> documentCache;
public long cacheHit_Hit = 0, cacheHit_Miss = 0, cacheHit_Insert = 0; // for statistics only; do not write
public long cacheMiss_Hit = 0, cacheMiss_Miss = 0, cacheMiss_Insert = 0; // for statistics only; do not write
public long cacheDocument_Hit = 0, cacheDocument_Miss = 0, cacheDocument_Insert = 0; // for statistics only; do not write
public MirrorSolrConnector(int hitCacheMax, int missCacheMax, int docCacheMax) {
@ -149,6 +152,7 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
public void delete(final String id) throws IOException {
this.hitCache.remove(id);
this.missCache.put(id, EXIST);
cacheMiss_Insert++;
this.documentCache.remove(id);
if (this.solr0 != null) this.solr0.delete(id);
if (this.solr1 != null) this.solr1.delete(id);
@ -164,6 +168,7 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
for (String id: ids) {
this.hitCache.remove(id);
this.missCache.put(id, EXIST);
cacheMiss_Insert++;
this.documentCache.remove(id);
}
if (this.solr0 != null) this.solr0.delete(ids);
@ -185,34 +190,60 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
*/
@Override
public boolean exists(final String id) throws IOException {
if (this.hitCache.containsKey(id) || this.documentCache.containsKey(id)) return true;
if (this.missCache.containsKey(id)) return false;
if (this.hitCache.containsKey(id)) {
cacheHit_Hit++;
return true;
}
cacheHit_Miss++;
if (this.documentCache.containsKey(id)) {
cacheDocument_Hit++;
return true;
}
cacheDocument_Miss++;
if (this.missCache.containsKey(id)) {
cacheMiss_Hit++;
return false;
}
cacheMiss_Miss++;
if (this.solr0 != null) {
if (this.solr0.exists(id)) {
this.hitCache.put(id, EXIST);
cacheHit_Insert++;
return true;
}
}
if (this.solr1 != null) {
if (this.solr1.exists(id)) {
this.hitCache.put(id, EXIST);
cacheHit_Insert++;
return true;
}
}
this.missCache.put(id, EXIST);
cacheMiss_Insert++;
return false;
}
@Override
public SolrDocument get(String id) throws IOException {
SolrDocument doc = this.documentCache.get(id);
if (doc != null) return doc;
if (this.missCache.containsKey(id)) return null;
if (doc != null) {
cacheDocument_Hit++;
return doc;
}
cacheDocument_Miss++;
if (this.missCache.containsKey(id)) {
cacheMiss_Hit++;
return null;
}
cacheMiss_Miss++;
if (this.solr0 != null) {
doc = this.solr0.get(id);
if (doc != null) {
this.hitCache.put(id, EXIST);
cacheHit_Insert++;
this.documentCache.put(id, doc);
cacheDocument_Insert++;
return doc;
}
}
@ -220,11 +251,14 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
doc = this.solr1.get(id);
if (doc != null) {
this.hitCache.put(id, EXIST);
cacheHit_Insert++;
this.documentCache.put(id, doc);
cacheDocument_Insert++;
return doc;
}
}
this.missCache.put(id, EXIST);
cacheMiss_Insert++;
return null;
}
@ -240,9 +274,11 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
if (id == null) return;
this.missCache.remove(id);
this.documentCache.put(id, ClientUtils.toSolrDocument(solrdoc));
cacheDocument_Insert++;
if (this.solr0 != null) this.solr0.add(solrdoc);
if (this.solr1 != null) this.solr1.add(solrdoc);
this.hitCache.put(id, EXIST);
cacheHit_Insert++;
}
@Override
@ -340,7 +376,9 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
String id = (String) solrdoc.getFieldValue(YaCySchema.id.name());
if (id != null) {
this.hitCache.put(id, EXIST);
cacheHit_Insert++;
this.documentCache.put(id, solrdoc);
cacheDocument_Insert++;
}
}
}
@ -353,4 +391,15 @@ public class MirrorSolrConnector extends AbstractSolrConnector implements SolrCo
return s;
}
public int nameCacheHitSize() {
return this.hitCache.size();
}
public int nameCacheMissSize() {
return this.missCache.size();
}
public int nameCacheDocumentSize() {
return this.documentCache.size();
}
}

Loading…
Cancel
Save