本文整理匯總了Java中com.google.common.base.Ticker.systemTicker方法的典型用法代碼示例。如果您正苦於以下問題:Java Ticker.systemTicker方法的具體用法?Java Ticker.systemTicker怎麽用?Java Ticker.systemTicker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.base.Ticker
的用法示例。
在下文中一共展示了Ticker.systemTicker方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ManualSerializationProxy
import com.google.common.base.Ticker; //導入方法依賴的package包/類
private ManualSerializationProxy(
Strength keyStrength,
Strength valueStrength,
Equivalence<Object> keyEquivalence,
Equivalence<Object> valueEquivalence,
long expireAfterWriteNanos,
long expireAfterAccessNanos,
long maxWeight,
Weigher<K, V> weigher,
int concurrencyLevel,
RemovalListener<? super K, ? super V> removalListener,
Ticker ticker,
CacheLoader<? super K, V> loader) {
this.keyStrength = keyStrength;
this.valueStrength = valueStrength;
this.keyEquivalence = keyEquivalence;
this.valueEquivalence = valueEquivalence;
this.expireAfterWriteNanos = expireAfterWriteNanos;
this.expireAfterAccessNanos = expireAfterAccessNanos;
this.maxWeight = maxWeight;
this.weigher = weigher;
this.concurrencyLevel = concurrencyLevel;
this.removalListener = removalListener;
this.ticker = (ticker == Ticker.systemTicker() || ticker == NULL_TICKER) ? null : ticker;
this.loader = loader;
}
示例2: ManualSerializationProxy
import com.google.common.base.Ticker; //導入方法依賴的package包/類
private ManualSerializationProxy(
Strength keyStrength, Strength valueStrength,
Equivalence<Object> keyEquivalence, Equivalence<Object> valueEquivalence,
long expireAfterWriteNanos, long expireAfterAccessNanos, long maxWeight,
Weigher<K, V> weigher, int concurrencyLevel,
RemovalListener<? super K, ? super V> removalListener,
Ticker ticker, CacheLoader<? super K, V> loader) {
this.keyStrength = keyStrength;
this.valueStrength = valueStrength;
this.keyEquivalence = keyEquivalence;
this.valueEquivalence = valueEquivalence;
this.expireAfterWriteNanos = expireAfterWriteNanos;
this.expireAfterAccessNanos = expireAfterAccessNanos;
this.maxWeight = maxWeight;
this.weigher = weigher;
this.concurrencyLevel = concurrencyLevel;
this.removalListener = removalListener;
this.ticker = (ticker == Ticker.systemTicker() || ticker == NULL_TICKER)
? null : ticker;
this.loader = loader;
}
示例3: beforeEachTest
import com.google.common.base.Ticker; //導入方法依賴的package包/類
@Before
public void beforeEachTest() throws Exception {
dataSource = new DataSource();
if (dataSource.tableExists("overall_point")) {
dataSource.execute("drop table overall_point");
}
if (dataSource.tableExists("transaction_point")) {
dataSource.execute("drop table transaction_point");
}
cappedFile = File.createTempFile("glowroot-test-", ".capped.db");
cappedDatabase = new CappedDatabase(cappedFile, 1000000, Ticker.systemTicker());
ConfigRepositoryImpl configRepository = mock(ConfigRepositoryImpl.class);
when(configRepository.getAdvancedConfig(AGENT_ID))
.thenReturn(AdvancedConfig.getDefaultInstance());
ImmutableList<RollupConfig> rollupConfigs = ImmutableList.<RollupConfig>of(
ImmutableRollupConfig.of(1000, 0), ImmutableRollupConfig.of(15000, 3600000),
ImmutableRollupConfig.of(900000000, 8 * 3600000));
when(configRepository.getRollupConfigs()).thenReturn(rollupConfigs);
aggregateDao = new AggregateDao(
dataSource, ImmutableList.<CappedDatabase>of(cappedDatabase, cappedDatabase,
cappedDatabase, cappedDatabase),
configRepository, mock(TransactionTypeDao.class), mock(FullQueryTextDao.class));
}
示例4: shouldWrapAndResize
import com.google.common.base.Ticker; //導入方法依賴的package包/類
private void shouldWrapAndResize(int newSizeKb) throws Exception {
// when
// because of compression, use somewhat random text and loop until wrap occurs
String text = createRandomText();
cappedDatabase.write(ByteSource.wrap(text.getBytes(Charsets.UTF_8)), "test");
cappedDatabase.write(ByteSource.wrap(text.getBytes(Charsets.UTF_8)), "test");
cappedDatabase.write(ByteSource.wrap(text.getBytes(Charsets.UTF_8)), "test");
long cappedId =
cappedDatabase.write(ByteSource.wrap(text.getBytes(Charsets.UTF_8)), "test");
cappedDatabase.resize(newSizeKb);
// then
String text2 = cappedDatabase.read(cappedId).read();
assertThat(text2).isEqualTo(text);
// also test close and re-open
cappedDatabase.close();
cappedDatabase = new CappedDatabase(tempFile, 2, Ticker.systemTicker());
text2 = cappedDatabase.read(cappedId).read();
assertThat(text2).isEqualTo(text);
}
示例5: shouldResizeAndWrap
import com.google.common.base.Ticker; //導入方法依賴的package包/類
private void shouldResizeAndWrap(int newSizeKb) throws Exception {
// when
cappedDatabase.resize(newSizeKb);
// because of compression, use somewhat random text and loop until wrap occurs
String text = createRandomText();
cappedDatabase.write(ByteSource.wrap(text.getBytes(Charsets.UTF_8)), "test");
cappedDatabase.write(ByteSource.wrap(text.getBytes(Charsets.UTF_8)), "test");
cappedDatabase.write(ByteSource.wrap(text.getBytes(Charsets.UTF_8)), "test");
long cappedId =
cappedDatabase.write(ByteSource.wrap(text.getBytes(Charsets.UTF_8)), "test");
// then
String text2 = cappedDatabase.read(cappedId).read();
assertThat(text2).isEqualTo(text);
// also test close and re-open
cappedDatabase.close();
cappedDatabase = new CappedDatabase(tempFile, 2, Ticker.systemTicker());
text2 = cappedDatabase.read(cappedId).read();
assertThat(text2).isEqualTo(text);
}
示例6: ManualSerializationProxy
import com.google.common.base.Ticker; //導入方法依賴的package包/類
private ManualSerializationProxy(Strength keyStrength, Strength valueStrength,
Equivalence<Object> keyEquivalence, Equivalence<Object> valueEquivalence, long expireAfterWriteNanos,
long expireAfterAccessNanos, long maxWeight, Weigher<K, V> weigher, int concurrencyLevel,
RemovalListener<? super K, ? super V> removalListener, Ticker ticker, CacheLoader<? super K, V> loader) {
this.keyStrength = keyStrength;
this.valueStrength = valueStrength;
this.keyEquivalence = keyEquivalence;
this.valueEquivalence = valueEquivalence;
this.expireAfterWriteNanos = expireAfterWriteNanos;
this.expireAfterAccessNanos = expireAfterAccessNanos;
this.maxWeight = maxWeight;
this.weigher = weigher;
this.concurrencyLevel = concurrencyLevel;
this.removalListener = removalListener;
this.ticker = (ticker == Ticker.systemTicker() || ticker == NULL_TICKER) ? null : ticker;
this.loader = loader;
}
示例7: testTicker_setTwice
import com.google.common.base.Ticker; //導入方法依賴的package包/類
public void testTicker_setTwice() {
Ticker testTicker = Ticker.systemTicker();
CacheBuilder<Object, Object> builder =
new CacheBuilder<Object, Object>().ticker(testTicker);
try {
// even to the same instance is not allowed
builder.ticker(testTicker);
fail();
} catch (IllegalStateException expected) {}
}
示例8: ControlFilter
import com.google.common.base.Ticker; //導入方法依賴的package包/類
@VisibleForTesting
public ControlFilter(@Nullable Client client, @Nullable String projectId, @Nullable Ticker ticker,
@Nullable Clock clock, @Nullable HttpTransport transport) {
this.client = client;
setProjectId(projectId);
this.ticker = ticker == null ? Ticker.systemTicker() : ticker;
this.clock = clock == null ? Clock.SYSTEM : clock;
transport = transport == null ? new NetHttpTransport() : transport;
platform = getPlatformFromEnvironment(System.getenv(), System.getProperties(), transport);
this.statistics = new Statistics();
}
示例9: CheckRequestAggregator
import com.google.common.base.Ticker; //導入方法依賴的package包/類
/**
* Constructor.
*
* @param serviceName the service whose {@code CheckRequest}s are being aggregated
* @param options configures this instance's caching behavior
* @param kinds specifies the {@link MetricKind} for specific metric names
* @param ticker the time source used to determine expiration. When not specified, this defaults
* to {@link Ticker#systemTicker()}
*/
public CheckRequestAggregator(String serviceName, CheckAggregationOptions options,
@Nullable Map<String, MetricKind> kinds, @Nullable Ticker ticker) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(serviceName),
"service name cannot be empty");
Preconditions.checkNotNull(options, "options must be non-null");
this.out = new ConcurrentLinkedDeque<CachedItem>();
this.ticker = ticker == null ? Ticker.systemTicker() : ticker;
this.cache = options.createCache(out, this.ticker);
this.serviceName = serviceName;
this.options = options;
this.kinds = kinds;
}
示例10: QuotaRequestAggregator
import com.google.common.base.Ticker; //導入方法依賴的package包/類
public QuotaRequestAggregator(String serviceName, QuotaAggregationOptions options,
@Nullable Ticker ticker) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(serviceName),
"service name cannot be empty");
Preconditions.checkNotNull(options, "options must be non-null");
this.out = new ConcurrentLinkedDeque<>();
this.ticker = ticker == null ? Ticker.systemTicker() : ticker;
this.serviceName = serviceName;
this.options = options;
this.cache = createCache(this.ticker);
this.timeoutIntervalNs = options.getTimeoutMillis() * NANOS_PER_MILLI;
}
示例11: run
import com.google.common.base.Ticker; //導入方法依賴的package包/類
@Override
public ProgramResult run(Map<String, Object> arguments, boolean debug, ExecutionScope inputScope, long timeout, TimeUnit timeoutUnit) throws Exception {
TimeoutTracker tracker = new TimeoutTracker(timeout, timeoutUnit, new RelativeTicker(Ticker.systemTicker()));
ProgramTracer tracer = new ProgramTracer(Ticker.systemTicker(), debug, "program", name);
scoper.enter(new ScopedObjects(inputScope));
TaskMetricEmitter requestEmitter = injector.getInstance(TaskMetricEmitter.class);
TaskContext context = new TaskContext(requestEmitter, tracer, tracker);
PlanProgramResultAdapter adapter = new PlanProgramResultAdapter(tracer, resultSetInfos, scoper);
invoke(adapter, arguments, inputScope, context);
requestEmitter.end();
scoper.exit();
return adapter;
}
示例12: ManualSerializationProxy
import com.google.common.base.Ticker; //導入方法依賴的package包/類
private ManualSerializationProxy(Strength keyStrength, Strength valueStrength, Equivalence<Object> keyEquivalence, Equivalence<Object> valueEquivalence, long expireAfterWriteNanos, long expireAfterAccessNanos, long maxWeight, Weigher<K, V> weigher, int concurrencyLevel, RemovalListener<? super K, ? super V> removalListener, Ticker ticker, CacheLoader<? super K, V> loader) {
this.keyStrength = keyStrength;
this.valueStrength = valueStrength;
this.keyEquivalence = keyEquivalence;
this.valueEquivalence = valueEquivalence;
this.expireAfterWriteNanos = expireAfterWriteNanos;
this.expireAfterAccessNanos = expireAfterAccessNanos;
this.maxWeight = maxWeight;
this.weigher = weigher;
this.concurrencyLevel = concurrencyLevel;
this.removalListener = removalListener;
this.ticker = (ticker == Ticker.systemTicker() || ticker == NULL_TICKER) ? null : ticker;
this.loader = loader;
}
示例13: ManualSerializationProxy
import com.google.common.base.Ticker; //導入方法依賴的package包/類
private ManualSerializationProxy(Strength keyStrength, Strength valueStrength, Equivalence<Object> keyEquivalence, Equivalence<Object> valueEquivalence, long expireAfterWriteNanos, long expireAfterAccessNanos, long maxWeight, Weigher<K, V> weigher, int concurrencyLevel, RemovalListener<? super K, ? super V> removalListener, Ticker ticker, CacheLoader<? super K, V> loader) {
this.keyStrength = keyStrength;
this.valueStrength = valueStrength;
this.keyEquivalence = keyEquivalence;
this.valueEquivalence = valueEquivalence;
this.expireAfterWriteNanos = expireAfterWriteNanos;
this.expireAfterAccessNanos = expireAfterAccessNanos;
this.maxWeight = maxWeight;
this.weigher = weigher;
this.concurrencyLevel = concurrencyLevel;
this.removalListener = removalListener;
this.ticker = (ticker == Ticker.systemTicker() || ticker == NULL_TICKER) ? null : ticker;
this.loader = loader;
}
示例14: testTicker_setTwice
import com.google.common.base.Ticker; //導入方法依賴的package包/類
public void testTicker_setTwice() {
Ticker testTicker = Ticker.systemTicker();
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder().ticker(testTicker);
try {
// even to the same instance is not allowed
builder.ticker(testTicker);
fail();
} catch (IllegalStateException expected) {
}
}
示例15: getTicker
import com.google.common.base.Ticker; //導入方法依賴的package包/類
@VisibleForTesting
static Ticker getTicker(boolean dummyTicker) {
if (dummyTicker) {
return new DummyTicker();
} else {
return Ticker.systemTicker();
}
}