distributedlog-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leighst <...@git.apache.org>
Subject [GitHub] incubator-distributedlog pull request #15: DL-37: add an offset sequencer fo...
Date Fri, 26 Aug 2016 15:07:21 GMT
Github user leighst commented on a diff in the pull request:

    https://github.com/apache/incubator-distributedlog/pull/15#discussion_r76434565
  
    --- 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 --
    
    what if we make the offset here represent the next offset?
    ex. 
    [0 0] -> offset = 2
    [0 0] -> offset = 4


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message