當前位置: 首頁>>代碼示例>>Java>>正文


Java Ticker.systemTicker方法代碼示例

本文整理匯總了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;
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:27,代碼來源:LocalCache.java

示例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;
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:22,代碼來源:LocalCache.java

示例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));
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:24,代碼來源:AggregateDaoTest.java

示例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);
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:22,代碼來源:CappedDatabaseResizeTest.java

示例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);
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:22,代碼來源:CappedDatabaseResizeTest.java

示例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;
}
 
開發者ID:ketao1989,項目名稱:cnGuava,代碼行數:18,代碼來源:LocalCache.java

示例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) {}
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:11,代碼來源:CacheBuilderTest.java

示例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();
}
 
開發者ID:cloudendpoints,項目名稱:endpoints-management-java,代碼行數:12,代碼來源:ControlFilter.java

示例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;
}
 
開發者ID:cloudendpoints,項目名稱:endpoints-management-java,代碼行數:22,代碼來源:CheckRequestAggregator.java

示例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;
}
 
開發者ID:cloudendpoints,項目名稱:endpoints-management-java,代碼行數:13,代碼來源:QuotaRequestAggregator.java

示例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;
}
 
開發者ID:yahoo,項目名稱:yql-plus,代碼行數:14,代碼來源:PlanCompiledProgram.java

示例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;
}
 
開發者ID:antlr,項目名稱:codebuff,代碼行數:15,代碼來源:LocalCache.java

示例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;
}
 
開發者ID:antlr,項目名稱:codebuff,代碼行數:15,代碼來源:LocalCache.java

示例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) {
  }
}
 
開發者ID:google,項目名稱:guava,代碼行數:11,代碼來源:CacheBuilderTest.java

示例15: getTicker

import com.google.common.base.Ticker; //導入方法依賴的package包/類
@VisibleForTesting
static Ticker getTicker(boolean dummyTicker) {
    if (dummyTicker) {
        return new DummyTicker();
    } else {
        return Ticker.systemTicker();
    }
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:9,代碼來源:Tickers.java


注:本文中的com.google.common.base.Ticker.systemTicker方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。