Search in sources :

Example 1 with Receipt

use of com.cinchapi.concourse.server.storage.db.kernel.Segment.Receipt in project concourse by cinchapi.

the class Database method accept.

@Override
public void accept(Write write) {
    // is only called from the Buffer, which transports data serially.
    if (running) {
        try {
            Receipt receipt = seg0.acquire(write, writer);
            Logger.debug("Indexed '{}' in {}", write, seg0);
            // Update cached records
            TableRecord cpr = tableCache.getIfPresent(receipt.table().getLocatorComposite());
            TableRecord cppr = tablePartialCache.getIfPresent(receipt.table().getLocatorKeyComposite());
            IndexRecord csr = indexCache.getIfPresent(receipt.index().getLocatorComposite());
            if (cpr != null) {
                cpr.append(receipt.table().revision());
            }
            if (cppr != null) {
                cppr.append(receipt.table().revision());
            }
            if (csr != null) {
                csr.append(receipt.index().revision());
            }
            if (ENABLE_SEARCH_CACHE) {
                Cache<Composite, CorpusRecord> cache = corpusCaches.get(write.getKey());
                if (cache != null) {
                    for (CorpusArtifact artifact : receipt.corpus()) {
                        CorpusRecord corpus = cache.getIfPresent(artifact.getLocatorKeyComposite());
                        if (corpus != null) {
                            corpus.append(artifact.revision());
                        }
                    }
                }
            }
        } catch (InterruptedException e) {
            Logger.warn("The database was interrupted while trying to accept {}. " + "If the write could not be fully accepted, it will " + "remain in the buffer and re-tried when the Database is able to accept writes.", write);
            Thread.currentThread().interrupt();
            return;
        }
    } else {
        // The #accept method may be called when the database is stopped
        // during test cases
        Logger.warn("The database is being asked to accept a Write, even though it is not running.");
        seg0.acquire(write);
    }
}
Also used : Receipt(com.cinchapi.concourse.server.storage.db.kernel.Segment.Receipt) Composite(com.cinchapi.concourse.server.io.Composite) CorpusArtifact(com.cinchapi.concourse.server.storage.db.kernel.CorpusArtifact)

Aggregations

Composite (com.cinchapi.concourse.server.io.Composite)1 CorpusArtifact (com.cinchapi.concourse.server.storage.db.kernel.CorpusArtifact)1 Receipt (com.cinchapi.concourse.server.storage.db.kernel.Segment.Receipt)1