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

ASF GitHub Bot commented on DL-37:
----------------------------------

Github user khurrumnasimm commented on a diff in the pull request:

    
https://github.com/apache/incubator-distributedlog/pull/15#discussion_r76534790
  
    --- Diff: 
distributedlog-core/src/main/java/com/twitter/distributedlog/util/OffsetSequencer.java
 ---
    @@ -0,0 +1,51 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package com.twitter.distributedlog.util;
    +
    +import com.twitter.distributedlog.LogRecord;
    +
    +/**
    + * Offset based sequencer. It generated non-decreasing transaction id 
using offsets.
    + * It isn't thread-safe. The caller takes the responsibility on 
synchronization.
    + */
    +public class OffsetSequencer implements Sequencer {
    +
    +    private long lastOffset = -1L;
    +
    +    @Override
    +    public void setLastId(long lastId) {
    +        // NOTE: it is a bit tricky here. when a log stream is recovered, 
we can only get the last transaction id,
    +        //       but not the length of last record. so we don't know how 
many `bytes` to advance. so just to advance
    +        //       one here.
    +        this.lastOffset = lastId + 1;
    --- End diff --
    
    @leighst that seems to work.


> Add OffsetSequencer
> -------------------
>
>                 Key: DL-37
>                 URL: https://issues.apache.org/jira/browse/DL-37
>             Project: DistributedLog
>          Issue Type: Improvement
>          Components: distributedlog-core, distributedlog-service
>            Reporter: Khurrum Nasim
>            Assignee: Khurrum Nasim
>             Fix For: 0.4.0
>
>
> In order to support kafka like offset, we'd like to introduce an offset 
> sequencer.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to