本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
});
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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);
}