Replace System.currentTimeMillis with Clock.Global.currentTimeMillis

Patch by brandonwilliams; reviewed by bereng for CASSANDRA-17123
This commit is contained in:
Brandon Williams 2021-11-08 11:52:54 -06:00
parent 8ddcd43b0c
commit 599294c919
26 changed files with 88 additions and 58 deletions

View File

@ -360,7 +360,7 @@ public abstract class Lists
else
{
// in addition to being at the same millisecond, we handle the unexpected case of the millis parameter
// being in the past. That could happen if the System.currentTimeMillis() not operating montonically
// being in the past. That could happen if the Global.currentTimeMillis() not operating montonically
// or if one thread is just a really big loser in the compareAndSet game of life.
long millisToUse = millis <= current.millis ? millis : current.millis;

View File

@ -148,7 +148,7 @@ final class HintsBuffer
/**
* Retrieve the time of the earliest hint in the buffer for a specific node
* @param hostId UUID of the node
* @return timestamp for the earliest hint in the buffer, or {@link System#currentTimeMillis()}
* @return timestamp for the earliest hint in the buffer, or {@link Global#currentTimeMillis()}
*/
long getEarliestHintTime(UUID hostId)
{

View File

@ -184,7 +184,7 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
};
/**
* maxDataAge is a timestamp in local server time (e.g. System.currentTimeMilli) which represents an upper bound
* maxDataAge is a timestamp in local server time (e.g. Global.currentTimeMilli) which represents an upper bound
* to the newest piece of data stored in the sstable. In other words, this sstable does not contain items created
* later than maxDataAge.
*

View File

@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory;
import org.apache.cassandra.utils.concurrent.OpOrder;
import static org.junit.Assert.assertTrue;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
// TODO: we don't currently test SAFE functionality at all!
// TODO: should also test markBlocking and SyncOrdered
@ -85,13 +86,13 @@ public class LongOpOrderTest
@Override
public void run()
{
final long until = System.currentTimeMillis() + RUNTIME;
long lastReport = System.currentTimeMillis();
final long until = currentTimeMillis() + RUNTIME;
long lastReport = currentTimeMillis();
long count = 0;
long opCount = 0;
while (true)
{
long now = System.currentTimeMillis();
long now = currentTimeMillis();
if (now > until)
break;
if (now > lastReport + REPORT_INTERVAL)

View File

@ -52,6 +52,7 @@ import static com.google.common.collect.Iterables.transform;
import static java.util.Comparator.naturalOrder;
import static java.util.Comparator.reverseOrder;
import static org.apache.cassandra.utils.btree.BTree.iterable;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
import static org.junit.Assert.assertTrue;
public class LongBTreeTest
@ -1073,7 +1074,7 @@ public class LongBTreeTest
{
args = Arrays.copyOf(args, args.length + 1);
System.arraycopy(args, 0, args, 1, args.length - 1);
args[0] = System.currentTimeMillis();
args[0] = currentTimeMillis();
System.out.printf("%tT: " + formatstr + "\n", args);
}
}

View File

@ -50,6 +50,7 @@ import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.utils.FBUtilities;
import static org.apache.cassandra.distributed.impl.DistributedTestSnitch.toCassandraInetAddressAndPort;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
public class GossipHelper
{
@ -329,14 +330,14 @@ public class GossipHelper
public static VersionedApplicationState statusLeft(IInvokableInstance instance)
{
return versionedToken(instance, ApplicationState.STATUS, (partitioner, tokens) -> {
return new VersionedValue.VersionedValueFactory(partitioner).left(tokens, System.currentTimeMillis() + Gossiper.aVeryLongTime);
return new VersionedValue.VersionedValueFactory(partitioner).left(tokens, currentTimeMillis() + Gossiper.aVeryLongTime);
});
}
public static VersionedApplicationState statusWithPortLeft(IInvokableInstance instance)
{
return versionedToken(instance, ApplicationState.STATUS_WITH_PORT, (partitioner, tokens) -> {
return new VersionedValue.VersionedValueFactory(partitioner).left(tokens, System.currentTimeMillis() + Gossiper.aVeryLongTime);
return new VersionedValue.VersionedValueFactory(partitioner).left(tokens, currentTimeMillis() + Gossiper.aVeryLongTime);
});
}

View File

@ -46,6 +46,7 @@ import org.apache.cassandra.utils.UUIDGen;
import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
import static org.apache.cassandra.distributed.api.Feature.NETWORK;
import static org.apache.cassandra.repair.consistent.ConsistentSession.State.REPAIRING;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
import static org.junit.Assert.assertTrue;
public class IncRepairAdminTest extends TestBaseImpl
@ -153,7 +154,7 @@ public class IncRepairAdminTest extends TestBaseImpl
Lists.newArrayList(cfs),
Sets.newHashSet(range),
true,
System.currentTimeMillis(),
currentTimeMillis(),
true,
PreviewKind.NONE);
LocalSessionAccessor.prepareUnsafe(sessionId,

View File

@ -68,6 +68,7 @@ import static org.apache.cassandra.distributed.shared.AssertUtils.row;
import static org.apache.cassandra.net.Verb.READ_REPAIR_REQ;
import static org.apache.cassandra.net.Verb.READ_REPAIR_RSP;
import static org.apache.cassandra.net.Verb.READ_REQ;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
import static org.apache.cassandra.utils.concurrent.Condition.newOneTimeCondition;
import static org.junit.Assert.fail;
@ -132,7 +133,7 @@ public class ReadRepairTest extends TestBaseImpl
cluster.get(2).executeInternal("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, 1, 1)");
assertRows(cluster.get(3).executeInternal("SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1"));
cluster.verbs(READ_REPAIR_RSP).to(1).drop();
final long start = System.currentTimeMillis();
final long start = currentTimeMillis();
try
{
cluster.coordinator(1).execute("SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1", ConsistencyLevel.ALL);
@ -142,7 +143,7 @@ public class ReadRepairTest extends TestBaseImpl
{
// the containing exception class was loaded by another class loader. Comparing the message as a workaround to assert the exception
Assert.assertTrue(ex.getClass().toString().contains("ReadTimeoutException"));
long actualTimeTaken = System.currentTimeMillis() - start;
long actualTimeTaken = currentTimeMillis() - start;
long magicDelayAmount = 100L; // it might not be the best way to check if the time taken is around the timeout value.
// Due to the delays, the actual time taken from client perspective is slighly more than the timeout value
Assert.assertTrue(actualTimeTaken > reducedReadTimeout);
@ -506,4 +507,4 @@ public class ReadRepairTest extends TestBaseImpl
return r.call();
}
}
}
}

View File

@ -67,6 +67,7 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
import static org.apache.cassandra.distributed.api.Feature.NETWORK;
import static org.apache.cassandra.distributed.shared.AssertUtils.assertRows;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -544,7 +545,7 @@ public class RepairDigestTrackingTest extends TestBaseImpl
SSTableReader sstable = sstables.next();
Descriptor descriptor = sstable.descriptor;
descriptor.getMetadataSerializer()
.mutateRepairMetadata(descriptor, System.currentTimeMillis(), null, false);
.mutateRepairMetadata(descriptor, currentTimeMillis(), null, false);
sstable.reloadSSTableMetadata();
}
} catch (IOException e) {

View File

@ -33,6 +33,7 @@ import static org.apache.cassandra.distributed.action.GossipHelper.decommission;
import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
import static org.apache.cassandra.distributed.api.Feature.NATIVE_PROTOCOL;
import static org.apache.cassandra.distributed.api.Feature.NETWORK;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
public class CommunicationDuringDecommissionTest extends TestBaseImpl
{
@ -53,10 +54,10 @@ public class CommunicationDuringDecommissionTest extends TestBaseImpl
Map<Integer, Long> connectionAttempts = new HashMap<>();
long deadline = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(10);
long deadline = currentTimeMillis() + TimeUnit.SECONDS.toMillis(10);
// Wait 10 seconds and check if there are any new connection attempts to the decomissioned node
while (System.currentTimeMillis() <= deadline)
while (currentTimeMillis() <= deadline)
{
for (int i = 2; i <= cluster.size(); i++)
{

View File

@ -48,6 +48,7 @@ import org.apache.cassandra.io.sstable.format.SSTableReader;
import org.apache.cassandra.io.util.FileUtils;
import org.apache.cassandra.utils.FBUtilities;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
import static org.apache.cassandra.utils.Clock.Global.nanoTime;
import static org.assertj.core.api.Assertions.assertThat;
@ -204,7 +205,7 @@ public class CachingBench extends CQLTester
ColumnFamilyStore cfs = getCurrentColumnFamilyStore();
cfs.disableAutoCompaction();
long onStartTime = System.currentTimeMillis();
long onStartTime = currentTimeMillis();
ExecutorService es = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
List<Future<?>> tasks = new ArrayList<>();
for (int ti = 0; ti < 1; ++ti)
@ -228,7 +229,7 @@ public class CachingBench extends CQLTester
task.get();
flush();
long onEndTime = System.currentTimeMillis();
long onEndTime = currentTimeMillis();
int startRowCount = countRows(cfs);
int startTombCount = countTombstoneMarkers(cfs);
int startRowDeletions = countRowDeletions(cfs);
@ -258,9 +259,9 @@ public class CachingBench extends CQLTester
System.out.println();
String hashesBefore = getHashes();
long startTime = System.currentTimeMillis();
long startTime = currentTimeMillis();
CompactionManager.instance.performMaximal(cfs, true);
long endTime = System.currentTimeMillis();
long endTime = currentTimeMillis();
int endRowCount = countRows(cfs);
int endTombCount = countTombstoneMarkers(cfs);
@ -281,9 +282,9 @@ public class CachingBench extends CQLTester
private String getHashes() throws Throwable
{
long startTime = System.currentTimeMillis();
long startTime = currentTimeMillis();
String hashes = Arrays.toString(getRows(execute(hashQuery))[0]);
long endTime = System.currentTimeMillis();
long endTime = currentTimeMillis();
System.out.println(String.format("Hashes: %s, retrieved in %.3fs", hashes, (endTime - startTime) * 1e-3));
return hashes;
}

View File

@ -46,6 +46,7 @@ import org.apache.cassandra.io.sstable.format.SSTableReader;
import org.apache.cassandra.schema.CompactionParams.TombstoneOption;
import org.apache.cassandra.utils.FBUtilities;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
import static org.apache.cassandra.utils.Clock.Global.nanoTime;
public class GcCompactionBench extends CQLTester
@ -202,7 +203,7 @@ public class GcCompactionBench extends CQLTester
ColumnFamilyStore cfs = getCurrentColumnFamilyStore();
cfs.disableAutoCompaction();
long onStartTime = System.currentTimeMillis();
long onStartTime = currentTimeMillis();
ExecutorService es = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
List<Future<?>> tasks = new ArrayList<>();
for (int ti = 0; ti < 1; ++ti)
@ -226,7 +227,7 @@ public class GcCompactionBench extends CQLTester
task.get();
flush();
long onEndTime = System.currentTimeMillis();
long onEndTime = currentTimeMillis();
int startRowCount = countRows(cfs);
int startTombCount = countTombstoneMarkers(cfs);
int startRowDeletions = countRowDeletions(cfs);
@ -237,9 +238,9 @@ public class GcCompactionBench extends CQLTester
String hashesBefore = getHashes();
long startTime = System.currentTimeMillis();
long startTime = currentTimeMillis();
CompactionManager.instance.performGarbageCollection(cfs, tombstoneOption, 0);
long endTime = System.currentTimeMillis();
long endTime = currentTimeMillis();
int endRowCount = countRows(cfs);
int endTombCount = countTombstoneMarkers(cfs);
@ -266,9 +267,9 @@ public class GcCompactionBench extends CQLTester
private String getHashes() throws Throwable
{
long startTime = System.currentTimeMillis();
long startTime = currentTimeMillis();
String hashes = Arrays.toString(getRows(execute(hashQuery))[0]);
long endTime = System.currentTimeMillis();
long endTime = currentTimeMillis();
System.out.println(String.format("Hashes: %s, retrieved in %.3fs", hashes, (endTime - startTime) * 1e-3));
return hashes;
}

View File

@ -57,6 +57,7 @@ import org.apache.cassandra.schema.Schema;
import org.apache.cassandra.security.EncryptionContext;
import org.apache.cassandra.security.EncryptionContextGenerator;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
@Ignore
public abstract class CommitLogStressTest
@ -309,7 +310,7 @@ public abstract class CommitLogStressTest
t.start();
}
final long start = System.currentTimeMillis();
final long start = currentTimeMillis();
Runnable printRunnable = new Runnable()
{
long lastUpdate = 0;
@ -327,11 +328,11 @@ public abstract class CommitLogStressTest
temp += clt.counter.get();
sz += clt.dataSize;
}
double time = (System.currentTimeMillis() - start) / 1000.0;
double time = (currentTimeMillis() - start) / 1000.0;
double avg = (temp / time);
System.out.println(
String.format("second %d mem max %.0fmb allocated %.0fmb free %.0fmb mutations %d since start %d avg %.3f content %.1fmb ondisk %.1fmb transfer %.3fmb",
((System.currentTimeMillis() - start) / 1000),
((currentTimeMillis() - start) / 1000),
mb(maxMemory),
mb(allocatedMemory),
mb(freeMemory),

View File

@ -41,6 +41,7 @@ import org.apache.cassandra.schema.KeyspaceParams;
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.utils.FBUtilities;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
import static org.apache.cassandra.utils.Clock.Global.nanoTime;
import static org.junit.Assert.assertEquals;
@ -125,7 +126,7 @@ public class LongCompactionsTest
Thread.sleep(1000);
long start = nanoTime();
final int gcBefore = (int) (System.currentTimeMillis() / 1000) - Schema.instance.getTableMetadata(KEYSPACE1, "Standard1").params.gcGraceSeconds;
final int gcBefore = (int) (currentTimeMillis() / 1000) - Schema.instance.getTableMetadata(KEYSPACE1, "Standard1").params.gcGraceSeconds;
try (LifecycleTransaction txn = store.getTracker().tryModify(sstables, OperationType.COMPACTION))
{
assert txn != null : "Cannot markCompacting all sstables";

View File

@ -35,6 +35,8 @@ import org.apache.cassandra.cql3.CQLTester;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.utils.Hex;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
public class LongLeveledCompactionStrategyCQLTest extends CQLTester
{
@ -47,7 +49,7 @@ public class LongLeveledCompactionStrategyCQLTest extends CQLTester
ExecutorService es = Executors.newSingleThreadExecutor();
DatabaseDescriptor.setConcurrentCompactors(8);
AtomicBoolean stop = new AtomicBoolean(false);
long start = System.currentTimeMillis();
long start = currentTimeMillis();
try
{
Random r = new Random();
@ -75,7 +77,7 @@ public class LongLeveledCompactionStrategyCQLTest extends CQLTester
}
});
while(System.currentTimeMillis() - start < TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES))
while(currentTimeMillis() - start < TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES))
{
StorageService.instance.getTokenMetadata().invalidateCachedRings();
Uninterruptibles.sleepUninterruptibly(r.nextInt(1000), TimeUnit.MILLISECONDS);

View File

@ -31,6 +31,8 @@ import org.junit.Ignore;
import org.apache.cassandra.dht.IPartitioner;
import org.apache.cassandra.dht.Token;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
/**
* Base class for {@link Murmur3ReplicationAwareTokenAllocatorTest} and {@link RandomReplicationAwareTokenAllocatorTest},
* we need to separate classes to avoid timeous in case flaky tests need to be repeated, see CASSANDRA-12784.
@ -489,7 +491,7 @@ abstract class AbstractReplicationAwareTokenAllocatorTest extends TokenAllocator
if (size < targetClusterSize)
{
System.out.format("Adding %d unit(s) using %s...", targetClusterSize - size, t.toString());
long time = System.currentTimeMillis();
long time = currentTimeMillis();
while (size < targetClusterSize)
{
int tokens = tc.tokenCount(perUnitCount, rand);
@ -500,7 +502,7 @@ abstract class AbstractReplicationAwareTokenAllocatorTest extends TokenAllocator
if (verifyMetrics)
updateSummary(t, su, st, false);
}
System.out.format(" Done in %.3fs\n", (System.currentTimeMillis() - time) / 1000.0);
System.out.format(" Done in %.3fs\n", (currentTimeMillis() - time) / 1000.0);
if (verifyMetrics)
{
updateSummary(t, su, st, true);

View File

@ -34,6 +34,8 @@ import org.apache.cassandra.dht.Murmur3Partitioner;
import org.apache.cassandra.dht.RandomPartitioner;
import org.apache.cassandra.dht.Token;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
public class NoReplicationTokenAllocatorTest extends TokenAllocatorTestBase
{
@ -149,7 +151,7 @@ public class NoReplicationTokenAllocatorTest extends TokenAllocatorTestBase
if (size < targetClusterSize)
{
System.out.format("Adding %d unit(s) using %s...", targetClusterSize - size, t.toString());
long time = System.currentTimeMillis();
long time = currentTimeMillis();
while (size < targetClusterSize)
{
@ -160,7 +162,7 @@ public class NoReplicationTokenAllocatorTest extends TokenAllocatorTestBase
if (verifyMetrics)
updateSummary(t, su, st, false);
}
System.out.format(" Done in %.3fs\n", (System.currentTimeMillis() - time) / 1000.0);
System.out.format(" Done in %.3fs\n", (currentTimeMillis() - time) / 1000.0);
if (verifyMetrics)
{

View File

@ -48,6 +48,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
public class HintsWriteThenReadTest
{
private static final String KEYSPACE = "hints_write_then_read_test";
@ -61,7 +63,7 @@ public class HintsWriteThenReadTest
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE, KeyspaceParams.simple(1), SchemaLoader.standardCFMD(KEYSPACE, TABLE));
HintsDescriptor descriptor = new HintsDescriptor(UUID.randomUUID(), System.currentTimeMillis());
HintsDescriptor descriptor = new HintsDescriptor(UUID.randomUUID(), currentTimeMillis());
File directory = new File(Files.createTempDirectory(null));
try

View File

@ -28,6 +28,8 @@ import org.openjdk.jmh.profile.*;
import org.openjdk.jmh.runner.*;
import org.openjdk.jmh.runner.options.*;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@ -45,7 +47,7 @@ public class StreamingTombstoneHistogramBuilderBench
static
{
final int now = (int) (System.currentTimeMillis() / 1000L);
final int now = (int) (currentTimeMillis() / 1000L);
Random random = new Random();
for(int i = 0 ; i < 10000000; i++)
{

View File

@ -50,6 +50,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
/**
* Prints XML output of the test to a specified Writer.
@ -240,7 +241,7 @@ public class CassandraXMLJUnitResultFormatter implements JUnitResultFormatter, X
* @param t the test.
*/
public void startTest(final Test t) {
testStarts.put(createDescription(t), System.currentTimeMillis());
testStarts.put(createDescription(t), currentTimeMillis());
}
private static String createDescription(final Test test) throws BuildException {
@ -284,7 +285,7 @@ public class CassandraXMLJUnitResultFormatter implements JUnitResultFormatter, X
final Long l = testStarts.get(createDescription(test));
currentTest.setAttribute(ATTR_TIME,
"" + ((System.currentTimeMillis() - l) / ONE_SECOND));
"" + ((currentTimeMillis() - l) / ONE_SECOND));
}
/**

View File

@ -50,6 +50,8 @@ import org.apache.cassandra.utils.FBUtilities;
import org.junit.After;
import org.junit.BeforeClass;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
public class SchemaLoader
{
@BeforeClass
@ -82,7 +84,7 @@ public class SchemaLoader
// skip shadow round and endpoint collision check in tests
System.setProperty("cassandra.allow_unsafe_join", "true");
if (!Gossiper.instance.isEnabled())
Gossiper.instance.start((int) (System.currentTimeMillis() / 1000));
Gossiper.instance.start((int) (currentTimeMillis() / 1000));
}
public static void schemaDefinition(String testName) throws ConfigurationException

View File

@ -55,6 +55,7 @@ import org.apache.cassandra.utils.UUIDGen;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.cassandra.cql3.QueryProcessor.executeInternal;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
import static org.junit.Assert.*;
public class BatchlogManagerTest
@ -146,8 +147,8 @@ public class BatchlogManagerTest
}
long timestamp = i < 50
? (System.currentTimeMillis() - BatchlogManager.getBatchlogTimeout())
: (System.currentTimeMillis() + BatchlogManager.getBatchlogTimeout());
? (currentTimeMillis() - BatchlogManager.getBatchlogTimeout())
: (currentTimeMillis() + BatchlogManager.getBatchlogTimeout());
BatchlogManager.store(Batch.createLocal(UUIDGen.getTimeUUID(timestamp, i), timestamp * 1000, mutations));
}
@ -220,7 +221,7 @@ public class BatchlogManagerTest
List<Mutation> mutations = Lists.newArrayList(mutation1, mutation2);
// Make sure it's ready to be replayed, so adjust the timestamp.
long timestamp = System.currentTimeMillis() - BatchlogManager.getBatchlogTimeout();
long timestamp = currentTimeMillis() - BatchlogManager.getBatchlogTimeout();
if (i == 500)
SystemKeyspace.saveTruncationRecord(Keyspace.open(KEYSPACE1).getColumnFamilyStore(CF_STANDARD2),
@ -275,7 +276,7 @@ public class BatchlogManagerTest
long initialAllBatches = BatchlogManager.instance.countAllBatches();
TableMetadata cfm = Keyspace.open(KEYSPACE1).getColumnFamilyStore(CF_STANDARD5).metadata();
long timestamp = (System.currentTimeMillis() - DatabaseDescriptor.getWriteRpcTimeout(MILLISECONDS) * 2) * 1000;
long timestamp = (currentTimeMillis() - DatabaseDescriptor.getWriteRpcTimeout(MILLISECONDS) * 2) * 1000;
UUID uuid = UUIDGen.getTimeUUID();
// Add a batch with 10 mutations
@ -307,7 +308,7 @@ public class BatchlogManagerTest
long initialAllBatches = BatchlogManager.instance.countAllBatches();
TableMetadata cfm = Keyspace.open(KEYSPACE1).getColumnFamilyStore(CF_STANDARD5).metadata();
long timestamp = (System.currentTimeMillis() - DatabaseDescriptor.getWriteRpcTimeout(MILLISECONDS) * 2) * 1000;
long timestamp = (currentTimeMillis() - DatabaseDescriptor.getWriteRpcTimeout(MILLISECONDS) * 2) * 1000;
UUID uuid = UUIDGen.getTimeUUID();
// Add a batch with 10 mutations
@ -349,7 +350,7 @@ public class BatchlogManagerTest
TableMetadata cfm = Keyspace.open(KEYSPACE1).getColumnFamilyStore(CF_STANDARD1).metadata();
long timestamp = (System.currentTimeMillis() - DatabaseDescriptor.getWriteRpcTimeout(MILLISECONDS) * 2) * 1000;
long timestamp = (currentTimeMillis() - DatabaseDescriptor.getWriteRpcTimeout(MILLISECONDS) * 2) * 1000;
UUID uuid = UUIDGen.getTimeUUID();
// Add a batch with 10 mutations

View File

@ -34,6 +34,8 @@ import org.apache.cassandra.schema.KeyspaceParams;
import org.apache.cassandra.service.CacheService;
import org.apache.cassandra.utils.ByteBufferUtil;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
public class AutoSavingCacheTest
{
private static final String KEYSPACE1 = "AutoSavingCacheTest1";
@ -71,7 +73,7 @@ public class AutoSavingCacheTest
for (int i = 0; i < 2; i++)
{
ColumnMetadata colDef = ColumnMetadata.regularColumn(cfs.metadata(), ByteBufferUtil.bytes("col1"), AsciiType.instance);
RowUpdateBuilder rowBuilder = new RowUpdateBuilder(cfs.metadata(), System.currentTimeMillis(), "key1");
RowUpdateBuilder rowBuilder = new RowUpdateBuilder(cfs.metadata(), currentTimeMillis(), "key1");
rowBuilder.add(colDef, "val1");
rowBuilder.build().apply();
cfs.forceBlockingFlush();

View File

@ -45,6 +45,7 @@ import org.apache.cassandra.schema.TableId;
import org.apache.cassandra.schema.TableMetadata;
import org.apache.cassandra.utils.FBUtilities;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@ -80,7 +81,7 @@ public class CacheProviderTest
private CachedBTreePartition createPartition()
{
PartitionUpdate update = new RowUpdateBuilder(cfm, System.currentTimeMillis(), "key1")
PartitionUpdate update = new RowUpdateBuilder(cfm, currentTimeMillis(), "key1")
.add("col1", "val1")
.buildUpdate();
@ -113,12 +114,12 @@ public class CacheProviderTest
private void concurrentCase(final CachedBTreePartition partition, final ICache<MeasureableString, IRowCacheEntry> cache) throws InterruptedException
{
final long startTime = System.currentTimeMillis() + 500;
final long startTime = currentTimeMillis() + 500;
Runnable runnable = new Runnable()
{
public void run()
{
while (System.currentTimeMillis() < startTime) {}
while (currentTimeMillis() < startTime) {}
for (int j = 0; j < 1000; j++)
{
cache.put(key1, partition);

View File

@ -34,6 +34,7 @@ import org.apache.cassandra.transport.ProtocolVersion;
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.utils.UUIDGen;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
import static org.junit.Assert.assertEquals;
/**
@ -225,7 +226,7 @@ public class CQL3TypeLiteralTest
for (int i = 0; i < 20; i++)
{
UUID v = UUIDGen.getTimeUUID(randLong(System.currentTimeMillis()));
UUID v = UUIDGen.getTimeUUID(randLong(currentTimeMillis()));
addNativeValue(v.toString(), CQL3Type.Native.TIMEUUID, TimeUUIDType.instance.decompose(v));
}
addNativeValue("null", CQL3Type.Native.TIMEUUID, ByteBufferUtil.EMPTY_BYTE_BUFFER);

View File

@ -103,6 +103,7 @@ import org.apache.cassandra.utils.Pair;
import static com.datastax.driver.core.SocketOptions.DEFAULT_CONNECT_TIMEOUT_MILLIS;
import static com.datastax.driver.core.SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS;
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -940,7 +941,7 @@ public abstract class CQLTester
*/
protected boolean waitForIndex(String keyspace, String table, String index) throws Throwable
{
long start = System.currentTimeMillis();
long start = currentTimeMillis();
boolean indexCreated = false;
while (!indexCreated)
{
@ -954,7 +955,7 @@ public abstract class CQLTester
}
}
if (System.currentTimeMillis() - start > 5000)
if (currentTimeMillis() - start > 5000)
break;
Thread.sleep(10);
@ -975,7 +976,7 @@ public abstract class CQLTester
*/
protected boolean waitForIndexBuilds(String keyspace, String indexName) throws InterruptedException
{
long start = System.currentTimeMillis();
long start = currentTimeMillis();
SecondaryIndexManager indexManager = getCurrentColumnFamilyStore(keyspace).indexManager;
while (true)
@ -984,7 +985,7 @@ public abstract class CQLTester
{
return true;
}
else if (System.currentTimeMillis() - start > 5000)
else if (currentTimeMillis() - start > 5000)
{
return false;
}