当前位置: 首页>>代码示例>>Java>>正文


Java AbstractFunction0类代码示例

本文整理汇总了Java中scala.runtime.AbstractFunction0的典型用法代码示例。如果您正苦于以下问题:Java AbstractFunction0类的具体用法?Java AbstractFunction0怎么用?Java AbstractFunction0使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbstractFunction0类属于scala.runtime包,在下文中一共展示了AbstractFunction0类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: letOverridesDefault

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
@Test public void letOverridesDefault() {
  final String override = "localhost:9410";

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(host$.Flag.isDefined()).isTrue();
      assertThat(host$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  host$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
开发者ID:openzipkin,项目名称:zipkin-finagle,代码行数:17,代码来源:hostTest.java

示例2: letOverridesDefault

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
@Test public void letOverridesDefault() {
  final String override = "amazon";

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(hostHeader$.Flag.isDefined()).isTrue();
      assertThat(hostHeader$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  hostHeader$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
开发者ID:openzipkin,项目名称:zipkin-finagle,代码行数:17,代码来源:hostHeaderTest.java

示例3: letOverridesDefault

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
@Test public void letOverridesDefault() {
  final String override = "foo:9411";

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(host$.Flag.isDefined()).isTrue();
      assertThat(host$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  host$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
开发者ID:openzipkin,项目名称:zipkin-finagle,代码行数:17,代码来源:hostTest.java

示例4: letOverridesDefault

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
@Test public void letOverridesDefault() {
  final boolean override = false;

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(compressionEnabled$.Flag.isDefined()).isTrue();
      assertThat(compressionEnabled$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  compressionEnabled$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
开发者ID:openzipkin,项目名称:zipkin-finagle,代码行数:17,代码来源:compressionEnabledTest.java

示例5: sendSpans

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
@Override public void sendSpans(final List<byte[]> spans, final Callback callback) {
  Trace.letClear(new AbstractFunction0<Void>() {
    @Override public Void apply() {
      try {
        if (closeCalled) throw new IllegalStateException("closed");
        client.apply(makeRequest(spans)).respond(new AbstractFunction1<Try<Rep>, BoxedUnit>() {
          @Override public BoxedUnit apply(Try<Rep> result) {
            if (result.isReturn()) {
              callback.onComplete();
            } else {
              callback.onError(result.throwable());
            }
            return BoxedUnit.UNIT;
          }
        });
      } catch (Throwable e) {
        callback.onError(e);
        if (e instanceof Error) throw (Error) e;
      }
      return null;
    }
  });
}
 
开发者ID:openzipkin,项目名称:zipkin-finagle,代码行数:24,代码来源:FinagleSender.java

示例6: letOverridesDefault

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
@Test public void letOverridesDefault() {
  final float override = 1.0f;

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(initialSampleRate$.Flag.isDefined()).isTrue();
      assertThat(initialSampleRate$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  initialSampleRate$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
开发者ID:openzipkin,项目名称:zipkin-finagle,代码行数:17,代码来源:initialSampleRateTest.java

示例7: letOverridesDefault

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
@Test public void letOverridesDefault() {
  final String override = "zipkin-dev";

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(topic$.Flag.isDefined()).isTrue();
      assertThat(topic$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  topic$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
开发者ID:openzipkin,项目名称:zipkin-finagle,代码行数:17,代码来源:topicTest.java

示例8: letOverridesDefault

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
@Test public void letOverridesDefault() {
  final List<InetSocketAddress> override = singletonList(new InetSocketAddress("zipkin", 9092));

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(bootstrapServers$.Flag.isDefined()).isTrue();
      assertThat(bootstrapServers$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  bootstrapServers$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
开发者ID:openzipkin,项目名称:zipkin-finagle,代码行数:17,代码来源:bootstrapServersTest.java

示例9: deleteLedger

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
void deleteLedger(final long ledgerId) {
    final Future<Void> deleteFuture = bkc.deleteLedger(ledgerId, true);
    synchronized (ledgerDeletions) {
        ledgerDeletions.add(deleteFuture);
    }
    deleteFuture.onFailure(new AbstractFunction1<Throwable, BoxedUnit>() {
        @Override
        public BoxedUnit apply(Throwable cause) {
            LOG.error("Error deleting ledger {} for ledger allocator {}, retrying : ",
                    new Object[] { ledgerId, allocatePath, cause });
            if (!isClosing()) {
                deleteLedger(ledgerId);
            }
            return BoxedUnit.UNIT;
        }
    }).ensure(new AbstractFunction0<BoxedUnit>() {
        @Override
        public BoxedUnit apply() {
            synchronized (ledgerDeletions) {
                ledgerDeletions.remove(deleteFuture);
            }
            return BoxedUnit.UNIT;
        }
    });
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:26,代码来源:SimpleLedgerAllocator.java

示例10: asyncReadFirstUserRecord

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
private Future<LogRecordWithDLSN> asyncReadFirstUserRecord(LogSegmentMetadata ledger, DLSN beginDLSN) {
    final LedgerHandleCache handleCache =
            LedgerHandleCache.newBuilder().bkc(bookKeeperClient).conf(conf).build();
    return ReadUtils.asyncReadFirstUserRecord(
            getFullyQualifiedName(),
            ledger,
            firstNumEntriesPerReadLastRecordScan,
            maxNumEntriesPerReadLastRecordScan,
            new AtomicInteger(0),
            scheduler,
            handleCache,
            beginDLSN
    ).ensure(new AbstractFunction0<BoxedUnit>() {
        @Override
        public BoxedUnit apply() {
            handleCache.clear();
            return BoxedUnit.UNIT;
        }
    });
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:21,代码来源:BKLogHandler.java

示例11: getDLSNNotLessThanTxId

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
private Future<DLSN> getDLSNNotLessThanTxId(long fromTxnId,
                                            final List<LogSegmentMetadata> segments) {
    if (segments.isEmpty()) {
        return getLastDLSNAsync();
    }
    final int segmentIdx = DLUtils.findLogSegmentNotLessThanTxnId(segments, fromTxnId);
    if (segmentIdx < 0) {
        return Future.value(new DLSN(segments.get(0).getLogSegmentSequenceNumber(), 0L, 0L));
    }
    final LedgerHandleCache handleCache =
            LedgerHandleCache.newBuilder().bkc(readerBKC).conf(conf).build();
    return getDLSNNotLessThanTxIdInSegment(
            fromTxnId,
            segmentIdx,
            segments,
            handleCache
    ).ensure(new AbstractFunction0<BoxedUnit>() {
        @Override
        public BoxedUnit apply() {
            handleCache.clear();
            return BoxedUnit.UNIT;
        }
    });
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:25,代码来源:BKDistributedLogManager.java

示例12: getLogRecordNotLessThanTxId

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
private Future<Optional<LogRecordWithDLSN>> getLogRecordNotLessThanTxId(
        BKDistributedLogManager bkdlm, int logsegmentIdx, long transactionId) throws Exception {
    List<LogSegmentMetadata> logSegments = bkdlm.getLogSegments();
    final LedgerHandleCache handleCache = LedgerHandleCache.newBuilder()
            .bkc(bkdlm.getWriterBKC())
            .conf(conf)
            .build();
    return ReadUtils.getLogRecordNotLessThanTxId(
            bkdlm.getStreamName(),
            logSegments.get(logsegmentIdx),
            transactionId,
            Executors.newSingleThreadExecutor(),
            handleCache,
            10
    ).ensure(new AbstractFunction0<BoxedUnit>() {
        @Override
        public BoxedUnit apply() {
            handleCache.clear();
            return BoxedUnit.UNIT;
        }
    });
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:23,代码来源:TestReadUtils.java

示例13: getFirstGreaterThanRecord

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
private Future<LogRecordWithDLSN> getFirstGreaterThanRecord(BKDistributedLogManager bkdlm, int ledgerNo, DLSN dlsn) throws Exception {
    List<LogSegmentMetadata> ledgerList = bkdlm.getLogSegments();
    final LedgerHandleCache handleCache = LedgerHandleCache.newBuilder()
            .bkc(bkdlm.getWriterBKC())
            .conf(conf)
            .build();
    return ReadUtils.asyncReadFirstUserRecord(
            bkdlm.getStreamName(), ledgerList.get(ledgerNo), 2, 16, new AtomicInteger(0), Executors.newFixedThreadPool(1),
            handleCache, dlsn
    ).ensure(new AbstractFunction0<BoxedUnit>() {
        @Override
        public BoxedUnit apply() {
            handleCache.clear();
            return BoxedUnit.UNIT;
        }
    });
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:18,代码来源:TestReadUtils.java

示例14: getLastUserRecord

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
private Future<LogRecordWithDLSN> getLastUserRecord(BKDistributedLogManager bkdlm, int ledgerNo) throws Exception {
    BKLogReadHandler readHandler = bkdlm.createReadHandler();
    List<LogSegmentMetadata> ledgerList = readHandler.getLedgerList(false, false, LogSegmentMetadata.COMPARATOR, false);
    final LedgerHandleCache handleCache = LedgerHandleCache.newBuilder()
            .bkc(bkdlm.getWriterBKC())
            .conf(conf)
            .build();
    return ReadUtils.asyncReadLastRecord(
            bkdlm.getStreamName(), ledgerList.get(ledgerNo), false, false, false, 2, 16, new AtomicInteger(0), Executors.newFixedThreadPool(1),
            handleCache
    ).ensure(new AbstractFunction0<BoxedUnit>() {
        @Override
        public BoxedUnit apply() {
            handleCache.clear();
            return BoxedUnit.UNIT;
        }
    });
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:19,代码来源:TestReadUtils.java

示例15: testInstantiateProducer

import scala.runtime.AbstractFunction0; //导入依赖的package包/类
@Test
public void testInstantiateProducer() {
  KafkaSystemProducer ksp = new KafkaSystemProducer("SysName", new ExponentialSleepStrategy(2.0, 200, 10000),
      new AbstractFunction0<Producer<byte[], byte[]>>() {
        @Override
        public Producer<byte[], byte[]> apply() {
          return new KafkaProducer<>(new HashMap<String, Object>());
        }
      }, new KafkaSystemProducerMetrics("SysName", new MetricsRegistryMap()), new AbstractFunction0<Object>() {
    @Override
    public Object apply() {
      return System.currentTimeMillis();
    }
  }, false);

  long now = System.currentTimeMillis();
  assertTrue((Long)ksp.clock().apply() >= now);
}
 
开发者ID:apache,项目名称:samza,代码行数:19,代码来源:TestKafkaSystemProducerJava.java


注:本文中的scala.runtime.AbstractFunction0类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。