/**
 * Copyright 2015 Palantir Technologies
 *
 * Licensed under the BSD-3 License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://opensource.org/licenses/BSD-3-Clause
 *
 * 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.palantir.timestamp;

import java.util.concurrent.atomic.AtomicLong;

/**
 * In-memory implementation of timestamp service. There are a few legitimate uses for this in
 * production code, but primarily this should only be used in test code.
 *
 * @author bdorne
 *
 */
public class InMemoryTimestampService implements TimestampService {
    private final AtomicLong counter = new AtomicLong(0);

    @Override
    public long getFreshTimestamp() {
        return counter.incrementAndGet();
    }

    @Override
    public TimestampRange getFreshTimestamps(int timestampsToGet) {
        if (timestampsToGet <= 0) {
            throw new IllegalArgumentException("Argument must be positive: " + timestampsToGet);
        }
        long topValue = counter.addAndGet(timestampsToGet);
        return TimestampRange.createInclusiveRange(topValue - timestampsToGet + 1, topValue);
    }
}

@@ -927,16 +927,43 @@
 pService
+, TimestampMigrationService
  %7B%0A    p
@@ -1501,11 +1501,366 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public void fastForwardTimestamp(long currentTimestamp) %7B%0A        long currentTimestampFromService = counter.get();%0A        while (currentTimestampFromService %3C currentTimestamp) %7B%0A            counter.compareAndSet(currentTimestamp, currentTimestampFromService);%0A            currentTimestampFromService = counter.get();%0A        %7D%0A    %7D
 %0A%7D%0A

Implement TimestampMigrationService for InMemoryTimestampService