You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Tsz Wo Nicholas Sze (JIRA)" <ji...@apache.org> on 2017/04/25 15:24:06 UTC

[jira] [Commented] (RATIS-76) Add loading policy for RaftLogCache

    [ https://issues.apache.org/jira/browse/RATIS-76?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15983061#comment-15983061 ] 

Tsz Wo Nicholas Sze commented on RATIS-76:
------------------------------------------

Thanks for adding the loading policy.  Some comments:
- In LogSegment, change loadCache to return LogEntryProto since there is no additional cost.
{code}
  synchronized LogEntryProto loadCache(LogRecord record) throws RaftLogIOException {
    LogEntryProto entry = entryCache.get(record.getTermIndex());
    if (entry != null) {
      return entry;
    }
    try {
      return cacheLoader.load(record);
    } catch (Exception e) {
      throw new RaftLogIOException(e);
    }
  }
{code}
Then, getEntryWithoutLoading and getEntryWithLoading can be easily implemented separately.
{code}
  LogEntryProto getEntryWithoutLoading(long index) {
    LogRecord record = getLogRecord(index);
    if (record == null) {
      return null;
    }
    return entryCache.get(record.getTermIndex());
  }

  @VisibleForTesting
  LogEntryProto getEntryWithLoading(long index) throws RaftLogIOException {
    LogRecord record = getLogRecord(index);
    if (record == null) {
      return null;
    }
    return loadCache(record);
  }
{code}
- Question: Is getEntryWithLoading intended to be only used in TestRaftLogSegment?

> Add loading policy for RaftLogCache
> -----------------------------------
>
>                 Key: RATIS-76
>                 URL: https://issues.apache.org/jira/browse/RATIS-76
>             Project: Ratis
>          Issue Type: Sub-task
>            Reporter: Jing Zhao
>            Assignee: Jing Zhao
>         Attachments: RATIS-76.000.patch, RATIS-76.001.patch, RATIS-76.002.patch
>
>
> RATIS-70 separates term/index/offset and entry content in {{LogSegment}}. Now {{LogSegment}} can always holds term/index/offset part in memory as index, and load log entry into a cache only when necessary. In this jira we will add a cache loading policy in {{LogSegment}}.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)